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      }
48  
49      /**
50       * Gets the instance of BusinessObjectService
51       *
52       * @return businessObjectService(BusinessObjectService)
53       */
54      public BusinessObjectService getBusinessObjectService() {
55          if (null == businessObjectService) {
56              businessObjectService = KRADServiceLocator.getBusinessObjectService();
57          }
58          return businessObjectService;
59      }
60  
61      public String getMessage() {
62          return message;
63      }
64  
65      public void setMessage(String message) {
66          this.message = message;
67      }
68  
69      public InstanceRecordMetaData getItemRecordMetaData() {
70          return itemRecordMetaData;
71      }
72  
73      public String getCurrentBarcode() {
74          return currentBarcode;
75      }
76  
77      public void setCurrentBarcode(String currentBarcode) {
78          this.currentBarcode = currentBarcode;
79      }
80  
81      public String getProxyBarcode() {
82          return proxyBarcode;
83      }
84  
85      public void setProxyBarcode(String proxyBarcode) {
86          this.proxyBarcode = proxyBarcode;
87      }
88  
89      public void setItemRecordMetaData(InstanceRecordMetaData itemRecordMetaData) {
90          this.itemRecordMetaData = itemRecordMetaData;
91      }
92  
93      public InstanceRecordMetaData getHoldingRecordMetaData() {
94          return holdingRecordMetaData;
95      }
96  
97      public void setHoldingRecordMetaData(InstanceRecordMetaData holdingRecordMetaData) {
98          this.holdingRecordMetaData = holdingRecordMetaData;
99      }
100 
101     public OleHoldings getSelectedHolding() {
102         if (null == selectedHolding) {
103             selectedHolding = new OleHoldings();
104             selectedHolding.setCallNumber(new CallNumber());
105         }
106         return selectedHolding;
107     }
108 
109     public void setSelectedHolding(OleHoldings selectedHolding) {
110         this.selectedHolding = selectedHolding;
111     }
112 
113     public Instance getInstance() {
114         return instance;
115     }
116 
117     public void setInstance(Instance instance) {
118         this.instance = instance;
119     }
120 
121     public Item getSelectedItem() {
122         if (null == selectedItem) {
123             selectedItem = new Item();
124             selectedItem.setCallNumber(new CallNumber());
125         }
126         return selectedItem;
127     }
128 
129     public void setSelectedItem(Item selectedItem) {
130         this.selectedItem = selectedItem;
131     }
132 
133     public SourceEditorForUI getSelectedSourceHolding() {
134         return selectedSourceHolding;
135     }
136 
137     public void setSelectedSourceHolding(SourceEditorForUI selectedSourceHolding) {
138         this.selectedSourceHolding = selectedSourceHolding;
139     }
140 
141     public String getOldItemStatus() {
142         return oldItemStatus;
143     }
144 
145     public void setOldItemStatus(String oldItemStatus) {
146         this.oldItemStatus = oldItemStatus;
147     }
148 
149     public String getRedirectUrl() {
150         String purchaseOrderLineItemIdentifier = this.getSelectedItem().getPurchaseOrderLineItemIdentifier();
151         if (purchaseOrderLineItemIdentifier != null && !"".equals(purchaseOrderLineItemIdentifier)) {
152             Map poNumber = new HashMap();
153             poNumber.put(OLEConstants.PUR_DOC_IDENTIFIER, purchaseOrderLineItemIdentifier);
154             List<OlePurchaseOrderDocument> olePurchaseOrderDocumentList = (List) getBusinessObjectService().findMatching(OlePurchaseOrderDocument.class, poNumber);
155             for (OlePurchaseOrderDocument olePurchaseOrderDocument : olePurchaseOrderDocumentList) {
156                 if (olePurchaseOrderDocument != null) {
157                     boolean validPO = olePurchaseOrderDocument!=null ? olePurchaseOrderDocument.getPurchaseOrderCurrentIndicatorForSearching() : false;
158                     if (validPO){
159                         redirectUrl = ConfigContext.getCurrentContextConfig().getProperty("kew.url") + OLEConstants.PO_LINE_ITEM_URL + olePurchaseOrderDocument.getDocumentNumber();
160                     }
161                 }
162             }
163         }
164         return redirectUrl;
165     }
166 
167     public void setRedirectUrl(String redirectUrl) {
168         this.redirectUrl = redirectUrl;
169     }
170 
171 
172 }