1
2
3
4
5
6
7 package gov.bnl.gums.groupToAccount;
8
9 import java.util.ArrayList;
10 import java.util.Iterator;
11 import java.util.List;
12
13 import gov.bnl.gums.configuration.Configuration;
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public class GroupToAccountMapping {
28 private ArrayList userGroups = new ArrayList();
29 private ArrayList accountMappers = new ArrayList();
30 private String name = "";
31 private String description = "";
32 private String accountingVo = "";
33 private String accountingVoSubgroup = "";
34 private Configuration configuration = null;
35
36
37
38
39 public GroupToAccountMapping() {
40 }
41
42
43
44
45
46
47 public GroupToAccountMapping(Configuration configuration) {
48 this.configuration = configuration;
49 }
50
51
52
53
54
55
56
57 public GroupToAccountMapping(Configuration configuration, String name) {
58 this.configuration = configuration;
59 this.name = name;
60 }
61
62
63
64
65
66
67 public void addAccountMapper(String accountMapper) {
68 accountMappers.add(accountMapper);
69 }
70
71
72
73
74
75
76 public void addUserGroup(String userGroup) {
77 userGroups.add(userGroup);
78 }
79
80
81
82
83
84
85
86 public GroupToAccountMapping clone(Configuration configuration) {
87 GroupToAccountMapping groupToAccountMapping = new GroupToAccountMapping(configuration, new String(name));
88 groupToAccountMapping.setDescription(new String(getDescription()));
89 groupToAccountMapping.setAccountingVoSubgroup(new String(accountingVoSubgroup));
90 groupToAccountMapping.setAccountingVo(new String(accountingVo));
91 Iterator it = getUserGroups().iterator();
92 while (it.hasNext())
93 groupToAccountMapping.addUserGroup( new String((String)it.next()) );
94 it = getAccountMappers().iterator();
95 while (it.hasNext())
96 groupToAccountMapping.addAccountMapper( new String((String)it.next()) );
97 return groupToAccountMapping;
98 }
99
100
101
102
103 public boolean containsUserGroup(String userGroupQuery) {
104 Iterator userGroupIt = userGroups.iterator();
105 while(userGroupIt.hasNext()) {
106 String userGroup = (String)userGroupIt.next();
107 if(userGroup.equals(userGroupQuery))
108 return true;
109 }
110 return false;
111 }
112
113
114
115
116
117
118 public String getAccountingVo() {
119
120 return this.accountingVo;
121 }
122
123
124
125
126
127
128 public String getAccountingVoSubgroup() {
129
130 return this.accountingVoSubgroup;
131 }
132
133
134
135
136
137
138 public ArrayList getAccountMappers() {
139 return accountMappers;
140 }
141
142
143
144
145
146
147 public Configuration getConfiguration() {
148 return configuration;
149 }
150
151
152
153
154
155
156 public String getDescription() {
157 return description;
158 }
159
160
161
162
163
164
165 public String getName() {
166 return (name!=null ? name : "");
167 }
168
169
170
171
172
173
174 public ArrayList getUserGroups() {
175 return this.userGroups;
176 }
177
178
179
180
181
182 public void setAccountingVo(String accountingVo) {
183
184 this.accountingVo = accountingVo;
185 }
186
187
188
189
190
191
192 public void setAccountingVoSubgroup(java.lang.String accountingVoSubgroup) {
193
194 this.accountingVoSubgroup = accountingVoSubgroup;
195 }
196
197
198
199
200
201
202 public void setConfiguration(Configuration configuration) {
203 this.configuration = configuration;
204 }
205
206
207
208
209
210
211 public void setDescription(String description) {
212 this.description = description;
213 }
214
215
216
217
218
219
220 public void setName(String name) {
221 this.name = name;
222 }
223
224 public String toString(String bgColor) {
225 return "<td bgcolor=\""+bgColor+"\"><a href=\"groupToAccountMappings.jsp?command=edit&name=" + getName() + "\">" + getName() + "</a></td><td bgcolor=\""+bgColor+"\">" + getAccountingVoSubgroup() + " </td><td bgcolor=\""+bgColor+"\">" + getAccountingVo() + " </td>";
226 }
227
228
229
230
231
232
233 public String toXML() {
234 String retStr = "\t\t<groupToAccountMapping\n"+
235 "\t\t\tname='"+name+"'\n"+
236 "\t\t\tdescription='"+getDescription()+"'\n"+
237 "\t\t\taccountingVoSubgroup='"+accountingVoSubgroup+"'\n"+
238 "\t\t\taccountingVo='"+accountingVo+"'\n"+
239 "\t\t\tuserGroups='";
240
241 List userGroups = getUserGroups();
242 Iterator it = (Iterator)userGroups.iterator();
243 while(it.hasNext()) {
244 String userGroup = (String)it.next();
245 retStr += userGroup + (it.hasNext()?", ":"");
246 }
247
248 retStr += "'\n";
249
250 retStr += "\t\t\taccountMappers='";
251
252 List accountMappers = getAccountMappers();
253 it = (Iterator)accountMappers.iterator();
254 while(it.hasNext()) {
255 String accountMapper = (String)it.next();
256 retStr += accountMapper + (it.hasNext()?", ":"");
257 }
258
259 retStr += "'/>\n\n";
260
261 return retStr;
262 }
263
264 }