Source Code Cross Referenced for EmployeeAttribute.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » sampleu » travel » workflow » 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.sampleu.travel.workflow 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation
003:         *
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.opensource.org/licenses/ecl1.php
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package edu.sampleu.travel.workflow;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collections;
020:        import java.util.HashMap;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import org.apache.commons.lang.StringUtils;
025:
026:        import edu.iu.uis.eden.Id;
027:        import edu.iu.uis.eden.KEWServiceLocator;
028:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
029:        import edu.iu.uis.eden.engine.RouteContext;
030:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
031:        import edu.iu.uis.eden.exception.WorkflowRuntimeException;
032:        import edu.iu.uis.eden.lookupable.Field;
033:        import edu.iu.uis.eden.lookupable.Row;
034:        import edu.iu.uis.eden.routeheader.DocumentContent;
035:        import edu.iu.uis.eden.routetemplate.GenericRoleAttribute;
036:        import edu.iu.uis.eden.routetemplate.QualifiedRoleName;
037:        import edu.iu.uis.eden.routetemplate.Role;
038:        import edu.iu.uis.eden.user.AuthenticationUserId;
039:        import edu.iu.uis.eden.user.EmplId;
040:        import edu.iu.uis.eden.user.UserId;
041:        import edu.iu.uis.eden.user.WorkflowUser;
042:        import edu.iu.uis.eden.user.WorkflowUserId;
043:        import edu.iu.uis.eden.util.KeyLabelPair;
044:
045:        /**
046:         * An attribute implementation that can resolve organizational roles
047:         */
048:        public class EmployeeAttribute extends GenericRoleAttribute {
049:            private static final Role EMPLOYEE_ROLE = new Role(
050:                    EmployeeAttribute.class, "employee", "Employee");
051:            private static final Role SUPERVISOR_ROLE = new Role(
052:                    EmployeeAttribute.class, "supervisr", "Supervisor");
053:            private static final Role DIRECTOR_ROLE = new Role(
054:                    EmployeeAttribute.class, "director", "Dean/Director");
055:            private static final List<Role> ROLES;
056:            static {
057:                List<Role> tmp = new ArrayList<Role>(1);
058:                tmp.add(EMPLOYEE_ROLE);
059:                tmp.add(SUPERVISOR_ROLE);
060:                tmp.add(DIRECTOR_ROLE);
061:                ROLES = Collections.unmodifiableList(tmp);
062:            }
063:
064:            private static String USERID_FORM_FIELDNAME = "userid";
065:
066:            /**
067:             * Traveler to be set by client application so that doc content can be generated appropriately
068:             */
069:            private String traveler;
070:
071:            //private AttributeParser _attributeParser = new AttributeParser(ATTRIBUTE_TAGNAME);
072:
073:            public EmployeeAttribute() {
074:                super ("employee");
075:            }
076:
077:            public EmployeeAttribute(String traveler) {
078:                super ("employee");
079:                this .traveler = traveler;
080:            }
081:
082:            /** for edoclite?? */
083:            public void setTraveler(String traveler) {
084:                this .traveler = traveler;
085:            }
086:
087:            /* RoleAttribute methods */
088:            public List<Role> getRoleNames() {
089:                return ROLES;
090:            }
091:
092:            protected boolean isValidRole(String roleName) {
093:                for (Role role : ROLES) {
094:                    if (role.getBaseName().equals(roleName)) {
095:                        return true;
096:                    }
097:                }
098:                return false;
099:            }
100:
101:            @Override
102:            protected List<String> getRoleNameQualifiers(String roleName,
103:                    DocumentContent documentContent)
104:                    throws EdenUserNotFoundException {
105:                if (!isValidRole(roleName)) {
106:                    throw new WorkflowRuntimeException("Invalid role: "
107:                            + roleName);
108:                }
109:
110:                List<String> qualifiers = new ArrayList<String>();
111:                qualifiers.add(roleName);
112:                // find all traveller inputs in incoming doc
113:                //        List<Map<String, String>> attrs;
114:                //        try {
115:                //            attrs = content.parseContent(documentContent.getAttributeContent());
116:                //        } catch (XPathExpressionException xpee) {
117:                //            throw new WorkflowRuntimeException("Error parsing attribute content: " + XmlHelper.jotNode(documentContent.getAttributeContent()));
118:                //        }
119:                //        for (Map<String, String> props: attrs) {
120:                //            String attrTraveler = props.get("traveler");
121:                //            if (attrTraveler != null) {
122:                //                qualifiers.add(attrTraveler);
123:                //            }
124:                //        }
125:                return qualifiers;
126:            }
127:
128:            @Override
129:            protected List<Id> resolveRecipients(RouteContext routeContext,
130:                    QualifiedRoleName qualifiedRoleName)
131:                    throws EdenUserNotFoundException {
132:                List<Id> members = new ArrayList<Id>();
133:                UserId roleUserId = null;
134:                String roleName = qualifiedRoleName.getBaseRoleName();
135:                String roleTraveler = qualifiedRoleName.getQualifier();
136:
137:                /* EMPLOYEE role routes to traveler */
138:                if (StringUtils.equals(EMPLOYEE_ROLE.getBaseName(), roleName)) {
139:                    roleUserId = new WorkflowUserId(roleTraveler);
140:
141:                    /* SUPERVISOR role routes to... supervisor */
142:                } else if (StringUtils.equals(SUPERVISOR_ROLE.getBaseName(),
143:                        roleName)) {
144:                    // HACK: need to create an organizational-hierarchy service which
145:                    // has methods like
146:                    // getSupervisor( user ), getDirector( user ), getSupervised( user
147:                    // ), etc.
148:                    // using q.uhuuid() as input
149:                    roleUserId = new EmplId("supervisr");
150:
151:                    /* SUPERVISOR role routes to... director */
152:                } else if (StringUtils.equals(DIRECTOR_ROLE.getBaseName(),
153:                        roleName)) {
154:                    // HACK: need to create an organizational-hierarchy service which
155:                    // has methods like
156:                    // getSupervisor( user ), getDirector( user ), getSupervised( user
157:                    // ), etc.
158:                    // using q.uhuuid() as input
159:                    roleUserId = new EmplId("director");
160:                } else {
161:                    // throw an exception if you get an unrecognized roleName
162:                    throw new WorkflowRuntimeException(
163:                            "unable to process unknown role '" + roleName + "'");
164:                }
165:                members.add(roleUserId);
166:
167:                return members;
168:            }
169:
170:            public Map<String, String> getProperties() {
171:                Map<String, String> properties = new HashMap<String, String>();
172:                properties.put("traveler", traveler);
173:                return properties;
174:            }
175:
176:            /**
177:             * Required to support flex routing report
178:             * 
179:             * @see edu.iu.uis.eden.routetemplate.WorkflowAttribute#getFieldConversions()
180:             */
181:            public List getFieldConversions() {
182:                List conversionFields = new ArrayList();
183:                conversionFields.add(new KeyLabelPair("userid",
184:                        USERID_FORM_FIELDNAME));
185:                return conversionFields;
186:            }
187:
188:            public List<Row> getRoutingDataRows() {
189:                List<Row> rows = new ArrayList<Row>();
190:
191:                List<Field> fields = new ArrayList<Field>();
192:                fields.add(new Field("Traveler username", "", Field.TEXT,
193:                        false, USERID_FORM_FIELDNAME, "", null, null));
194:                rows.add(new Row(fields));
195:
196:                return rows;
197:            }
198:
199:            public List validateRoutingData(Map paramMap) {
200:                List errors = new ArrayList();
201:
202:                String userid = StringUtils.trim((String) paramMap
203:                        .get(USERID_FORM_FIELDNAME));
204:                if (isRequired() && StringUtils.isBlank(userid)) {
205:                    errors.add(new WorkflowServiceErrorImpl(
206:                            "userid is required",
207:                            "uh.accountattribute.userid.required"));
208:                }
209:
210:                WorkflowUser user = null;
211:                if (!StringUtils.isBlank(userid)) {
212:                    try {
213:                        user = KEWServiceLocator.getUserService()
214:                                .getWorkflowUser(
215:                                        new AuthenticationUserId(userid));
216:                    } catch (EdenUserNotFoundException e) {
217:                        errors.add(new WorkflowServiceErrorImpl(
218:                                "unable to retrieve user for userid '" + userid
219:                                        + "'",
220:                                "uh.accountattribute.userid.invalid"));
221:                    }
222:                }
223:                if (errors.size() == 0) {
224:                    traveler = user.getUuId().getUuId();
225:                }
226:
227:                return errors;
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.