View Javadoc

1   package org.kuali.ole.select.document;
2   
3   import org.kuali.ole.select.bo.OleLicenseRequestBo;
4   import org.kuali.ole.service.OleLicenseRequestService;
5   import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
6   import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
7   import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
8   
9   import java.util.ArrayList;
10  import java.util.List;
11  
12  /**
13   * Created with IntelliJ IDEA.
14   * User: juliyamonicas
15   * Date: 6/27/13
16   * Time: 11:25 AM
17   * To change this template use File | Settings | File Templates.
18   */
19  public class OLEEResourceLicense extends PersistableBusinessObjectBase {
20  
21      private String oleEResourceLicenseId;
22      private String oleERSIdentifier;
23      private String oleLicenseRequestId;
24      private String licenseDocumentNumber;
25      private String attachments;
26      private String licenseStartDate;
27      private String licenseEndDate;
28      private String licensor;
29      private DocumentRouteHeaderValue documentRouteHeaderValue = new DocumentRouteHeaderValue();
30      private OleLicenseRequestService oleLicenseRequestService;
31      private OleLicenseRequestBo oleLicenseRequestBo;
32      private OLEEResourceRecordDocument oleERSDocument = new OLEEResourceRecordDocument();
33      private String attachmentString = "No Attachments";
34  
35      public String getLicensor() {
36          return licensor;
37      }
38  
39      public void setLicensor(String licensor) {
40          this.licensor = licensor;
41      }
42  
43      public String getAttachmentString() {
44          return attachmentString;
45      }
46  
47      public void setAttachmentString(String attachmentString) {
48          this.attachmentString = attachmentString;
49      }
50  
51      public String getOleEResourceLicenseId() {
52          return oleEResourceLicenseId;
53      }
54  
55      public void setOleEResourceLicenseId(String oleEResourceLicenseId) {
56          this.oleEResourceLicenseId = oleEResourceLicenseId;
57      }
58  
59      public String getOleERSIdentifier() {
60          return oleERSIdentifier;
61      }
62  
63      public void setOleERSIdentifier(String oleERSIdentifier) {
64          this.oleERSIdentifier = oleERSIdentifier;
65      }
66  
67      public String getOleLicenseRequestId() {
68          return oleLicenseRequestId;
69      }
70  
71      public void setOleLicenseRequestId(String oleLicenseRequestId) {
72          this.oleLicenseRequestId = oleLicenseRequestId;
73      }
74  
75      public String getLicenseDocumentNumber() {
76          return licenseDocumentNumber;
77      }
78  
79      public void setLicenseDocumentNumber(String licenseDocumentNumber) {
80          this.licenseDocumentNumber = licenseDocumentNumber;
81      }
82  
83  
84      public String getAttachments() {
85          return attachments;
86      }
87  
88      public void setAttachments(String attachments) {
89          this.attachments = attachments;
90      }
91  
92      public String getLicenseStartDate() {
93          return licenseStartDate;
94      }
95  
96      public void setLicenseStartDate(String licenseStartDate) {
97          this.licenseStartDate = licenseStartDate;
98      }
99  
100     public String getLicenseEndDate() {
101         return licenseEndDate;
102     }
103 
104     public void setLicenseEndDate(String licenseEndDate) {
105         this.licenseEndDate = licenseEndDate;
106     }
107 
108     public DocumentRouteHeaderValue getDocumentRouteHeaderValue() {
109         return documentRouteHeaderValue;
110     }
111 
112     public void setDocumentRouteHeaderValue(DocumentRouteHeaderValue documentRouteHeaderValue) {
113         this.documentRouteHeaderValue = documentRouteHeaderValue;
114     }
115 
116     public OleLicenseRequestBo getOleLicenseRequestBo() {
117         if (oleLicenseRequestBo == null && documentRouteHeaderValue.getDocumentId() != null &&
118                 documentRouteHeaderValue != null) {
119             oleLicenseRequestBo = getOleLicenseRequestService().getLicenseRequestFromDocumentContent(documentRouteHeaderValue.getDocContent());
120         }
121         return oleLicenseRequestBo;
122     }
123 
124     public void setOleLicenseRequestBo(OleLicenseRequestBo oleLicenseRequestBo) {
125         this.oleLicenseRequestBo = oleLicenseRequestBo;
126     }
127 
128     public OleLicenseRequestService getOleLicenseRequestService() {
129         if (oleLicenseRequestService == null) {
130             oleLicenseRequestService = GlobalResourceLoader.getService("oleLicenseRequestService");
131         }
132         return oleLicenseRequestService;
133     }
134 
135     public OLEEResourceRecordDocument getOleERSDocument() {
136         return oleERSDocument;
137     }
138 
139     public void setOleERSDocument(OLEEResourceRecordDocument oleERSDocument) {
140         this.oleERSDocument = oleERSDocument;
141     }
142 
143     public String getAttachmentDisplay() {
144         String str = "";
145         List<String> list = new ArrayList<>();
146         list.add(getDocumentRouteHeaderValue().getDocumentId());
147 
148         for (String l : list) {
149             int i = getOleLicenseRequestService().getLicenseAttachments(getDocumentRouteHeaderValue().getDocumentId());
150             if (i > 1) {
151                 str = "MultipleAttachments";
152 
153             } else if (i == 1) {
154                 str = "View Attachments";
155 
156             } else if (i == 0) {
157                 str = "No Attachments";
158             } else {
159             }
160         }
161 
162         return str;
163 
164     }
165 
166     public String getUrl() {
167         String str = "";
168         List<String> list = new ArrayList<>();
169         list.add(getDocumentRouteHeaderValue().getDocumentId());
170 
171         for (String l : list) {
172             int i = getOleLicenseRequestService().getLicenseAttachments(getDocumentRouteHeaderValue().getDocumentId());
173             if (i > 1) {
174                 str = "oleLicenseRequest?methodToCall=docHandler&amp;docId=" + getDocumentRouteHeaderValue().getDocumentId() + "&amp;command=displayDocSearchView";
175 
176             } else if (i == 1) {
177                 str = "oleLicenseRequest?methodToCall=docHandler&amp;docId=" + getDocumentRouteHeaderValue().getDocumentId() + "&amp;command=displayDocSearchView";
178             } else if (i == 0) {
179                 str = "oleLicenseRequest?methodToCall=docHandler&amp;docId=" + getDocumentRouteHeaderValue().getDocumentId() + "&amp;command=displayDocSearchView";
180             } else {
181             }
182         }
183 
184         return str;
185 
186     }
187 }