1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.property.processor;
17
18 import java.util.Properties;
19
20 import org.kuali.common.util.Mode;
21 import org.kuali.common.util.OrgUtils;
22 import org.kuali.common.util.PropertyUtils;
23 import org.kuali.common.util.property.Constants;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26 import org.springframework.util.Assert;
27
28 public class OrgProcessor implements PropertyProcessor {
29 private static final Logger logger = LoggerFactory.getLogger(OrgProcessor.class);
30
31 Mode propertyOverwriteMode = Constants.DEFAULT_PROPERTY_OVERWRITE_MODE;
32
33 String organizationGroupCodeSuffix = Constants.GROUP_ID + "." + Constants.DEFAULT_CODE_SUFFIX;
34 String groupCodeProperty = Constants.DEFAULT_GROUP_ID_PROPERTY + "." + Constants.DEFAULT_CODE_SUFFIX;
35 String organizationGroupId;
36 String groupId;
37
38 public OrgProcessor() {
39 this(null, null);
40 }
41
42 public OrgProcessor(String organizationGroupId, String groupId) {
43 super();
44 this.organizationGroupId = organizationGroupId;
45 this.groupId = groupId;
46 }
47
48 @Override
49 public void process(Properties properties) {
50 logger.debug("organizationGroupId={}", organizationGroupId);
51 logger.debug("groupId={}", groupId);
52
53 Assert.notNull(organizationGroupId, "organizationGroupId is null");
54 Assert.notNull(groupId, "groupId is null");
55
56 String organizationCode = OrgUtils.getOrgCode(organizationGroupId);
57 String groupCode = OrgUtils.getGroupCode(organizationGroupId, groupId);
58
59 String organizationGroupCodeProperty = organizationCode + "." + organizationGroupCodeSuffix;
60
61 PropertyUtils.addOrOverrideProperty(properties, organizationGroupCodeProperty, organizationCode, propertyOverwriteMode);
62 PropertyUtils.addOrOverrideProperty(properties, groupCodeProperty, groupCode, propertyOverwriteMode);
63 }
64
65 public String getOrganizationGroupId() {
66 return organizationGroupId;
67 }
68
69 public void setOrganizationGroupId(String organizationGroupId) {
70 this.organizationGroupId = organizationGroupId;
71 }
72
73 public String getGroupId() {
74 return groupId;
75 }
76
77 public void setGroupId(String groupId) {
78 this.groupId = groupId;
79 }
80
81 public String getGroupCodeProperty() {
82 return groupCodeProperty;
83 }
84
85 public void setGroupCodeProperty(String groupCodeProperty) {
86 this.groupCodeProperty = groupCodeProperty;
87 }
88
89 public Mode getPropertyOverwriteMode() {
90 return propertyOverwriteMode;
91 }
92
93 public void setPropertyOverwriteMode(Mode propertyOverwriteMode) {
94 this.propertyOverwriteMode = propertyOverwriteMode;
95 }
96
97 public String getOrganizationGroupCodeSuffix() {
98 return organizationGroupCodeSuffix;
99 }
100
101 public void setOrganizationGroupCodeSuffix(String organizationGroupCodeSuffix) {
102 this.organizationGroupCodeSuffix = organizationGroupCodeSuffix;
103 }
104
105 }