001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.module.purap.businessobject; 017 018 import java.sql.Timestamp; 019 import java.util.List; 020 021 import org.kuali.kfs.module.purap.PurapConstants.PurchaseOrderStatuses; 022 import org.kuali.kfs.module.purap.document.service.PurchaseOrderService; 023 import org.kuali.kfs.sys.context.SpringContext; 024 import org.kuali.rice.kns.bo.Note; 025 import org.kuali.rice.kns.util.TypedArrayList; 026 027 /** 028 * Purchase Order View Business Object. 029 */ 030 public class PurchaseOrderView extends AbstractRelatedView { 031 032 private Boolean purchaseOrderCurrentIndicator; 033 private String purchaseOrderStatusCode; 034 private String recurringPaymentTypeCode; 035 private String vendorChoiceCode; 036 private Timestamp recurringPaymentEndDate; 037 private Timestamp purchaseOrderInitialOpenTimestamp; 038 039 private List<Note> notes; 040 041 public boolean isPurchaseOrderCurrentIndicator() { 042 return purchaseOrderCurrentIndicator; 043 } 044 045 public boolean getPurchaseOrderCurrentIndicator() { 046 return purchaseOrderCurrentIndicator; 047 } 048 049 public void setPurchaseOrderCurrentIndicator(boolean purchaseOrderCurrentIndicator) { 050 this.purchaseOrderCurrentIndicator = purchaseOrderCurrentIndicator; 051 } 052 053 public String getPurchaseOrderStatusCode() { 054 return purchaseOrderStatusCode; 055 } 056 057 public void setPurchaseOrderStatusCode(String purchaseOrderStatusCode) { 058 this.purchaseOrderStatusCode = purchaseOrderStatusCode; 059 } 060 061 public String getRecurringPaymentTypeCode() { 062 return recurringPaymentTypeCode; 063 } 064 065 public void setRecurringPaymentTypeCode(String recurringPaymentTypeCode) { 066 this.recurringPaymentTypeCode = recurringPaymentTypeCode; 067 } 068 069 public String getVendorChoiceCode() { 070 return vendorChoiceCode; 071 } 072 073 public void setVendorChoiceCode(String vendorChoiceCode) { 074 this.vendorChoiceCode = vendorChoiceCode; 075 } 076 077 public Timestamp getRecurringPaymentEndDate() { 078 return recurringPaymentEndDate; 079 } 080 081 public void setRecurringPaymentEndDate(Timestamp recurringPaymentEndDate) { 082 this.recurringPaymentEndDate = recurringPaymentEndDate; 083 } 084 085 public Timestamp getPurchaseOrderInitialOpenTimestamp() { 086 return purchaseOrderInitialOpenTimestamp; 087 } 088 089 public void setPurchaseOrderInitialOpenTimestamp(Timestamp purchaseOrderInitialOpenTimestamp) { 090 this.purchaseOrderInitialOpenTimestamp = purchaseOrderInitialOpenTimestamp; 091 } 092 093 /** 094 * @see org.kuali.kfs.module.purap.businessobject.AbstractRelatedView#getNotes() 095 */ 096 @Override 097 public List<Note> getNotes() { 098 if (this.isPurchaseOrderCurrentIndicator()) { 099 if (notes == null) { 100 notes = new TypedArrayList(Note.class); 101 List<Note> tmpNotes = SpringContext.getBean(PurchaseOrderService.class).getPurchaseOrderNotes(this.getPurapDocumentIdentifier()); 102 //FIXME if NoteService returns notes in descending order (newer ones first) then remove the following 103 // reverse the order of notes retrieved so that newest note is in the front 104 for (int i = tmpNotes.size()-1; i>=0; i--) { 105 Note note = tmpNotes.get(i); 106 notes.add(note); 107 } 108 } 109 } 110 else { 111 notes = null; 112 } 113 return notes; 114 } 115 116 /** 117 * The next four methods are overridden but shouldn't be! If they aren't overridden, they don't show up in the tag, not sure why at 118 * this point! (AAP) 119 * 120 * @see org.kuali.kfs.module.purap.businessobject.AbstractRelatedView#getPurapDocumentIdentifier() 121 */ 122 @Override 123 public Integer getPurapDocumentIdentifier() { 124 return super.getPurapDocumentIdentifier(); 125 } 126 127 @Override 128 public String getDocumentIdentifierString() { 129 return super.getDocumentIdentifierString(); 130 } 131 132 /** 133 * @see org.kuali.kfs.module.purap.businessobject.AbstractRelatedView#getDocumentNumber() 134 */ 135 @Override 136 public String getDocumentNumber() { 137 return super.getDocumentNumber(); 138 } 139 140 /** 141 * @see org.kuali.kfs.module.purap.businessobject.AbstractRelatedView#getUrl() 142 */ 143 @Override 144 public String getUrl() { 145 return super.getUrl(); 146 } 147 148 /** 149 * Checks whether the purchase order view needs a warning to be displayed, i.e. it never has been opened. 150 * @return true if the purchase order needs a warning; false otherwise. 151 */ 152 public boolean getNeedWarning() { 153 return getPurchaseOrderInitialOpenTimestamp() == null; 154 } 155 }