1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document;
17
18 import java.util.List;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.ole.sys.businessobject.TaxRegion;
23 import org.kuali.rice.kns.document.MaintenanceDocument;
24 import org.kuali.rice.kns.maintenance.Maintainable;
25 import org.kuali.rice.kns.web.ui.Section;
26
27 public class TaxRegionMaintainableImpl extends FinancialSystemMaintainable {
28
29
30
31
32
33
34
35
36
37
38 @Override
39 public List<Section> getCoreSections(MaintenanceDocument document, Maintainable oldMaintainable) {
40 List<Section> sections = super.getCoreSections(document, oldMaintainable);
41
42 TaxRegion taxRegion = (TaxRegion) getBusinessObject();
43
44
45 if( StringUtils.isNotEmpty( taxRegion.getTaxRegionTypeCode() ) ) {
46 String sectionIdToDisplay = getSectionIdToDisplay(taxRegion.getTaxRegionTypeCode());
47 for (Section section : sections) {
48 if (!isMainOrRateSection(section.getSectionId()) && !sectionIdToDisplay.equals(section.getSectionId())) {
49 section.setHidden(true);
50 }
51 }
52 }
53
54 return sections;
55 }
56
57
58
59
60
61
62
63 protected String getSectionIdToDisplay(String taxRegionTypeCode) {
64 if (OLEConstants.TaxRegionConstants.TAX_REGION_TYPE_CODE_STATE.equals(taxRegionTypeCode)) {
65 return OLEConstants.TaxRegionConstants.TAX_REGION_STATES_SECTION_ID;
66 }
67 else if (OLEConstants.TaxRegionConstants.TAX_REGION_TYPE_CODE_COUNTY.equals(taxRegionTypeCode)) {
68 return OLEConstants.TaxRegionConstants.TAX_REGION_COUNTIES_SECTION_ID;
69 }
70 else if (OLEConstants.TaxRegionConstants.TAX_REGION_TYPE_CODE_POSTAL_CODE.equals(taxRegionTypeCode)) {
71 return OLEConstants.TaxRegionConstants.TAX_REGION_POSTAL_CODES_SECTION_ID;
72 }
73 else {
74 throw new RuntimeException("No section is set up for tax region type code " + taxRegionTypeCode);
75 }
76 }
77
78
79
80
81
82
83
84 protected boolean isMainOrRateSection(String sectionId) {
85 return OLEConstants.TaxRegionConstants.TAX_REGION_RATES_SECTION_ID.equals(sectionId) || OLEConstants.TaxRegionConstants.TAX_REGION_CREATE_SECTION_ID.equals(sectionId);
86 }
87 }