1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.struts.action;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.struts.action.ActionForm;
20 import org.apache.struts.action.ActionForward;
21 import org.apache.struts.action.ActionMapping;
22 import org.kuali.rice.core.api.util.RiceConstants;
23 import org.kuali.rice.kns.web.struts.form.DisplayInactivationBlockersForm;
24 import org.kuali.rice.krad.bo.BusinessObject;
25 import org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata;
26 import org.kuali.rice.krad.service.DataDictionaryService;
27 import org.kuali.rice.krad.service.InactivationBlockingDisplayService;
28 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
29 import org.kuali.rice.krad.util.ObjectUtils;
30
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.Set;
36 import java.util.TreeMap;
37
38
39
40
41
42
43
44
45 @Deprecated
46 public class DisplayInactivationBlockersAction extends KualiAction {
47 @Deprecated
48 public ActionForward displayAllInactivationBlockers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
49 DisplayInactivationBlockersForm displayInactivationBlockersForm = (DisplayInactivationBlockersForm) form;
50 DataDictionaryService dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService();
51 InactivationBlockingDisplayService inactivationBlockingDisplayService = KRADServiceLocatorWeb
52 .getInactivationBlockingDisplayService();
53
54 Class blockedBoClass = Class.forName(displayInactivationBlockersForm.getBusinessObjectClassName());
55 BusinessObject blockedBo = (BusinessObject) blockedBoClass.newInstance();
56 for (String key : displayInactivationBlockersForm.getPrimaryKeyFieldValues().keySet()) {
57 ObjectUtils.setObjectProperty(blockedBo, key, displayInactivationBlockersForm.getPrimaryKeyFieldValues().get(key));
58 }
59
60 Map<String, List<String>> allBlockers = new TreeMap<String, List<String>>();
61
62 Set<InactivationBlockingMetadata> inactivationBlockers = dataDictionaryService.getAllInactivationBlockingDefinitions(blockedBoClass);
63 for (InactivationBlockingMetadata inactivationBlockingMetadata : inactivationBlockers) {
64 String blockingBoLabel = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass().getName()).getObjectLabel();
65 String relationshipLabel = inactivationBlockingMetadata.getRelationshipLabel();
66 String displayLabel;
67 if (StringUtils.isEmpty(relationshipLabel)) {
68 displayLabel = blockingBoLabel;
69 }
70 else {
71 displayLabel = blockingBoLabel + " (" + relationshipLabel + ")";
72 }
73 List<String> blockerObjectList = inactivationBlockingDisplayService.listAllBlockerRecords(blockedBo, inactivationBlockingMetadata);
74
75 if (!blockerObjectList.isEmpty()) {
76 List<String> existingList = allBlockers.get(displayLabel);
77 if (existingList != null) {
78 existingList.addAll(blockerObjectList);
79 }
80 else {
81 allBlockers.put(displayLabel, blockerObjectList);
82 }
83 }
84 }
85
86 displayInactivationBlockersForm.setBlockingValues(allBlockers);
87
88 return mapping.findForward(RiceConstants.MAPPING_BASIC);
89 }
90 }