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