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
14
15
16
17
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 String documentDescription;
30 private DocumentRouteHeaderValue documentRouteHeaderValue = new DocumentRouteHeaderValue();
31 private OleLicenseRequestService oleLicenseRequestService;
32 private OleLicenseRequestBo oleLicenseRequestBo;
33 private OLEEResourceRecordDocument oleERSDocument = new OLEEResourceRecordDocument();
34 private String attachmentString = "No Attachments";
35
36 public String getLicensor() {
37 return licensor;
38 }
39
40 public void setLicensor(String licensor) {
41 this.licensor = licensor;
42 }
43
44 public String getDocumentDescription() {
45 return documentDescription;
46 }
47
48 public void setDocumentDescription(String documentDescription) {
49 this.documentDescription = documentDescription;
50 }
51
52 public String getAttachmentString() {
53 return attachmentString;
54 }
55
56 public void setAttachmentString(String attachmentString) {
57 this.attachmentString = attachmentString;
58 }
59
60 public String getOleEResourceLicenseId() {
61 return oleEResourceLicenseId;
62 }
63
64 public void setOleEResourceLicenseId(String oleEResourceLicenseId) {
65 this.oleEResourceLicenseId = oleEResourceLicenseId;
66 }
67
68 public String getOleERSIdentifier() {
69 return oleERSIdentifier;
70 }
71
72 public void setOleERSIdentifier(String oleERSIdentifier) {
73 this.oleERSIdentifier = oleERSIdentifier;
74 }
75
76 public String getOleLicenseRequestId() {
77 return oleLicenseRequestId;
78 }
79
80 public void setOleLicenseRequestId(String oleLicenseRequestId) {
81 this.oleLicenseRequestId = oleLicenseRequestId;
82 }
83
84 public String getLicenseDocumentNumber() {
85 return licenseDocumentNumber;
86 }
87
88 public void setLicenseDocumentNumber(String licenseDocumentNumber) {
89 this.licenseDocumentNumber = licenseDocumentNumber;
90 }
91
92
93 public String getAttachments() {
94 return attachments;
95 }
96
97 public void setAttachments(String attachments) {
98 this.attachments = attachments;
99 }
100
101 public String getLicenseStartDate() {
102 return licenseStartDate;
103 }
104
105 public void setLicenseStartDate(String licenseStartDate) {
106 this.licenseStartDate = licenseStartDate;
107 }
108
109 public String getLicenseEndDate() {
110 return licenseEndDate;
111 }
112
113 public void setLicenseEndDate(String licenseEndDate) {
114 this.licenseEndDate = licenseEndDate;
115 }
116
117 public DocumentRouteHeaderValue getDocumentRouteHeaderValue() {
118 return documentRouteHeaderValue;
119 }
120
121 public void setDocumentRouteHeaderValue(DocumentRouteHeaderValue documentRouteHeaderValue) {
122 this.documentRouteHeaderValue = documentRouteHeaderValue;
123 }
124
125 public OleLicenseRequestBo getOleLicenseRequestBo() {
126 if (oleLicenseRequestBo == null && documentRouteHeaderValue.getDocumentId() != null &&
127 documentRouteHeaderValue != null) {
128 oleLicenseRequestBo = getOleLicenseRequestService().getLicenseRequestFromDocumentContent(documentRouteHeaderValue.getDocContent());
129 }
130 return oleLicenseRequestBo;
131 }
132
133 public void setOleLicenseRequestBo(OleLicenseRequestBo oleLicenseRequestBo) {
134 this.oleLicenseRequestBo = oleLicenseRequestBo;
135 }
136
137 public OleLicenseRequestService getOleLicenseRequestService() {
138 if (oleLicenseRequestService == null) {
139 oleLicenseRequestService = GlobalResourceLoader.getService("oleLicenseRequestService");
140 }
141 return oleLicenseRequestService;
142 }
143
144 public OLEEResourceRecordDocument getOleERSDocument() {
145 return oleERSDocument;
146 }
147
148 public void setOleERSDocument(OLEEResourceRecordDocument oleERSDocument) {
149 this.oleERSDocument = oleERSDocument;
150 }
151
152 public String getAttachmentDisplay() {
153 String attachmentLinkLabel = "";
154 List<String> lists = new ArrayList<>();
155 lists.add(getDocumentRouteHeaderValue().getDocumentId());
156
157 for (String list : lists) {
158 int i = getOleLicenseRequestService().getLicenseAttachments(getDocumentRouteHeaderValue().getDocumentId());
159 if (i > 1) {
160 attachmentLinkLabel = "Multiple Attachments";
161 } else if (i == 1) {
162 attachmentLinkLabel = "View Attachments";
163 } else if (i == 0) {
164 attachmentLinkLabel = "No Attachments";
165 } else {
166 }
167 }
168
169 return attachmentLinkLabel;
170
171 }
172
173 public String getUrl() {
174 String link = "";
175 List<String> list = new ArrayList<>();
176 list.add(getDocumentRouteHeaderValue().getDocumentId());
177 for (String l : list) {
178 int i = getOleLicenseRequestService().getLicenseAttachments(getDocumentRouteHeaderValue().getDocumentId());
179 if (i > 1) {
180 link ="oleLicenseRequest?methodToCall=getDocument&viewId=OLEEresourceAgreementView&documentClass=org.kuali.rice.krad.web.form.MaintenanceDocumentForm&docId=" + getDocumentRouteHeaderValue().getDocumentId();
181 }
182 else if (i == 1) {
183 link = "oleLicenseRequest?methodToCall=downloadDocument&documentClass=org.kuali.rice.krad.web.form.MaintenanceDocumentForm&docId=" + getDocumentRouteHeaderValue().getDocumentId() + "&command=displayDocSearchView&selectedLineIndex=0";
184 }
185 else {
186 }
187 }
188
189 return link;
190
191 }
192 }