View Javadoc
1   package org.kuali.ole.describe.form;
2   
3   /**
4    * Created with IntelliJ IDEA.
5    * User: pp7788
6    * Date: 12/11/12
7    * Time: 2:57 PM
8    * To change this template use File | Settings | File Templates.
9    */
10  
11  import org.kuali.ole.docstore.common.document.content.instance.*;
12  import org.kuali.ole.describe.bo.InstanceRecordMetaData;
13  import org.kuali.ole.describe.bo.SourceEditorForUI;
14  import org.kuali.ole.select.businessobject.OlePurchaseOrderItem;
15  import org.kuali.ole.select.document.OlePurchaseOrderDocument;
16  import org.kuali.ole.sys.OLEConstants;
17  import org.kuali.rice.core.api.config.property.ConfigContext;
18  import org.kuali.rice.krad.service.BusinessObjectService;
19  import org.kuali.rice.krad.service.KRADServiceLocator;
20  
21  import java.util.HashMap;
22  import java.util.List;
23  import java.util.Map;
24  
25  /**
26   * InstanceEditorForm is the form class for Instance Editor
27   */
28  public class WorkInstanceOlemlForm extends EditorForm {
29  
30      private InstanceRecordMetaData itemRecordMetaData = new InstanceRecordMetaData();
31      private InstanceRecordMetaData holdingRecordMetaData = new InstanceRecordMetaData();
32      private OleHoldings selectedHolding;
33      private Instance instance;
34      private Item selectedItem;
35      private SourceEditorForUI selectedSourceHolding;
36      private String oldItemStatus;
37      private String redirectUrl;
38      private String currentBarcode;
39      private String proxyBarcode;
40      private BusinessObjectService businessObjectService;
41      public WorkInstanceOlemlForm() {
42          getSelectedHolding().getUri().add(new Uri());
43          getSelectedHolding().getNote().add(new Note());
44          getSelectedHolding().getExtentOfOwnership().add(new ExtentOfOwnership());
45          getSelectedHolding().getExtentOfOwnership().get(0).getNote().add(new Note());
46          getSelectedItem().getNote().add(new Note());
47          getSelectedItem().getDonorInfo().add(new DonorInfo());
48      }
49  
50      /**
51       * Gets the instance of BusinessObjectService
52       *
53       * @return businessObjectService(BusinessObjectService)
54       */
55      public BusinessObjectService getBusinessObjectService() {
56          if (null == businessObjectService) {
57              businessObjectService = KRADServiceLocator.getBusinessObjectService();
58          }
59          return businessObjectService;
60      }
61  
62      public String getMessage() {
63          return message;
64      }
65  
66      public void setMessage(String message) {
67          this.message = message;
68      }
69  
70      public InstanceRecordMetaData getItemRecordMetaData() {
71          return itemRecordMetaData;
72      }
73  
74      public String getCurrentBarcode() {
75          return currentBarcode;
76      }
77  
78      public void setCurrentBarcode(String currentBarcode) {
79          this.currentBarcode = currentBarcode;
80      }
81  
82      public String getProxyBarcode() {
83          return proxyBarcode;
84      }
85  
86      public void setProxyBarcode(String proxyBarcode) {
87          this.proxyBarcode = proxyBarcode;
88      }
89  
90      public void setItemRecordMetaData(InstanceRecordMetaData itemRecordMetaData) {
91          this.itemRecordMetaData = itemRecordMetaData;
92      }
93  
94      public InstanceRecordMetaData getHoldingRecordMetaData() {
95          return holdingRecordMetaData;
96      }
97  
98      public void setHoldingRecordMetaData(InstanceRecordMetaData holdingRecordMetaData) {
99          this.holdingRecordMetaData = holdingRecordMetaData;
100     }
101 
102     public OleHoldings getSelectedHolding() {
103         if (null == selectedHolding) {
104             selectedHolding = new OleHoldings();
105             selectedHolding.setCallNumber(new CallNumber());
106         }
107         return selectedHolding;
108     }
109 
110     public void setSelectedHolding(OleHoldings selectedHolding) {
111         this.selectedHolding = selectedHolding;
112     }
113 
114     public Instance getInstance() {
115         return instance;
116     }
117 
118     public void setInstance(Instance instance) {
119         this.instance = instance;
120     }
121 
122     public Item getSelectedItem() {
123         if (null == selectedItem) {
124             selectedItem = new Item();
125             selectedItem.setCallNumber(new CallNumber());
126         }
127         return selectedItem;
128     }
129 
130     public void setSelectedItem(Item selectedItem) {
131         this.selectedItem = selectedItem;
132     }
133 
134     public SourceEditorForUI getSelectedSourceHolding() {
135         return selectedSourceHolding;
136     }
137 
138     public void setSelectedSourceHolding(SourceEditorForUI selectedSourceHolding) {
139         this.selectedSourceHolding = selectedSourceHolding;
140     }
141 
142     public String getOldItemStatus() {
143         return oldItemStatus;
144     }
145 
146     public void setOldItemStatus(String oldItemStatus) {
147         this.oldItemStatus = oldItemStatus;
148     }
149 
150     public String getRedirectUrl() {
151         String purchaseOrderLineItemIdentifier = this.getSelectedItem().getPurchaseOrderLineItemIdentifier();
152         if (purchaseOrderLineItemIdentifier != null && !"".equals(purchaseOrderLineItemIdentifier)) {
153             Map poNumber = new HashMap();
154             poNumber.put(OLEConstants.PUR_DOC_IDENTIFIER, purchaseOrderLineItemIdentifier);
155             List<OlePurchaseOrderDocument> olePurchaseOrderDocumentList = (List) getBusinessObjectService().findMatching(OlePurchaseOrderDocument.class, poNumber);
156             for (OlePurchaseOrderDocument olePurchaseOrderDocument : olePurchaseOrderDocumentList) {
157                 if (olePurchaseOrderDocument != null) {
158                     boolean validPO = olePurchaseOrderDocument!=null ? olePurchaseOrderDocument.getPurchaseOrderCurrentIndicatorForSearching() : false;
159                     if (validPO){
160                         redirectUrl = ConfigContext.getCurrentContextConfig().getProperty("kew.url") + OLEConstants.PO_LINE_ITEM_URL + olePurchaseOrderDocument.getDocumentNumber();
161                     }
162                 }
163             }
164         }
165         return redirectUrl;
166     }
167 
168     public void setRedirectUrl(String redirectUrl) {
169         this.redirectUrl = redirectUrl;
170     }
171 
172 
173 }