View Javadoc
1   package org.kuali.ole.describe.controller;
2   
3   import com.lowagie.text.*;
4   import com.lowagie.text.pdf.PdfPCell;
5   import com.lowagie.text.pdf.PdfPTable;
6   import com.lowagie.text.pdf.PdfWriter;
7   import org.apache.commons.collections.CollectionUtils;
8   import org.apache.commons.lang.StringUtils;
9   import org.apache.log4j.Logger;
10  import org.kuali.ole.OLEConstants;
11  import org.kuali.ole.OLEPropertyConstants;
12  import org.kuali.ole.deliver.bo.OlePatronDocument;
13  import org.kuali.ole.describe.bo.*;
14  import org.kuali.ole.describe.bo.marc.structuralfields.LeaderField;
15  import org.kuali.ole.describe.bo.marc.structuralfields.controlfield006.ControlField006;
16  import org.kuali.ole.describe.bo.marc.structuralfields.controlfield008.ControlField008;
17  import org.kuali.ole.describe.bo.marc.structuralfields.controlfield007.ControlField007;
18  import org.kuali.ole.describe.form.EditorForm;
19  import org.kuali.ole.describe.form.WorkBibMarcForm;
20  import org.kuali.ole.describe.form.WorkEInstanceOlemlForm;
21  import org.kuali.ole.describe.form.WorkInstanceOlemlForm;
22  import org.kuali.ole.describe.service.DiscoveryHelperService;
23  import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
24  import org.kuali.ole.docstore.common.document.BibTree;
25  import org.kuali.ole.docstore.common.document.config.DocFieldConfig;
26  import org.kuali.ole.docstore.common.document.config.DocFormatConfig;
27  import org.kuali.ole.docstore.common.document.config.DocTypeConfig;
28  import org.kuali.ole.docstore.common.document.config.DocumentSearchConfig;
29  import org.kuali.ole.docstore.common.document.content.instance.*;
30  import org.kuali.ole.docstore.common.search.*;
31  import org.kuali.ole.docstore.model.bo.WorkBibDocument;
32  import org.kuali.ole.docstore.model.bo.WorkInstanceDocument;
33  import org.kuali.ole.docstore.model.bo.WorkItemDocument;
34  import org.kuali.ole.docstore.model.enums.DocFormat;
35  import org.kuali.ole.docstore.model.enums.DocType;
36  import org.kuali.ole.select.bo.OLEDonor;
37  import org.kuali.ole.sys.context.SpringContext;
38  import org.kuali.rice.core.api.config.property.ConfigContext;
39  import org.kuali.rice.kim.api.permission.PermissionService;
40  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
41  import org.kuali.rice.krad.service.KRADServiceLocator;
42  import org.kuali.rice.krad.uif.UifParameters;
43  import org.kuali.rice.krad.uif.container.CollectionGroup;
44  import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
45  import org.kuali.rice.krad.uif.view.View;
46  import org.kuali.rice.krad.util.GlobalVariables;
47  import org.kuali.rice.krad.web.controller.UifControllerBase;
48  import org.kuali.rice.krad.web.form.UifFormBase;
49  import org.springframework.stereotype.Controller;
50  import org.springframework.validation.BindingResult;
51  import org.springframework.web.bind.annotation.ModelAttribute;
52  import org.springframework.web.bind.annotation.RequestMapping;
53  import org.springframework.web.servlet.ModelAndView;
54  
55  import javax.servlet.http.HttpServletRequest;
56  import javax.servlet.http.HttpServletResponse;
57  import java.io.IOException;
58  import java.io.OutputStream;
59  import java.sql.*;
60  import java.util.*;
61  import java.util.Date;
62  import java.util.List;
63  
64  /**
65   * Created with IntelliJ IDEA.
66   * User: PP7788
67   * Date: 12/6/12
68   * Time: 4:34 PM
69   * To change this template use File | Settings | File Templates.
70   */
71  
72  @Controller
73  @RequestMapping(value = "/editorcontroller")
74  
75  public class EditorController extends UifControllerBase {
76  
77      private DocumentEditor editor;
78      private EditorFormDataHandler editorFormDataHandler;
79      private DiscoveryHelperService discoveryHelperService;
80      private boolean isFormInitialized = false;
81      private DocstoreClientLocator docstoreClientLocator;
82  
83      public DocstoreClientLocator getDocstoreClientLocator() {
84          if (null == docstoreClientLocator) {
85              return SpringContext.getBean(DocstoreClientLocator.class);
86          }
87          return docstoreClientLocator;
88      }
89  
90      private static final Logger LOG = Logger.getLogger(EditorController.class);
91  
92      private boolean canDeleteItem(String principalId) {
93          PermissionService service = KimApiServiceLocator.getPermissionService();
94          return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.INSTANCE_EDITOR_DELETE_ITEM);
95      }
96  
97      private boolean canDeleteInstance(String principalId) {
98          PermissionService service = KimApiServiceLocator.getPermissionService();
99          return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.INSTANCE_EDITOR_DELETE_INSTANCE);
100     }
101 
102     private boolean canAddItem(String principalId) {
103         PermissionService service = KimApiServiceLocator.getPermissionService();
104         return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.INSTANCE_EDITOR_ADD_ITEM);
105     }
106 
107     private boolean canDeleteEInstance(String principalId) {
108         PermissionService service = KimApiServiceLocator.getPermissionService();
109         return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.INSTANCE_EDITOR_DELETE_EINSTANCE);
110     }
111 
112     @Override
113     protected UifFormBase createInitialForm(HttpServletRequest httpServletRequest) {
114         UifFormBase uifFormBase = null;
115         uifFormBase = new EditorForm();
116         return uifFormBase;
117     }
118 
119     @RequestMapping(params = "methodToCall=copy")
120     public ModelAndView copy(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
121                              HttpServletRequest request, HttpServletResponse response) {
122         if (!isFormInitialized) {
123             super.start(form, result, request, response);
124             isFormInitialized = true;
125         }
126         EditorForm editorForm = (EditorForm) form;
127         ModelAndView modelAndView = null;
128         String docCategory = request.getParameter("docCategory");
129         String docType = request.getParameter("docType");
130         String docFormat = request.getParameter("docFormat");
131         ((EditorForm) form).setDocCategory(docCategory);
132         ((EditorForm) form).setDocType(docType);
133         ((EditorForm) form).setDocFormat(docFormat);
134         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
135                 .getDocumentEditor(docCategory, docType, docFormat);
136         editorForm = documentEditor.copy((EditorForm) form);
137         modelAndView = getUIFModelAndView(editorForm, "WorkEInstanceViewPage");
138         return modelAndView;
139     }
140 
141     @Override
142     @RequestMapping(params = "methodToCall=start")
143     public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
144                               HttpServletRequest request, HttpServletResponse response) {
145 
146         if (!isFormInitialized) {
147             super.start(form, result, request, response);
148             isFormInitialized = true;
149         }
150         EditorForm editorForm = (EditorForm) form;
151         editorForm.setMainSerialReceivingHistoryList(null);
152         editorForm.setSupplementSerialReceivingHistoryList(null);
153         editorForm.setIndexSerialReceivingHistoryList(null);
154         editorForm.setBibFlag(false);
155         editorForm.setHoldingFlag(false);
156         editorForm.setItemFlag(false);
157         editorForm.seteHoldingsFlag(false);
158 
159         ModelAndView modelAndView = null;
160         // get the document details from request and set them in the form.
161         String docCategory = request.getParameter("docCategory");
162         String docType = request.getParameter("docType");
163         String docFormat = request.getParameter("docFormat");
164         String docId = request.getParameter("docId");
165         String bibId = request.getParameter("bibId");
166         String instanceId = request.getParameter("instanceId");
167         String editable = request.getParameter("editable");
168         String callNumberFlag = request.getParameter("isCallNumberFlag");
169 
170 
171         if (null == editable || editable.length() > 0) {
172             editable = "true";
173         }
174 
175         if (docFormat == null || docFormat.length() == 0) {
176             docFormat = ((EditorForm) form).getDocFormat();
177         }
178         if (docId == null || docId.length() == 0) {
179             docId = ((EditorForm) form).getDocId();
180         }
181 
182         if (DocType.ITEM.getCode().equalsIgnoreCase(docType)) {
183             ((EditorForm) form).setItemLocalIdentifier(docId);
184         }
185 
186         /* if (docType.equalsIgnoreCase("holdings")) {
187             ((EditorForm) form).setHoldingLocalIdentifier(docId);
188         }*/
189 
190         // modified code for Global Edit - start
191 
192         if (Boolean.parseBoolean(editorForm.getGlobalEditFlag())) {
193             prepareGlobalEditFields(editorForm, docType);
194         }
195 
196         // modified code for Global Edit - end
197 
198         ((EditorForm) form).setEditable(editable);
199         ((EditorForm) form).setDocCategory(docCategory);
200         ((EditorForm) form).setDocType(docType);
201         ((EditorForm) form).setDocFormat(docFormat);
202 
203         if (DocFormat.MARC.getCode().equals(docFormat)) {
204             editorForm.setDocumentForm(new WorkBibMarcForm());
205             modelAndView = getUIFModelAndView(form, "WorkBibEditorViewPage");
206         } else if (DocType.INSTANCE.getCode().equals(docType) || DocType.HOLDINGS.getCode().equals(docType)) {
207             editorForm.setDocumentForm(new WorkInstanceOlemlForm());
208             modelAndView = getUIFModelAndView(form, "WorkHoldingsViewPage");
209         } else if (DocType.EINSTANCE.getCode().equals(docType) || DocType.EHOLDINGS.getCode().equals(docType)) {
210             editorForm.setDocumentForm(new WorkEInstanceOlemlForm());
211             if (Boolean.parseBoolean(editorForm.getGlobalEditFlag())) {
212                 OleHoldings eHoldings = new OleHoldings();
213                 eHoldings.setStatusDate(new java.sql.Date(System.currentTimeMillis()).toString());
214                 eHoldings.setEResourceId(editorForm.geteResourceId());
215                 //getOleEResourceSearchService().getAccessLocationFromEInstance(eHoldings, workEInstanceOlemlForm);
216                 if (eHoldings.getExtentOfOwnership() != null && eHoldings.getExtentOfOwnership().size() > 0
217                         && eHoldings.getExtentOfOwnership().get(0).getCoverages() != null
218                         && eHoldings.getExtentOfOwnership().get(0).getCoverages().getCoverage().size() == 0) {
219                     eHoldings.getExtentOfOwnership().get(0).getCoverages().getCoverage().add(new Coverage());
220                 }
221                 else if (eHoldings.getExtentOfOwnership() == null || eHoldings.getExtentOfOwnership().size() == 0) {
222                     eHoldings.getExtentOfOwnership().add(new ExtentOfOwnership());
223                     eHoldings.getExtentOfOwnership().get(0).setCoverages(new Coverages());
224                     eHoldings.getExtentOfOwnership().get(0).setPerpetualAccesses(new PerpetualAccesses());
225                 }
226                 if (eHoldings.getExtentOfOwnership() != null && eHoldings.getExtentOfOwnership().size() > 0
227                         && eHoldings.getExtentOfOwnership().get(0).getPerpetualAccesses() != null
228                         && eHoldings.getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().size() == 0) {
229                     eHoldings.getExtentOfOwnership().get(0).getCoverages().getCoverage().add(new Coverage());
230                     eHoldings.getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().add(new PerpetualAccess());
231                 }
232                 if (eHoldings.getNote() != null && eHoldings.getNote().size() == 0) {
233                     eHoldings.getNote().add(new Note());
234                 }
235                 ((WorkEInstanceOlemlForm)editorForm.getDocumentForm()).setSelectedEHoldings(eHoldings);
236             }
237             modelAndView = getUIFModelAndView(form, "WorkEInstanceViewPage");
238         } else if (DocType.ITEM.getCode().equals(docType)) {
239             editorForm.setDocumentForm(new WorkInstanceOlemlForm());
240             modelAndView = getUIFModelAndView(form, "WorkItemViewPage");
241         }
242         return modelAndView;
243     }
244 
245 
246     /**
247      * Load a (new or existing) document in the editor.
248      *
249      * @param form
250      * @param result
251      * @param request
252      * @param response
253      * @return
254      */
255     @RequestMapping(params = "methodToCall=load")
256     public ModelAndView load(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
257                              HttpServletRequest request, HttpServletResponse response) {
258 
259         String tokenId = request.getParameter("tokenId");
260         EditorForm editorForm = (EditorForm) form;
261         if (tokenId != null) {
262             editorForm.setTokenId(tokenId);
263         }
264         if (editorForm.getBibId() == null) {
265             request.getSession().removeAttribute("treeDocumentList");
266         }
267         if (!isFormInitialized) {
268             super.start(form, result, request, response);
269             isFormInitialized = true;
270         }
271         editorForm.setMainSerialReceivingHistoryList(null);
272         editorForm.setSupplementSerialReceivingHistoryList(null);
273         editorForm.setIndexSerialReceivingHistoryList(null);
274 		editorForm.setShowTime(true);
275         // get the document details from request and set them in the form.
276         String docCategory = request.getParameter("docCategory");
277         String docType = request.getParameter("docType");
278         String docFormat = request.getParameter("docFormat");
279         String docId = request.getParameter("docId");
280         String bibId = request.getParameter("bibId");
281         String instanceId = request.getParameter("instanceId");
282         String editable = request.getParameter("editable");
283         String callNumberFlag = request.getParameter("isCallNumberFlag");
284         String eResourceId = request.getParameter("eResourceId");
285         String holdingsId = request.getParameter("holdingsId");
286 
287         //Verifying editable at form object
288         if ((null == editable) || (editable.length() == 0)) {
289             editable = ((EditorForm) form).getEditable();
290         }
291 
292         //Default value for editable field if it is null
293         if (null == editable || editable.length() == 0) {
294             editable = "true";
295         }
296 
297         /*if (docType.equalsIgnoreCase("item")) {
298             ((EditorForm) form).setItemLocalIdentifier(docId);
299         }*/
300 
301         if (docType.equalsIgnoreCase("holdings")) {
302 
303             ((EditorForm) form).setInstanceId(docId);
304         }
305         if (docType.equalsIgnoreCase("instance")) {
306             ((EditorForm) form).setInstanceId(docId);
307         }
308         ((EditorForm) form).setEditable(editable);
309         ((EditorForm) form).setDocCategory(docCategory);
310         ((EditorForm) form).setDocType(docType);
311         ((EditorForm) form).setDocFormat(docFormat);
312         ((EditorForm) form).setDocId(docId);
313         ((EditorForm) form).setBibId(bibId);
314         ((EditorForm) form).setCallNumberFlag(callNumberFlag);
315         ((EditorForm) form).setHideFooter(true);
316         boolean canDelete = canDeleteItem(GlobalVariables.getUserSession().getPrincipalId()) && canDeleteInstance(GlobalVariables.getUserSession().getPrincipalId());
317         ((EditorForm) form).setCanDelete(canDelete);
318         boolean canAdd = canAddItem(GlobalVariables.getUserSession().getPrincipalId());
319         ((EditorForm) form).setCanAdd(canAdd);
320         //if the user doesn't have permission to add or edit item, editable will be set as false
321         if (!canAdd) {
322             ((EditorForm) form).setEditable(String.valueOf(canAdd));
323         }
324         boolean canDeleteEInstance = canDeleteEInstance(GlobalVariables.getUserSession().getPrincipalId());
325         ((EditorForm) form).setCanDeleteEInstance(canDeleteEInstance);
326 
327         if (eResourceId != null) {
328             ((EditorForm) form).seteResourceId(eResourceId);
329         }
330         if (holdingsId != null) {
331             ((EditorForm) form).setHoldingsId(holdingsId);
332         }
333         // Identify the document editor to be used for the requested document.
334         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
335                 .getDocumentEditor(docCategory, docType, docFormat);
336 
337         // TODO: Need to save the editorForm in the session.
338         // Get documentList from session.
339         /*List<WorkBibDocument> workBibDocumentList = (List) request.getSession().getAttribute("treeDocumentList");
340         if (null != workBibDocumentList) {
341             ((EditorForm) form).setWorkBibDocumentList(workBibDocumentList);
342         }*/
343 
344         List<BibTree> bibTreeList = (List) request.getSession().getAttribute("treeDocumentList");
345         if (null != bibTreeList) {
346             ((EditorForm) form).setBibTreeList(bibTreeList);
347         }
348         if ("bibliographic".equals(editorForm.getDocType())) {
349             editorForm.setBibFlag(false);
350         }
351         if ("holdings".equals(editorForm.getDocType())) {
352             editorForm.setHoldingFlag(false);
353         }
354         if ("item".equals(editorForm.getDocType())) {
355             editorForm.setItemFlag(false);
356         }
357         if ("eHoldings".equals(editorForm.getDocType())) {
358             editorForm.seteHoldingsFlag(false);
359         }
360 
361         EditorForm documentForm = null;
362         //get request object fromm session and build new work bib marc record.
363         if (request.getSession() != null && request.getSession().getAttribute("bibTree") != null &&
364                 "true".equalsIgnoreCase(request.getParameter("loadFromSession"))) {
365             BibTree bibTree = (BibTree) request.getSession().getAttribute("bibTree");
366             if (docId != null && docId.length() > 0 && !docId.equalsIgnoreCase("null")) {
367                 ((EditorForm) form).setShowLeftPane(false);
368             } else {
369                 ((EditorForm) form).setShowLeftPane(false);
370                 ((EditorForm) form).setShowEditorFooter(false);
371             }
372             documentForm = documentEditor.createNewRecord((EditorForm) form, bibTree);
373         } else {
374             // Send the input through one (request)form and get the output through another (response) form.
375             documentForm = documentEditor.loadDocument((EditorForm) form);
376             if (documentForm instanceof WorkInstanceOlemlForm) {
377                 Item item = ((WorkInstanceOlemlForm) documentForm).getSelectedItem();
378                 if (item.getCurrentBorrower() != null && !item.getCurrentBorrower().isEmpty()) {
379                     OlePatronDocument olePatronDocument = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(OlePatronDocument.class, item.getCurrentBorrower());
380                     ((WorkInstanceOlemlForm) documentForm).setCurrentBarcode(olePatronDocument.getBarcode());
381                 }
382                 if (item.getProxyBorrower() != null && !item.getProxyBorrower().isEmpty()) {
383                     OlePatronDocument olePatronDocument = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(OlePatronDocument.class, item.getProxyBorrower());
384                     ((WorkInstanceOlemlForm) documentForm).setProxyBarcode(olePatronDocument.getBarcode());
385                 }
386             }
387         }
388 
389         // Set the output (response) form containing document info into the current form.
390         ((EditorForm) form).setDocumentForm(documentForm);
391         // Set documentlist to session.
392         request.getSession().setAttribute("treeDocumentList", ((EditorForm) form).getDocumentForm().getBibTreeList());
393 
394         // Build or update left pane data (tree structure of documents)
395         getEditorFormDataHandler().buildLeftPaneData((EditorForm) form);
396 
397         // Return the next view to be shown to user.
398         ModelAndView modelAndView = getUIFModelAndView(form, documentForm.getViewId());
399         return modelAndView;
400     }
401 
402     @RequestMapping(params = "methodToCall=updateLeftPane")
403     public ModelAndView updateLeftPane(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
404                                        HttpServletRequest request, HttpServletResponse response) {
405         EditorForm editorForm = (EditorForm) form;
406         String hiddenVal = editorForm.getHdnUuid();
407         int hdnIndex = editorForm.getHdnIndex();
408         DiscoveryHelperService discoveryHelperService = getDiscoveryHelperService();
409         List responseFromSOLR = discoveryHelperService.getResponseFromSOLR("id", hiddenVal);
410         String docType = null;
411         for (Iterator iterator = responseFromSOLR.iterator(); iterator.hasNext(); ) {
412             Map map = (Map) iterator.next();
413             if (map.containsKey(OLEConstants.DOC_TYPE)) {
414                 String list = (String) map.get(OLEConstants.DOC_TYPE);
415                 docType = list;
416                 break;
417             }
418         }
419         if ((docType.toString().equals(OLEConstants.ITEM_DOC_TYPE))) {
420             WorkInstanceOlemlForm instanceEditorForm = new WorkInstanceOlemlForm();
421             //instanceEditorForm.setInstance(editorForm.getInstance());
422             //instanceEditorForm.setUuid(editorForm.getInstance().getInstanceIdentifier());
423             //editor = new WorkInstanceOlemlEditor();
424             //instanceEditorForm.setSelectedItem(editorForm.getInstance().getItems().getItem().get(hdnIndex));
425             //return getUIFModelAndView(editorForm, "WorkItemViewPage");
426             //ModelAndView modelAndView = editor.load(form, result, request, response);
427             //return modelAndView;
428             return null;
429         } else {
430             //editorForm.setSelectedHolding(editorForm.getInstance().getOleHoldings());
431             return getUIFModelAndView(editorForm, "WorkHoldingsViewPage");
432         }
433     }
434 
435     public DiscoveryHelperService getDiscoveryHelperService() {
436         if (null == discoveryHelperService) {
437             return new DiscoveryHelperService();
438         }
439         return discoveryHelperService;
440     }
441 
442     public EditorFormDataHandler getEditorFormDataHandler() {
443         if (null == editorFormDataHandler) {
444             editorFormDataHandler = new EditorFormDataHandler();
445         }
446         return editorFormDataHandler;
447     }
448 
449     @RequestMapping(params = "methodToCall=EditNewInstance")
450     public ModelAndView EditNewInstance(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
451                                         HttpServletRequest request, HttpServletResponse response) {
452 
453         EditorForm editorForm = (EditorForm) form;
454         // get request object from session
455         BibTree bibTree = (BibTree) request.getSession().getAttribute("bibTree");
456         // Get documentList from session.
457         /*List<WorkBibDocument> workBibDocumentList = (List) request.getSession().getAttribute("treeDocumentList");
458         if (null != workBibDocumentList) {
459             ((EditorForm) form).setWorkBibDocumentList(workBibDocumentList);
460         }*/
461         if (editorForm.getDocumentForm().getViewId().equalsIgnoreCase("WorkHoldingsViewPage")) {
462             // call instance editor
463             DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
464                     .getDocumentEditor("work", "item", "oleml");
465             // set item record to display on item tab
466             editorForm = documentEditor.createNewRecord((EditorForm) form, bibTree);
467             editorForm.setNeedToCreateInstance(false);
468 
469         } else {
470             // call bib editor to store bib data
471             DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
472                     .getDocumentEditor("work", "bibliographic", "marc");
473             // update request object with modified marc data.
474             EditorForm marcEditorForm = documentEditor.editNewRecord(editorForm, bibTree);
475 
476             // validate bib before going to instance
477             if (!marcEditorForm.isValidInput()) {
478                 return getUIFModelAndView(form, marcEditorForm.getViewId());
479             }
480 
481             // call instance editor and set holding record to display on holding tab
482             documentEditor = DocumentEditorFactory.getInstance().getDocumentEditor("work", "holdings", "oleml");
483             ((EditorForm) form).setDocCategory("work");
484             ((EditorForm) form).setDocType("holdings");
485             ((EditorForm) form).setDocFormat("oleml");
486             editorForm = documentEditor.createNewRecord((EditorForm) form, bibTree);
487         }
488 
489         // Set the output (response) form containing document info into the current form.
490         ((EditorForm) form).setDocumentForm(editorForm);
491         // Set documentlist to session.
492         //request.getSession().setAttribute("treeDocumentList", ((EditorForm) form).getWorkBibDocumentList());
493 
494         // Build or update left pane data (tree structure of documents)
495         getEditorFormDataHandler().buildLeftPaneData((EditorForm) form);
496 
497         // Return the next view to be shown to user.
498         ModelAndView modelAndView = getUIFModelAndView(form, editorForm.getViewId());
499         return modelAndView;
500 
501     }
502 
503     @RequestMapping(params = "methodToCall=save")
504     public ModelAndView save(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
505                              HttpServletRequest request, HttpServletResponse response) {
506         long startTime = System.currentTimeMillis();
507         if ("bibliographic".equals(((EditorForm) form).getDocType())) {
508             ((EditorForm) form).setBibFlag(false);
509         }
510         if ("holdings".equals(((EditorForm) form).getDocType())) {
511             ((EditorForm) form).setHoldingFlag(false);
512         }
513         if ("item".equals(((EditorForm) form).getDocType())) {
514             ((EditorForm) form).setItemFlag(false);
515         }
516         if ("eHoldings".equals(((EditorForm) form).getDocType())) {
517             ((EditorForm) form).seteHoldingsFlag(false);
518         }
519         if (request.getSession() != null && request.getSession().getAttribute("bibTree") != null) {
520             DocumentEditor documentEditor = null;
521             if (((EditorForm) form).getDocId() == null || "null".equalsIgnoreCase(((EditorForm) form).getDocId())) {
522                 documentEditor = DocumentEditorFactory.getInstance()
523                         .getDocumentEditor("work", "item", "oleml");
524             } else {
525                 documentEditor = DocumentEditorFactory.getInstance()
526                         .getDocumentEditor("work", "bibliographic", "marc");
527             }
528 
529             BibTree bibTree = (BibTree) request.getSession().getAttribute("bibTree");
530             EditorForm editorForm = documentEditor.editNewRecord((EditorForm) form, bibTree);
531 
532             // validate user entered item data before saving to docstore.
533             if (!editorForm.isValidInput()) {
534                 return getUIFModelAndView(form, editorForm.getViewId());
535             }
536 
537             String responseFromDocstore = documentEditor.saveDocument(bibTree, (EditorForm) form);
538             if (StringUtils.isNotEmpty(responseFromDocstore) && responseFromDocstore.contains("success")) {
539                 request.getSession().setAttribute("responseBibTree", bibTree);
540 
541                 String url = ConfigContext.getCurrentContextConfig().getProperty(OLEPropertyConstants.OLE_URL_BASE);
542                 url = url + "/portal.do?channelTitle=Import Bib&channelUrl=" + url +
543                         "/ole-kr-krad/importBibController?viewId=ImportBibView&methodToCall=viewRecordNext";
544                 return performRedirect(editorForm, url);
545             }
546         } else {
547             if (!isFormInitialized) {
548                 super.start(form, result, request, response);
549                 isFormInitialized = true;
550             }
551 
552             // get the document details from request and set them in the form.
553             String docCategory = request.getParameter("docCategory");
554             String docType = request.getParameter("docType");
555             String docFormat = request.getParameter("docFormat");
556             String docId = request.getParameter("docId");
557             String bibId = request.getParameter("bibId");
558             String instanceId = request.getParameter("instanceId");
559 
560             String editable = request.getParameter("editable");
561 
562             if (docType != null && docType.equalsIgnoreCase("item")) {
563                 ((EditorForm) form).setItemLocalIdentifier(docId);
564             }
565 
566             /* if (docType != null && docType.equalsIgnoreCase("holdings")) {
567                 ((EditorForm) form).setHoldingLocalIdentifier(docId);
568             }*/
569 
570             if ((null == editable) || (editable.length() == 0)) {
571                 editable = "true";
572             }
573             if (docCategory == null || docCategory.length() == 0) {
574                 docCategory = ((EditorForm) form).getDocCategory();
575             }
576             if (docType == null || docType.length() == 0) {
577                 docType = ((EditorForm) form).getDocType();
578             }
579 
580             if (docFormat == null || docFormat.length() == 0) {
581                 docFormat = ((EditorForm) form).getDocFormat();
582             }
583             if (docId == null || docId.length() == 0) {
584                 docId = ((EditorForm) form).getDocId();
585             }
586 
587             ((EditorForm) form).setEditable(editable);
588             ((EditorForm) form).setDocCategory(docCategory);
589             ((EditorForm) form).setDocType(docType);
590             ((EditorForm) form).setDocFormat(docFormat);
591             ((EditorForm) form).setDocId(docId);
592             ((EditorForm) form).setBibId(bibId);
593             ((EditorForm) form).setInstanceId(instanceId);
594 
595             // Identify the document editor to be used for the requested document.
596             DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
597                     .getDocumentEditor(docCategory, docType, docFormat);
598 
599             // TODO: Need to save the editorForm in the session.
600             // Get documentList from session.
601             /* List<WorkBibDocument> workBibDocumentList = (List) request.getSession().getAttribute("treeDocumentList");
602             if (null != workBibDocumentList) {
603                 ((EditorForm) form).setWorkBibDocumentList(workBibDocumentList);
604             }*/
605 
606             List<BibTree> bibTreeList = (List) request.getSession().getAttribute("treeDocumentList");
607             if (null != bibTreeList) {
608                 ((EditorForm) form).getDocumentForm().setBibTreeList(bibTreeList);
609                 ((EditorForm) form).setBibTreeList(bibTreeList);
610             }
611             if("overwrite".equals(((EditorForm) form).getCheckOverwriteFlag())) {
612                 EditorForm documentForm = documentEditor.saveDocument((EditorForm) form);
613                 ((EditorForm) form).setDocumentForm(documentForm);
614             } else {
615                 if (documentEditor.isValidUpdate((EditorForm) form) && ((EditorForm) form).getAllowUpdate().equals
616                         ("true") || documentEditor.isValidUpdate((EditorForm) form) && ((EditorForm) form).getAllowUpdate().equals
617                         ("")) {
618                     // Send the input through one (request)form and get the output through another (response) form.
619                     EditorForm documentForm = documentEditor.saveDocument((EditorForm) form);
620                     // Set the output (response) form containing docum ((EditorForm) form).isAllowUpdate()ent info into the current form.
621                     ((EditorForm) form).setDocumentForm(documentForm);
622                     ((EditorForm) form).setAllowUpdate("true");
623                 } else {
624                     ((EditorForm) form).setAllowUpdate("false");
625                     // EditorForm documentForm = documentEditor.loadDocument((EditorForm) form);
626                     // ((EditorForm) form).setDocumentForm(documentForm);
627                 }
628 
629             }
630             ((EditorForm) form).setCheckOverwriteFlag("");
631             // Set documentlist to session.
632             request.getSession().setAttribute("treeDocumentList", ((EditorForm) form).getDocumentForm().getBibTreeList());
633 
634             // Build or update left pane data (tree structure of documents)
635             getEditorFormDataHandler().buildLeftPaneData((EditorForm) form);
636 
637         }
638         ((EditorForm) form).setDisplayField006("false");
639         ((EditorForm) form).setDisplayField007("false");
640         ((EditorForm) form).setDisplayField008("false");
641         ((EditorForm) form).setBibFlag(false);
642         ((EditorForm) form).setHoldingFlag(false);
643         ((EditorForm) form).setItemFlag(false);
644         ((EditorForm) form).seteHoldingsFlag(false);
645         // Return the next view to be shown to user.
646         long endTime = System.currentTimeMillis();
647         ((EditorForm) form).setTotalTime(String.valueOf((endTime-startTime)/1000));
648         ModelAndView modelAndView = getUIFModelAndView(form, ((EditorForm) form).getDocumentForm().getViewId());
649         return modelAndView;
650     }
651 
652     /**
653      * This method will add the controlField 006 record based on the selected Line index and updates the component.
654      *
655      * @param form
656      * @param result
657      * @param request
658      * @param response
659      * @return ModelAndView
660      */
661     @RequestMapping(params = "methodToCall=addControlField006")
662     public ModelAndView addControlField(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
663                                         HttpServletRequest request, HttpServletResponse response) {
664         if (!isFormInitialized) {
665             super.start(form, result, request, response);
666             isFormInitialized = true;
667         }
668         EditorForm editorForm = (EditorForm) form;
669         String docCategory = request.getParameter("docCategory");
670         String docType = request.getParameter("docType");
671         String docFormat = request.getParameter("docFormat");
672         if (docCategory == null) {
673             docCategory = editorForm.getDocCategory();
674         }
675         if (docType == null) {
676             docType = editorForm.getDocType();
677         }
678         if (docFormat == null) {
679             docFormat = editorForm.getDocFormat();
680         }
681 
682         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
683                 .getDocumentEditor(docCategory, docType, docFormat);
684 
685         editorForm = documentEditor.addORDeleteFields(editorForm, request);
686         return super.navigate(editorForm, result, request, response);
687     }
688 
689     /**
690      * This method will remove the controlField  006 based on the index position and updates the component.
691      *
692      * @param form
693      * @param result
694      * @param request
695      * @param response
696      * @return ModelAndView
697      */
698     @RequestMapping(params = "methodToCall=removeControlField006")
699     public ModelAndView removeControlField(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
700                                            HttpServletRequest request, HttpServletResponse response) {
701         if (!isFormInitialized) {
702             super.start(form, result, request, response);
703             isFormInitialized = true;
704         }
705         EditorForm editorForm = (EditorForm) form;
706         String docCategory = request.getParameter("docCategory");
707         String docType = request.getParameter("docType");
708         String docFormat = request.getParameter("docFormat");
709         if (docCategory == null) {
710             docCategory = editorForm.getDocCategory();
711         }
712         if (docType == null) {
713             docType = editorForm.getDocType();
714         }
715         if (docFormat == null) {
716             docFormat = editorForm.getDocFormat();
717         }
718 
719         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
720                 .getDocumentEditor(docCategory, docType, docFormat);
721 
722         editorForm = documentEditor.addORDeleteFields(editorForm, request);
723         return super.navigate(editorForm, result, request, response);
724     }
725 
726 
727     /**
728      * This method will add the controlField 007 record based on the selected Line index and updates the component.
729      *
730      * @param form
731      * @param result
732      * @param request
733      * @param response
734      * @return ModelAndView
735      */
736     @RequestMapping(params = "methodToCall=addControlField007")
737     public ModelAndView addControlField007(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
738                                            HttpServletRequest request, HttpServletResponse response) {
739         if (!isFormInitialized) {
740             super.start(form, result, request, response);
741             isFormInitialized = true;
742         }
743         EditorForm editorForm = (EditorForm) form;
744         String docCategory = request.getParameter("docCategory");
745         String docType = request.getParameter("docType");
746         String docFormat = request.getParameter("docFormat");
747         if (docCategory == null) {
748             docCategory = editorForm.getDocCategory();
749         }
750         if (docType == null) {
751             docType = editorForm.getDocType();
752         }
753         if (docFormat == null) {
754             docFormat = editorForm.getDocFormat();
755         }
756 
757         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
758                 .getDocumentEditor(docCategory, docType, docFormat);
759 
760         editorForm = documentEditor.addORDeleteFields(editorForm, request);
761         return super.navigate(editorForm, result, request, response);
762     }
763 
764     /**
765      * This method will remove the controlField  007 based on the index position and updates the component.
766      *
767      * @param form
768      * @param result
769      * @param request
770      * @param response
771      * @return ModelAndView
772      */
773     @RequestMapping(params = "methodToCall=removeControlField007")
774     public ModelAndView removeControlField007(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
775                                               HttpServletRequest request, HttpServletResponse response) {
776         if (!isFormInitialized) {
777             super.start(form, result, request, response);
778             isFormInitialized = true;
779         }
780         EditorForm editorForm = (EditorForm) form;
781         String docCategory = request.getParameter("docCategory");
782         String docType = request.getParameter("docType");
783         String docFormat = request.getParameter("docFormat");
784         if (docCategory == null) {
785             docCategory = editorForm.getDocCategory();
786         }
787         if (docType == null) {
788             docType = editorForm.getDocType();
789         }
790         if (docFormat == null) {
791             docFormat = editorForm.getDocFormat();
792         }
793 
794         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
795                 .getDocumentEditor(docCategory, docType, docFormat);
796 
797         editorForm = documentEditor.addORDeleteFields(editorForm, request);
798         return super.navigate(editorForm, result, request, response);
799     }
800 
801 
802     /**
803      * This method will add the datField record based on the selected Line index and updates the component.
804      *
805      * @param form
806      * @param result
807      * @param request
808      * @param response
809      * @return ModelAndView
810      */
811     @RequestMapping(params = "methodToCall=addDataField")
812     public ModelAndView addDataField(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
813                                      HttpServletRequest request, HttpServletResponse response) {
814         if (!isFormInitialized) {
815             super.start(form, result, request, response);
816             isFormInitialized = true;
817         }
818         EditorForm editorForm = (EditorForm) form;
819         String docCategory = request.getParameter("docCategory");
820         String docType = request.getParameter("docType");
821         String docFormat = request.getParameter("docFormat");
822         if (docCategory == null) {
823             docCategory = editorForm.getDocCategory();
824         }
825         if (docType == null) {
826             docType = editorForm.getDocType();
827         }
828         if (docFormat == null) {
829             docFormat = editorForm.getDocFormat();
830         }
831 
832         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
833                 .getDocumentEditor(docCategory, docType, docFormat);
834 
835         editorForm = documentEditor.addORDeleteFields(editorForm, request);
836         return super.navigate(editorForm, result, request, response);
837     }
838 
839     /**
840      * This method will remove the dataField based on the index position and updates the component.
841      *
842      * @param form
843      * @param result
844      * @param request
845      * @param response
846      * @return ModelAndView
847      */
848     @RequestMapping(params = "methodToCall=removeDataField")
849     public ModelAndView removeDataField(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
850                                         HttpServletRequest request, HttpServletResponse response) {
851         if (!isFormInitialized) {
852             super.start(form, result, request, response);
853             isFormInitialized = true;
854         }
855         EditorForm editorForm = (EditorForm) form;
856         String docCategory = request.getParameter("docCategory");
857         String docType = request.getParameter("docType");
858         String docFormat = request.getParameter("docFormat");
859         if (docCategory == null) {
860             docCategory = editorForm.getDocCategory();
861         }
862         if (docType == null) {
863             docType = editorForm.getDocType();
864         }
865         if (docFormat == null) {
866             docFormat = editorForm.getDocFormat();
867         }
868 
869         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
870                 .getDocumentEditor(docCategory, docType, docFormat);
871 
872         editorForm = documentEditor.addORDeleteFields(editorForm, request);
873         return super.navigate(editorForm, result, request, response);
874     }
875 
876 /*
877     private UifFormBase buildUifForm (HttpServletRequest httpServletRequest) {
878         UifFormBase uifFormBase = null;
879 
880         String docType = httpServletRequest.getParameter("docType");
881         String docFormat = httpServletRequest.getParameter("docFormat");
882         if ("bibliographic".equalsIgnoreCase(docType)) {
883             if ("marc".equalsIgnoreCase(docFormat)) {
884                 LOG.info("Inside EditorController createInitialForm if bibliographic marc");
885                 editor = new WorkBibMarcEditor();
886                 uifFormBase = editor.createInitialForm(httpServletRequest);
887             } else if ("dublin".equalsIgnoreCase(docFormat)) {
888                 editor = new WorkBibDublinEditor();
889                 uifFormBase = editor.createInitialForm(httpServletRequest);
890             }
891         } else if ("instance".equalsIgnoreCase(docType)) {
892             if ("oleml".equalsIgnoreCase(docFormat)) {
893                 editor = new WorkInstanceOlemlEditor();
894                 uifFormBase = editor.createInitialForm(httpServletRequest);
895             }
896         } else if ("holdings".equalsIgnoreCase(docType) || "item".equalsIgnoreCase(docType)) {
897             if ("oleml".equalsIgnoreCase(docFormat)) {
898                 editor = new WorkInstanceOlemlEditor();
899                 uifFormBase = editor.createInitialForm(httpServletRequest);
900             }
901         }
902         return uifFormBase;
903 
904     }
905 */
906 
907     /**
908      * DeleteVerify a  document in the editor.
909      *
910      * @param form
911      * @param result
912      * @param request
913      * @param response
914      * @return
915      */
916     @RequestMapping(params = "methodToCall=deleteVerify")
917     public ModelAndView deleteVerify(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
918                                      HttpServletRequest request, HttpServletResponse response) throws Exception {
919         ModelAndView modelAndView = null;
920         if (!isFormInitialized) {
921             super.start(form, result, request, response);
922             isFormInitialized = true;
923         }
924 
925         // get the document details from request and set them in the form.
926         String docCategory = request.getParameter("docCategory");
927         String docType = request.getParameter("docType");
928         String docFormat = request.getParameter("docFormat");
929         String docId = request.getParameter("docId");
930         ((EditorForm) form).setDocCategory(docCategory);
931         ((EditorForm) form).setDocType(docType);
932         ((EditorForm) form).setDocFormat(docFormat);
933         ((EditorForm) form).setDocId(docId);
934         ((EditorForm) form).setMessage("");
935 //        ((EditorForm) form).setEditable("false");
936         ((EditorForm) form).setHideFooter(false);
937 
938         DocumentEditor documentEditor = DocumentEditorFactory.getInstance().getDocumentEditor(docCategory, docType, docFormat);
939         EditorForm documentForm = documentEditor.deleteVerify((EditorForm) form);
940         LOG.info("view id-->" + documentForm.getViewId());
941         //List<String> uuidList  = new ArrayList<String>();
942         EditorForm editorForm = (EditorForm) form;
943         //uuidList.add(docId);
944 
945 /*        DocumentSelectionTree dst = new DocumentSelectionTree();
946         LOG.info("get uud list from form-->"+editorForm.getUuidList());
947         Node<DocumentTreeNode, String> rootNode = dst.add(editorForm.getUuidList());
948 
949          editorForm.getDocTree().setRootElement(rootNode);*/
950 
951         return getUIFModelAndView(editorForm, documentForm.getViewId());
952 /*
953         System.out.println("delete verify method is executed-----1");
954 
955         ((EditorForm) form).setDocCategory(docCategory);
956         ((EditorForm) form).setDocType(docType);
957         ((EditorForm) form).setDocFormat(docFormat);
958         ((EditorForm) form).setDocId(docId);
959 
960         // Identify the document editor to be used for the requested document.
961         DocumentEditor documentEditor = DocumentEditorFactory.getInstance().getDocumentEditor(docCategory, docType, docFormat);
962         System.out.println("delete verify method is executed-----2");
963         //EditorForm documentForm = null;
964         EditorForm documentForm = documentEditor.deleteVerify((EditorForm) form);
965         ((EditorForm) form).setDocumentForm(documentForm);
966 
967         try {
968             documentForm = documentEditor.deleteVerify((EditorForm) form);
969             modelAndView =getUIFModelAndView(form,documentForm.getViewId());
970             System.out.println("delete verify method is executed-----3");
971         }catch (Exception e) {
972             modelAndView =getUIFModelAndView(form,"WorkBibEditorViewPage");
973             System.out.println("delete verify method is executed-----4");
974         }
975         System.out.println("delete verify method is executed-----5");
976         return modelAndView;
977 */
978     }
979 
980     /**
981      * Delete a  document in the editor.
982      *
983      * @param form
984      * @param result
985      * @param request
986      * @param response
987      * @return
988      */
989     @RequestMapping(params = "methodToCall=delete")
990     public ModelAndView delete(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
991                                HttpServletRequest request, HttpServletResponse response) throws Exception {
992         ModelAndView modelAndView = null;
993         EditorForm editorForm = (EditorForm) form;
994         if (!isFormInitialized) {
995             super.start(form, result, request, response);
996             isFormInitialized = true;
997         }
998 
999         // get the document details from request and set them in the form.
1000         String docCategory = ((EditorForm) form).getDocCategory();
1001         String docType = ((EditorForm) form).getDocType();
1002         String docFormat = ((EditorForm) form).getDocFormat();
1003         String docId = ((EditorForm) form).getDocId();
1004 
1005 
1006         LOG.info("docCategory-->" + docCategory);
1007         LOG.info("docType-->" + docType);
1008         LOG.info("docFormat-->" + docFormat);
1009         LOG.info("uuid-->" + docId);
1010 
1011 
1012 /*        ((EditorForm) form).setDocCategory(docCategory);
1013         ((EditorForm) form).setDocType(docType);
1014         ((EditorForm) form).setDocFormat(docFormat);
1015         ((EditorForm) form).setUuid(docId);*/
1016 
1017         // Identify the document editor to be used for the requested document.
1018         DocumentEditor documentEditor = DocumentEditorFactory.getInstance().getDocumentEditor(docCategory, docType, docFormat);
1019 
1020         EditorForm documentForm = documentEditor.delete((EditorForm) form);
1021 
1022         /*       //boolean hasLinks = delete();
1023         try {
1024 
1025             modelAndView =getUIFModelAndView(form,"deleteConfirmation");
1026         } catch (Exception e) {
1027             modelAndView =getUIFModelAndView(form,"");
1028             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
1029         }*/
1030         // Send the input through one (request)form and get the output through another (response) form.
1031 
1032         // Build or update left pane data (tree structure of documents)
1033         getEditorFormDataHandler().buildLeftPaneData((EditorForm) form);
1034 
1035         // Redirect to bib page after deleting eholdings.
1036         if (documentForm.isCanDeleteEHoldings() && docType.equalsIgnoreCase(DocType.EHOLDINGS.getCode())) {
1037             String url = ConfigContext.getCurrentContextConfig().getProperty(OLEPropertyConstants.OLE_URL_BASE);
1038             url = url + "/portal.do?channelTitle=Editor&channelUrl=" + url +
1039                     "/ole-kr-krad/editorcontroller?viewId=EditorView&methodToCall=load&docCategory=work&docType=bibliographic&docFormat=marc&bibId=&editable=true&docId=" + editorForm.getBibId();
1040             return performRedirect(editorForm, url);
1041         }
1042 
1043         return getUIFModelAndView(editorForm, documentForm.getViewId());
1044     }
1045 
1046     /**
1047      * This method will add the ExtentOfOwnership record based on the selected Line index and updates the component.
1048      *
1049      * @param form
1050      * @param result
1051      * @param request
1052      * @param response
1053      * @return ModelAndView
1054      */
1055     @RequestMapping(params = "methodToCall=addExtentOfOwnership")
1056     public ModelAndView addExtentOfOwnership(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1057                                              HttpServletRequest request, HttpServletResponse response) {
1058         if (!isFormInitialized) {
1059             super.start(form, result, request, response);
1060             isFormInitialized = true;
1061         }
1062         EditorForm editorForm = (EditorForm) form;
1063         String docCategory = request.getParameter("docCategory");
1064         String docType = request.getParameter("docType");
1065         String docFormat = request.getParameter("docFormat");
1066         if (docCategory == null) {
1067             docCategory = editorForm.getDocCategory();
1068         }
1069         if (docType == null) {
1070             docType = editorForm.getDocType();
1071         }
1072         if (docFormat == null) {
1073             docFormat = editorForm.getDocFormat();
1074         }
1075 
1076         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1077                 .getDocumentEditor(docCategory, docType, docFormat);
1078 
1079         editorForm = documentEditor.addORRemoveExtentOfOwnership(editorForm, request);
1080         return super.navigate(editorForm, result, request, response);
1081     }
1082 
1083     /**
1084      * This method will remove the ExtentOfOwnership based on the index position and updates the component.
1085      *
1086      * @param form
1087      * @param result
1088      * @param request
1089      * @param response
1090      * @return ModelAndView
1091      */
1092     @RequestMapping(params = "methodToCall=removeExtentOfOwnership")
1093     public ModelAndView removeExtentOfOwnership(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1094                                                 HttpServletRequest request, HttpServletResponse response) {
1095         if (!isFormInitialized) {
1096             super.start(form, result, request, response);
1097             isFormInitialized = true;
1098         }
1099         EditorForm editorForm = (EditorForm) form;
1100         String docCategory = request.getParameter("docCategory");
1101         String docType = request.getParameter("docType");
1102         String docFormat = request.getParameter("docFormat");
1103         if (docCategory == null) {
1104             docCategory = editorForm.getDocCategory();
1105         }
1106         if (docType == null) {
1107             docType = editorForm.getDocType();
1108         }
1109         if (docFormat == null) {
1110             docFormat = editorForm.getDocFormat();
1111         }
1112 
1113         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1114                 .getDocumentEditor(docCategory, docType, docFormat);
1115 
1116         editorForm = documentEditor.addORRemoveExtentOfOwnership(editorForm, request);
1117         return super.navigate(editorForm, result, request, response);
1118     }
1119 
1120     /**
1121      * This method will add the EOWHoldingNotes record based on the selected Line index and updates the component.
1122      *
1123      * @param form
1124      * @param result
1125      * @param request
1126      * @param response
1127      * @return ModelAndView
1128      */
1129     @RequestMapping(params = "methodToCall=addEOWHoldingNotes")
1130     public ModelAndView addEOWHoldingNotes(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1131                                            HttpServletRequest request, HttpServletResponse response) {
1132         if (!isFormInitialized) {
1133             super.start(form, result, request, response);
1134             isFormInitialized = true;
1135         }
1136         EditorForm editorForm = (EditorForm) form;
1137         String docCategory = request.getParameter("docCategory");
1138         String docType = request.getParameter("docType");
1139         String docFormat = request.getParameter("docFormat");
1140         if (docCategory == null) {
1141             docCategory = editorForm.getDocCategory();
1142         }
1143         if (docType == null) {
1144             docType = editorForm.getDocType();
1145         }
1146         if (docFormat == null) {
1147             docFormat = editorForm.getDocFormat();
1148         }
1149 
1150         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1151                 .getDocumentEditor(docCategory, docType, docFormat);
1152 
1153         editorForm = documentEditor.addORRemoveExtentOfOwnership(editorForm, request);
1154         return super.navigate(editorForm, result, request, response);
1155     }
1156 
1157     /**
1158      * This method will remove the EOWHoldingNotes based on the index position and updates the component.
1159      *
1160      * @param form
1161      * @param result
1162      * @param request
1163      * @param response
1164      * @return ModelAndView
1165      */
1166     @RequestMapping(params = "methodToCall=removeEOWHoldingNotes")
1167     public ModelAndView removeEOWHoldingNotes(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1168                                               HttpServletRequest request, HttpServletResponse response) {
1169         if (!isFormInitialized) {
1170             super.start(form, result, request, response);
1171             isFormInitialized = true;
1172         }
1173         EditorForm editorForm = (EditorForm) form;
1174         String docCategory = request.getParameter("docCategory");
1175         String docType = request.getParameter("docType");
1176         String docFormat = request.getParameter("docFormat");
1177         if (docCategory == null) {
1178             docCategory = editorForm.getDocCategory();
1179         }
1180         if (docType == null) {
1181             docType = editorForm.getDocType();
1182         }
1183         if (docFormat == null) {
1184             docFormat = editorForm.getDocFormat();
1185         }
1186 
1187         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1188                 .getDocumentEditor(docCategory, docType, docFormat);
1189 
1190         editorForm = documentEditor.addORRemoveExtentOfOwnership(editorForm, request);
1191         return super.navigate(editorForm, result, request, response);
1192     }
1193 
1194     /**
1195      * This method will add the AccessInformation record based on the selected Line index and updates the component.
1196      *
1197      * @param form
1198      * @param result
1199      * @param request
1200      * @param response
1201      * @return ModelAndView
1202      */
1203     @RequestMapping(params = "methodToCall=addAccessInformation")
1204     public ModelAndView addAccessInformation(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1205                                              HttpServletRequest request, HttpServletResponse response) {
1206         if (!isFormInitialized) {
1207             super.start(form, result, request, response);
1208             isFormInitialized = true;
1209         }
1210         EditorForm editorForm = (EditorForm) form;
1211         String docCategory = request.getParameter("docCategory");
1212         String docType = request.getParameter("docType");
1213         String docFormat = request.getParameter("docFormat");
1214         if (docCategory == null) {
1215             docCategory = editorForm.getDocCategory();
1216         }
1217         if (docType == null) {
1218             docType = editorForm.getDocType();
1219         }
1220         if (docFormat == null) {
1221             docFormat = editorForm.getDocFormat();
1222         }
1223 
1224         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1225                 .getDocumentEditor(docCategory, docType, docFormat);
1226 
1227         editorForm = documentEditor.addORRemoveAccessInformationAndHoldingsNotes(editorForm, request);
1228         return super.navigate(editorForm, result, request, response);
1229     }
1230 
1231     /**
1232      * This method will remove the AccessInformation based on the index position and updates the component.
1233      *
1234      * @param form
1235      * @param result
1236      * @param request
1237      * @param response
1238      * @return ModelAndView
1239      */
1240     @RequestMapping(params = "methodToCall=removeAccessInformation")
1241     public ModelAndView removeAccessInformation(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1242                                                 HttpServletRequest request, HttpServletResponse response) {
1243         if (!isFormInitialized) {
1244             super.start(form, result, request, response);
1245             isFormInitialized = true;
1246         }
1247         EditorForm editorForm = (EditorForm) form;
1248         String docCategory = request.getParameter("docCategory");
1249         String docType = request.getParameter("docType");
1250         String docFormat = request.getParameter("docFormat");
1251         if (docCategory == null) {
1252             docCategory = editorForm.getDocCategory();
1253         }
1254         if (docType == null) {
1255             docType = editorForm.getDocType();
1256         }
1257         if (docFormat == null) {
1258             docFormat = editorForm.getDocFormat();
1259         }
1260 
1261         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1262                 .getDocumentEditor(docCategory, docType, docFormat);
1263 
1264         editorForm = documentEditor.addORRemoveAccessInformationAndHoldingsNotes(editorForm, request);
1265         return super.navigate(editorForm, result, request, response);
1266     }
1267 
1268     /**
1269      * This method will add the HoldingNotes record based on the selected Line index and updates the component.
1270      *
1271      * @param form
1272      * @param result
1273      * @param request
1274      * @param response
1275      * @return ModelAndView
1276      */
1277     @RequestMapping(params = "methodToCall=addHoldingNotes")
1278     public ModelAndView addHoldingNotes(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1279                                         HttpServletRequest request, HttpServletResponse response) {
1280         if (!isFormInitialized) {
1281             super.start(form, result, request, response);
1282             isFormInitialized = true;
1283         }
1284         EditorForm editorForm = (EditorForm) form;
1285         String docCategory = request.getParameter("docCategory");
1286         String docType = request.getParameter("docType");
1287         String docFormat = request.getParameter("docFormat");
1288         if (docCategory == null) {
1289             docCategory = editorForm.getDocCategory();
1290         }
1291         if (docType == null) {
1292             docType = editorForm.getDocType();
1293         }
1294         if (docFormat == null) {
1295             docFormat = editorForm.getDocFormat();
1296         }
1297 
1298         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1299                 .getDocumentEditor(docCategory, docType, docFormat);
1300 
1301         editorForm = documentEditor.addORRemoveAccessInformationAndHoldingsNotes(editorForm, request);
1302         return super.navigate(editorForm, result, request, response);
1303     }
1304 
1305     /**
1306      * This method will remove the HoldingNotes based on the index position and updates the component.
1307      *
1308      * @param form
1309      * @param result
1310      * @param request
1311      * @param response
1312      * @return ModelAndView
1313      */
1314     @RequestMapping(params = "methodToCall=removeHoldingNotes")
1315     public ModelAndView removeHoldingNotes(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1316                                            HttpServletRequest request, HttpServletResponse response) {
1317         if (!isFormInitialized) {
1318             super.start(form, result, request, response);
1319             isFormInitialized = true;
1320         }
1321         EditorForm editorForm = (EditorForm) form;
1322         String docCategory = request.getParameter("docCategory");
1323         String docType = request.getParameter("docType");
1324         String docFormat = request.getParameter("docFormat");
1325         if (docCategory == null) {
1326             docCategory = editorForm.getDocCategory();
1327         }
1328         if (docType == null) {
1329             docType = editorForm.getDocType();
1330         }
1331         if (docFormat == null) {
1332             docFormat = editorForm.getDocFormat();
1333         }
1334 
1335         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1336                 .getDocumentEditor(docCategory, docType, docFormat);
1337 
1338         editorForm = documentEditor.addORRemoveAccessInformationAndHoldingsNotes(editorForm, request);
1339         return super.navigate(editorForm, result, request, response);
1340     }
1341 
1342     @RequestMapping(params = "methodToCall=addField")
1343     public ModelAndView addField(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1344                                  HttpServletRequest request, HttpServletResponse response) {
1345         if (!isFormInitialized) {
1346             super.start(form, result, request, response);
1347             isFormInitialized = true;
1348         }
1349         EditorForm editorForm = (EditorForm) form;
1350         String docCategory = request.getParameter("docCategory");
1351         String docType = request.getParameter("docType");
1352         String docFormat = request.getParameter("docFormat");
1353         if (docCategory == null) {
1354             docCategory = editorForm.getDocCategory();
1355         }
1356         if (docType == null) {
1357             docType = editorForm.getDocType();
1358         }
1359         if (docFormat == null) {
1360             docFormat = editorForm.getDocFormat();
1361         }
1362 
1363         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1364                 .getDocumentEditor(docCategory, docType, docFormat);
1365 
1366         editorForm = documentEditor.addORDeleteFields(editorForm, request);
1367         return super.navigate(editorForm, result, request, response);
1368     }
1369 
1370     @RequestMapping(params = "methodToCall=removeField")
1371     public ModelAndView removeField(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1372                                     HttpServletRequest request, HttpServletResponse response) {
1373         if (!isFormInitialized) {
1374             super.start(form, result, request, response);
1375             isFormInitialized = true;
1376         }
1377         EditorForm editorForm = (EditorForm) form;
1378         String docCategory = request.getParameter("docCategory");
1379         String docType = request.getParameter("docType");
1380         String docFormat = request.getParameter("docFormat");
1381         if (docCategory == null) {
1382             docCategory = editorForm.getDocCategory();
1383         }
1384         if (docType == null) {
1385             docType = editorForm.getDocType();
1386         }
1387         if (docFormat == null) {
1388             docFormat = editorForm.getDocFormat();
1389         }
1390 
1391         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1392                 .getDocumentEditor(docCategory, docType, docFormat);
1393 
1394         editorForm = documentEditor.addORDeleteFields(editorForm, request);
1395         return super.navigate(editorForm, result, request, response);
1396     }
1397 
1398 
1399     /**
1400      * Used for Test-case
1401      *
1402      * @param result
1403      * @param request
1404      * @param response
1405      * @param editorForm
1406      * @return ModelAndView
1407      */
1408     protected ModelAndView callSuper(BindingResult result, HttpServletRequest request, HttpServletResponse response,
1409                                      EditorForm editorForm) {
1410         return super.navigate(editorForm, result, request, response);
1411     }
1412 
1413     @RequestMapping(params = "methodToCall=addItemNote")
1414     public ModelAndView addItemNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1415                                     HttpServletRequest request, HttpServletResponse response) {
1416         if (!isFormInitialized) {
1417             super.start(form, result, request, response);
1418             isFormInitialized = true;
1419         }
1420         EditorForm editorForm = (EditorForm) form;
1421         String docCategory = request.getParameter("docCategory");
1422         String docType = request.getParameter("docType");
1423         String docFormat = request.getParameter("docFormat");
1424         if (docCategory == null) {
1425             docCategory = editorForm.getDocCategory();
1426         }
1427         if (docType == null) {
1428             docType = editorForm.getDocType();
1429         }
1430         if (docFormat == null) {
1431             docFormat = editorForm.getDocFormat();
1432         }
1433 
1434         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1435                 .getDocumentEditor(docCategory, docType, docFormat);
1436 
1437         editorForm = documentEditor.addORRemoveItemNote(editorForm, request);
1438         return super.navigate(editorForm, result, request, response);
1439     }
1440 
1441     @RequestMapping(params = "methodToCall=addDonorToItem")
1442     public ModelAndView addDonorToItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1443                                        HttpServletRequest request, HttpServletResponse response) {
1444         EditorForm editorForm = (EditorForm) form;
1445         WorkInstanceOlemlForm workInstanceOlemlForm = (WorkInstanceOlemlForm) editorForm.getDocumentForm();
1446         List<DonorInfo> donorInfoList = workInstanceOlemlForm.getSelectedItem().getDonorInfo();
1447         String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
1448         CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(
1449                 selectedCollectionPath);
1450         String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
1451         Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
1452         DonorInfo donorInfo = (DonorInfo) eventObject;
1453         if (donorInfo != null && StringUtils.isNotEmpty(donorInfo.getDonorCode())) {
1454             Map map = new HashMap();
1455             map.put("donorCode", donorInfo.getDonorCode());
1456             OLEDonor oleDonor = KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(OLEDonor.class, map);
1457             if (oleDonor != null) {
1458                 for (DonorInfo donor : donorInfoList) {
1459                     if (donor.getDonorCode().equals(donorInfo.getDonorCode())) {
1460                         GlobalVariables.getMessageMap().putErrorForSectionId("OleDonorInformation-ListOfDonors", "error.donor.code.exist");
1461                         return getUIFModelAndView(form);
1462                     }
1463                 }
1464             } else {
1465                 GlobalVariables.getMessageMap().putErrorForSectionId("OleDonorInformation-ListOfDonors", "error.donor.code.doesnt.exist");
1466                 return getUIFModelAndView(form);
1467             }
1468         }
1469         View view = form.getPostedView();
1470         view.getViewHelperService().processCollectionAddLine(view, form, selectedCollectionPath);
1471         return getUIFModelAndView(form);
1472     }
1473 
1474     @RequestMapping(params = "methodToCall=addDonorToEInstance")
1475     public ModelAndView addDonorToEInstance(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1476                                             HttpServletRequest request, HttpServletResponse response) {
1477         EditorForm editorForm = (EditorForm) form;
1478         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
1479         List<DonorInfo> donorInfoList = workEInstanceOlemlForm.getSelectedEHoldings().getDonorInfo();
1480         String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
1481         CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(
1482                 selectedCollectionPath);
1483         String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
1484         Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
1485         DonorInfo donorInfo = (DonorInfo) eventObject;
1486         if (donorInfo != null && StringUtils.isNotEmpty(donorInfo.getDonorCode())) {
1487             Map map = new HashMap();
1488             map.put("donorCode", donorInfo.getDonorCode());
1489             OLEDonor oleDonor = KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(OLEDonor.class, map);
1490             if (oleDonor != null) {
1491                 for (DonorInfo donor : donorInfoList) {
1492                     if (donor.getDonorCode().equals(donorInfo.getDonorCode())) {
1493                         GlobalVariables.getMessageMap().putErrorForSectionId("OleEInstanceDonorInformation-ListOfDonors", "error.donor.code.exist");
1494                         return getUIFModelAndView(form);
1495                     }
1496                 }
1497             } else {
1498                 GlobalVariables.getMessageMap().putErrorForSectionId("OleEInstanceDonorInformation-ListOfDonors", "error.donor.code.doesnt.exist");
1499                 return getUIFModelAndView(form);
1500             }
1501         }
1502         View view = form.getPostedView();
1503         view.getViewHelperService().processCollectionAddLine(view, form, selectedCollectionPath);
1504         return getUIFModelAndView(form);
1505     }
1506 
1507     @RequestMapping(params = "methodToCall=removeItemNote")
1508     public ModelAndView removeItemNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1509                                        HttpServletRequest request, HttpServletResponse response) {
1510         if (!isFormInitialized) {
1511             super.start(form, result, request, response);
1512             isFormInitialized = true;
1513         }
1514         EditorForm editorForm = (EditorForm) form;
1515         String docCategory = request.getParameter("docCategory");
1516         String docType = request.getParameter("docType");
1517         String docFormat = request.getParameter("docFormat");
1518         if (docCategory == null) {
1519             docCategory = editorForm.getDocCategory();
1520         }
1521         if (docType == null) {
1522             docType = editorForm.getDocType();
1523         }
1524         if (docFormat == null) {
1525             docFormat = editorForm.getDocFormat();
1526         }
1527 
1528         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1529                 .getDocumentEditor(docCategory, docType, docFormat);
1530 
1531         editorForm = documentEditor.addORRemoveItemNote(editorForm, request);
1532         return super.navigate(editorForm, result, request, response);
1533     }
1534 
1535     /**
1536      * Display the linked Bib details for corresponding Holdings/Items.
1537      *
1538      * @param form
1539      * @param result
1540      * @param request
1541      * @param response
1542      * @return
1543      */
1544     @RequestMapping(params = "methodToCall=showBibs")
1545     public ModelAndView showBibs(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1546                                  HttpServletRequest request, HttpServletResponse response) {
1547         EditorForm documentForm = null;
1548         if (!isFormInitialized) {
1549             super.start(form, result, request, response);
1550             isFormInitialized = true;
1551         }
1552         // get the document details from request and set them in the form.
1553         String docCategory = request.getParameter("docCategory");
1554         String docType = request.getParameter("docType");
1555         String docFormat = request.getParameter("docFormat");
1556         String docId = request.getParameter("docId");
1557         String instanceId = request.getParameter("instanceId");
1558         String editable = request.getParameter("editable");
1559 
1560         //Verifying editable at form object
1561         if ((null == editable) || (editable.length() == 0)) {
1562             editable = ((EditorForm) form).getEditable();
1563         }
1564 
1565         //Default value for editable field if it is null
1566         if (null == editable || editable.length() == 0) {
1567             editable = "true";
1568         }
1569 
1570         ((EditorForm) form).setEditable(editable);
1571         ((EditorForm) form).setDocCategory(docCategory);
1572         ((EditorForm) form).setDocType(docType);
1573         ((EditorForm) form).setDocFormat(docFormat);
1574         ((EditorForm) form).setDocId(docId);
1575         ((EditorForm) form).setInstanceId(instanceId);
1576 
1577         // Identify the document editor to be used for the requested document.
1578         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1579                 .getDocumentEditor(docCategory, docType, docFormat);
1580 
1581         documentForm = documentEditor.showBibs((EditorForm) form);
1582         // Set the output (response) form containing document info into the current form.
1583         ((EditorForm) form).setDocumentForm(documentForm);
1584 
1585         // Return the next view to be shown to user.
1586         ModelAndView modelAndView = getUIFModelAndView(form, ((EditorForm) form).getDocumentForm().getViewId());
1587         return modelAndView;
1588     }
1589 
1590 
1591     @RequestMapping(params = "methodToCall=leaderFieldReset")
1592     public ModelAndView resetLeaderField(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1593                                          HttpServletRequest request, HttpServletResponse response) {
1594         LOG.debug("Inside the clear leader method");
1595         EditorForm editForm = (EditorForm) form;
1596         WorkBibMarcForm workBibMarcForm = (WorkBibMarcForm) editForm.getDocumentForm();
1597         workBibMarcForm.setLeaderField(new LeaderField());
1598         ((EditorForm) form).setDocumentForm(workBibMarcForm);
1599         return navigate(form, result, request, response);
1600     }
1601 
1602 
1603     @RequestMapping(params = "methodToCall=createSerialReceiving")
1604     public ModelAndView createSerialReceiving(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1605                                               HttpServletRequest request, HttpServletResponse response) {
1606         LOG.debug("Inside the createSerialReceiving method");
1607         ModelAndView modelAndView = getUIFModelAndView(form, ((EditorForm) form).getDocumentForm().getViewId());
1608         return modelAndView;
1609 
1610     }
1611 
1612 
1613     @RequestMapping(params = "methodToCall=loadControlField006")
1614     public ModelAndView loadControlField006(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1615                                             HttpServletRequest request, HttpServletResponse response) {
1616         ((EditorForm) form).setDisplayField006("true");
1617         WorkBibMarcForm workBibMarcForm = (WorkBibMarcForm) ((EditorForm) form).getDocumentForm();
1618         String controlField006Format = workBibMarcForm.getMarcControlFields().getValue();
1619         if(workBibMarcForm.getMarcControlFields().getControlField006()==null){
1620             ControlField006 controlField006 = new ControlField006();
1621             workBibMarcForm.getMarcControlFields().setControlField006(controlField006);
1622         }
1623         String controlField006Format1 = workBibMarcForm.getMarcControlFields().getControlField006().getFormat();
1624         if(controlField006Format1!=null){
1625             controlField006Format=controlField006Format1;
1626         }
1627         ControlField006 controlFiled006 = new ControlField006();
1628         controlFiled006.setFormat(workBibMarcForm.getMarcControlFields().getValue());
1629         if(controlField006Format1==null){
1630         controlFiled006.setFormat(workBibMarcForm.getMarcControlFields().getValue());
1631         workBibMarcForm.getMarcControlFields().setControlField006(controlFiled006);
1632         }else {
1633             controlFiled006.setFormat(controlField006Format1);
1634             workBibMarcForm.getMarcControlFields().setControlField006(controlFiled006);
1635 
1636         }
1637         workBibMarcForm.getMarcControlFields().setMapVisible("false");
1638         workBibMarcForm.getMarcControlFields().setBooksVisible("false");
1639         workBibMarcForm.getMarcControlFields().setMusicVisible("false");
1640         workBibMarcForm.getMarcControlFields().setComputerFilesVisible("false");
1641         workBibMarcForm.getMarcControlFields().setContinuingResourcesVisible("false");
1642         workBibMarcForm.getMarcControlFields().setMixedMaterialVisible("false");
1643         workBibMarcForm.getMarcControlFields().setVisualMaterialsVisible("false");
1644 
1645         if (controlField006Format.equalsIgnoreCase("e") || controlField006Format.equalsIgnoreCase("f")) {
1646             workBibMarcForm.getMarcControlFields().setMapVisible("true");
1647         } else if (controlField006Format.equalsIgnoreCase("a") || controlField006Format.equalsIgnoreCase("t")) {
1648             workBibMarcForm.getMarcControlFields().setBooksVisible("true");
1649         } else if (controlField006Format.equalsIgnoreCase("c") || controlField006Format.equalsIgnoreCase("d") ||
1650                 controlField006Format.equalsIgnoreCase("i") || controlField006Format.equalsIgnoreCase("j")) {
1651             workBibMarcForm.getMarcControlFields().setMusicVisible("true");
1652         } else if (controlField006Format.equalsIgnoreCase("m")) {
1653             workBibMarcForm.getMarcControlFields().setComputerFilesVisible("true");
1654         } else if (controlField006Format.equalsIgnoreCase("s")) {
1655             workBibMarcForm.getMarcControlFields().setContinuingResourcesVisible("true");
1656         } else if (controlField006Format.equalsIgnoreCase("p")) {
1657             workBibMarcForm.getMarcControlFields().setMixedMaterialVisible("true");
1658         } else if (controlField006Format.equalsIgnoreCase("g") || controlField006Format.equalsIgnoreCase("k") ||
1659                 controlField006Format.equalsIgnoreCase("o") || controlField006Format.equalsIgnoreCase("r")) {
1660             workBibMarcForm.getMarcControlFields().setVisualMaterialsVisible("true");
1661         }
1662         ((EditorForm) form).setDocumentForm(workBibMarcForm);
1663         return navigate(form, result, request, response);
1664     }
1665 
1666     @RequestMapping(params = "methodToCall=loadControlField007")
1667     public ModelAndView loadControlField007(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1668                                             HttpServletRequest request, HttpServletResponse response) {
1669         ((EditorForm) form).setDisplayField007("true");
1670         WorkBibMarcForm workBibMarcForm = (WorkBibMarcForm) ((EditorForm) form).getDocumentForm();
1671         if(workBibMarcForm.getMarcControlFields().getControlField007()==null){
1672             ControlField007 controlField007 = new ControlField007();
1673             workBibMarcForm.getMarcControlFields().setControlField007(controlField007);
1674         }
1675 
1676         String controlField007Format = workBibMarcForm.getMarcControlFields().getValue007();
1677         String controlField007Format1 = workBibMarcForm.getMarcControlFields().getControlField007().getFormat();
1678 
1679         ControlField007 controlFiled007 = new ControlField007();
1680 
1681         if(controlField007Format1!=null){
1682             controlField007Format=controlField007Format1;
1683         }
1684         if(controlField007Format1!=null){
1685             controlFiled007.setFormat(controlField007Format1);
1686             workBibMarcForm.getMarcControlFields().setControlField007(controlFiled007);
1687         }   else{
1688             controlFiled007.setFormat(controlField007Format);
1689             workBibMarcForm.getMarcControlFields().setControlField007(controlFiled007);
1690         }
1691 
1692         workBibMarcForm.getMarcControlFields().setMapVisible007("false");
1693         workBibMarcForm.getMarcControlFields().setElectronicResourcesVisible007("false");
1694         workBibMarcForm.getMarcControlFields().setGlobeVisible007("false");
1695         workBibMarcForm.getMarcControlFields().setTactileMaterialVisible007("false");
1696         workBibMarcForm.getMarcControlFields().setProjectGraphicVisible007("false");
1697         workBibMarcForm.getMarcControlFields().setMicroFormVisible007("false");
1698         workBibMarcForm.getMarcControlFields().setNonProjectedGraphicVisible007("false");
1699         workBibMarcForm.getMarcControlFields().setMotionPictureVisible007("false");
1700         workBibMarcForm.getMarcControlFields().setKitVisible007("false");
1701         workBibMarcForm.getMarcControlFields().setNotatedMusicVisible007("false");
1702         workBibMarcForm.getMarcControlFields().setRemoteSensingImageVisible007("false");
1703         workBibMarcForm.getMarcControlFields().setSoundRecordingVisible007("false");
1704         workBibMarcForm.getMarcControlFields().setTextVisible007("false");
1705         workBibMarcForm.getMarcControlFields().setVideoRecordingVisible007("false");
1706         workBibMarcForm.getMarcControlFields().setUnspecifiedVisible007("false");
1707 
1708         if (controlField007Format.equalsIgnoreCase("a")) {
1709             workBibMarcForm.getMarcControlFields().setMapVisible007("true");
1710         } else if (controlField007Format.equalsIgnoreCase("c")) {
1711             workBibMarcForm.getMarcControlFields().setElectronicResourcesVisible007("true");
1712         } else if (controlField007Format.equalsIgnoreCase("d")) {
1713             workBibMarcForm.getMarcControlFields().setGlobeVisible007("true");
1714         } else if (controlField007Format.equalsIgnoreCase("f")) {
1715             workBibMarcForm.getMarcControlFields().setTactileMaterialVisible007("true");
1716         } else if (controlField007Format.equalsIgnoreCase("g")) {
1717             workBibMarcForm.getMarcControlFields().setProjectGraphicVisible007("true");
1718         } else if (controlField007Format.equalsIgnoreCase("h")) {
1719             workBibMarcForm.getMarcControlFields().setMicroFormVisible007("true");
1720         } else if (controlField007Format.equalsIgnoreCase("k")) {
1721             workBibMarcForm.getMarcControlFields().setNonProjectedGraphicVisible007("true");
1722         } else if (controlField007Format.equalsIgnoreCase("m")) {
1723             workBibMarcForm.getMarcControlFields().setMotionPictureVisible007("true");
1724         } else if (controlField007Format.equalsIgnoreCase("o")) {
1725             workBibMarcForm.getMarcControlFields().setKitVisible007("true");
1726         } else if (controlField007Format.equalsIgnoreCase("q")) {
1727             workBibMarcForm.getMarcControlFields().setNotatedMusicVisible007("true");
1728         } else if (controlField007Format.equalsIgnoreCase("r")) {
1729             workBibMarcForm.getMarcControlFields().setRemoteSensingImageVisible007("true");
1730         } else if (controlField007Format.equalsIgnoreCase("s")) {
1731             workBibMarcForm.getMarcControlFields().setSoundRecordingVisible007("true");
1732         } else if (controlField007Format.equalsIgnoreCase("t")) {
1733             workBibMarcForm.getMarcControlFields().setTextVisible007("true");
1734         } else if (controlField007Format.equalsIgnoreCase("v")) {
1735             workBibMarcForm.getMarcControlFields().setVideoRecordingVisible007("true");
1736         } else if (controlField007Format.equalsIgnoreCase("z")) {
1737             workBibMarcForm.getMarcControlFields().setUnspecifiedVisible007("true");
1738         }
1739         ((EditorForm) form).setDocumentForm(workBibMarcForm);
1740 
1741         return navigate(form, result, request, response);
1742     }
1743 
1744     @RequestMapping(params = "methodToCall=loadControlField008")
1745     public ModelAndView loadControlField008(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1746                                             HttpServletRequest request, HttpServletResponse response) {
1747         ((EditorForm) form).setDisplayField008("true");
1748         WorkBibMarcForm workBibMarcForm = (WorkBibMarcForm) ((EditorForm) form).getDocumentForm();
1749 
1750         if(workBibMarcForm.getMarcControlFields().getControlField008()==null){
1751             ControlField008 controlField008 = new ControlField008();
1752             workBibMarcForm.getMarcControlFields().setControlField008(controlField008);
1753         }
1754         String controlField008Format = workBibMarcForm.getMarcControlFields().getValue008();
1755         workBibMarcForm.getMarcControlFields().setControlField008(new ControlField008());
1756 
1757 
1758         workBibMarcForm.getMarcControlFields().setMapVisible008("false");
1759         workBibMarcForm.getMarcControlFields().setBooksVisible008("false");
1760         workBibMarcForm.getMarcControlFields().setMusicVisible008("false");
1761         workBibMarcForm.getMarcControlFields().setComputerFilesVisible008("false");
1762         workBibMarcForm.getMarcControlFields().setContinuingResourcesVisible008("false");
1763         workBibMarcForm.getMarcControlFields().setMixedMaterialVisible008("false");
1764         workBibMarcForm.getMarcControlFields().setVisualMaterialsVisible008("false");
1765 
1766         if (controlField008Format.equalsIgnoreCase("map")) {
1767             workBibMarcForm.getMarcControlFields().setMapVisible008("true");
1768         } else if (controlField008Format.equalsIgnoreCase("books")) {
1769             workBibMarcForm.getMarcControlFields().setBooksVisible008("true");
1770         } else if (controlField008Format.equalsIgnoreCase("music")) {
1771             workBibMarcForm.getMarcControlFields().setMusicVisible008("true");
1772         } else if (controlField008Format.equalsIgnoreCase("computer")) {
1773             workBibMarcForm.getMarcControlFields().setComputerFilesVisible008("true");
1774         } else if (controlField008Format.equalsIgnoreCase("countRes")) {
1775             workBibMarcForm.getMarcControlFields().setContinuingResourcesVisible008("true");
1776         } else if (controlField008Format.equalsIgnoreCase("mixMat")) {
1777             workBibMarcForm.getMarcControlFields().setMixedMaterialVisible008("true");
1778         } else if (controlField008Format.equalsIgnoreCase("visMat")) {
1779             workBibMarcForm.getMarcControlFields().setVisualMaterialsVisible008("true");
1780         }
1781 
1782         ((EditorForm) form).setDocumentForm(workBibMarcForm);
1783         return navigate(form, result, request, response);
1784     }
1785 
1786     @RequestMapping(params = "methodToCall=addCoverageSection")
1787     public ModelAndView addCoverageSection(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1788                                            HttpServletRequest request, HttpServletResponse response) {
1789         if (!isFormInitialized) {
1790             super.start(form, result, request, response);
1791             isFormInitialized = true;
1792         }
1793         EditorForm editorForm = (EditorForm) form;
1794         String docCategory = request.getParameter("docCategory");
1795         String docType = request.getParameter("docType");
1796         String docFormat = request.getParameter("docFormat");
1797         if (docCategory == null) {
1798             docCategory = editorForm.getDocCategory();
1799         }
1800         if (docType == null) {
1801             docType = editorForm.getDocType();
1802         }
1803         if (docFormat == null) {
1804             docFormat = editorForm.getDocFormat();
1805         }
1806 
1807         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1808                 .getDocumentEditor(docCategory, docType, docFormat);
1809 
1810         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
1811         int index = Integer.parseInt(form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
1812         workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getCoverages().getCoverage().add(new Coverage());
1813         return super.navigate(editorForm, result, request, response);
1814     }
1815 
1816     @RequestMapping(params = "methodToCall=removeCoverageSection")
1817     public ModelAndView removeCoverageSection(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1818                                               HttpServletRequest request, HttpServletResponse response) {
1819         if (!isFormInitialized) {
1820             super.start(form, result, request, response);
1821             isFormInitialized = true;
1822         }
1823         EditorForm editorForm = (EditorForm) form;
1824         String docCategory = request.getParameter("docCategory");
1825         String docType = request.getParameter("docType");
1826         String docFormat = request.getParameter("docFormat");
1827         if (docCategory == null) {
1828             docCategory = editorForm.getDocCategory();
1829         }
1830         if (docType == null) {
1831             docType = editorForm.getDocType();
1832         }
1833         if (docFormat == null) {
1834             docFormat = editorForm.getDocFormat();
1835         }
1836 
1837         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1838                 .getDocumentEditor(docCategory, docType, docFormat);
1839 
1840         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
1841         int index = Integer.parseInt(form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
1842         if (workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getCoverages().getCoverage().size() > 1) {
1843             workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getCoverages().getCoverage().remove(index);
1844         } else {
1845             if (workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getCoverages().getCoverage().size() == 1) {
1846                 workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getCoverages().getCoverage().remove(index);
1847                 Coverage coverage = new Coverage();
1848                 workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getCoverages().getCoverage().add(coverage);
1849             }
1850         }
1851         return super.navigate(editorForm, result, request, response);
1852     }
1853 
1854     @RequestMapping(params = "methodToCall=addLink")
1855     public ModelAndView addLink(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1856                                            HttpServletRequest request, HttpServletResponse response) {
1857         if (!isFormInitialized) {
1858             super.start(form, result, request, response);
1859             isFormInitialized = true;
1860         }
1861         EditorForm editorForm = (EditorForm) form;
1862         String docCategory = request.getParameter("docCategory");
1863         String docType = request.getParameter("docType");
1864         String docFormat = request.getParameter("docFormat");
1865         if (docCategory == null) {
1866             docCategory = editorForm.getDocCategory();
1867         }
1868         if (docType == null) {
1869             docType = editorForm.getDocType();
1870         }
1871         if (docFormat == null) {
1872             docFormat = editorForm.getDocFormat();
1873         }
1874 
1875         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1876                 .getDocumentEditor(docCategory, docType, docFormat);
1877 
1878         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
1879         int index = Integer.parseInt(form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
1880         workEInstanceOlemlForm.getSelectedEHoldings().getLink().add(index+1,new Link());
1881         return super.navigate(editorForm, result, request, response);
1882     }
1883 
1884     @RequestMapping(params = "methodToCall=deleteLink")
1885     public ModelAndView deleteLink(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1886                                 HttpServletRequest request, HttpServletResponse response) {
1887         if (!isFormInitialized) {
1888             super.start(form, result, request, response);
1889             isFormInitialized = true;
1890         }
1891         EditorForm editorForm = (EditorForm) form;
1892         String docCategory = request.getParameter("docCategory");
1893         String docType = request.getParameter("docType");
1894         String docFormat = request.getParameter("docFormat");
1895         if (docCategory == null) {
1896             docCategory = editorForm.getDocCategory();
1897         }
1898         if (docType == null) {
1899             docType = editorForm.getDocType();
1900         }
1901         if (docFormat == null) {
1902             docFormat = editorForm.getDocFormat();
1903         }
1904 
1905         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1906                 .getDocumentEditor(docCategory, docType, docFormat);
1907 
1908         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
1909         int index = Integer.parseInt(form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
1910         if (workEInstanceOlemlForm.getSelectedEHoldings().getLink().size() > 1) {
1911             workEInstanceOlemlForm.getSelectedEHoldings().getLink().remove(index);
1912         } else {
1913             if (workEInstanceOlemlForm.getSelectedEHoldings().getLink().size() == 1) {
1914                 workEInstanceOlemlForm.getSelectedEHoldings().getLink().remove(index);
1915                 Link link = new Link();
1916                 workEInstanceOlemlForm.getSelectedEHoldings().getLink().add(link);
1917             }
1918         }
1919         return super.navigate(editorForm, result, request, response);
1920     }
1921 
1922     @RequestMapping(params = "methodToCall=addPerpetualAccessSection")
1923     public ModelAndView addPerpetualAccessSection(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1924                                                   HttpServletRequest request, HttpServletResponse response) {
1925         if (!isFormInitialized) {
1926             super.start(form, result, request, response);
1927             isFormInitialized = true;
1928         }
1929         EditorForm editorForm = (EditorForm) form;
1930         String docCategory = request.getParameter("docCategory");
1931         String docType = request.getParameter("docType");
1932         String docFormat = request.getParameter("docFormat");
1933         if (docCategory == null) {
1934             docCategory = editorForm.getDocCategory();
1935         }
1936         if (docType == null) {
1937             docType = editorForm.getDocType();
1938         }
1939         if (docFormat == null) {
1940             docFormat = editorForm.getDocFormat();
1941         }
1942 
1943         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1944                 .getDocumentEditor(docCategory, docType, docFormat);
1945 
1946         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
1947         //int index = Integer.parseInt(workEInstanceOlemlForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
1948        /* String selectedPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
1949         int selectedExtentIndex = Integer.parseInt(StringUtils.substring(selectedPath,
1950                 (StringUtils.indexOf(selectedPath, "[") + 1),
1951                 StringUtils.lastIndexOf(selectedPath, "]")));*/
1952         workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().add(new PerpetualAccess());
1953         return super.navigate(editorForm, result, request, response);
1954     }
1955 
1956     @RequestMapping(params = "methodToCall=removePerpetualAccessSection")
1957     public ModelAndView removePerpetualAccessSection(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1958                                                      HttpServletRequest request, HttpServletResponse response) {
1959         if (!isFormInitialized) {
1960             super.start(form, result, request, response);
1961             isFormInitialized = true;
1962         }
1963         EditorForm editorForm = (EditorForm) form;
1964         String docCategory = request.getParameter("docCategory");
1965         String docType = request.getParameter("docType");
1966         String docFormat = request.getParameter("docFormat");
1967         if (docCategory == null) {
1968             docCategory = editorForm.getDocCategory();
1969         }
1970         if (docType == null) {
1971             docType = editorForm.getDocType();
1972         }
1973         if (docFormat == null) {
1974             docFormat = editorForm.getDocFormat();
1975         }
1976 
1977         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
1978                 .getDocumentEditor(docCategory, docType, docFormat);
1979 
1980         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
1981         int index = Integer.parseInt(form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
1982         if (workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().size() > 1) {
1983             workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().remove(index);
1984         } else {
1985             if (workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().size() == 1) {
1986                 workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().remove(index);
1987                 PerpetualAccess perpetualAccess = new PerpetualAccess();
1988                 workEInstanceOlemlForm.getSelectedEHoldings().getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().add(perpetualAccess);
1989             }
1990         }
1991         return super.navigate(editorForm, result, request, response);
1992     }
1993 
1994     @RequestMapping(params = "methodToCall=addOleEInstanceHoldingNotes")
1995     public ModelAndView addOleEInstanceHoldingNotes(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1996                                                     HttpServletRequest request, HttpServletResponse response) {
1997         if (!isFormInitialized) {
1998             super.start(form, result, request, response);
1999             isFormInitialized = true;
2000         }
2001         EditorForm editorForm = (EditorForm) form;
2002         String docCategory = request.getParameter("docCategory");
2003         String docType = request.getParameter("docType");
2004         String docFormat = request.getParameter("docFormat");
2005         if (docCategory == null) {
2006             docCategory = editorForm.getDocCategory();
2007         }
2008         if (docType == null) {
2009             docType = editorForm.getDocType();
2010         }
2011         if (docFormat == null) {
2012             docFormat = editorForm.getDocFormat();
2013         }
2014 
2015         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
2016                 .getDocumentEditor(docCategory, docType, docFormat);
2017 
2018         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
2019         workEInstanceOlemlForm.getSelectedEHoldings().getNote().add(new Note());
2020         return super.navigate(editorForm, result, request, response);
2021     }
2022 
2023     @RequestMapping(params = "methodToCall=removeOleEInstanceHoldingNotes")
2024     public ModelAndView removeOleEInstanceHoldingNotes(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2025                                                        HttpServletRequest request, HttpServletResponse response) {
2026         if (!isFormInitialized) {
2027             super.start(form, result, request, response);
2028             isFormInitialized = true;
2029         }
2030         EditorForm editorForm = (EditorForm) form;
2031         String docCategory = request.getParameter("docCategory");
2032         String docType = request.getParameter("docType");
2033         String docFormat = request.getParameter("docFormat");
2034         if (docCategory == null) {
2035             docCategory = editorForm.getDocCategory();
2036         }
2037         if (docType == null) {
2038             docType = editorForm.getDocType();
2039         }
2040         if (docFormat == null) {
2041             docFormat = editorForm.getDocFormat();
2042         }
2043 
2044         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
2045                 .getDocumentEditor(docCategory, docType, docFormat);
2046 
2047         WorkEInstanceOlemlForm workEInstanceOlemlForm = (WorkEInstanceOlemlForm) editorForm.getDocumentForm();
2048         int index = Integer.parseInt(form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
2049         if (workEInstanceOlemlForm.getSelectedEHoldings().getNote().size() > 1) {
2050             workEInstanceOlemlForm.getSelectedEHoldings().getNote().remove(index);
2051         } else {
2052             if (workEInstanceOlemlForm.getSelectedEHoldings().getNote().size() == 1) {
2053                 workEInstanceOlemlForm.getSelectedEHoldings().getNote().remove(index);
2054                 Note note = new Note();
2055                 workEInstanceOlemlForm.getSelectedEHoldings().getNote().add(note);
2056             }
2057         }
2058         return super.navigate(editorForm, result, request, response);
2059     }
2060 
2061 
2062     @RequestMapping(params = "methodToCall=globalEditSave")
2063     public ModelAndView globalEditSave(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2064                                        HttpServletRequest request, HttpServletResponse response) {
2065         if (!isFormInitialized) {
2066             super.start(form, result, request, response);
2067             isFormInitialized = true;
2068         }
2069         EditorForm editorForm = (EditorForm) form;
2070         String docCategory = request.getParameter("docCategory");
2071         String docType = request.getParameter("docType");
2072         String docFormat = request.getParameter("docFormat");
2073         List<String> ids = (List<String>) request.getSession().getAttribute("Ids");
2074         if (docCategory == null) {
2075             docCategory = editorForm.getDocCategory();
2076         }
2077         if (docType == null) {
2078             docType = editorForm.getDocType();
2079         }
2080         if (docFormat == null) {
2081             docFormat = editorForm.getDocFormat();
2082         }
2083 
2084         ((EditorForm) form).setDocCategory(docCategory);
2085         ((EditorForm) form).setDocType(docType);
2086         ((EditorForm) form).setDocFormat(docFormat);
2087         DocumentEditor documentEditor = DocumentEditorFactory.getInstance()
2088                 .getDocumentEditor(docCategory, docType, docFormat);
2089 
2090         if (documentEditor != null && documentEditor.isValidUpdate((EditorForm) form) || ((EditorForm) form).getAllowUpdate().equals
2091                 ("true")) {
2092             // Send the input through one (request)form and get the output through another (response) form.
2093             EditorForm documentForm = documentEditor.bulkUpdate((EditorForm) form, ids);
2094             // Set the output (response) form containing docum ((EditorForm) form).isAllowUpdate()ent info into the current form.
2095             ((EditorForm) form).setDocumentForm(documentForm);
2096             ((EditorForm) form).setAllowUpdate(" ");
2097         } else {
2098             ((EditorForm) form).setAllowUpdate("false");
2099         }
2100         return super.navigate(editorForm, result, request, response);
2101     }
2102 
2103 
2104     @RequestMapping(params = "methodToCall=printCallSlip")
2105     public void printCallSlip(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request, HttpServletResponse response) {
2106         String formKey = request.getParameter("formKey");
2107         EditorForm editorForm = (EditorForm) GlobalVariables.getUifFormManager().getSessionForm(formKey);
2108         generateCallSlip(editorForm, response);
2109     }
2110 
2111     private void generateCallSlip(EditorForm editorForm, HttpServletResponse response) {
2112         LOG.debug("Creating pdf");
2113         String title = "", author = "", callNumber = "", location = "", copyNumber = "", enumeration = "", chronology = "", barcode = "";
2114         SearchResponse searchResponse = null;
2115         SearchParams searchParams = new SearchParams();
2116         SearchField searchField1 = searchParams.buildSearchField("item", "ItemIdentifier_search", editorForm.getDocId());
2117         searchParams.getSearchConditions().add(searchParams.buildSearchCondition("OR", searchField1, "AND"));
2118         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("bibliographic", "Title"));
2119         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("bibliographic", "Author"));
2120         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "CallNumber"));
2121         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "LocationName"));
2122         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "CopyNumber"));
2123         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "enumeration"));
2124         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "chronology"));
2125         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "ItemBarcode"));
2126         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("holdings", "CallNumber"));
2127         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("holdings", "LocationName"));
2128         try {
2129             searchResponse = getDocstoreClientLocator().getDocstoreClient().search(searchParams);
2130         } catch (Exception e) {
2131             LOG.error(e, e);
2132         }
2133         if (CollectionUtils.isNotEmpty(searchResponse.getSearchResults())) {
2134             for (SearchResultField searchResultField : searchResponse.getSearchResults().get(0).getSearchResultFields()) {
2135                 if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("Title")) {
2136                     if (StringUtils.isBlank(title)) {
2137                         title = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2138                     }
2139                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("Author")) {
2140                     if (StringUtils.isBlank(author)) {
2141                         author = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2142                     }
2143                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("CallNumber")) {
2144                     callNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2145                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("LocationName")) {
2146                     location = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2147                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("CopyNumber")) {
2148                     copyNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2149                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("enumeration")) {
2150                     enumeration = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2151                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("chronology")) {
2152                     chronology = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2153                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("ItemBarcode")) {
2154                     barcode = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2155                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("CallNumber")) {
2156                     if (StringUtils.isBlank(callNumber)) {
2157                         callNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2158                     }
2159                 } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode()) && searchResultField.getFieldName().equalsIgnoreCase("LocationName")) {
2160                     if (StringUtils.isBlank(location)) {
2161                         location = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
2162                     }
2163                 }
2164             }
2165         }
2166         String fileName = "Call/Paging Slip" + "_" + (editorForm.getTitle() != null ? editorForm.getTitle() : "") + "_" + new Date(System.currentTimeMillis()) + ".pdf";
2167         if (LOG.isInfoEnabled()) {
2168             LOG.info("File Created :" + title + "file name ::" + fileName + "::");
2169         }
2170         try {
2171             Document document = this.getDocument(0, 0, 5, 5);
2172             OutputStream outputStream = null;
2173             response.setContentType("application/pdf");
2174             //response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
2175             outputStream = response.getOutputStream();
2176             PdfWriter.getInstance(document, outputStream);
2177             Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
2178             document.open();
2179             document.newPage();
2180             PdfPTable pdfTable = new PdfPTable(3);
2181             pdfTable.setWidths(new int[]{20, 2, 30});
2182             Paragraph paraGraph = new Paragraph();
2183             paraGraph.setAlignment(Element.ALIGN_CENTER);
2184             paraGraph.add(new Chunk("Call/Paging Slip", boldFont));
2185             paraGraph.add(Chunk.NEWLINE);
2186             paraGraph.add(Chunk.NEWLINE);
2187             paraGraph.add(Chunk.NEWLINE);
2188             document.add(paraGraph);
2189 
2190             pdfTable.addCell(getPdfPCellInJustified("Title"));
2191             pdfTable.addCell(getPdfPCellInLeft(":"));
2192             pdfTable.addCell(getPdfPCellInJustified(title));
2193 
2194             pdfTable.addCell(getPdfPCellInJustified("Author"));
2195             pdfTable.addCell(getPdfPCellInLeft(":"));
2196             pdfTable.addCell(getPdfPCellInJustified(author));
2197 
2198             pdfTable.addCell(getPdfPCellInJustified("Call Number"));
2199             pdfTable.addCell(getPdfPCellInLeft(":"));
2200             pdfTable.addCell(getPdfPCellInJustified(callNumber));
2201 
2202             pdfTable.addCell(getPdfPCellInJustified("Location"));
2203             pdfTable.addCell(getPdfPCellInLeft(":"));
2204             pdfTable.addCell(getPdfPCellInJustified(location));
2205 
2206             pdfTable.addCell(getPdfPCellInJustified("Copy Number"));
2207             pdfTable.addCell(getPdfPCellInLeft(":"));
2208             pdfTable.addCell(getPdfPCellInJustified(copyNumber));
2209 
2210             pdfTable.addCell(getPdfPCellInJustified("Enumeration"));
2211             pdfTable.addCell(getPdfPCellInLeft(":"));
2212             pdfTable.addCell(getPdfPCellInJustified(enumeration));
2213 
2214             pdfTable.addCell(getPdfPCellInJustified("Chronology"));
2215             pdfTable.addCell(getPdfPCellInLeft(":"));
2216             pdfTable.addCell(getPdfPCellInJustified(chronology));
2217 
2218             pdfTable.addCell(getPdfPCellInJustified("Barcode"));
2219             pdfTable.addCell(getPdfPCellInLeft(":"));
2220             pdfTable.addCell(getPdfPCellInJustified(barcode));
2221 
2222             document.add(pdfTable);
2223             document.close();
2224             outputStream.flush();
2225             outputStream.close();
2226         } catch (Exception e) {
2227             LOG.error(e, e);
2228         }
2229     }
2230 
2231     private PdfPCell getPdfPCellInJustified(String chunk) {
2232         PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
2233         pdfPCell.setBorder(pdfPCell.NO_BORDER);
2234         pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
2235         return pdfPCell;
2236     }
2237 
2238     private PdfPCell getPdfPCellInLeft(String chunk) {
2239         PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
2240         pdfPCell.setBorder(pdfPCell.NO_BORDER);
2241         pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
2242         return pdfPCell;
2243     }
2244 
2245     public Document getDocument(float f1, float f2, float f3, float f4) {
2246         Document document = new Document(PageSize.A4);
2247         document.setMargins(f1, f2, f3, f4);
2248         return document;
2249     }
2250 
2251 
2252     private void prepareGlobalEditFields(EditorForm editorForm, String docType) {
2253 
2254         if (DocType.INSTANCE.getCode().equals(docType) || DocType.HOLDINGS.getCode().equals(docType)) {
2255             editorForm.setHeaderText(OLEConstants.GLOBAL_EDIT_HOLDINGS_HEADER_MESSAGE);
2256         } else if (DocType.EINSTANCE.getCode().equals(docType) || DocType.EHOLDINGS.getCode().equals(docType)) {
2257             editorForm.setHeaderText(OLEConstants.GLOBAL_EDIT_EHOLDINGS_HEADER_MESSAGE);
2258         } else if (DocType.ITEM.getCode().equals(docType)) {
2259             editorForm.setHeaderText(OLEConstants.GLOBAL_EDIT_ITEM_HEADER_MESSAGE);
2260         }
2261 
2262         DocumentSearchConfig documentSearchConfig = DocumentSearchConfig.getDocumentSearchConfig();
2263         List<DocTypeConfig> docTypeFields = documentSearchConfig.getDocTypeConfigs();
2264 
2265         for (DocTypeConfig docTypeConfig : docTypeFields) {
2266 
2267             List<DocFormatConfig> docFormatConfigList = docTypeConfig.getDocFormatConfigList();
2268 
2269             if (DocType.HOLDINGS.getCode().equals(docTypeConfig.getName()) && DocType.HOLDINGS.getCode().equals(docType)) {
2270                 setGlobalEditFlagValues(editorForm, docFormatConfigList, docType);
2271             } else if (DocType.EHOLDINGS.getCode().equals(docTypeConfig.getName()) && DocType.EHOLDINGS.getCode().equals(docType)) {
2272                 setGlobalEditFlagValues(editorForm, docFormatConfigList, docType);
2273             } else if (DocType.ITEM.getCode().equals(docType) && DocType.ITEM.getCode().equals(docTypeConfig.getName())) {
2274                 setGlobalEditFlagValues(editorForm, docFormatConfigList, docType);
2275             }
2276 
2277         }
2278 
2279     }
2280 
2281     private void setGlobalEditFlagValues(EditorForm editorForm, List<DocFormatConfig> docFormatConfigList, String docType) {
2282 
2283         for (DocFormatConfig docFormatConfig : docFormatConfigList) {
2284 
2285             List<DocFieldConfig> docFieldConfigList = docFormatConfig.getDocFieldConfigList();
2286 
2287             if (OLEConstants.OLEML_FORMAT.equals(docFormatConfig.getName())) {
2288                 if (DocType.INSTANCE.getCode().equals(docType) || DocType.HOLDINGS.getCode().equals(docType)) {
2289                     GlobalEditHoldingsFieldsFlagBO globalEditHoldingsFieldsFlagBO = editorForm.getGlobalEditHoldingsFieldsFlagBO();
2290                     for (DocFieldConfig docFieldConfig : docFieldConfigList) {
2291 
2292                         if (docFieldConfig.isGloballyEditable()) {
2293 
2294                             if (OLEConstants.CALL_NUMBER.equals(docFieldConfig.getName())) {
2295                                 globalEditHoldingsFieldsFlagBO.setCallNumberEditFlag(true);
2296                             } else if (OLEConstants.CALL_NUMBER_PREFIX.equals(docFieldConfig.getName())) {
2297                                 globalEditHoldingsFieldsFlagBO.setCallNumberPrefixEditFlag(true);
2298                             } else if (OLEConstants.CALL_NUMBER_TYPE_CODE.equals(docFieldConfig.getName())) {
2299                                 globalEditHoldingsFieldsFlagBO.setCallNumberTypeEditFlag(true);
2300                             } else if (OLEConstants.SHELVING_ORDER.equals(docFieldConfig.getName())) {
2301                                 globalEditHoldingsFieldsFlagBO.setShelvingOrderEditFlag(true);
2302                             } else if (OLEConstants.LOCATION_LEVEL.equals(docFieldConfig.getName())) {
2303                                 globalEditHoldingsFieldsFlagBO.setLocationEditFlag(true);
2304                             } else if (OLEConstants.HOLDINGS_NOTE.equals(docFieldConfig.getName())) {
2305                                 globalEditHoldingsFieldsFlagBO.setHoldingsNoteEditFlag(true);
2306                             } else if (OLEConstants.URI.equals(docFieldConfig.getName())) {
2307                                 globalEditHoldingsFieldsFlagBO.setAccessInformationEditFlag(true);
2308                             } else if (OLEConstants.RECEIPT_STATUS_CODE.equals(docFieldConfig.getName())) {
2309                                 globalEditHoldingsFieldsFlagBO.setReceiptStatusEditFlag(true);
2310                             } else if (OLEConstants.COPY_NUMBER_LABEL.equals(docFieldConfig.getName())) {
2311                                 globalEditHoldingsFieldsFlagBO.setCopyNumberEditFlag(true);
2312                             } else if (OLEConstants.EXTENTOFOWNERSHIP_NOTE_VALUE_DISPLAY.equals(docFieldConfig.getName()) || OLEConstants.EXTENTOFOWNERSHIP_NOTE_TYPE_DISPLAY.equals(docFieldConfig.getName()) || OLEConstants.EXTENTOFOWNERSHIP_Type_display.equals(docFieldConfig.getName())) {
2313                                 globalEditHoldingsFieldsFlagBO.setExtentOwnerShipEditFlag(true);
2314                             } else if (OLEConstants.URI_SEARCH.equals(docFieldConfig.getName()) || OLEConstants.URI_DISPLAY.equals(docFieldConfig.getName())) {
2315                                 globalEditHoldingsFieldsFlagBO.setExtendedInfoEditFlag(true);
2316                             }
2317                             //TODO - Need to do for other fields in holdings
2318                         }
2319                     }
2320                 } else if (DocType.EINSTANCE.getCode().equals(docType) || DocType.EHOLDINGS.getCode().equals(docType)) {
2321                     GlobalEditEHoldingsFieldsFlagBO globalEditEHoldingsFieldsFlagBO = editorForm.getGlobalEditEHoldingsFieldsFlagBO();
2322                     for (DocFieldConfig docFieldConfig : docFieldConfigList) {
2323 
2324                             if (docFieldConfig.isGloballyEditable()) {
2325                             if (OLEConstants.CALL_NUMBER.equals(docFieldConfig.getName())) {
2326                                 globalEditEHoldingsFieldsFlagBO.setCallNumberEditFlag(true);
2327                             } else if (OLEConstants.CALL_NUMBER_PREFIX.equals(docFieldConfig.getName())) {
2328                                 globalEditEHoldingsFieldsFlagBO.setCallNumberPrefixEditFlag(true);
2329                             } else if (OLEConstants.CALL_NUMBER_TYPE_CODE.equals(docFieldConfig.getName())) {
2330                                 globalEditEHoldingsFieldsFlagBO.setCallNumberTypeEditFlag(true);
2331                             } else if (OLEConstants.SHELVING_ORDER.equals(docFieldConfig.getName())) {
2332                                 globalEditEHoldingsFieldsFlagBO.setShelvingOrderEditFlag(true);
2333                             } else if (OLEConstants.LOCATION_LEVEL.equals(docFieldConfig.getName())) {
2334                                 globalEditEHoldingsFieldsFlagBO.setLocationEditFlag(true);
2335                             } else if (OLEConstants.EHOLDING_ACCESS_STATUS.equals(docFieldConfig.getName())) {
2336                                 globalEditEHoldingsFieldsFlagBO.setAccessStatusEditFlag(true);
2337                             } else if (OLEConstants.EHOLDING_PLATFORM_DISPLAY.equals(docFieldConfig.getName())) {
2338                                 globalEditEHoldingsFieldsFlagBO.setPlatformEditFlag(true);
2339                             } else if (OLEConstants.EHOLDING_IMPRINT.equals(docFieldConfig.getName())) {
2340                                 globalEditEHoldingsFieldsFlagBO.setImprintEditFlag(true);
2341                             } else if (OLEConstants.EHOLDING_E_PUBLISHER.equals(docFieldConfig.getName())) {
2342                                 globalEditEHoldingsFieldsFlagBO.setPublisherEditFlag(true);
2343                             } else if (OLEConstants.EHOLDING_STATISTICAL_CODE.equals(docFieldConfig.getName())) {
2344                                 globalEditEHoldingsFieldsFlagBO.setStatisticalCodeEditFlag(true);
2345                             } /*else if (OLEConstants.EHOLDING_SUBSCRIPTION_STATUS.equals(docFieldConfig.getName())) {
2346                                 // TODO add field to js staffOnlyEditFlag
2347                                 globalEditEHoldingsFieldsFlagBO.setSubscriptionEditFlag(true);
2348                             }*/ else if (OLEConstants.EHOLDING_SUBSCRIPTION_STATUS.equals(docFieldConfig.getName())) {
2349                                 globalEditEHoldingsFieldsFlagBO.setAcquisitionInformationEditFlag(true);
2350                                 globalEditEHoldingsFieldsFlagBO.setSubscriptionEditFlag(true);
2351                             } else if (OLEConstants.EHOLDING_LINK.equals(docFieldConfig.getName())) {
2352                                 globalEditEHoldingsFieldsFlagBO.setLinkEditFlag(true);
2353                                 globalEditEHoldingsFieldsFlagBO.setAccessInformationEditFlag(true);
2354                             } else if (OLEConstants.EHOLDING_SIMULTANEOUS_USER.equals(docFieldConfig.getName())) {
2355                                 globalEditEHoldingsFieldsFlagBO.setSimultaneousEditFlag(true);
2356                                 globalEditEHoldingsFieldsFlagBO.setAccessInformationEditFlag(true);
2357                             } else if (OLEConstants.EHOLDING_PERSIST_LINK.equals(docFieldConfig.getName())) {
2358                                 globalEditEHoldingsFieldsFlagBO.setPersistentLinkEditFlag(true);
2359                                 globalEditEHoldingsFieldsFlagBO.setAccessInformationEditFlag(true);
2360                             } else if (OLEConstants.EHOLDING_ACCESS_LOCATION.equals(docFieldConfig.getName())) {
2361                                 globalEditEHoldingsFieldsFlagBO.setAccessInformationEditFlag(true);
2362                                 globalEditEHoldingsFieldsFlagBO.setAccessLocationEditFlag(true);
2363                             } else if (OLEConstants.EHOLDING_LINK_TEXT.equals(docFieldConfig.getName())) {
2364                                 globalEditEHoldingsFieldsFlagBO.setLinkTextEditFlag(true);
2365                             } else if (OLEConstants.EHOLDING_ADMIN_USER.equals(docFieldConfig.getName())) {
2366                                 globalEditEHoldingsFieldsFlagBO.setAdminUserNameEditFlag(true);
2367                             } else if (OLEConstants.EHOLDING_ADMIN_PWSD.equals(docFieldConfig.getName())) {
2368                                 globalEditEHoldingsFieldsFlagBO.setAdminPasswordEditFlag(true);
2369                             } else if (OLEConstants.EHOLDING_ACCESS_USR_NAME.equals(docFieldConfig.getName())) {
2370                                 globalEditEHoldingsFieldsFlagBO.setAccessUserNameEditFlag(true);
2371                             } else if (OLEConstants.EHOLDING_ACCESS_PSWD.equals(docFieldConfig.getName())) {
2372                                 globalEditEHoldingsFieldsFlagBO.setAccessPasswordEditFlag(true);
2373                             } else if (OLEConstants.EHOLDING_ADMIN_URL.equals(docFieldConfig.getName())) {
2374                                 globalEditEHoldingsFieldsFlagBO.setAdminUrlEditFlag(true);
2375                             } else if (OLEConstants.EHOLDING_AUTHENTICATION_TYPE.equals(docFieldConfig.getName())) {
2376                                 globalEditEHoldingsFieldsFlagBO.setAuthenticationEditFlag(true);
2377                             } else if (OLEConstants.EHOLDING_PROXIED.equals(docFieldConfig.getName())) {
2378                                 globalEditEHoldingsFieldsFlagBO.setProxiedEditFlag(true);
2379                             } else if (OLEConstants.EHOLDING_ILL_IND.equals(docFieldConfig.getName())) {
2380                                 globalEditEHoldingsFieldsFlagBO.setLicenseDetailsEditFlag(true);
2381                                 globalEditEHoldingsFieldsFlagBO.setIllEditFlag(true);
2382                             } else if (OLEConstants.EHOLDING_COVERAGE.equals(docFieldConfig.getName())) {
2383                                 //globalEditEHoldingsFieldsFlagBO.setExtentOfOwnerShipEditFlag(true);
2384                                 globalEditEHoldingsFieldsFlagBO.setCoverageExtentOfOwnerShipEditFlag(true);
2385                             } else if (OLEConstants.EHOLDING_PERPETUAL.equals(docFieldConfig.getName())) {
2386                                 globalEditEHoldingsFieldsFlagBO.setExtentOfOwnerShipEditFlag(true);
2387                                 globalEditEHoldingsFieldsFlagBO.setPerpetualAccessEditFlag(true);
2388                             } else if (OLEConstants.HOLDINGS_NOTE.equals(docFieldConfig.getName())) {
2389                                 globalEditEHoldingsFieldsFlagBO.seteHoldingsNoteEditFlag(true);
2390                             } else if (OLEConstants.DONOR_CODE_DISPLAY.equals(docFieldConfig.getName())) {
2391                                 globalEditEHoldingsFieldsFlagBO.setDonorCodeEditFlag(true);
2392                             } else if (OLEConstants.EHOLDING_DONOR_PUBLIC_DISPLAY.equals(docFieldConfig.getName())) {
2393                                 globalEditEHoldingsFieldsFlagBO.setDonorPublicDisplayEditFlag(true);
2394                             } else if (OLEConstants.EHOLDING_DONOR_NOTE.equals(docFieldConfig.getName())) {
2395                                 globalEditEHoldingsFieldsFlagBO.setDonorNoteEditFlag(true);
2396                             }
2397                         }
2398                     }
2399 
2400                     // TODO -  need to do for E-holdings for global edit
2401 
2402                 } else if (DocType.ITEM.getCode().equals(docType)) {
2403 
2404                     GlobalEditItemFieldsFlagBO globalEditItemFieldsFlagBO = editorForm.getGlobalEditItemFieldsFlagBO();
2405                     for (DocFieldConfig docFieldConfig : docFieldConfigList) {
2406                         if (docFieldConfig.isGloballyEditable()) {
2407 
2408                             if (OLEConstants.CALL_NUMBER.equals(docFieldConfig.getName())) {
2409                                 globalEditItemFieldsFlagBO.setCallNumberEditFlag(true);
2410                             } else if (OLEConstants.CALL_NUMBER_PREFIX.equals(docFieldConfig.getName())) {
2411                                 globalEditItemFieldsFlagBO.setCallNumberPrefixEditFlag(true);
2412                             } else if (OLEConstants.CALL_NUMBER_TYPE_CODE.equals(docFieldConfig.getName())) {
2413                                 globalEditItemFieldsFlagBO.setCallNumberTypeEditFlag(true);
2414                             } else if (OLEConstants.SHELVING_ORDER.equals(docFieldConfig.getName())) {
2415                                 globalEditItemFieldsFlagBO.setShelvingOrderEditFlag(true);
2416                             } else if (OLEConstants.LOCATION_LEVEL.equals(docFieldConfig.getName())) {
2417                                 globalEditItemFieldsFlagBO.setLocationEditFlag(true);
2418                             } else if (OLEConstants.ITEM_STATUS_CODE_VALUE.equals(docFieldConfig.getName())) {
2419                                 globalEditItemFieldsFlagBO.setItemStatusEditFlag(true);
2420                                 globalEditItemFieldsFlagBO.setAccessInfoEditFlag(true);
2421                             } else if (OLEConstants.PO_LINE_ITEM_IDENTIFIER.equals(docFieldConfig.getName())) {
2422                                 globalEditItemFieldsFlagBO.setCallNumberTypeEditFlag(true);
2423                             } else if (OLEConstants.VENDOR_LINE_ITEM_IDENTIFIER.equals(docFieldConfig.getName())) {
2424                                 globalEditItemFieldsFlagBO.setVendorLineItemIDEditFlag(true);
2425                             } else if (OLEConstants.BAR_CODE_ARSL.equals(docFieldConfig.getName())) {
2426                                 globalEditItemFieldsFlagBO.setBarcodeARSLEditFlag(true);
2427                             } else if (OLEConstants.STATISTICAL_SEARCH_CODE.equals(docFieldConfig.getName())) {
2428                                 globalEditItemFieldsFlagBO.setStatisticalSearchingCodesEditFlag(true);
2429                             } else if (OLEConstants.ITEM_TYPE_CODE_VALUE.equals(docFieldConfig.getName())) {
2430                                 globalEditItemFieldsFlagBO.setItemTypeEditFlag(true);
2431                             } else if (OLEConstants.COPY_NUMBER_LABEL.equals(docFieldConfig.getName())) {
2432                                 globalEditItemFieldsFlagBO.setCopyNumberEditFlag(true);
2433                             } else if (OLEConstants.VOLUME_NUMBER.equals(docFieldConfig.getName()) || OLEConstants.VOLUME_NUMBER_LABEL.equals(docFieldConfig.getName())) {
2434                                 //globalEditItemFieldsFlagBO.set(true);
2435                             } else if (OLEConstants.ENUMARATION.equals(docFieldConfig.getName())) {
2436                                 globalEditItemFieldsFlagBO.setEnumerationEditFlag(true);
2437                             } else if (OLEConstants.CHRONOLOGY.equals(docFieldConfig.getName())) {
2438                                 globalEditItemFieldsFlagBO.setChronologyEditFlag(true);
2439                             } else if (OLEConstants.DONORPUBLIC_DISPLAY.equals(docFieldConfig.getName())) {
2440                                 globalEditItemFieldsFlagBO.setDonorPublicDisplayEditFlag(true);
2441                             } else if (OLEConstants.DONORNOTE_DISPLAY.equals(docFieldConfig.getName())) {
2442                                 globalEditItemFieldsFlagBO.setDonorNoteEditFlag(true);
2443                             } else if (OLEConstants.ITEMNOTE_TYPE_DISPLAY.equals(docFieldConfig.getName()) ) {
2444                                 globalEditItemFieldsFlagBO.setExtndInfoEditFlag(true);
2445                             } else if (OLEConstants.ITEMBARCODE_DISPLAY.equals(docFieldConfig.getName()) || OLEConstants.ITEMBARCODE_SEARCH.equals(docFieldConfig.getName())) {
2446                                 globalEditItemFieldsFlagBO.setBarcodeEditFlag(true);
2447                             } else if (OLEConstants.TEMPITEMTYPE_DISPLAY.equals(docFieldConfig.getName())) {
2448                                 globalEditItemFieldsFlagBO.setTempItemTypeEditFlag(true);
2449                             } else if (OLEConstants.DONORCODE_DISPLAY.equals(docFieldConfig.getName())) {
2450                                 globalEditItemFieldsFlagBO.setDonorCodeEditFlag(true);
2451                             } else if (OLEConstants.FORMERIDENTIFIER_DISPLAY.equals(docFieldConfig.getName())) {
2452                                 globalEditItemFieldsFlagBO.setFormerIdentifiersEditFlag(true);
2453                             } else if (OLEConstants.FASTADD_DISPLAY.equals(docFieldConfig.getName())) {
2454                                 globalEditItemFieldsFlagBO.setFastAddEditFlag(true);
2455                             } else if (OLEConstants.PIECES_DISPLAY.equals(docFieldConfig.getName())) {
2456                                 globalEditItemFieldsFlagBO.setNumberOfPiecesEditFlag(true);
2457                             } else if (OLEConstants.ITEMSTATUSDATE_DISPLAY.equals(docFieldConfig.getName())) {
2458                                 globalEditItemFieldsFlagBO.setItemStatusDateEditFlag(true);
2459                             } else if (OLEConstants.CHECKINNOTE_DISPLAY.equals(docFieldConfig.getName())) {
2460                                 globalEditItemFieldsFlagBO.setCheckinNoteEditFlag(true);
2461                             } else if (OLEConstants.DUEDATETIME_DISPLAY.equals(docFieldConfig.getName())) {
2462                                 globalEditItemFieldsFlagBO.setDueDatetimeEditFlag(true);
2463                             } else if (OLEConstants.CLAIMSRETURNFLAG_DISPLAY.equals(docFieldConfig.getName())) {
2464                                 globalEditItemFieldsFlagBO.setClaimsReturnEditFlag(true);
2465                             } else if (OLEConstants.MISSINGPIECEFLAG_DISPLAY.equals(docFieldConfig.getName())) {
2466                                 globalEditItemFieldsFlagBO.setMissingPieceEditFlag(true);
2467                             } else if (OLEConstants.ITEMDAMAGEDSTATUS_DISPLAY.equals(docFieldConfig.getName())) {
2468                                 globalEditItemFieldsFlagBO.setItemDamagedStatusEditFlag(true);
2469                             }
2470 
2471                             // TODO - need to do for other fields in ITEM
2472                         }
2473                     }
2474                 }
2475             }
2476 
2477 
2478         }
2479 
2480 
2481     }
2482 
2483 }