1 package org.kuali.ole.describe.controller;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.apache.solr.client.solrj.SolrServerException;
5 import org.kuali.asr.service.ASRHelperServiceImpl;
6 import org.kuali.ole.DocumentUniqueIDPrefix;
7 import org.kuali.ole.OLEConstants;
8 import org.kuali.ole.deliver.bo.ASRItem;
9 import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
10 import org.kuali.ole.deliver.bo.OleLoanDocument;
11 import org.kuali.ole.describe.bo.DocumentSelectionTree;
12 import org.kuali.ole.describe.bo.DocumentTreeNode;
13 import org.kuali.ole.describe.bo.InstanceEditorFormDataHandler;
14 import org.kuali.ole.describe.form.EditorForm;
15 import org.kuali.ole.describe.form.WorkBibMarcForm;
16 import org.kuali.ole.describe.form.WorkInstanceOlemlForm;
17 import org.kuali.ole.describe.keyvalue.LocationValuesBuilder;
18 import org.kuali.ole.docstore.common.client.DocstoreClient;
19 import org.kuali.ole.docstore.common.document.*;
20 import org.kuali.ole.docstore.common.document.HoldingsTree;
21 import org.kuali.ole.docstore.common.document.Item;
22 import org.kuali.ole.docstore.common.document.content.enums.DocCategory;
23 import org.kuali.ole.docstore.common.document.content.enums.DocFormat;
24 import org.kuali.ole.docstore.common.document.content.enums.DocType;
25 import org.kuali.ole.docstore.common.document.content.instance.*;
26 import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
27 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
28 import org.kuali.ole.docstore.common.exception.DocstoreException;
29 import org.kuali.ole.docstore.engine.client.DocstoreLocalClient;
30 import org.kuali.ole.select.bo.OLESerialReceivingDocument;
31 import org.kuali.ole.select.bo.OLESerialReceivingHistory;
32 import org.kuali.ole.select.businessobject.OleCopy;
33 import org.kuali.ole.service.impl.OLESerialReceivingServiceImpl;
34 import org.kuali.ole.sys.context.SpringContext;
35 import org.kuali.rice.core.api.config.property.ConfigurationService;
36 import org.kuali.rice.core.api.util.RiceConstants;
37 import org.kuali.rice.core.api.util.tree.Node;
38 import org.kuali.rice.kim.api.permission.PermissionService;
39 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
40 import org.kuali.rice.krad.service.BusinessObjectService;
41 import org.kuali.rice.krad.service.KRADServiceLocator;
42 import org.kuali.rice.krad.uif.UifParameters;
43 import org.kuali.rice.krad.util.GlobalVariables;
44 import org.kuali.rice.krad.util.KRADConstants;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
47
48 import javax.servlet.http.HttpServletRequest;
49 import java.text.Format;
50 import java.text.SimpleDateFormat;
51 import java.util.*;
52
53
54
55
56
57
58
59
60 public class WorkHoldingsOlemlEditor extends AbstractEditor {
61
62 private static final Logger LOG = LoggerFactory.getLogger(WorkHoldingsOlemlEditor.class);
63 private InstanceEditorFormDataHandler instanceEditorFormDataHandler = null;
64 private static WorkHoldingsOlemlEditor workHoldingsOlemlEditor = null;
65 private ItemOlemlRecordProcessor itemOlemlRecordProcessor ;
66 private ASRHelperServiceImpl asrHelperService ;
67 private BusinessObjectService businessObjectService ;
68 private DocstoreClient docstoreClient = getDocstoreLocalClient();
69
70 public static WorkHoldingsOlemlEditor getInstance() {
71 if (workHoldingsOlemlEditor == null) {
72 workHoldingsOlemlEditor = new WorkHoldingsOlemlEditor();
73 }
74 return workHoldingsOlemlEditor;
75 }
76
77 public ItemOlemlRecordProcessor getItemOlemlRecordProcessor(){
78 if(itemOlemlRecordProcessor == null){
79 itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
80 }
81 return itemOlemlRecordProcessor;
82 }
83
84
85 public ASRHelperServiceImpl getAsrHelperService(){
86 if(asrHelperService == null){
87 asrHelperService = new ASRHelperServiceImpl();
88 }
89 return asrHelperService;
90
91 }
92
93 public BusinessObjectService getBusinessObjectService(){
94 if(businessObjectService == null){
95 businessObjectService = KRADServiceLocator.getBusinessObjectService();
96 }
97 return businessObjectService;
98 }
99
100 private WorkHoldingsOlemlEditor() {
101
102 }
103
104 @Override
105 public EditorForm loadDocument(EditorForm editorForm) {
106
107
108 WorkInstanceOlemlForm workInstanceOlemlForm = new WorkInstanceOlemlForm();
109 String directory = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(org.kuali.ole.sys.OLEConstants.EXTERNALIZABLE_HELP_URL_KEY);
110 editorForm.setExternalHelpUrl(directory+"/reference/webhelp/CG/content/ch01s03.html#_Holdings");
111 editorForm.setHeaderText("Holdings");
112 editorForm.setHasLink(true);
113 editorForm.setShowEditorFooter(true);
114 String bibId = editorForm.getBibId();
115 List<BibTree> bibTreeList = new ArrayList();
116 Date date = new Date();
117 SimpleDateFormat sdf = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE+" HH:mm:ss");
118 String dateStr = sdf.format(date);
119 BibTree bibTree = null;
120 if (!StringUtils.isNotEmpty(bibId)) {
121 workInstanceOlemlForm.setMessage("Error: Invalid bibId id:" + bibId);
122 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO, "invalid.bib");
123 return workInstanceOlemlForm;
124 }
125
126 Bib bib = null;
127 try {
128 bibTree = docstoreClient.retrieveBibTree(bibId);
129 }catch (DocstoreException e) {
130 LOG.error("Exception : ", e);
131 DocstoreException docstoreException = (DocstoreException) e;
132 if (org.apache.commons.lang3.StringUtils.isNotEmpty(docstoreException.getErrorCode())) {
133 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, docstoreException.getErrorCode());
134 } else {
135 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, e.getMessage());
136 }
137 return workInstanceOlemlForm;
138 } catch (Exception e) {
139 LOG.error("Exception ", e);
140 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,"docstore.response", e.getMessage() );
141 }
142 bibTreeList.add(bibTree);
143 workInstanceOlemlForm.setBibTreeList(bibTreeList);
144 bib = bibTree.getBib();
145 editorForm.setTitle(bib.getTitle() + " / " + bib.getAuthor());
146 editorForm.setHasLink(true);
147 if (!isValidBib(bib.getContent())) {
148 workInstanceOlemlForm.setMessage("Error: Invalid bibId id:" + bibId);
149 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO, "invalid.bib");
150 return workInstanceOlemlForm;
151 }
152
153 String docId = editorForm.getDocId();
154 if (StringUtils.isNotEmpty(docId)) {
155 editorForm.setHoldingLocalIdentifier(DocumentUniqueIDPrefix.getDocumentId(editorForm.getDocId()));
156 Holdings holdings = null;
157 try {
158 holdings = docstoreClient.retrieveHoldings(editorForm.getDocId());
159 }catch (DocstoreException e) {
160 LOG.error("Exception : ", e);
161 DocstoreException docstoreException = (DocstoreException) e;
162 if (org.apache.commons.lang3.StringUtils.isNotEmpty(docstoreException.getErrorCode())) {
163 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, docstoreException.getErrorCode());
164 } else {
165 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, e.getMessage());
166 }
167 return workInstanceOlemlForm;
168 } catch (Exception e) {
169 LOG.error("Exception ", e);
170 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,"docstore.response", e.getMessage() );
171 } String docStoreData = holdings.getContent();
172 OleHoldings oleHoldings = null;
173 if (StringUtils.isNotEmpty(docStoreData)) {
174 oleHoldings = new HoldingOlemlRecordProcessor().fromXML(docStoreData);
175 editorForm.setStaffOnlyFlagForHoldings(holdings.isStaffOnly());
176 editorForm.setHoldingCreatedDate(holdings.getCreatedOn());
177 editorForm.setHoldingCreatedBy(holdings.getCreatedBy());
178 editorForm.setHoldingUpdatedDate(holdings.getUpdatedOn());
179 editorForm.setHoldingUpdatedBy(holdings.getUpdatedBy());
180
181
182 ensureMultipleValuesInOleHoldings(oleHoldings);
183
184 workInstanceOlemlForm.setSelectedHolding(oleHoldings);
185 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
186 } else {
187 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, "ds.error.holdings.notfound");
188 workInstanceOlemlForm.setViewId("WorkHoldingsViewPage");
189 return workInstanceOlemlForm;
190 }
191
192 if (editorForm.getEditable().equalsIgnoreCase("false")) {
193 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO,
194 "holdings.record.load.message");
195 } else {
196 boolean hasPermission = canEditInstance(GlobalVariables.getUserSession().getPrincipalId());
197 if (hasPermission) {
198 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO, "holdings.record.load.message");
199 } else {
200 editorForm.setHideFooter(false);
201 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_INFO, OLEConstants.ERROR_EDIT_INSTANCE);
202 }
203 }
204 } else {
205 editorForm.setHoldingLocalIdentifier("");
206 editorForm.setHoldingUpdatedBy("");
207 editorForm.setHoldingUpdatedDate("");
208 editorForm.setStaffOnlyFlagForHoldings(false);
209 editorForm.setHoldingCreatedBy(GlobalVariables.getUserSession().getPrincipalName());
210 editorForm.setHoldingCreatedDate(dateStr);
211 boolean hasPermission = canCreateInstance(GlobalVariables.getUserSession().getPrincipalId());
212 if (hasPermission) {
213 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO, "holdings.record.new.load.message");
214 } else {
215 editorForm.setHideFooter(false);
216 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_INFO, OLEConstants.ERROR_CREATE_INSTANCE);
217 }
218 }
219 if (editorForm.getDocId() != null) {
220 OLESerialReceivingServiceImpl oleSerialReceivingService = new OLESerialReceivingServiceImpl();
221 Map<String, String> map = new HashMap<>();
222 map.put("instanceId", editorForm.getDocId());
223 List<OLESerialReceivingDocument> oleSerialReceivingDocuments = (List<OLESerialReceivingDocument>) KRADServiceLocator.getBusinessObjectService().findMatching(OLESerialReceivingDocument.class, map);
224 for (OLESerialReceivingDocument oleSerialReceivingDocument : oleSerialReceivingDocuments) {
225 if (oleSerialReceivingDocument.isActive()) {
226 editorForm.setSerialFlag(true);
227 oleSerialReceivingService.readReceivingRecordType(oleSerialReceivingDocument);
228 oleSerialReceivingService.updateEnumCaptionValues(oleSerialReceivingDocument, null);
229 if (oleSerialReceivingDocument.getOleSerialReceivingHistoryList() != null && oleSerialReceivingDocument.getOleSerialReceivingHistoryList().size() > 0) {
230 for (int serialReceivingHistoryList = 0; serialReceivingHistoryList < oleSerialReceivingDocument.getOleSerialReceivingHistoryList().size(); serialReceivingHistoryList++) {
231 oleSerialReceivingService.setEnumerationAndChronologyValues(oleSerialReceivingDocument.getOleSerialReceivingHistoryList().get(serialReceivingHistoryList));
232 }
233 }
234 if (oleSerialReceivingDocument.getUnboundLocation() != null) {
235 editorForm.setUnboundLocation(oleSerialReceivingDocument.getUnboundLocation());
236 }
237 oleSerialReceivingService.sortById(oleSerialReceivingDocument.getOleSerialReceivingHistoryList());
238 for (OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
239 if (oleSerialReceivingHistory.isPublicDisplay()) {
240 if (oleSerialReceivingHistory.getReceivingRecordType().equalsIgnoreCase("Main")) {
241 editorForm.getMainSerialReceivingHistoryList().add(oleSerialReceivingHistory);
242 }
243 if (oleSerialReceivingHistory.getReceivingRecordType().equalsIgnoreCase("Supplementary")) {
244 editorForm.getSupplementSerialReceivingHistoryList().add(oleSerialReceivingHistory);
245 }
246 if (oleSerialReceivingHistory.getReceivingRecordType().equalsIgnoreCase("Index")) {
247 editorForm.getIndexSerialReceivingHistoryList().add(oleSerialReceivingHistory);
248 }
249 }
250 }
251 }
252 }
253 }
254 workInstanceOlemlForm.setViewId("WorkHoldingsViewPage");
255 return workInstanceOlemlForm;
256 }
257
258 private void ensureMultipleValuesInOleHoldings(OleHoldings oleHoldings) {
259 List<ExtentOfOwnership> extentOfOwnerships = ensureAtleastOneExtentOfOwnership(
260 oleHoldings.getExtentOfOwnership());
261 oleHoldings.setExtentOfOwnership(extentOfOwnerships);
262
263 List<Note> notes = ensureAtleastOneNote(oleHoldings.getNote());
264 oleHoldings.setNote(notes);
265
266 List<Uri> uriList = ensureAtleastOneUri(oleHoldings.getUri());
267 oleHoldings.setUri(uriList);
268 }
269
270 @Override
271 public EditorForm saveDocument(EditorForm editorForm) {
272 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
273 String bibId = editorForm.getBibId();
274 List<BibTree> bibTreeList = null;
275 BibTree bibTree = null;
276 HoldingsTree holdingsTree = new HoldingsTree();
277 String editorMessage = "";
278 Bib bib = null;
279 Date date = new Date();
280 SimpleDateFormat sdf = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE+" HH:mm:ss");
281 String dateStr = sdf.format(date);
282 String user = GlobalVariables.getUserSession().getPrincipalName();
283 try {
284 bibTree = docstoreClient.retrieveBibTree(bibId);
285 }catch (DocstoreException e) {
286 LOG.error("Exception : ", e);
287 DocstoreException docstoreException = (DocstoreException) e;
288 if (org.apache.commons.lang3.StringUtils.isNotEmpty(docstoreException.getErrorCode())) {
289 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, docstoreException.getErrorCode());
290 } else {
291 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, e.getMessage());
292 }
293 return workInstanceOlemlForm;
294 } catch (Exception e) {
295 LOG.error("Exception ", e);
296 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,"docstore.response", e.getMessage() );
297 }
298 bibTreeList = new ArrayList();
299 bibTreeList.add(bibTree);
300 workInstanceOlemlForm.setBibTreeList(bibTreeList);
301 bib = bibTree.getBib();
302 editorForm.setTitle(bib.getTitle() + " / " + bib.getAuthor());
303 editorForm.setHasLink(true);
304
305 editorForm.setHeaderText("Holdings");
306 editorForm.setShowEditorFooter(true);
307 String docId = editorForm.getDocId();
308 if (StringUtils.isNotEmpty(docId)) {
309 List<HoldingsTree> holdingsTreeList = new ArrayList<>();
310 for(HoldingsTree holdingsTree1 : bibTree.getHoldingsTrees()) {
311 if(!holdingsTree1.getHoldings().getId().equals(docId)) {
312 holdingsTreeList.add(holdingsTree1);
313 }
314 }
315 bibTree.getHoldingsTrees().clear();
316 bibTree.getHoldingsTrees().addAll(holdingsTreeList);
317 Holdings holdings = new PHoldings();
318 OleHoldings holdingData = workInstanceOlemlForm.getSelectedHolding();
319 if (!isValidHoldingsData(workInstanceOlemlForm)) {
320 return workInstanceOlemlForm;
321 }
322 try {
323 String holdingXmlContent = getInstanceEditorFormDataHandler().buildHoldingContent(holdingData);
324 holdings.setContent(holdingXmlContent);
325 } catch (Exception e) {
326 LOG.error("Exception :", e);
327 GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.GLOBAL_ERRORS,
328 "docstore.response", e.getMessage());
329 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
330 return workInstanceOlemlForm;
331 }
332 holdings.setId(docId);
333 holdings.setStaffOnly(editorForm.isStaffOnlyFlagForHoldings());
334 holdings.setCreatedBy(editorForm.getCreatedBy());
335 holdings.setCreatedOn(editorForm.getCreatedDate());
336 holdings.setUpdatedBy(user);
337 holdings.setUpdatedOn(dateStr);
338 String holdingsCreatedDate = null;
339 Format formatter = new SimpleDateFormat("dd-MM-yyyy HH-mm-ss");
340 holdingsCreatedDate = formatter.format(new Date());
341 holdings.setLastUpdated(holdingsCreatedDate);
342 holdings.setBib(bib);
343 holdings.setCategory(editorForm.getDocCategory());
344 holdings.setType(editorForm.getDocType());
345 holdings.setFormat(editorForm.getDocFormat());
346 long startTime = System.currentTimeMillis();
347 try {
348 docstoreClient.updateHoldings(holdings);
349 } catch (Exception e) {
350 LOG.error("Exception :", e);
351 DocstoreException docstoreException = (DocstoreException) e;
352 if (org.apache.commons.lang3.StringUtils.isNotEmpty(docstoreException.getErrorCode())) {
353 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, docstoreException.getErrorCode());
354 } else {
355 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, e.getMessage());
356 }
357 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
358 return workInstanceOlemlForm;
359 }
360 long endTime = System.currentTimeMillis();
361 editorForm.setSolrTime(String.valueOf((endTime-startTime)/1000));
362 editorForm.setUpdatedDate(holdings.getUpdatedOn());
363 editorForm.setUpdatedBy(holdings.getUpdatedBy());
364 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
365 editorMessage = "holdings.record.update.message";
366 workInstanceOlemlForm.setViewId("WorkHoldingsViewPage");
367 } else {
368
369 if (!isValidHoldingsData(workInstanceOlemlForm)) {
370 return workInstanceOlemlForm;
371 }
372 String content = null;
373 try {
374 content = getInstanceEditorFormDataHandler().buildHoldingContent(workInstanceOlemlForm.getSelectedHolding());
375 } catch (Exception e) {
376 LOG.error("Exception :", e);
377 e.printStackTrace();
378 return workInstanceOlemlForm;
379 }
380
381 String staffOnlyFlagForHoldings = String.valueOf(editorForm.isStaffOnlyFlagForHoldings());
382
383
384
385 Holdings holdings = new PHoldings();
386 holdings.setCategory(DocCategory.WORK.getCode());
387 holdings.setType(DocType.HOLDINGS.getCode());
388 holdings.setFormat(DocFormat.OLEML.getCode());
389 holdings.setCreatedOn(dateStr);
390 holdings.setCreatedBy(user);
391 holdings.setStaffOnly(editorForm.isStaffOnlyFlagForHoldings());
392 holdings.setContent(content);
393 holdings.setBib(bib);
394
395 holdingsTree.setHoldings(holdings);
396 holdingsTree.getItems().add(getItemRecord());
397
398 long startTime = System.currentTimeMillis();
399 try {
400 docstoreClient.createHoldingsTree(holdingsTree);
401 editorForm.setDocId(holdingsTree.getHoldings().getId());
402 editorForm.setHoldingCreatedBy(holdingsTree.getHoldings().getCreatedBy());
403 editorForm.setHoldingCreatedDate(holdingsTree.getHoldings().getCreatedOn());
404 if (workInstanceOlemlForm.getBibTreeList() == null && workInstanceOlemlForm.getBibTreeList().size() == 0) {
405 bibTreeList = new ArrayList<>();
406 bibTree = new BibTree();
407 bibTree.setId(bib.getId());
408 bibTree.setBib(bib);
409 bibTreeList.add(bibTree);
410 workInstanceOlemlForm.setBibTreeList(bibTreeList);
411 } else {
412 bibTreeList = workInstanceOlemlForm.getBibTreeList();
413 bibTree = bibTreeList.get(0);
414 }
415
416 List<HoldingsTree> holdingsTreeList = new ArrayList<>();
417 holdingsTreeList.add(holdingsTree);
418
419 }catch (DocstoreException e) {
420 LOG.error("Exception : ", e);
421 DocstoreException docstoreException = (DocstoreException) e;
422 if (org.apache.commons.lang3.StringUtils.isNotEmpty(docstoreException.getErrorCode())) {
423 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, docstoreException.getErrorCode());
424 } else {
425 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, e.getMessage());
426 }
427 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
428 return workInstanceOlemlForm;
429 } catch (Exception e) {
430 LOG.error("Exception ", e);
431 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,"docstore.response", e.getMessage() );
432 }
433 long endTime = System.currentTimeMillis();
434 editorForm.setSolrTime(String.valueOf((endTime-startTime)/1000));
435 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
436 editorMessage = "record.create.message";
437 }
438
439
440
441 if (processAsr(editorForm, workInstanceOlemlForm, bibTree, holdingsTree, editorMessage, bib)){
442 return workInstanceOlemlForm;
443 }
444
445 return workInstanceOlemlForm;
446 }
447
448 private boolean processAsr(EditorForm editorForm, WorkInstanceOlemlForm workInstanceOlemlForm, BibTree bibTree, HoldingsTree holdingsTree, String editorMessage, Bib bib) {
449 try {
450 if(holdingsTree.getHoldings() == null) {
451 holdingsTree = docstoreClient.retrieveHoldingsTree(editorForm.getDocId());
452 }
453 String holdingLocation = null;
454 if (workInstanceOlemlForm.getSelectedHolding() != null && workInstanceOlemlForm.getSelectedHolding().getLocation() != null && workInstanceOlemlForm.getSelectedHolding().getLocation().getLocationLevel() != null) {
455 holdingLocation = instanceEditorFormDataHandler.getLocationCode(workInstanceOlemlForm.getSelectedHolding().getLocation().getLocationLevel());
456 }
457 String callNumber;
458 String prefix;
459 if(holdingLocation != null){
460 if(getAsrHelperService().isAnASRItem(holdingLocation)){
461 List<Item> items = holdingsTree.getItems();
462 List<ASRItem> asrItems = new ArrayList<ASRItem>();
463 ASRItem asrItem = null;
464 if(items != null && items.size()>0){
465 for(Item item : items){
466 org.kuali.ole.docstore.common.document.content.instance.Item itemData = getItemOlemlRecordProcessor().fromXML(item.getContent());
467 asrItem = new ASRItem();
468 if(itemData.getAccessInformation()!=null && itemData.getAccessInformation().getBarcode()!=null){
469 asrItem.setItemBarcode(itemData.getAccessInformation().getBarcode());
470 }
471
472 Map<String,String> asrItemMap = new HashMap<String,String>();
473 asrItemMap.put("itemBarcode", asrItem.getItemBarcode());
474 List<ASRItem> existingASRItems = (List<ASRItem>)getBusinessObjectService().findMatching(ASRItem.class,asrItemMap);
475
476 if(existingASRItems.size()==0){
477 if(bib.getTitle()!=null){
478 asrItem.setTitle((bib.getTitle().length()>37)?bib.getTitle().substring(0,36):bib.getTitle());
479 }
480 if(bib.getAuthor()!=null){
481 asrItem.setAuthor((bib.getAuthor().length()>37)?bib.getAuthor().substring(0,36):bib.getAuthor());
482 }
483 if (itemData.getCallNumber() != null && itemData.getCallNumber().getNumber() != null && !itemData.getCallNumber().getNumber().isEmpty()) {
484 callNumber=(itemData.getCallNumber().getNumber().length() > 37) ? itemData.getCallNumber().getNumber().substring(0, 36) : itemData.getCallNumber().getNumber();
485 prefix=itemData.getCallNumber().getPrefix()!=null&&!itemData.getCallNumber().getPrefix().isEmpty()?itemData.getCallNumber().getPrefix():"";
486 asrItem.setCallNumber(prefix+" "+callNumber);
487 } else if(workInstanceOlemlForm.getSelectedHolding() !=null && workInstanceOlemlForm.getSelectedHolding().getCallNumber() !=null &&
488 workInstanceOlemlForm.getSelectedHolding().getCallNumber().getNumber() !=null && !workInstanceOlemlForm.getSelectedHolding().getCallNumber().getNumber().isEmpty()){
489 callNumber=(workInstanceOlemlForm.getSelectedHolding().getCallNumber().getNumber().length() > 37) ? workInstanceOlemlForm.getSelectedHolding().getCallNumber().getNumber().substring(0, 36) : workInstanceOlemlForm.getSelectedHolding().getCallNumber().getNumber();
490 prefix=workInstanceOlemlForm.getSelectedHolding().getCallNumber().getPrefix()!=null&&!workInstanceOlemlForm.getSelectedHolding().getCallNumber().getPrefix().isEmpty()?workInstanceOlemlForm.getSelectedHolding().getCallNumber().getPrefix():"";
491 asrItem.setCallNumber(prefix+" "+callNumber);
492 }
493
494 asrItems.add(asrItem);
495 }
496 }
497 }
498 getBusinessObjectService().save(asrItems);
499 }
500 }
501 Holdings holdings = holdingsTree.getHoldings();
502 bibTree.getHoldingsTrees().add(holdingsTree);
503 Collections.sort(bibTree.getHoldingsTrees());
504 String docStoreData = holdings.getContent();
505 OleHoldings oleHoldings = new HoldingOlemlRecordProcessor().fromXML(docStoreData);
506 workInstanceOlemlForm.setSelectedHolding(oleHoldings);
507 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
508 editorForm.setHoldingLocalIdentifier(DocumentUniqueIDPrefix.getDocumentId(holdings.getId()));
509 editorForm.setHoldingUpdatedBy(holdings.getUpdatedBy());
510 editorForm.setHoldingCreatedDate(holdings.getCreatedOn());
511 editorForm.setHoldingCreatedBy(holdings.getCreatedBy());
512 editorForm.setHoldingUpdatedDate(holdings.getUpdatedOn());
513 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_MESSAGES, editorMessage);
514 ensureMultipleValuesInOleHoldings(oleHoldings);
515 }catch (DocstoreException e) {
516 LOG.error("Exception : ", e);
517 DocstoreException docstoreException = (DocstoreException) e;
518 if (org.apache.commons.lang3.StringUtils.isNotEmpty(docstoreException.getErrorCode())) {
519 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, docstoreException.getErrorCode());
520 } else {
521 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, e.getMessage());
522 }
523 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
524 return true;
525 } catch (Exception e) {
526 LOG.error("Exception ", e);
527 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,"docstore.response", e.getMessage() );
528 }
529 return false;
530 }
531
532 private List<Uri> ensureAtleastOneUri(List<Uri> uris) {
533 if (uris == null) {
534 uris = new ArrayList<Uri>();
535 }
536 if (uris.size() == 0) {
537 Uri uri = new Uri();
538 uris.add(uri);
539 }
540 return uris;
541 }
542
543 private List<Note> ensureAtleastOneNote(List<Note> notes) {
544 if (notes == null) {
545 notes = new ArrayList<Note>();
546 }
547 if (notes.size() == 0) {
548 Note note = new Note();
549 notes.add(note);
550 }
551 return notes;
552 }
553
554
555 private List<ExtentOfOwnership> ensureAtleastOneExtentOfOwnership(List<ExtentOfOwnership> extentOfOwnerships) {
556 if (extentOfOwnerships == null) {
557 extentOfOwnerships = new ArrayList<ExtentOfOwnership>();
558 }
559 if (extentOfOwnerships.size() == 0) {
560 ExtentOfOwnership extentOfOwnership = new ExtentOfOwnership();
561 extentOfOwnership.getNote().add(new Note());
562 extentOfOwnerships.add(0, extentOfOwnership);
563 }
564 return extentOfOwnerships;
565 }
566
567
568
569
570
571
572 private InstanceEditorFormDataHandler getInstanceEditorFormDataHandler() {
573 if (null == instanceEditorFormDataHandler) {
574 instanceEditorFormDataHandler = new InstanceEditorFormDataHandler();
575 }
576 return instanceEditorFormDataHandler;
577 }
578
579 private boolean canCreateInstance(String principalId) {
580 PermissionService service = KimApiServiceLocator.getPermissionService();
581 return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.INSTANCE_EDITOR_ADD_INSTANCE);
582 }
583
584 private boolean canEditInstance(String principalId) {
585 PermissionService service = KimApiServiceLocator.getPermissionService();
586 return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.INSTANCE_EDITOR_EDIT_INSTANCE);
587 }
588
589
590
591
592
593
594 private boolean isValidHoldingsData(WorkInstanceOlemlForm workInstanceOlemlForm) {
595 OleHoldings oleHoldings = workInstanceOlemlForm.getSelectedHolding();
596 String location = null;
597 if (oleHoldings != null && oleHoldings.getLocation() != null && oleHoldings.getLocation().getLocationLevel() != null) {
598 location = oleHoldings.getLocation().getLocationLevel().getName();
599 }
600 if (location != null && location.length() != 0 && !isValidLocation(location)) {
601
602 GlobalVariables.getMessageMap().putError("documentForm.selectedHolding.location.locationLevel.name", "error.location");
603 workInstanceOlemlForm.setValidInput(false);
604 return false;
605 }
606 return true;
607 }
608
609 private boolean isValidLocation(String location) {
610
611 List<String> locationList = LocationValuesBuilder.retrieveLocationDetailsForSuggest(location);
612 if (locationList != null && locationList.size() > 0) {
613 for (String locationValue : locationList) {
614 if (locationValue.equalsIgnoreCase(location)) {
615 return true;
616 }
617 }
618 }
619 return false;
620 }
621
622 @Override
623 public EditorForm addORRemoveExtentOfOwnership(EditorForm editorForm, HttpServletRequest request) {
624 String methodName = request.getParameter("methodToCall");
625 if (methodName.equalsIgnoreCase("addExtentOfOwnership")) {
626 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
627 int index = Integer.parseInt(editorForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
628 index++;
629 List<ExtentOfOwnership> extentOfOwnershipForUI = workInstanceOlemlForm.getSelectedHolding().getExtentOfOwnership();
630 ExtentOfOwnership extentOfOwnership = new ExtentOfOwnership();
631 extentOfOwnership.getNote().add(new Note());
632 extentOfOwnershipForUI.add(index, extentOfOwnership);
633 editorForm.setDocumentForm(workInstanceOlemlForm);
634 } else if (methodName.equalsIgnoreCase("removeExtentOfOwnership")) {
635 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
636 int index = Integer.parseInt(editorForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
637 List<ExtentOfOwnership> extentOfOwnershipForUI = workInstanceOlemlForm.getSelectedHolding().getExtentOfOwnership();
638 if (extentOfOwnershipForUI.size() > 1) {
639 extentOfOwnershipForUI.remove(index);
640 } else {
641 if (extentOfOwnershipForUI.size() == 1) {
642 extentOfOwnershipForUI.remove(index);
643 ExtentOfOwnership extentOfOwnership = new ExtentOfOwnership();
644 extentOfOwnershipForUI.add(extentOfOwnership);
645 extentOfOwnership.getNote().add(new Note());
646 }
647 }
648 editorForm.setDocumentForm(workInstanceOlemlForm);
649 } else if (methodName.equalsIgnoreCase("addEOWHoldingNotes")) {
650 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
651 int index = Integer.parseInt(editorForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
652 String selectedPath = editorForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
653 int selectedExtentIndex = Integer.parseInt(StringUtils.substring(selectedPath,
654 (StringUtils.indexOf(selectedPath, "[") + 1),
655 StringUtils.lastIndexOf(selectedPath, "]")));
656 index++;
657 List<Note> holdingsNote = workInstanceOlemlForm.getSelectedHolding().getExtentOfOwnership()
658 .get(selectedExtentIndex).getNote();
659 holdingsNote.add(index, new Note());
660 editorForm.setDocumentForm(workInstanceOlemlForm);
661 } else if (methodName.equalsIgnoreCase("removeEOWHoldingNotes")) {
662 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
663 int index = Integer.parseInt(editorForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
664 String selectedPath = editorForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
665 int selectedExtentIndex = Integer.parseInt(StringUtils.substring(selectedPath,
666 (StringUtils.indexOf(selectedPath, "[") + 1),
667 StringUtils.lastIndexOf(selectedPath, "]")));
668 List<Note> holdingsNote = workInstanceOlemlForm.getSelectedHolding().getExtentOfOwnership()
669 .get(selectedExtentIndex).getNote();
670 if (holdingsNote.size() > 1) {
671 holdingsNote.remove(index);
672 } else {
673 if (holdingsNote.size() == 1) {
674 holdingsNote.remove(index);
675 Note note = new Note();
676 holdingsNote.add(note);
677 }
678 }
679 editorForm.setDocumentForm(workInstanceOlemlForm);
680 }
681 return editorForm;
682 }
683
684 @Override
685 public EditorForm addORRemoveAccessInformationAndHoldingsNotes(EditorForm editorForm, HttpServletRequest request) {
686 String methodName = request.getParameter("methodToCall");
687 if (methodName.equalsIgnoreCase("addAccessInformation")) {
688 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
689 int index = Integer.parseInt(editorForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
690 index++;
691 List<Uri> accessInformation = workInstanceOlemlForm.getSelectedHolding().getUri();
692 accessInformation.add(index, new Uri());
693 editorForm.setDocumentForm(workInstanceOlemlForm);
694 } else if (methodName.equalsIgnoreCase("removeAccessInformation")) {
695 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
696 int index = Integer.parseInt(editorForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
697 List<Uri> accessInformation = workInstanceOlemlForm.getSelectedHolding().getUri();
698 if (accessInformation.size() > 1) {
699 accessInformation.remove(index);
700 } else {
701 if (accessInformation.size() == 1) {
702 accessInformation.remove(index);
703 Uri uri = new Uri();
704 accessInformation.add(uri);
705 }
706 }
707 editorForm.setDocumentForm(workInstanceOlemlForm);
708 } else if (methodName.equalsIgnoreCase("addHoldingNotes")) {
709 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
710 int index = Integer.parseInt(editorForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
711 index++;
712 List<Note> holdingsNote = workInstanceOlemlForm.getSelectedHolding().getNote();
713 holdingsNote.add(index, new Note());
714 editorForm.setDocumentForm(workInstanceOlemlForm);
715 } else if (methodName.equalsIgnoreCase("removeHoldingNotes")) {
716 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
717 int index = Integer.parseInt(editorForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
718 List<Note> holdingsNote = workInstanceOlemlForm.getSelectedHolding().getNote();
719 if (holdingsNote.size() > 1) {
720 holdingsNote.remove(index);
721 } else {
722 if (holdingsNote.size() == 1) {
723 holdingsNote.remove(index);
724 Note note = new Note();
725 holdingsNote.add(note);
726 }
727 }
728 editorForm.setDocumentForm(workInstanceOlemlForm);
729 }
730 return editorForm;
731 }
732
733 private boolean isValidBib(String bibData) {
734 if (bibData.contains("collection") || bibData.contains("OAI-PMH")) {
735 return true;
736 }
737 return false;
738 }
739
740 @Override
741 public EditorForm createNewRecord(EditorForm editorForm, BibTree bibTree) {
742
743 if (editorForm.getDocumentForm().getViewId().equalsIgnoreCase("WorkHoldingsViewPage")) {
744 editorForm.setNeedToCreateInstance(true);
745 }
746 editNewRecord(editorForm, bibTree);
747 return editorForm.getDocumentForm();
748 }
749
750
751 @Override
752 public EditorForm editNewRecord(EditorForm editorForm, BibTree bibTree) {
753 WorkInstanceOlemlForm workInstanceOlemlForm = new WorkInstanceOlemlForm();
754 if ((editorForm.getDocumentForm() instanceof WorkInstanceOlemlForm)) {
755 workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
756 workInstanceOlemlForm.setViewId(editorForm.getDocumentForm().getViewId());
757 }
758
759 workInstanceOlemlForm.setDocCategory("work");
760 workInstanceOlemlForm.setDocType("holdings");
761 workInstanceOlemlForm.setDocFormat("oleml");
762
763 if (bibTree != null && bibTree.getHoldingsTrees() != null) {
764 HoldingsTree holdingsTree = bibTree.getHoldingsTrees().get(0);
765 HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor();
766 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
767 OleHoldings oleHoldings = holdingOlemlRecordProcessor.fromXML(holdingsTree.getHoldings().getContent());
768 if (editorForm.getDocumentForm().getViewId().equalsIgnoreCase("WorkHoldingsViewPage")) {
769
770 editorForm.setHeaderText("Import Bib Step-4 Item");
771
772 if (!isValidHoldingsData(workInstanceOlemlForm)) {
773 return workInstanceOlemlForm;
774 }
775 holdingsTree.getHoldings().setStaffOnly(editorForm.isStaffOnlyFlagForHoldings());
776 holdingsTree.getHoldings().setCreatedBy(GlobalVariables.getUserSession().getPrincipalName());
777 org.kuali.ole.docstore.common.document.content.instance.Item item = itemOlemlRecordProcessor.fromXML(holdingsTree.getItems().get(0).getContent());
778 List<Note> notes = ensureAtleastOneNote(item.getNote());
779 item.setNote(notes);
780 workInstanceOlemlForm.setSelectedItem(item);
781 workInstanceOlemlForm.setViewId("WorkItemViewPage");
782
783 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO,
784 "item.details.new.message");
785 } else if (editorForm.getDocumentForm().getViewId().equalsIgnoreCase("WorkBibEditorViewPage")) {
786
787 editorForm.setHeaderText("Import Bib Step-4 Holdings");
788 workInstanceOlemlForm.setViewId("WorkHoldingsViewPage");
789
790 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO,
791 "holdings.record.new.load.message");
792 workInstanceOlemlForm
793 .setSelectedHolding(oleHoldings);
794 }
795 }
796 editorForm.setDocumentForm(workInstanceOlemlForm);
797 return editorForm;
798 }
799
800 public EditorForm deleteVerify(EditorForm editorForm) {
801
802 WorkInstanceOlemlForm workInstanceOlemlForm = new WorkInstanceOlemlForm();
803 String docId = editorForm.getDocId();
804 String operation = "deleteVerify";
805
806
807
808 editorForm.setShowDeleteTree(true);
809 editorForm.setHasLink(true);
810
811 List<String> uuidList = new ArrayList<>(0);
812 uuidList.add(editorForm.getDocId());
813 DocumentSelectionTree documentSelectionTree = new DocumentSelectionTree();
814 Node<DocumentTreeNode, String> docTree = null;
815 try {
816 docTree = documentSelectionTree.add(uuidList, editorForm.getDocType());
817 } catch (SolrServerException e) {
818 LOG.error("Exception :", e);
819 e.printStackTrace();
820 }
821 editorForm.getDocTree().setRootElement(docTree);
822 editorForm.setViewId("DeleteViewPage");
823 return editorForm;
824
825 }
826
827
828
829
830
831
832
833 public EditorForm delete(EditorForm editorForm) throws Exception {
834 return deleteFromDocStore(editorForm);
835 }
836
837 @Override
838 public EditorForm showBibs(EditorForm editorForm) {
839 String instanceId = "";
840 String docType = editorForm.getDocType();
841 List<Bib> bibs = new ArrayList<Bib>();
842 if ((docType.equalsIgnoreCase(DocType.HOLDINGS.getCode())) || (docType
843 .equalsIgnoreCase(DocType.ITEM.getCode()))) {
844 instanceId = editorForm.getHoldingsId();
845 }
846 if (StringUtils.isNotEmpty(instanceId)) {
847 try {
848 Holdings holdings = docstoreClient.retrieveHoldings(instanceId);
849 bibs = holdings.getBibs().getBibs();
850 } catch (Exception e) {
851 LOG.error("Exception :", e);
852 e.printStackTrace();
853 }
854 }
855 editorForm.setBibList(bibs);
856 editorForm.setViewId("ShowBibViewPage");
857 return editorForm;
858 }
859
860
861 public EditorForm bulkUpdate(EditorForm editorForm,List<String> holdingIds) {
862 WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
863 String bibId = editorForm.getBibId();
864 List<BibTree> bibTreeList = new ArrayList<BibTree>();
865 BibTree bibTree = null;
866 String editorMessage = "";
867 Bib bib = null;
868 Date date = new Date();
869 SimpleDateFormat sdf = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE+" HH:mm:ss");
870 String dateStr = sdf.format(date);
871 String user = GlobalVariables.getUserSession().getPrincipalName();
872 workInstanceOlemlForm.setBibTreeList(bibTreeList);
873 editorForm.setHeaderText("Global Instance Editor");
874 String docId = editorForm.getDocId();
875 Holdings holdings = new PHoldings();
876 OleHoldings holdingData = workInstanceOlemlForm.getSelectedHolding();
877 if (!isValidHoldingsData(workInstanceOlemlForm)) {
878 return workInstanceOlemlForm;
879 }
880 try {
881 String holdingXmlContent = getInstanceEditorFormDataHandler().buildHoldingContent(holdingData);
882 holdings.setCategory(holdingXmlContent);
883 holdings.setContent(holdingXmlContent);
884 } catch (Exception e) {
885 LOG.error("Exception :", e);
886 GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.GLOBAL_ERRORS,
887 "docstore.response", e.getMessage());
888 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
889 return workInstanceOlemlForm;
890 }
891 holdings.setId(docId);
892 String canUpdateStaffOnlyFlag = "false";
893 if (editorForm.getStaffOnlyFlagInGlobalEdit() != null && editorForm.getStaffOnlyFlagInGlobalEdit().equalsIgnoreCase("Y")) {
894 canUpdateStaffOnlyFlag = "true";
895 editorForm.setStaffOnlyFlagForHoldings(true);
896 holdings.setStaffOnly(editorForm.isStaffOnlyFlagForHoldings());
897 }
898 else if (editorForm.getStaffOnlyFlagInGlobalEdit() != null && editorForm.getStaffOnlyFlagInGlobalEdit().equalsIgnoreCase("N")) {
899 canUpdateStaffOnlyFlag = "true";
900 editorForm.setStaffOnlyFlagForHoldings(false);
901 holdings.setStaffOnly(editorForm.isStaffOnlyFlagForHoldings());
902 }
903 holdings.setStaffOnly(editorForm.isStaffOnlyFlagForHoldings());
904 holdings.setCreatedBy(editorForm.getCreatedBy());
905 holdings.setCreatedOn(editorForm.getCreatedDate());
906 holdings.setUpdatedBy(user);
907 holdings.setUpdatedOn(dateStr);
908 String holdingsCreatedDate = null;
909 Format formatter = new SimpleDateFormat("dd-MM-yyyy HH-mm-ss");
910 holdingsCreatedDate = formatter.format(new Date());
911 holdings.setLastUpdated(holdingsCreatedDate);
912
913 holdings.setCategory(editorForm.getDocCategory());
914 holdings.setType(editorForm.getDocType());
915 holdings.setFormat(editorForm.getDocFormat());
916 try {
917 getDocstoreClientLocator().getDocstoreClient().bulkUpdateHoldings(holdings, holdingIds,canUpdateStaffOnlyFlag);
918 }
919 catch (DocstoreException e) {
920 LOG.error("Exception :", e);
921 DocstoreException docstoreException = (DocstoreException) e;
922 if (org.apache.commons.lang3.StringUtils.isNotEmpty(docstoreException.getErrorCode())) {
923 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, docstoreException.getErrorCode());
924 } else {
925 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, e.getMessage());
926 }
927
928 return workInstanceOlemlForm;
929 }
930 catch(Exception ne){
931 LOG.error("Exception :", ne);
932 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO, "record.submit.fail.message");
933 return workInstanceOlemlForm;
934 }
935 editorForm.setUpdatedDate(holdings.getUpdatedOn());
936 editorForm.setUpdatedBy(holdings.getUpdatedBy());
937 getInstanceEditorFormDataHandler().setLocationDetails(workInstanceOlemlForm);
938 editorMessage = "holdings.record.update.message";
939 workInstanceOlemlForm.setViewId("WorkHoldingsViewPage");
940
941
942 GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO, editorMessage);
943 return workInstanceOlemlForm;
944
945 }
946
947 }