Source Code Cross Referenced for RoleLookupableImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » lookupable » 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.lookupable 
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.lookupable;
018:
019:        import java.util.ArrayList;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import javax.servlet.http.HttpServletRequest;
025:
026:        import org.apache.log4j.Logger;
027:        import org.kuali.rice.definition.ObjectDefinition;
028:        import org.kuali.rice.resourceloader.GlobalResourceLoader;
029:
030:        import edu.iu.uis.eden.KEWServiceLocator;
031:        import edu.iu.uis.eden.plugin.attributes.RoleAttribute;
032:        import edu.iu.uis.eden.plugin.attributes.WorkflowAttribute;
033:        import edu.iu.uis.eden.plugin.attributes.WorkflowLookupable;
034:        import edu.iu.uis.eden.routetemplate.Role;
035:        import edu.iu.uis.eden.routetemplate.RuleTemplate;
036:        import edu.iu.uis.eden.routetemplate.RuleTemplateAttribute;
037:        import edu.iu.uis.eden.routetemplate.RuleTemplateService;
038:        import edu.iu.uis.eden.util.Utilities;
039:
040:        /**
041:         * A {@link WorkflowLookupable} implementation which is used to lookup roles.
042:         *
043:         * @author jhopf
044:         */
045:        public class RoleLookupableImpl implements  WorkflowLookupable {
046:
047:            private static final Logger LOG = Logger
048:                    .getLogger(RoleLookupableImpl.class);
049:
050:            private List rows;
051:
052:            private static List columns = establishColumns();
053:
054:            private static final String TITLE = "Role Lookup";
055:            private static final String RETURNLOCATION = "Lookup.do";
056:            private static final String RULE_TEMPLATE_FIELD_LABEL = "Rule Template";
057:            private static final String RULE_TEMPLATE_FIELD_HELP = "";
058:            private static final String RULE_TEMPLATE_PROPERTY_NAME = "ruleTemplateName";
059:            private static final String RULE_TEMPLATE_ID_PROPERTY_NAME = "ruleTemplate.ruleTemplateId";
060:
061:            private static final String RULE_TEMPLATE_LOOKUPABLE = "RuleTemplateLookupableImplService";
062:            private static final String BACK_LOCATION_KEY_NAME = "backLocation";
063:            private static final String DOC_FORM_KEY_NAME = "docFormKey";
064:            private static final String ROLE_NAME = "roleName";
065:
066:            public RoleLookupableImpl() {
067:                rows = new ArrayList();
068:
069:                List fields = new ArrayList();
070:                fields.add(new Field(RULE_TEMPLATE_FIELD_LABEL,
071:                        RULE_TEMPLATE_FIELD_HELP, Field.TEXT, true,
072:                        RULE_TEMPLATE_PROPERTY_NAME, "", null,
073:                        RULE_TEMPLATE_LOOKUPABLE));
074:                fields.add(new Field("", "", Field.QUICKFINDER, false, "", "",
075:                        null, RULE_TEMPLATE_LOOKUPABLE));
076:                fields.add(new Field("", "", Field.LOOKUP_RESULT_ONLY, true,
077:                        RULE_TEMPLATE_ID_PROPERTY_NAME, "", null,
078:                        RULE_TEMPLATE_LOOKUPABLE));
079:                rows.add(new Row(fields));
080:            }
081:
082:            private static List establishColumns() {
083:                List columnList = new ArrayList();
084:                columnList.add(new Column("Role Label",
085:                        Column.COLUMN_IS_SORTABLE_VALUE, "label"));
086:                columnList.add(new Column("Role Name",
087:                        Column.COLUMN_IS_SORTABLE_VALUE, "name"));
088:                return columnList;
089:            }
090:
091:            public List getFieldConversions() {
092:                return new ArrayList();
093:            }
094:
095:            public void changeIdToName(Map fieldValues) {
096:                String ruleTemplateIdParam = (String) fieldValues
097:                        .get(RULE_TEMPLATE_ID_PROPERTY_NAME);
098:                String ruleTemplateNameParam = (String) fieldValues
099:                        .get(RULE_TEMPLATE_PROPERTY_NAME);
100:
101:                if (ruleTemplateNameParam != null
102:                        && !ruleTemplateNameParam.trim().equals("")
103:                        || ruleTemplateIdParam != null
104:                        && !"".equals(ruleTemplateIdParam)
105:                        && !"null".equals(ruleTemplateIdParam)) {
106:                    RuleTemplate ruleTemplate = null;
107:                    if (ruleTemplateIdParam != null
108:                            && !"".equals(ruleTemplateIdParam)) {
109:                        ruleTemplate = getRuleTemplateService()
110:                                .findByRuleTemplateId(
111:                                        new Long(ruleTemplateIdParam));
112:                    } else {
113:                        ruleTemplate = getRuleTemplateService()
114:                                .findByRuleTemplateName(
115:                                        ruleTemplateNameParam.trim());
116:                    }
117:                    if (ruleTemplate != null) {
118:                        setFieldValue(RULE_TEMPLATE_PROPERTY_NAME, ruleTemplate
119:                                .getName());
120:                    }
121:                } else {
122:                    setFieldValue(RULE_TEMPLATE_PROPERTY_NAME, "");
123:                }
124:
125:            }
126:
127:            public List getSearchResults(Map fieldValues, Map fieldConversions)
128:                    throws Exception {
129:                String ruleTemplateIdParam = (String) fieldValues
130:                        .get(RULE_TEMPLATE_ID_PROPERTY_NAME);
131:                String ruleTemplateNameParam = (String) fieldValues
132:                        .get(RULE_TEMPLATE_PROPERTY_NAME);
133:                String backLocation = (String) fieldValues
134:                        .get(BACK_LOCATION_KEY_NAME);
135:                String docFormKey = (String) fieldValues.get(DOC_FORM_KEY_NAME);
136:
137:                String roleReturn = (String) fieldConversions.get(ROLE_NAME);
138:
139:                Long ruleTemplateId = null;
140:
141:                List displayList = new ArrayList();
142:
143:                if (ruleTemplateNameParam != null
144:                        && !ruleTemplateNameParam.trim().equals("")
145:                        || ruleTemplateIdParam != null
146:                        && !"".equals(ruleTemplateIdParam)) {
147:                    RuleTemplate ruleTemplate = null;
148:                    if (ruleTemplateIdParam != null
149:                            && !"".equals(ruleTemplateIdParam)) {
150:                        ruleTemplateId = new Long(ruleTemplateIdParam);
151:                        ruleTemplate = getRuleTemplateService()
152:                                .findByRuleTemplateId(ruleTemplateId);
153:                    } else {
154:                        ruleTemplate = getRuleTemplateService()
155:                                .findByRuleTemplateName(
156:                                        ruleTemplateNameParam.trim());
157:                    }
158:                    if (ruleTemplate != null) {
159:                        for (Iterator iter = ruleTemplate
160:                                .getRuleTemplateAttributes().iterator(); iter
161:                                .hasNext();) {
162:                            RuleTemplateAttribute ruleTemplateAttribute = (RuleTemplateAttribute) iter
163:                                    .next();
164:                            try {
165:                                WorkflowAttribute attribute = (WorkflowAttribute) GlobalResourceLoader
166:                                        .getResourceLoader()
167:                                        .getObject(
168:                                                new ObjectDefinition(
169:                                                        ruleTemplateAttribute
170:                                                                .getRuleAttribute()
171:                                                                .getClassName()));
172:                                if (attribute instanceof  RoleAttribute) {
173:                                    RoleAttribute roleAttribute = (RoleAttribute) attribute;
174:
175:                                    for (Iterator iterator = roleAttribute
176:                                            .getRoleNames().iterator(); iterator
177:                                            .hasNext();) {
178:                                        Role role = (Role) iterator.next();
179:                                        StringBuffer returnUrl = new StringBuffer(
180:                                                "<a href=\"");
181:                                        returnUrl
182:                                                .append(backLocation)
183:                                                .append(
184:                                                        "?methodToCall=refresh&docFormKey=")
185:                                                .append(docFormKey).append("&");
186:                                        if (!Utilities.isEmpty(roleReturn)) {
187:                                            returnUrl.append(roleReturn);
188:                                        } else {
189:                                            returnUrl.append(ROLE_NAME);
190:                                        }
191:                                        returnUrl.append("=").append(
192:                                                role.getName()).append(
193:                                                " \">return value</a>");
194:                                        role.setReturnUrl(returnUrl.toString());
195:                                        displayList.add(role);
196:                                    }
197:                                }
198:                            } catch (Exception e) {
199:                                LOG
200:                                        .error(
201:                                                "Exception caught looking up Role Attribute",
202:                                                e);
203:                            }
204:                        }
205:                    }
206:                }
207:
208:                return displayList;
209:            }
210:
211:            public boolean checkForAdditionalFields(Map fieldValues,
212:                    HttpServletRequest request) throws Exception {
213:                return false;
214:            }
215:
216:            public List getDefaultReturnType() {
217:                List returnTypes = new ArrayList();
218:                returnTypes.add(ROLE_NAME);
219:                return returnTypes;
220:            }
221:
222:            public List getColumns() {
223:                return columns;
224:            }
225:
226:            public String getHtmlMenuBar() {
227:                return "";
228:            }
229:
230:            public String getLookupInstructions() {
231:                return "Use fields below to search for roles.";
232:            }
233:
234:            public String getNoReturnParams(Map fieldConversions) {
235:                String roleReturn = (String) fieldConversions.get(ROLE_NAME);
236:                StringBuffer noReturnParams = new StringBuffer("&");
237:                if (!Utilities.isEmpty(roleReturn)) {
238:                    noReturnParams.append(roleReturn);
239:                } else {
240:                    noReturnParams.append(ROLE_NAME);
241:                }
242:                noReturnParams.append("=");
243:
244:                return noReturnParams.toString();
245:            }
246:
247:            public String getReturnLocation() {
248:                return RETURNLOCATION;
249:            }
250:
251:            public List getRows() {
252:                return rows;
253:            }
254:
255:            public String getTitle() {
256:                return TITLE;
257:            }
258:
259:            private void setFieldValue(String name, String value) {
260:                for (Iterator iter = getRows().iterator(); iter.hasNext();) {
261:                    Row row = (Row) iter.next();
262:                    for (Iterator iterator = row.getFields().iterator(); iterator
263:                            .hasNext();) {
264:                        Field field = (Field) iterator.next();
265:                        if (field.getPropertyName() != null
266:                                && !field.getPropertyName().equals("")) {
267:                            if (name.equals(field.getPropertyName())) {
268:                                field.setPropertyValue(value);
269:                            }
270:                        }
271:                    }
272:                }
273:            }
274:
275:            private RuleTemplateService getRuleTemplateService() {
276:                return (RuleTemplateService) KEWServiceLocator
277:                        .getService(KEWServiceLocator.RULE_TEMPLATE_SERVICE);
278:            }
279:
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.