View Javadoc

1   package org.kuali.ole.describe.controller;
2   
3   import com.google.common.base.Joiner;
4   import org.apache.log4j.Logger;
5   import org.kuali.ole.describe.bo.BoundwithSelection;
6   import org.kuali.ole.describe.bo.DocumentSelectionTree;
7   import org.kuali.ole.describe.bo.DocumentTreeNode;
8   import org.kuali.ole.describe.bo.TransferRightToLeft;
9   import org.kuali.ole.describe.form.BoundwithForm;
10  import org.kuali.ole.docstore.model.bo.WorkInstanceDocument;
11  import org.kuali.ole.docstore.model.xmlpojo.ingest.Response;
12  import org.kuali.ole.docstore.model.xmlpojo.ingest.ResponseDocument;
13  import org.kuali.ole.docstore.model.xstream.ingest.ResponseHandler;
14  import org.kuali.ole.select.util.TransferUtil;
15  import org.kuali.rice.core.api.util.tree.Node;
16  import org.kuali.rice.core.api.util.tree.Tree;
17  import org.kuali.rice.krad.util.GlobalVariables;
18  import org.kuali.rice.krad.web.form.UifFormBase;
19  import org.springframework.stereotype.Controller;
20  import org.springframework.validation.BindingResult;
21  import org.springframework.web.bind.annotation.ModelAttribute;
22  import org.springframework.web.bind.annotation.RequestMapping;
23  import org.springframework.web.servlet.ModelAndView;
24  import javax.servlet.http.HttpServletRequest;
25  import javax.servlet.http.HttpServletResponse;
26  import java.util.ArrayList;
27  import java.util.HashMap;
28  import java.util.List;
29  
30  /**
31   * Created with IntelliJ IDEA.
32   * User: ?
33   * Date: 12/29/12
34   * Time: 12:03 PM
35   * To change this template use File | Settings | File Templates.
36   */
37  @Controller
38  @RequestMapping(value = "/transferController")
39  public class TransferController
40          extends BoundwithController {
41      private static final Logger LOG = Logger.getLogger(TransferController.class);
42  
43      /*private int totalRecCount;
44      private int start;
45      private int pageSize;
46  
47      public int getTotalRecCount() {
48          return totalRecCount;
49      }
50  
51      public void setTotalRecCount(int totalRecCount) {
52          this.totalRecCount = totalRecCount;
53      }
54  
55      public int getStart() {
56          return start;
57      }
58  
59      public void setStart(int start) {
60          this.start = start;
61      }
62  
63      public int getPageSize() {
64          return pageSize;
65      }
66  
67      public void setPageSize(int pageSize) {
68          this.pageSize = pageSize;
69      }
70  
71      public boolean getWorkbenchPreviousFlag() {
72          if (this.start == 0)
73              return false;
74          return true;
75      }
76  
77      public boolean getWorkbenchNextFlag() {
78          if (this.start + this.pageSize <= this.totalRecCount)
79              return true;
80          return false;
81      }
82  
83      public String getWorkbenchPageShowEntries() {
84          return "Showing " + ((this.start == 0) ? 1 : this.start + 1) + " to "
85                  + (((this.start + this.pageSize) > this.totalRecCount) ? this.totalRecCount : (this.start + this.pageSize))
86                  + " of " + this.totalRecCount + " entries";
87      }*/
88  
89      /*private boolean performTransferHoldingOrItem(String principalId) {
90          PermissionService service = KimApiServiceLocator.getPermissionService();
91          return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.TRANSFER_HOLDING_OR_ITEM);
92      }*/
93  
94      @Override
95      @RequestMapping(params = "methodToCall=start")
96      public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
97                                HttpServletRequest request, HttpServletResponse response) {
98          LOG.debug("Inside the workbenchForm--TransferController start method");
99          if (request.getSession().getAttribute("LeftList") != null && request.getSession().getAttribute("RightList") != null) {
100             request.getSession().removeAttribute("LeftList");
101             request.getSession().removeAttribute("RightList");
102         }
103         return super.start(form, result, request, response);
104     }
105 
106 
107     @RequestMapping(params = "methodToCall=selectRootNodeItems")
108     public ModelAndView selectRootNodeItems(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
109                                             HttpServletRequest request, HttpServletResponse response) throws Exception {
110         List<String> bibIdentifierListForTree1 = new ArrayList<String>();
111         List<String> bibInstanceListForTree1 = new ArrayList<String>();
112         List<String> bibItemListForTree1 = new ArrayList<String>();
113         List<String> bibIdentifierListForTree2 = new ArrayList<String>();
114         List<String> destBibIdentifierListForTree2 = new ArrayList<String>();
115         List<String> destInstanceIdentifierListForTree2 = new ArrayList<String>();
116         List<String> itemsSelectedListForRightTree = new ArrayList<String>();
117         List<String> bibIdentifiersSelectedListForLeftTree = new ArrayList<String>();
118         List<String> bibIdentifiersListWhenInstanceSelectedForLeftTree = new ArrayList<String>();
119         List<String> instanceIdentifiersToDelete = new ArrayList<String>();
120         boolean transferInstance = true;
121         //  StringBuffer stringBufferLeftTree=new StringBuffer();
122         //StringBuffer stringBufferRightTree=new StringBuffer();
123 
124         //String isLeftBibsSelected="false";
125         //String isRightItemsSelected="false";
126         String status1 = "";
127         String status2 = "";
128 
129         BoundwithForm transferForm = (BoundwithForm) form;
130         /*boolean hasPermission = performTransferHoldingOrItem(GlobalVariables.getUserSession().getPrincipalId());
131         if (!hasPermission) {
132             //transferForm.setMessage("<font size='3' color='red'> Current user is not authorized to perform this action.</font>");
133             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection1", "info.authorization");
134             return navigate(transferForm, result, request, response);
135         }*/
136         transferForm.setTransferLeftTree(true);
137         transferForm.setTransferRighttree(false);
138         //transferForm.setInDelete("false");
139         transferForm.setInDeleteLeftTree("false");
140         transferForm.setInDeleteRightTree("false");
141         // List<OleWorkBibDocument>  oleWorkBibDocumentList=transferForm.getWorkBibDocumentList();
142         Tree<DocumentTreeNode, String> leftTree = transferForm.getLeftTree();
143         Node<DocumentTreeNode, String> leftTreeRootElement = leftTree.getRootElement();
144         Tree<DocumentTreeNode, String> rightTree = transferForm.getRightTree();
145         Node<DocumentTreeNode, String> rightTreeRootElement = rightTree.getRootElement();
146         List<String> bibIdentifiersToDelete = new ArrayList<String>();
147         String deleteResponseFromDocStore = "";
148 
149         status1 = selectCheckedNodesTree1(leftTreeRootElement, bibIdentifierListForTree1, bibInstanceListForTree1,
150                 bibItemListForTree1, bibIdentifiersSelectedListForLeftTree,
151                 bibIdentifiersListWhenInstanceSelectedForLeftTree, bibIdentifiersToDelete,
152                 instanceIdentifiersToDelete);
153         selectCheckedNodesTree2(rightTreeRootElement, bibIdentifierListForTree2, itemsSelectedListForRightTree,
154                 destBibIdentifierListForTree2, destInstanceIdentifierListForTree2);
155         LOG.debug("bibIdentifiersToDelete " + bibIdentifiersToDelete);
156 
157         //  isLeftBibsSelected= stringBufferLeftTree.toString();
158         //
159         if (leftTreeRootElement == null) {
160             //transferForm.setMessage("No records copied for left tree");
161             //GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_INFO,"error.transfer.empty.records", "right");
162             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection1", "error.transfer.empty.records", "left");
163         } else if (rightTreeRootElement == null) {
164             //transferForm.setMessage("No records copied for right tree");
165             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "error.transfer.empty.records", "right");
166         } else if (bibIdentifiersSelectedListForLeftTree.size() > 0) {
167             //transferForm.setMessage("Bib(s) selected in Left Tree which is invalid");
168             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection1", "error.transfer.invalid", "Bib", "left");
169         } else if (bibInstanceListForTree1.size() == 0 && bibItemListForTree1.size() == 0) {
170             //transferForm.setMessage("Nothing selected in left tree");
171             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection1", "error.transfer.selected.none", "left");
172         } else if (itemsSelectedListForRightTree.size() > 0) {
173             //transferForm.setMessage("Item(s) selected in Right Tree which is invalid");
174             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "error.transfer.invalid", "Item", "right");
175         } else if (destBibIdentifierListForTree2.size() == 0 && destInstanceIdentifierListForTree2.size() == 0) {
176             //transferForm.setMessage("Nothing selected in right tree");
177             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "error.transfer.selected.none", "right");
178         } else if (bibInstanceListForTree1.size() > 0 && bibItemListForTree1.size() > 0) {
179             //transferForm.setMessage("Instances and items both selected in left tree: Transfer failed");
180             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection1", "error.transfer.selected.multiple", "Instances", "items", "left");
181         } else if (destBibIdentifierListForTree2.size() > 0 && destInstanceIdentifierListForTree2.size() > 0) {
182             //transferForm.setMessage("Bibs and instances both selected in right tree: Transfer failed");
183             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "error.transfer.selected.multiple", "Bibs", "instances", "right");
184         } else if (destBibIdentifierListForTree2.size() > 1) {
185             //transferForm.setMessage("Only one bib can be selected in right tree");
186             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "error.transfer.selected.invalid", "bib", "right");
187         } else if (destInstanceIdentifierListForTree2.size() > 1) {
188             //transferForm.setMessage("Only one instance can be selected in right tree");
189             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "error.transfer.selected.invalid", "instance", "right");
190         } else if (bibInstanceListForTree1.size() > 0 && destInstanceIdentifierListForTree2.size() > 0) {
191             //transferForm.setMessage("Instances of left tree cant be transferred to instances of right tree: Transfer failed");
192             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection1", "error.transfer.left", "Instances", "Instances");
193         } else if (bibItemListForTree1.size() > 0 && destBibIdentifierListForTree2.size() > 0) {
194             //transferForm.setMessage("Items of left tree cant be transferred to Bibs of right tree: Transfer failed");
195             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection1", "error.transfer.left", "Items", "Bibs");
196         }
197         //        else if(!status1.equalsIgnoreCase("success")){
198         //            System.out.println("in if checking status1");
199         //             transferForm.setMessage(status1);
200         //        }
201         else if (bibInstanceListForTree1.size() > 0) {
202             for (String bibUuid : bibIdentifiersListWhenInstanceSelectedForLeftTree) {
203                 if (destBibIdentifierListForTree2.contains(bibUuid)) {
204                     //transferForm.setMessage("Transfer of instances should not happen between same left bib and right bib. Transfer of instances failed");
205                     GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "error.transfer.bib");
206                     transferInstance = false;
207                     break;
208                 }
209             }
210             if (transferInstance) {
211                 String destBibIdentifier = destBibIdentifierListForTree2.get(0);
212                 if (bibIdentifiersToDelete.size() > 0) {
213                     transferForm.setDocFormat("marc");
214                     transferForm.setDocCategory("work");
215                     transferForm.setDocType("bibliographic");
216                     String bibIdentifiers = Joiner.on(",").join(bibIdentifiersToDelete);
217                     deleteResponseFromDocStore = TransferUtil.getInstance().getDeleteResponseFromDocStore("deleteVerify", bibIdentifiers,
218                             transferForm);
219                     transferForm.setBibInstanceListForTree1(bibInstanceListForTree1);
220                     transferForm.setDestBibIdentifier(destBibIdentifier);
221                     transferForm.setDeleteVerifyResponse(deleteResponseFromDocStore);
222                     TransferUtil.getInstance().deleteVerify(transferForm, deleteResponseFromDocStore);
223                     return getUIFModelAndView(transferForm);
224                 }
225                 TransferUtil.getInstance().transferInstances(bibInstanceListForTree1, destBibIdentifier);
226                 TransferUtil.getInstance().copyToTree(transferForm, bibIdentifierListForTree1, "leftTree");
227                 TransferUtil.getInstance().copyToTree(transferForm, bibIdentifierListForTree2, "rightTree");
228                 //transferForm.setMessage("Instances transferred successfully");
229                 GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer", "Instances");
230             }
231         } else if (bibItemListForTree1.size() > 0) {
232             String destInstanceIdentifier = destInstanceIdentifierListForTree2.get(0);
233             if (instanceIdentifiersToDelete.size() > 0) {
234                 transferForm.setDocFormat("oleml");
235                 transferForm.setDocCategory("work");
236                 transferForm.setDocType("instance");
237                 String instanceIdentifiers = Joiner.on(",").join(instanceIdentifiersToDelete);
238                 deleteResponseFromDocStore = TransferUtil.getInstance().getDeleteResponseFromDocStore("deleteVerify", instanceIdentifiers,
239                         transferForm);
240                 transferForm.setBibItemListForTree1(bibItemListForTree1);
241                 transferForm.setDestInstanceIdentifier(destInstanceIdentifier);
242                 transferForm.setDeleteVerifyResponse(deleteResponseFromDocStore);
243                 TransferUtil.getInstance().deleteVerify(transferForm, deleteResponseFromDocStore);
244                 return getUIFModelAndView(transferForm);
245                 //return deleteVerify(transferForm, deleteResponseFromDocStore);
246             }
247             TransferUtil.getInstance().transferItems(bibItemListForTree1, destInstanceIdentifier);
248             TransferUtil.getInstance().copyToTree(transferForm, bibIdentifierListForTree1, "leftTree");
249             TransferUtil.getInstance().copyToTree(transferForm, bibIdentifierListForTree2, "rightTree");
250             //transferForm.setMessage("Items transferred successfully");
251             GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer", "Items");
252         } else {
253             //transferForm.setMessage("Nothing selected or Selection is wrong");
254             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "error.transfer.bib");
255         }
256         return navigate(transferForm, result, request, response);
257         //        return getUIFModelAndView(transferForm);
258     }
259 
260     public void delete(ResponseDocument responseDocument) {
261     }
262 
263     @RequestMapping(params = "methodToCall=transferRightToLeft")
264     public ModelAndView transferRightToLeft(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
265                                             HttpServletRequest request, HttpServletResponse response) throws Exception {
266         BoundwithForm transferForm = (BoundwithForm) form;
267         /*boolean hasPermission = performTransferHoldingOrItem(GlobalVariables.getUserSession().getPrincipalId());
268         if (!hasPermission) {
269             //transferForm.setMessage("<font size='3' color='red'> Current user is not authorized to perform this action.</font>");
270             GlobalVariables.getMessageMap().putErrorForSectionId("TransferTreeSection2", "info.authorization");
271             return navigate(transferForm, result, request, response);
272         }*/
273         transferForm.setInDeleteLeftTree("false");
274         transferForm.setInDeleteRightTree("false");
275         transferForm.setTransferLeftTree(false);
276         transferForm.setTransferRighttree(true);
277         TransferRightToLeft transferRightToLeft = new TransferRightToLeft();
278         transferRightToLeft.transferRightToLeft(transferForm, result, request, response);
279         return navigate(transferForm, result, request, response);
280         //        return getUIFModelAndView(transferForm);
281     }
282 
283     private String selectCheckedNodesTree1(Node<DocumentTreeNode, String> rootElement,
284                                            List<String> bibIdentifierListForTree1, List<String> bibInstanceListForTree1,
285                                            List<String> bibItemListForTree1,
286                                            List<String> bibIdentifiersSelectedListForLeftTree,
287                                            List<String> bibIdentifiersListWhenInstanceSelectedForLeftTree,
288                                            List<String> bibIdentifiersToDelete,
289                                            List<String> instanceIdentifiersToDelete) {
290 
291         BoundwithSelection boundwithSelection;
292         DocumentTreeNode documentTreeNode;
293         String status = "success";
294         String bibTitle = "";
295         int instanceCount = 0;
296         int itemCount = 0;
297         List<String> instanceidenifiersListTemp = new ArrayList<String>();
298         if (rootElement != null) {
299             List<Node<DocumentTreeNode, String>> list = rootElement.getChildren();
300             for (Node<DocumentTreeNode, String> marcNode : list) {
301                 instanceCount = 0;
302                 itemCount = 0;
303                 String instanceUUID = "";
304                 documentTreeNode = marcNode.getData();
305 
306                 bibTitle = documentTreeNode.getTitle();
307                 String bibUUID = marcNode.getNodeType();
308                 bibIdentifierListForTree1.add(bibUUID);
309                 LOG.info("documentTreeNode.isSelectTree1()-->" + documentTreeNode.isSelect());
310                 if (documentTreeNode.isSelect()) {
311                     bibIdentifiersSelectedListForLeftTree.add(bibUUID);
312                     break;
313                 }
314                 List<Node<DocumentTreeNode, String>> instanceList = marcNode.getChildren();
315                 List<Node<DocumentTreeNode, String>> itemList = null;
316                 instanceidenifiersListTemp.clear();
317                 for (Node<DocumentTreeNode, String> instanceNode : instanceList) {
318                     itemCount = 0;
319                     documentTreeNode = instanceNode.getData();
320                     instanceUUID = instanceNode.getNodeType();
321                     LOG.debug("instanceUUID out of select " + instanceUUID);
322                     if (documentTreeNode.isSelect()) {
323                         instanceCount++;
324 
325                         LOG.debug("instanceUUID " + instanceUUID);
326                         bibInstanceListForTree1.add(instanceUUID);
327                         //instanceidenifiersListTemp.add(instanceUUID);
328                         bibIdentifiersListWhenInstanceSelectedForLeftTree.add(bibUUID);
329                     }
330                     itemList = instanceNode.getChildren();
331                     for (Node<DocumentTreeNode, String> itemNode : itemList) {
332                         documentTreeNode = itemNode.getData();
333                         if (documentTreeNode.isSelect()) {
334                             itemCount++;
335                             String itemUUID = itemNode.getNodeType();
336                             LOG.debug("itemUUID " + itemUUID);
337                             bibItemListForTree1.add(itemUUID);
338                         }
339                     }  //item loop end
340                     if (instanceNode.getNumberOfChildren() > 0 && itemCount == itemList.size()) {
341                         instanceidenifiersListTemp.add(instanceUUID);
342                         //status="Instance will remain with no items if this transfer takes place. Instance must have atleast one item. Transfer failed";
343                     }
344                 } //instance loop end
345                 if (marcNode.getNumberOfChildren() > 0 && instanceCount == instanceList.size()) {
346                     bibIdentifiersToDelete.add(bibUUID);
347                     LOG.debug("in if of no instances bibIdentifierToDelete " + bibIdentifiersToDelete);
348                 }
349                 instanceIdentifiersToDelete.addAll(instanceidenifiersListTemp);
350             }  //bib loop end
351         }
352         return status;
353     }
354 
355 
356     private void selectCheckedNodesTree2(Node<DocumentTreeNode, String> rootElement,
357                                          List<String> bibIdentifierListForTree2,
358                                          List<String> itemsSelectedListForRightTree,
359                                          List<String> destBibIdentifierListForTree2,
360                                          List<String> destInstanceIdentifierListForTree2) {
361 
362         BoundwithSelection boundwithSelection;
363         DocumentTreeNode documentTreeNode;
364         if (rootElement != null) {
365             List<Node<DocumentTreeNode, String>> list = rootElement.getChildren();
366             for (Node<DocumentTreeNode, String> marcNode : list) {
367                 documentTreeNode = marcNode.getData();
368                 String bibUUID = marcNode.getNodeType();
369                 bibIdentifierListForTree2.add(bibUUID);
370                 LOG.info("documentTreeNode.isSelectTree1()-->" + documentTreeNode.isSelect());
371                 if (documentTreeNode.isSelect()) {
372                     destBibIdentifierListForTree2.add(bibUUID);
373                 }
374                 List<Node<DocumentTreeNode, String>> instanceList = marcNode.getChildren();
375                 for (Node<DocumentTreeNode, String> instanceNode : instanceList) {
376                     documentTreeNode = instanceNode.getData();
377                     if (documentTreeNode.isSelect()) {
378                         String instanceUUID = instanceNode.getNodeType();
379                         destInstanceIdentifierListForTree2.add(instanceUUID);
380                     }
381                     List<Node<DocumentTreeNode, String>> itemList = instanceNode.getChildren();
382                     for (Node<DocumentTreeNode, String> itemNode : itemList) {
383                         documentTreeNode = itemNode.getData();
384                         if (documentTreeNode.isSelect()) {
385                             String itemUUID = itemNode.getNodeType();
386                             //stringBufferRightTree.append("true");
387                             itemsSelectedListForRightTree.add(itemUUID);
388                             break;
389                         }
390                     }
391 
392                 }
393             }
394         }
395     }
396 
397     String listToCsv(List<String> listOfStrings, char separator) {
398         StringBuilder sb = new StringBuilder();
399 
400         // all but last
401         for (int i = 0; i < listOfStrings.size() - 1; i++) {
402             sb.append(listOfStrings.get(i));
403             sb.append(separator);
404         }
405         // last string, no separator
406         sb.append(listOfStrings.get(listOfStrings.size() - 1));
407         return sb.toString();
408     }
409 
410     @RequestMapping(params = "methodToCall=delete")
411     public ModelAndView delete(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
412                                HttpServletRequest request, HttpServletResponse httpResponse) throws Exception {
413         StringBuilder uuidList = new StringBuilder();
414         BoundwithForm transferForm = (BoundwithForm) form;
415         DocumentSelectionTree documentSelectionTree = new DocumentSelectionTree();
416         //        uuidList.append(boundwithForm.getDocId());
417         //boundwithForm.setInDelete("false");
418         transferForm.setInDeleteLeftTree("false");
419         transferForm.setInDeleteRightTree("false");
420         WorkInstanceDocument workInstanceDocumentForTree1 = transferForm.getWorkInstanceDocumentForTree1();
421 
422         String deleteVerifyResponse = transferForm.getDeleteVerifyResponse();
423         Response response = new ResponseHandler().toObject(deleteVerifyResponse);
424         if (response.getStatus().contains("Failed")) {
425             /*transferForm.setSelectedInstance(
426                     "Unable to delete the instance " + workInstanceDocumentForTree1.getHoldingsDocument()
427                                                                                    .getLocationName()
428                     + "\t \n because it exists in OLE database");*/
429             String message = workInstanceDocumentForTree1.getHoldingsDocument().getLocationName();
430             GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer.delete.failure", message);
431         } else if (response.getStatus().contains("Success")) {
432             for (ResponseDocument responseDocument : response.getDocuments()) {
433                 if (responseDocument.getStatus() != null && responseDocument.getStatus().contains("failure")) {
434                     transferForm.setSelectedInstance(responseDocument.getStatusMessage());
435                     return getUIFModelAndView(transferForm);
436                 } else {
437                     uuidList.append(responseDocument.getUuid());
438                     uuidList.append(",");
439                 }
440             }
441             String treeId = transferForm.getActionParamaterValue("treeId");
442             if (transferForm.getDocType().equalsIgnoreCase("bibliographic")) {
443                 if (transferForm.getDestBibIdentifier() != null && transferForm.getDestBibIdentifier().length() > 0) {
444                     TransferUtil.getInstance().transferInstances(transferForm.getBibInstanceListForTree1(),
445                             transferForm.getDestBibIdentifier());
446                     //transferForm.setMessage("Instance transferred successfully. Bib is deleted.");
447                     if (treeId.equalsIgnoreCase("leftTree")) {
448                         HashMap leftList = (HashMap) request.getSession().getAttribute("LeftList");
449                         if (leftList.size() == 1) {
450                             clearTree(transferForm, result, request, httpResponse);
451                         }
452                         GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer.instance.success");
453                         GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer.instance.success.bib.delete");
454                     } else {
455                         HashMap rightList = (HashMap) request.getSession().getAttribute("RightList");
456                         if (rightList.size() == 1) {
457                             clearTree(transferForm, result, request, httpResponse);
458                         }
459                         GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer.instance.success");
460                         GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer.instance.success.bib.delete");
461                     }
462                 } else {
463                     TransferUtil.getInstance().transferItems(transferForm.getBibItemListForTree1(),
464                             transferForm.getDestInstanceIdentifier());
465                     //transferForm.setMessage("Item transferred successfully. Bib and Instance are deleted.");
466                     if (treeId.equalsIgnoreCase("leftTree")) {
467                         HashMap leftList = (HashMap) request.getSession().getAttribute("LeftList");
468                         if (leftList.size() == 1) {
469                             clearTree(transferForm, result, request, httpResponse);
470                         }
471                         GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer.item.success");
472                         GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer.item.success.bib.instance.delete");
473                     } else {
474                         HashMap rightList = (HashMap) request.getSession().getAttribute("RightList");
475                         if (rightList.size() == 1) {
476                             clearTree(transferForm, result, request, httpResponse);
477                         }
478                         GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer.item.success");
479                         GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer.item.success.bib.instance.delete");
480                     }
481                 }
482             } else if (transferForm.getDocType().equalsIgnoreCase("instance")) {
483                 TransferUtil.getInstance().transferItems(transferForm.getBibItemListForTree1(),
484                         transferForm.getDestInstanceIdentifier());
485 
486                 if (treeId.equalsIgnoreCase("leftTree")) {
487                     GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer.item.success");
488                     GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer.item.success.holdings.delete");
489                 } else {
490                     GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer.item.success");
491                     GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer.item.success.holdings.delete");
492                 }
493             }
494             String deleteResponseFromDocStore = TransferUtil.getInstance().getDeleteResponseFromDocStore("delete", uuidList.toString(),
495                     transferForm);
496             transferForm.setShowBoundwithTree(false);
497         }
498         return getUIFModelAndView(transferForm);
499     }
500 
501     @RequestMapping(params = "methodToCall=OnlyTransfer")
502     public ModelAndView OnlyTransfer(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
503                                      HttpServletRequest request, HttpServletResponse httpResponse) throws Exception {
504         BoundwithForm transferForm = (BoundwithForm) form;
505         String treeId = transferForm.getActionParamaterValue("treeId");
506         if (transferForm.getDocType().equalsIgnoreCase("bibliographic")) {
507             if (transferForm.getDestBibIdentifier() != null && transferForm.getDestBibIdentifier().length() > 0) {
508                 TransferUtil.getInstance().transferInstances(transferForm.getBibInstanceListForTree1(),
509                         transferForm.getDestBibIdentifier());
510                 //transferForm.setMessage("Instance transferred successfully.");
511                 if (treeId.equalsIgnoreCase("leftTree")) {
512                     GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer", "Instance");
513                 } else {
514                     GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer", "Instance");
515                 }
516             } else {
517                 TransferUtil.getInstance().transferItems(transferForm.getBibItemListForTree1(),
518                         transferForm.getDestInstanceIdentifier());
519                 //transferForm.setMessage("Item transferred successfully.");
520                 if (treeId.equalsIgnoreCase("leftTree")) {
521                     GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection2", "info.transfer", "Item");
522                 } else {
523                     GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer", "Item");
524                 }
525             }
526         } else if (transferForm.getDocType().equalsIgnoreCase("instance")) {
527             TransferUtil.getInstance().transferItems(transferForm.getBibItemListForTree1(),
528                     transferForm.getDestInstanceIdentifier());
529             //transferForm.setMessage("Item transferred successfully.");
530             GlobalVariables.getMessageMap().putInfoForSectionId("TransferTreeSection1", "info.transfer", "Item");
531         }
532         //boundwithForm.setInDelete("false");
533         transferForm.setInDeleteLeftTree("false");
534         transferForm.setInDeleteRightTree("false");
535         return getUIFModelAndView(transferForm);
536     }
537 
538     /**
539      * Enable, disable the next and previous and also show the message for number of entries
540      * @param boundwithForm
541      * @return
542      */
543     public void setPageNextPreviousAndEntriesInfo(BoundwithForm boundwithForm) {
544         this.totalRecCount = boundwithForm.getSearchParams().getTotalRecCount();
545         this.start = boundwithForm.getSearchParams().getStart();
546         this.pageSize = boundwithForm.getSearchParams().getRows();
547         boundwithForm.setPreviousFlag(getWorkbenchPreviousFlag());
548         boundwithForm.setNextFlag(getWorkbenchNextFlag());
549         boundwithForm.setPageShowEntries(getWorkbenchPageShowEntries());
550     }
551 
552 }