Source Code Cross Referenced for BaseWorkgroup.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » workgroup » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » edu.iu.uis.eden.workgroup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         *
004:         *
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         * http://www.opensource.org/licenses/ecl1.php
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.workgroup;
018:
019:        import java.util.ArrayList;
020:        import java.util.HashSet;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Set;
024:
025:        import org.kuali.workflow.attribute.Extension;
026:
027:        import sun.reflect.ReflectionFactory.GetReflectionFactoryAction;
028:
029:        import edu.iu.uis.eden.EdenConstants;
030:        import edu.iu.uis.eden.KEWServiceLocator;
031:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
032:        import edu.iu.uis.eden.routeheader.Routable;
033:        import edu.iu.uis.eden.user.Recipient;
034:        import edu.iu.uis.eden.user.WorkflowUser;
035:        import edu.iu.uis.eden.user.WorkflowUserId;
036:        import edu.iu.uis.eden.util.CodeTranslator;
037:
038:        /**
039:         * A simple Workgroup implementation.
040:         *
041:         * @author Aaron Hamid (arh14 at cornell dot edu)
042:         */
043:        public class BaseWorkgroup implements  Workgroup, Routable {
044:
045:            private static final long serialVersionUID = 8048445959385570128L;
046:
047:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
048:                    .getLogger(BaseWorkgroup.class);
049:
050:            private Long workgroupId;
051:            private String workgroupName;
052:            private String description;
053:            private Boolean activeInd = Boolean.TRUE;
054:            private String workgroupType;
055:            private Integer versionNumber = new Integer(0);
056:            private Integer lockVerNbr = new Integer(0);
057:            private List<Recipient> members = new ArrayList<Recipient>();
058:
059:            private List<BaseWorkgroupMember> workgroupMembers = new ArrayList<BaseWorkgroupMember>();
060:            private List<Extension> extensions = new ArrayList<Extension>();
061:
062:            private Long documentId;
063:            private Boolean currentInd;
064:
065:            public BaseWorkgroup() {
066:            }
067:
068:            public Boolean getActiveInd() {
069:                return activeInd;
070:            }
071:
072:            public void setActiveInd(Boolean activeInd) {
073:                this .activeInd = activeInd;
074:            }
075:
076:            public Integer getLockVerNbr() {
077:                return lockVerNbr;
078:            }
079:
080:            public void setLockVerNbr(Integer lockVerNbr) {
081:                this .lockVerNbr = lockVerNbr;
082:            }
083:
084:            public String getDescription() {
085:                return description;
086:            }
087:
088:            public void setDescription(String description) {
089:                this .description = description;
090:            }
091:
092:            public String getWorkgroupType() {
093:                return workgroupType;
094:            }
095:
096:            public void setWorkgroupType(String workgroupTypeCode) {
097:                this .workgroupType = workgroupTypeCode;
098:            }
099:
100:            public GroupNameId getGroupNameId() {
101:                return (workgroupName == null ? null : new GroupNameId(
102:                        workgroupName));
103:            }
104:
105:            public void setGroupNameId(GroupNameId groupNameId) {
106:                if (groupNameId == null || groupNameId.getNameId() == null) {
107:                    this .workgroupName = null;
108:                } else {
109:                    this .workgroupName = groupNameId.getNameId();
110:                }
111:            }
112:
113:            public WorkflowGroupId getWorkflowGroupId() {
114:                return (workgroupId == null ? null : new WorkflowGroupId(
115:                        workgroupId));
116:            }
117:
118:            public void setWorkflowGroupId(WorkflowGroupId workflowGroupId) {
119:                if (workflowGroupId == null
120:                        || workflowGroupId.getGroupId() == null) {
121:                    this .workgroupId = null;
122:                } else {
123:                    this .workgroupId = workflowGroupId.getGroupId();
124:                }
125:            }
126:
127:            public void setWorkgroupId(Long workgroupId) {
128:                this .workgroupId = workgroupId;
129:            }
130:
131:            public Long getWorkgroupId() {
132:                return this .workgroupId;
133:            }
134:
135:            public String getWorkgroupName() {
136:                return workgroupName;
137:            }
138:
139:            public List<Recipient> getMembers() {
140:                return members;
141:            }
142:
143:            public void setMembers(List<Recipient> members) {
144:                this .members = members;
145:            }
146:
147:            public List<WorkflowUser> getUsers() {
148:                List<WorkflowUser> users = new ArrayList<WorkflowUser>();
149:                Set<String> userIds = new HashSet<String>();
150:                Set<String> workgroupNames = new HashSet<String>();
151:                for (Recipient recipient : getMembers()) {
152:                    processRecipientUsers(recipient, users, userIds,
153:                            workgroupNames);
154:                }
155:                return users;
156:            }
157:
158:            /**
159:             * Prevents duplicate users from occuring in the users list as well as preventing infinite loops
160:             * should there happen to be cycles in the workgroups.
161:             */
162:            protected void processRecipientUsers(Recipient recipient,
163:                    List<WorkflowUser> users, Set<String> userIds,
164:                    Set<String> workgroupNames) {
165:                if (recipient instanceof  WorkflowUser) {
166:                    WorkflowUser user = (WorkflowUser) recipient;
167:                    if (!userIds.contains(user.getWorkflowId())) {
168:                        userIds.add(user.getWorkflowId());
169:                        users.add(user);
170:                    }
171:                } else if (recipient instanceof  Workgroup) {
172:                    Workgroup workgroup = (Workgroup) recipient;
173:                    if (!workgroupNames.contains(workgroup.getGroupNameId()
174:                            .getNameId())) {
175:                        workgroupNames.add(workgroup.getGroupNameId()
176:                                .getNameId());
177:                        for (Recipient workgroupRecipient : workgroup
178:                                .getMembers()) {
179:                            processRecipientUsers(workgroupRecipient, users,
180:                                    userIds, workgroupNames);
181:                        }
182:                    }
183:                } else {
184:                    LOG
185:                            .error("Invalid recipient type found for workgroup member: "
186:                                    + recipient.getClass().getName());
187:                }
188:            }
189:
190:            public boolean hasMember(Recipient member) {
191:                for (Recipient recipient : getMembers()) {
192:                    if (recipient instanceof  WorkflowUser
193:                            && member instanceof  WorkflowUser) {
194:                        WorkflowUser user1 = (WorkflowUser) recipient;
195:                        WorkflowUser user2 = (WorkflowUser) member;
196:                        if (user1.getWorkflowUserId().equals(
197:                                user2.getWorkflowUserId())) {
198:                            return true;
199:                        }
200:                    } else if (recipient instanceof  WorkflowUser
201:                            && member instanceof  Workgroup) {
202:                        continue;
203:                    } else if (recipient instanceof  Workgroup
204:                            && member instanceof  WorkflowUser) {
205:                        Workgroup workgroup = (Workgroup) recipient;
206:                        if (workgroup.hasMember(member)) {
207:                            return true;
208:                        }
209:                    } else if (recipient instanceof  Workgroup
210:                            && member instanceof  Workgroup) {
211:                        Workgroup workgroup1 = (Workgroup) recipient;
212:                        Workgroup workgroup2 = (Workgroup) member;
213:                        if (workgroup1.getWorkflowGroupId().equals(
214:                                workgroup2.getWorkflowGroupId())) {
215:                            return true;
216:                        }
217:                    } else {
218:                        LOG
219:                                .error("Invalid recipient type found for workgroup member: "
220:                                        + recipient.getClass().getName());
221:                    }
222:                }
223:                return false;
224:            }
225:
226:            public String getDisplayName() {
227:                if (getGroupNameId() == null)
228:                    return null;
229:                return getGroupNameId().getNameId();
230:            }
231:
232:            public Integer getVersionNumber() {
233:                return versionNumber;
234:            }
235:
236:            public void setVersionNumber(Integer versionNumber) {
237:                this .versionNumber = versionNumber;
238:            }
239:
240:            public Recipient getWorkgroupMember(int index) {
241:                return getMembers().get(index);
242:            }
243:
244:            public String getActiveIndDisplay() {
245:                if (getActiveInd() == null) {
246:                    return EdenConstants.INACTIVE_LABEL_LOWER;
247:                }
248:                return CodeTranslator.getActiveIndicatorLabel(getActiveInd());
249:            }
250:
251:            public List<BaseWorkgroupMember> getWorkgroupMembers() {
252:                return workgroupMembers;
253:            }
254:
255:            public void setWorkgroupMembers(List<BaseWorkgroupMember> members) {
256:                this .workgroupMembers = members;
257:            }
258:
259:            public Boolean getCurrentInd() {
260:                return currentInd;
261:            }
262:
263:            public void setCurrentInd(Boolean currentInd) {
264:                this .currentInd = currentInd;
265:            }
266:
267:            public Long getDocumentId() {
268:                return documentId;
269:            }
270:
271:            public void setDocumentId(Long documentId) {
272:                this .documentId = documentId;
273:            }
274:
275:            public List<Extension> getExtensions() {
276:                return extensions;
277:            }
278:
279:            public void setExtensions(List<Extension> extensions) {
280:                this .extensions = extensions;
281:            }
282:
283:            /**
284:             * Constructs the List of WorkflowUsers for the given workgroup from it's list of "workgroupMembers" and sets that
285:             * as the List of "members" on this Workgroup.
286:             */
287:            public void materializeMembers() throws EdenUserNotFoundException {
288:                // clear it out first, just to be safe
289:                getMembers().clear();
290:                for (Iterator iter = getWorkgroupMembers().iterator(); iter
291:                        .hasNext();) {
292:                    BaseWorkgroupMember member = (BaseWorkgroupMember) iter
293:                            .next();
294:                    if (EdenConstants.ACTION_REQUEST_USER_RECIPIENT_CD
295:                            .equals(member.getMemberType())) {
296:                        try {
297:                            getMembers().add(
298:                                    KEWServiceLocator.getUserService()
299:                                            .getWorkflowUser(
300:                                                    new WorkflowUserId(member
301:                                                            .getWorkflowId())));
302:                        } catch (IllegalArgumentException e) {
303:                            LOG.error(
304:                                    "Problem retrieving user from user service, workflowId="
305:                                            + member.getWorkflowId(), e);
306:                        }
307:                    } else if (EdenConstants.ACTION_REQUEST_WORKGROUP_RECIPIENT_CD
308:                            .equals(member.getMemberType())) {
309:                        Workgroup workgroup = KEWServiceLocator
310:                                .getWorkgroupService().getWorkgroup(
311:                                        new WorkflowGroupId(Long
312:                                                .parseLong(member
313:                                                        .getWorkflowId())));
314:                        if (workgroup == null) {
315:                            LOG
316:                                    .error("Problem retrieving workgroup from workgroup service, workgroup id="
317:                                            + member.getWorkgroupId());
318:                            continue;
319:                        }
320:                        getMembers().add(workgroup);
321:                    }
322:                }
323:            }
324:
325:            public int hashCode() {
326:                if (workgroupId == null)
327:                    return super .hashCode();
328:                return workgroupId.hashCode();
329:            }
330:
331:            public String toString() {
332:                return "[SimpleWorkgroup: name=" + workgroupName + ", type="
333:                        + workgroupType + ", groupId=" + workgroupId
334:                        + ", displayName=" + getDisplayName()
335:                        + ", description=" + description + ", lockVerNbr="
336:                        + lockVerNbr + ", activeInd=" + activeInd + "]";
337:            }
338:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.