1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.coa.document;
17
18 import java.util.HashMap;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.kuali.ole.coa.service.OrganizationService;
23 import org.kuali.ole.sys.OLEPropertyConstants;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.ole.sys.document.FinancialSystemMaintainable;
26 import org.kuali.rice.kns.document.MaintenanceDocument;
27 import org.kuali.rice.kns.maintenance.Maintainable;
28 import org.kuali.rice.kns.web.ui.Field;
29 import org.kuali.rice.kns.web.ui.Row;
30 import org.kuali.rice.kns.web.ui.Section;
31
32
33
34
35 public class KualiOrgMaintainable extends FinancialSystemMaintainable {
36 private static final long serialVersionUID = -3182120468758958991L;
37
38 protected static final String KUALI_ORG_SECTION = "Edit Organization Code";
39
40
41
42
43
44
45
46
47
48
49 @Override
50 public List getCoreSections(MaintenanceDocument document, Maintainable oldMaintainable) {
51
52 boolean fieldFound = false;
53 boolean sectionFound = false;
54
55
56 List<Section> sections = super.getCoreSections(document, oldMaintainable);
57 for ( Section section : sections ) {
58
59 if (section.getSectionTitle().equalsIgnoreCase(KUALI_ORG_SECTION)) {
60
61 sectionFound = true;
62
63 List rows = section.getRows();
64 for ( Row row : section.getRows() ) {
65
66 for ( Field field : row.getFields() ) {
67
68 if (field.getPropertyName().equalsIgnoreCase(OLEPropertyConstants.ORGANIZATION_ZIP_CODE)) {
69
70 Map<String,String> fieldConversions = new HashMap<String,String>(3);
71 fieldConversions.put(OLEPropertyConstants.CODE, OLEPropertyConstants.ORGANIZATION_ZIP_CODE);
72 fieldConversions.put(OLEPropertyConstants.POSTAL_STATE_CODE, OLEPropertyConstants.ORGANIZATION_STATE_CODE);
73 fieldConversions.put(OLEPropertyConstants.POSTAL_CITY_NAME, OLEPropertyConstants.ORGANIZATION_CITY_NAME);
74
75
76 field.setFieldConversions(fieldConversions);
77
78
79
80
81 fieldFound = true;
82 break;
83 }
84 }
85
86 if ( fieldFound ) {
87 break;
88 }
89 }
90 break;
91 }
92 }
93
94
95 if (!sectionFound) {
96 throw new RuntimeException("There is no longer a section titled '" + KUALI_ORG_SECTION + "'. " + "As a result, the lookup setup will not work as expected and the maintenance document will be broken. The correct name needs to be set in the Constant in this class.");
97 }
98
99 if (!fieldFound) {
100 throw new RuntimeException("There is no longer a field titled '" + OLEPropertyConstants.ORGANIZATION_ZIP_CODE + "'. " + "As a result, the lookup setup will not work as expected and the maintenance document will be broken. The correct name needs to be set in the OLEPropertyConstants class.");
101 }
102
103 return sections;
104 }
105
106
107
108
109 @Override
110 public void saveBusinessObject() {
111 super.saveBusinessObject();
112 SpringContext.getBean(OrganizationService.class).flushParentOrgCache();
113 }
114 }
115