Source Code Cross Referenced for RuleBaseValuesLookupableImpl.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.HashMap;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import javax.servlet.http.HttpServletRequest;
026:
027:        import org.kuali.rice.definition.ObjectDefinition;
028:        import org.kuali.rice.resourceloader.GlobalResourceLoader;
029:
030:        import edu.iu.uis.eden.EdenConstants;
031:        import edu.iu.uis.eden.KEWServiceLocator;
032:        import edu.iu.uis.eden.WorkflowServiceErrorException;
033:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
034:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
035:        import edu.iu.uis.eden.export.ExportDataSet;
036:        import edu.iu.uis.eden.export.ExportFormat;
037:        import edu.iu.uis.eden.export.Exportable;
038:        import edu.iu.uis.eden.plugin.attributes.OddSearchAttribute;
039:        import edu.iu.uis.eden.plugin.attributes.WorkflowAttribute;
040:        import edu.iu.uis.eden.plugin.attributes.WorkflowLookupable;
041:        import edu.iu.uis.eden.routetemplate.RuleAttribute;
042:        import edu.iu.uis.eden.routetemplate.RuleBaseValues;
043:        import edu.iu.uis.eden.routetemplate.RuleService;
044:        import edu.iu.uis.eden.routetemplate.RuleTemplate;
045:        import edu.iu.uis.eden.routetemplate.RuleTemplateAttribute;
046:        import edu.iu.uis.eden.routetemplate.RuleTemplateService;
047:        import edu.iu.uis.eden.routetemplate.xmlrouting.GenericXMLRuleAttribute;
048:        import edu.iu.uis.eden.user.AuthenticationUserId;
049:        import edu.iu.uis.eden.user.UserService;
050:        import edu.iu.uis.eden.user.WorkflowUser;
051:        import edu.iu.uis.eden.util.KeyLabelPair;
052:        import edu.iu.uis.eden.util.Utilities;
053:        import edu.iu.uis.eden.workgroup.GroupNameId;
054:        import edu.iu.uis.eden.workgroup.WorkflowGroupId;
055:        import edu.iu.uis.eden.workgroup.Workgroup;
056:        import edu.iu.uis.eden.workgroup.WorkgroupService;
057:
058:        /**
059:         * A {@link WorkflowLookupable} implementation for {@link RuleBaseValues}.
060:         *
061:         * @see RuleBaseValues
062:         * @see RuleService
063:         *
064:         * @author jhopf
065:         * @author ewestfal
066:         * @author rkirkend
067:         */
068:        public class RuleBaseValuesLookupableImpl implements 
069:                WorkflowLookupable, Exportable {
070:
071:            private List rows;
072:            private List columns = establishColumns();
073:            private static final String title = "Rule Lookup";
074:            private static final String returnLocation = "Lookup.do";
075:
076:            private static final String DOC_TYP_NAME_FIELD_LABEL = "Document Type Name";
077:            private static final String RULE_TEMPLATE_FIELD_LABEL = "Rule Template";
078:            private static final String WORKGROUP_FIELD_LABEL = "Workgroup Reviewer";
079:            private static final String PERSON_FIELD_LABEL = "Person Reviewer";
080:            private static final String ROLE_FIELD_LABEL = "Role";
081:            private static final String ACTIVE_IND_FIELD_LABEL = "Active Indicator";
082:            private static final String DELEGATE_RULE_FIELD_LABEL = "Delegate Rule";
083:            private static final String RULE_ID_FIELD_LABEL = "Rule Id";
084:            private static final String RULE_DESC_FIELD_LABEL = "Rule Description";
085:
086:            private static final String DOC_TYP_NAME_FIELD_HELP = "";
087:            private static final String RULE_TEMPLATE_FIELD_HELP = "";
088:            private static final String WORKGROUP_FIELD_HELP = "";
089:            private static final String PERSON_FIELD_HELP = "";
090:            private static final String ROLE_FIELD_HELP = "";
091:            private static final String ACTIVE_IND_FIELD_HELP = "";
092:            private static final String DELEGATE_RULE_FIELD_HELP = "";
093:            private static final String RULE_ID_FIELD_HELP = "";
094:            private static final String RULE_DESC_FIELD_HELP = "";
095:
096:            private static final String DOC_TYP_NAME_PROPERTY_NAME = "docTypeFullName";
097:            private static final String RULE_TEMPLATE_PROPERTY_NAME = "ruleTemplateName";
098:            private static final String WORKGROUP_PROPERTY_NAME = "workgroupName";
099:            private static final String PERSON_PROPERTY_NAME = "networkId";
100:            private static final String ROLE_PROPERTY_NAME = "roleName";
101:            private static final String DELEGATE_RULE_PROPERTY_NAME = "delegateRuleSearch";
102:            private static final String RULE_DESC_PROPERTY_NAME = "ruleDescription";
103:            private static final String RULE_DELEGATE_ONLY_PROPERTY_NAME = "ruleDelegationOnly";
104:
105:            private static final String DOC_TYP_LOOKUPABLE = "DocumentTypeLookupableImplService";
106:            private static final String RULE_TEMPLATE_LOOKUPABLE = "RuleTemplateLookupableImplService";
107:            private static final String WORKGROUP_LOOKUPABLE = "WorkGroupLookupableImplService";
108:            private static final String PERSON_LOOKUPABLE = "UserLookupableImplService";
109:            private static final String ROLE_LOOKUPABLE = "RoleLookupableImplService";
110:
111:            private static final String RULE_ID_PROPERTY_NAME = "ruleBaseValuesId";
112:            private static final String RULE_TEMPLATE_ID_PROPERTY_NAME = "ruleTemplate.ruleTemplateId";
113:            private static final String WORKGROUP_ID_PROPERTY_NAME = "workgroupId";
114:
115:            private static final String ACTIVE_IND_PROPERTY_NAME = "activeInd";
116:
117:            private static final String BACK_LOCATION = "backLocation";
118:            private static final String DOC_FORM_KEY = "docFormKey";
119:
120:            public RuleBaseValuesLookupableImpl() {
121:                rows = new ArrayList();
122:
123:                List fields = new ArrayList();
124:                fields.add(new Field(DOC_TYP_NAME_FIELD_LABEL,
125:                        DOC_TYP_NAME_FIELD_HELP, Field.TEXT, true,
126:                        DOC_TYP_NAME_PROPERTY_NAME, "", null,
127:                        DOC_TYP_LOOKUPABLE));
128:                fields.add(new Field("", "", Field.QUICKFINDER, false, "", "",
129:                        null, DOC_TYP_LOOKUPABLE));
130:                rows.add(new Row(fields));
131:
132:                fields = new ArrayList();
133:                fields.add(new Field("", "", Field.HIDDEN, true,
134:                        RULE_TEMPLATE_PROPERTY_NAME, "", null,
135:                        RULE_TEMPLATE_LOOKUPABLE));
136:                fields.add(new Field(RULE_TEMPLATE_FIELD_LABEL,
137:                        RULE_TEMPLATE_FIELD_HELP, Field.QUICKFINDER, false,
138:                        RULE_TEMPLATE_PROPERTY_NAME, "", null,
139:                        RULE_TEMPLATE_LOOKUPABLE));
140:                fields.add(new Field("", "", Field.LOOKUP_RESULT_ONLY, true,
141:                        RULE_TEMPLATE_ID_PROPERTY_NAME, "", null,
142:                        RULE_TEMPLATE_LOOKUPABLE));
143:                rows.add(new Row(fields));
144:
145:                fields = new ArrayList();
146:                fields.add(new Field(RULE_DESC_FIELD_LABEL,
147:                        RULE_DESC_FIELD_HELP, Field.TEXT, false,
148:                        RULE_DESC_PROPERTY_NAME, "", null, null));
149:                rows.add(new Row(fields));
150:
151:                fields = new ArrayList();
152:                fields
153:                        .add(new Field(WORKGROUP_FIELD_LABEL,
154:                                WORKGROUP_FIELD_HELP, Field.TEXT, true,
155:                                WORKGROUP_PROPERTY_NAME, "", null,
156:                                WORKGROUP_LOOKUPABLE));
157:                fields.add(new Field("", "", Field.QUICKFINDER, false, "", "",
158:                        null, WORKGROUP_LOOKUPABLE));
159:                fields.add(new Field("", "", Field.HIDDEN, false,
160:                        RULE_DELEGATE_ONLY_PROPERTY_NAME, "", null, null));
161:                fields.add(new Field("", "", Field.LOOKUP_RESULT_ONLY, true,
162:                        WORKGROUP_ID_PROPERTY_NAME, "", null, ""));
163:                rows.add(new Row(fields));
164:
165:                fields = new ArrayList();
166:                fields.add(new Field(PERSON_FIELD_LABEL, PERSON_FIELD_HELP,
167:                        Field.TEXT, true, PERSON_PROPERTY_NAME, "", null,
168:                        PERSON_LOOKUPABLE));
169:                fields.add(new Field("", "", Field.QUICKFINDER, false, "", "",
170:                        null, PERSON_LOOKUPABLE));
171:                rows.add(new Row(fields));
172:
173:                fields = new ArrayList();
174:                fields.add(new Field(ROLE_FIELD_LABEL, ROLE_FIELD_HELP,
175:                        Field.TEXT, true, ROLE_PROPERTY_NAME, "", null,
176:                        ROLE_LOOKUPABLE));
177:                fields.add(new Field("", "", Field.QUICKFINDER, false, "", "",
178:                        null, ROLE_LOOKUPABLE));
179:                rows.add(new Row(fields));
180:
181:                fields = new ArrayList();
182:                fields.add(new Field(RULE_ID_FIELD_LABEL, RULE_ID_FIELD_HELP,
183:                        Field.TEXT, false, RULE_ID_PROPERTY_NAME, "", null,
184:                        null));
185:                fields.add(new Field("", "", Field.HIDDEN, false,
186:                        EdenConstants.DELEGATION_WIZARD, "", null, null));
187:                rows.add(new Row(fields));
188:
189:                List options = new ArrayList();
190:                options.add(new KeyLabelPair("true", "Active"));
191:                options.add(new KeyLabelPair("false", "Inactive"));
192:                options.add(new KeyLabelPair("ALL", "Show All"));
193:
194:                fields = new ArrayList();
195:                fields.add(new Field(ACTIVE_IND_FIELD_LABEL,
196:                        ACTIVE_IND_FIELD_HELP, Field.RADIO, false,
197:                        ACTIVE_IND_PROPERTY_NAME, "true", options, null));
198:                rows.add(new Row(fields));
199:
200:                options = new ArrayList();
201:                options.add(new KeyLabelPair("false", "Non-Delegates"));
202:                options.add(new KeyLabelPair("true", "Delegates"));
203:                options.add(new KeyLabelPair("ALL", "Show All"));
204:
205:                fields = new ArrayList();
206:                fields.add(new Field(DELEGATE_RULE_FIELD_LABEL,
207:                        DELEGATE_RULE_FIELD_HELP, Field.RADIO, true,
208:                        DELEGATE_RULE_PROPERTY_NAME, "false", options, null));
209:                rows.add(new Row(fields));
210:
211:            }
212:
213:            private List establishColumns() {
214:                List columnList = new ArrayList();
215:                columnList.add(new Column("Rule Id",
216:                        Column.COLUMN_IS_SORTABLE_VALUE, "ruleBaseValuesId"));
217:                columnList.add(new Column("Document Type Name",
218:                        Column.COLUMN_IS_SORTABLE_VALUE, "docTypeName"));
219:                columnList.add(new Column("Rule Template Name",
220:                        Column.COLUMN_IS_SORTABLE_VALUE, "ruleTemplateName"));
221:                columnList.add(new Column("Description",
222:                        Column.COLUMN_IS_SORTABLE_VALUE, "description"));
223:                columnList.add(new Column("Active",
224:                        Column.COLUMN_IS_SORTABLE_VALUE, "activeIndDisplay"));
225:                columnList.add(new Column("Delegate Rule",
226:                        Column.COLUMN_IS_SORTABLE_VALUE, "delegateRule"));
227:                columnList.add(new Column("Actions",
228:                        Column.COLUMN_NOT_SORTABLE_VALUE, "destinationUrl"));
229:                return columnList;
230:            }
231:
232:            private void setFieldValue(String name, String value) {
233:                for (Iterator iter = getRows().iterator(); iter.hasNext();) {
234:                    Row row = (Row) iter.next();
235:                    for (Iterator iterator = row.getFields().iterator(); iterator
236:                            .hasNext();) {
237:                        Field field = (Field) iterator.next();
238:                        if (field.getPropertyName() != null
239:                                && !field.getPropertyName().equals("")) {
240:                            if (name.equals(field.getPropertyName())) {
241:                                field.setPropertyValue(value);
242:                            }
243:                        }
244:                    }
245:                }
246:            }
247:
248:            public boolean checkForAdditionalFields(Map fieldValues,
249:                    HttpServletRequest request) throws Exception {
250:                String ruleTemplateNameParam = (String) fieldValues
251:                        .get(RULE_TEMPLATE_PROPERTY_NAME);
252:                String ruleTemplateIdParam = (String) fieldValues
253:                        .get(RULE_TEMPLATE_ID_PROPERTY_NAME);
254:
255:                if (ruleTemplateNameParam != null
256:                        && !ruleTemplateNameParam.equals("")
257:                        || ruleTemplateIdParam != null
258:                        && !"".equals(ruleTemplateIdParam)
259:                        && !"null".equals(ruleTemplateIdParam)) {
260:                    RuleTemplate ruleTemplate = null;
261:                    if (ruleTemplateIdParam != null
262:                            && !"".equals(ruleTemplateIdParam)
263:                            && !"null".equals(ruleTemplateIdParam)) {
264:                        ruleTemplate = getRuleTemplateService()
265:                                .findByRuleTemplateId(
266:                                        new Long(ruleTemplateIdParam));
267:                    } else {
268:                        ruleTemplate = getRuleTemplateService()
269:                                .findByRuleTemplateName(ruleTemplateNameParam);
270:                    }
271:
272:                    int i = 0;
273:                    for (Iterator iter = ruleTemplate
274:                            .getRuleTemplateAttributes().iterator(); iter
275:                            .hasNext();) {
276:                        RuleTemplateAttribute ruleTemplateAttribute = (RuleTemplateAttribute) iter
277:                                .next();
278:                        if (!ruleTemplateAttribute.isWorkflowAttribute()) {
279:                            continue;
280:                        }
281:                        WorkflowAttribute attribute = ruleTemplateAttribute
282:                                .getWorkflowAttribute();
283:
284:                        RuleAttribute ruleAttribute = ruleTemplateAttribute
285:                                .getRuleAttribute();
286:                        if (ruleAttribute.getType().equals(
287:                                EdenConstants.RULE_XML_ATTRIBUTE_TYPE)) {
288:                            ((GenericXMLRuleAttribute) attribute)
289:                                    .setRuleAttribute(ruleAttribute);
290:                        }
291:                        // run through the attributes fields once to populate field values we have to do this
292:                        // to allow rows dependent on another row value to populate correctly in the loop below
293:                        List searchRows = null;
294:                        if (attribute instanceof  OddSearchAttribute) {
295:                            searchRows = ((OddSearchAttribute) attribute)
296:                                    .getSearchRows();
297:                        } else {
298:                            searchRows = attribute.getRuleRows();
299:                        }
300:                        for (Iterator iterator = searchRows.iterator(); iterator
301:                                .hasNext();) {
302:                            Row row = (Row) iterator.next();
303:                            List fields = new ArrayList();
304:                            for (Iterator iterator2 = row.getFields()
305:                                    .iterator(); iterator2.hasNext();) {
306:                                Field field = (Field) iterator2.next();
307:                                if (request.getParameter(field
308:                                        .getPropertyName()) != null) {
309:                                    field.setPropertyValue(request
310:                                            .getParameter(field
311:                                                    .getPropertyName()));
312:                                }
313:                                fields.add(field);
314:                                fieldValues.put(field.getPropertyName(), field
315:                                        .getPropertyValue());
316:                            }
317:                        }
318:
319:                        if (attribute instanceof  OddSearchAttribute) {
320:                            ((OddSearchAttribute) attribute)
321:                                    .validateSearchData(fieldValues);
322:                        } else {
323:                            attribute.validateRuleData(fieldValues);// populate attribute
324:                        }
325:
326:                        if (attribute instanceof  OddSearchAttribute) {
327:                            searchRows = ((OddSearchAttribute) attribute)
328:                                    .getSearchRows();
329:                        } else {
330:                            searchRows = attribute.getRuleRows();
331:                        }
332:                        for (Iterator iterator = searchRows.iterator(); iterator
333:                                .hasNext();) {
334:                            Row row = (Row) iterator.next();
335:                            List fields = new ArrayList();
336:                            for (Iterator iterator2 = row.getFields()
337:                                    .iterator(); iterator2.hasNext();) {
338:                                Field field = (Field) iterator2.next();
339:                                if (request.getParameter(field
340:                                        .getPropertyName()) != null) {
341:                                    field.setPropertyValue(request
342:                                            .getParameter(field
343:                                                    .getPropertyName()));
344:                                }
345:                                fields.add(field);
346:                                fieldValues.put(field.getPropertyName(), field
347:                                        .getPropertyValue());
348:                            }
349:                            row.setFields(fields);
350:                            rows.add(row);
351:
352:                        }
353:
354:                        if (attribute.getRuleRows() != null) {
355:                            for (Iterator iterator = attribute.getRuleRows()
356:                                    .iterator(); iterator.hasNext();) {
357:                                Row row = (Row) iterator.next();
358:                                for (Iterator iterator2 = row.getFields()
359:                                        .iterator(); iterator2.hasNext();) {
360:                                    Field field = (Field) iterator2.next();
361:                                    if (field.getFieldType().equals(Field.TEXT)
362:                                            || field.getFieldType().equals(
363:                                                    Field.DROPDOWN)
364:                                            || field.getFieldType().equals(
365:                                                    Field.DROPDOWN_REFRESH)
366:                                            || field.getFieldType().equals(
367:                                                    Field.RADIO)) {
368:                                        getColumns()
369:                                                .add(
370:                                                        i + 6,
371:                                                        new Column(
372:                                                                field
373:                                                                        .getFieldLabel(),
374:                                                                Column.COLUMN_IS_SORTABLE_VALUE,
375:                                                                "myColumns.columns["
376:                                                                        + i
377:                                                                        + "].label"));
378:                                        i++;
379:                                    }
380:                                }
381:                            }
382:                        }
383:                    }
384:
385:                    return true;
386:                }
387:                return false;
388:            }
389:
390:            public void changeIdToName(Map fieldValues) {
391:                String ruleTemplateIdParam = (String) fieldValues
392:                        .get(RULE_TEMPLATE_ID_PROPERTY_NAME);
393:                String ruleTemplateNameParam = (String) fieldValues
394:                        .get(RULE_TEMPLATE_PROPERTY_NAME);
395:                String workgroupIdParam = (String) fieldValues
396:                        .get(WORKGROUP_ID_PROPERTY_NAME);
397:                String workgroupNameParam = (String) fieldValues
398:                        .get(WORKGROUP_PROPERTY_NAME);
399:
400:                if (workgroupNameParam != null
401:                        && !workgroupNameParam.trim().equals("")
402:                        || workgroupIdParam != null
403:                        && !"".equals(workgroupIdParam)
404:                        && !"null".equals(workgroupIdParam)) {
405:                    Workgroup workgroup = null;
406:                    if (workgroupIdParam != null
407:                            && !"".equals(workgroupIdParam)) {
408:                        workgroup = getWorkgroupService().getWorkgroup(
409:                                new WorkflowGroupId(new Long(workgroupIdParam
410:                                        .trim())));
411:                    } else {
412:                        workgroup = getWorkgroupService().getWorkgroup(
413:                                new GroupNameId(workgroupNameParam.trim()));
414:                    }
415:                    if (workgroup != null) {
416:                        setFieldValue(WORKGROUP_PROPERTY_NAME, workgroup
417:                                .getGroupNameId().getNameId());
418:                    }
419:                } else {
420:                    setFieldValue(WORKGROUP_PROPERTY_NAME, "");
421:                }
422:
423:                if (ruleTemplateNameParam != null
424:                        && !ruleTemplateNameParam.trim().equals("")
425:                        || ruleTemplateIdParam != null
426:                        && !"".equals(ruleTemplateIdParam)
427:                        && !"null".equals(ruleTemplateIdParam)) {
428:                    RuleTemplate ruleTemplate = null;
429:                    if (ruleTemplateIdParam != null
430:                            && !"".equals(ruleTemplateIdParam)) {
431:                        ruleTemplate = getRuleTemplateService()
432:                                .findByRuleTemplateId(
433:                                        new Long(ruleTemplateIdParam));
434:                    } else {
435:                        ruleTemplate = getRuleTemplateService()
436:                                .findByRuleTemplateName(
437:                                        ruleTemplateNameParam.trim());
438:                    }
439:                    if (ruleTemplate != null) {
440:                        setFieldValue(RULE_TEMPLATE_PROPERTY_NAME, ruleTemplate
441:                                .getName());
442:                    }
443:                } else {
444:                    setFieldValue(RULE_TEMPLATE_PROPERTY_NAME, "");
445:                }
446:            }
447:
448:            /**
449:             * getSearchResults - searches for a RuleBaseValues information based on the criteria passed in by the map.
450:             *
451:             * @return Returns a list of RuleBaseValues objects that match the result.
452:             */
453:            public List getSearchResults(Map fieldValues, Map fieldConversions)
454:                    throws Exception {
455:                List errors = new ArrayList();
456:
457:                String docTypeNameParam = (String) fieldValues
458:                        .get(DOC_TYP_NAME_PROPERTY_NAME);
459:                String ruleTemplateIdParam = (String) fieldValues
460:                        .get(RULE_TEMPLATE_ID_PROPERTY_NAME);
461:                String ruleTemplateNameParam = (String) fieldValues
462:                        .get(RULE_TEMPLATE_PROPERTY_NAME);
463:                String workgroupIdParam = (String) fieldValues
464:                        .get(WORKGROUP_ID_PROPERTY_NAME);
465:                String workgroupNameParam = (String) fieldValues
466:                        .get(WORKGROUP_PROPERTY_NAME);
467:                String networkIdParam = (String) fieldValues
468:                        .get(PERSON_PROPERTY_NAME);
469:                String roleNameParam = (String) fieldValues
470:                        .get(ROLE_PROPERTY_NAME);
471:                String activeParam = (String) fieldValues
472:                        .get(ACTIVE_IND_PROPERTY_NAME);
473:                String delegateRuleParam = (String) fieldValues
474:                        .get(DELEGATE_RULE_PROPERTY_NAME);
475:                String ruleIdParam = (String) fieldValues
476:                        .get(RULE_ID_PROPERTY_NAME);
477:                String delegationWizard = (String) fieldValues
478:                        .get(EdenConstants.DELEGATION_WIZARD);
479:                String ruleDescription = (String) fieldValues
480:                        .get(RULE_DESC_PROPERTY_NAME);
481:
482:                String ruleBaseValueIdReturn = (String) fieldConversions
483:                        .get(RULE_ID_PROPERTY_NAME);
484:                String ruleDelegationOnly = (String) fieldValues
485:                        .get(RULE_DELEGATE_ONLY_PROPERTY_NAME);
486:
487:                String docTypeSearchName = null;
488:                String workflowId = null;
489:                Long workgroupId = null;
490:                Long ruleTemplateId = null;
491:                Boolean isDelegateRule = null;
492:                Boolean isActive = null;
493:                Long ruleId = null;
494:
495:                if (!delegateRuleParam.equals("ALL")) {
496:                    isDelegateRule = new Boolean(delegateRuleParam);
497:                }
498:
499:                if (ruleIdParam != null && !"".equals(ruleIdParam.trim())) {
500:                    try {
501:                        ruleId = new Long(ruleIdParam.trim());
502:                    } catch (NumberFormatException e) {
503:                        ruleId = new Long(-1);
504:                    }
505:                }
506:
507:                if (!activeParam.equals("ALL")) {
508:                    isActive = new Boolean(activeParam);
509:                }
510:
511:                if (docTypeNameParam != null
512:                        && !"".equals(docTypeNameParam.trim())) {
513:                    docTypeSearchName = docTypeNameParam.replace('*', '%');
514:                    docTypeSearchName = "%" + docTypeSearchName.trim() + "%";
515:                }
516:
517:                if (workgroupNameParam != null
518:                        && !workgroupNameParam.trim().equals("")
519:                        || workgroupIdParam != null
520:                        && !"".equals(workgroupIdParam)
521:                        && !"null".equals(workgroupIdParam)) {
522:                    Workgroup workgroup = null;
523:                    if (workgroupIdParam != null
524:                            && !"".equals(workgroupIdParam)) {
525:                        workgroupId = new Long(workgroupIdParam.trim());
526:                        workgroup = getWorkgroupService().getWorkgroup(
527:                                new WorkflowGroupId(workgroupId));
528:                    } else {
529:                        workgroup = getWorkgroupService().getWorkgroup(
530:                                new GroupNameId(workgroupNameParam.trim()));
531:                        if (workgroup == null) {
532:                            errors
533:                                    .add(new WorkflowServiceErrorImpl(
534:                                            "Document Type Invalid",
535:                                            "routetemplate.ruleservice.workgroup.invalid"));
536:                        } else {
537:                            workgroupId = new Long(workgroup
538:                                    .getWorkflowGroupId().getGroupId()
539:                                    .longValue());
540:                        }
541:                    }
542:                }
543:                Map attributes = null;
544:                MyColumns myColumns = new MyColumns();
545:                if (ruleTemplateNameParam != null
546:                        && !ruleTemplateNameParam.trim().equals("")
547:                        || ruleTemplateIdParam != null
548:                        && !"".equals(ruleTemplateIdParam)
549:                        && !"null".equals(ruleTemplateIdParam)) {
550:                    RuleTemplate ruleTemplate = null;
551:                    if (ruleTemplateIdParam != null
552:                            && !"".equals(ruleTemplateIdParam)) {
553:                        ruleTemplateId = new Long(ruleTemplateIdParam);
554:                        ruleTemplate = getRuleTemplateService()
555:                                .findByRuleTemplateId(ruleTemplateId);
556:                    } else {
557:                        ruleTemplate = getRuleTemplateService()
558:                                .findByRuleTemplateName(
559:                                        ruleTemplateNameParam.trim());
560:                        ruleTemplateId = new Long(ruleTemplate
561:                                .getRuleTemplateId().longValue());
562:                    }
563:
564:                    attributes = new HashMap();
565:                    for (Iterator iter = ruleTemplate
566:                            .getRuleTemplateAttributes().iterator(); iter
567:                            .hasNext();) {
568:                        RuleTemplateAttribute ruleTemplateAttribute = (RuleTemplateAttribute) iter
569:                                .next();
570:                        if (!ruleTemplateAttribute.isWorkflowAttribute()) {
571:                            continue;
572:                        }
573:                        WorkflowAttribute attribute = (WorkflowAttribute) GlobalResourceLoader
574:                                .getObject(new ObjectDefinition(
575:                                        ruleTemplateAttribute
576:                                                .getRuleAttribute()
577:                                                .getClassName(),
578:                                        ruleTemplateAttribute
579:                                                .getRuleAttribute()
580:                                                .getMessageEntity()));//SpringServiceLocator.getExtensionService().getWorkflowAttribute(ruleTemplateAttribute.getRuleAttribute().getClassName());
581:                        RuleAttribute ruleAttribute = ruleTemplateAttribute
582:                                .getRuleAttribute();
583:                        if (ruleAttribute.getType().equals(
584:                                EdenConstants.RULE_XML_ATTRIBUTE_TYPE)) {
585:                            ((GenericXMLRuleAttribute) attribute)
586:                                    .setRuleAttribute(ruleAttribute);
587:                        }
588:                        attribute.setRequired(false);
589:                        List searchRows = null;
590:                        if (attribute instanceof  OddSearchAttribute) {
591:                            errors.addAll(((OddSearchAttribute) attribute)
592:                                    .validateSearchData(fieldValues));
593:                            searchRows = ((OddSearchAttribute) attribute)
594:                                    .getSearchRows();
595:                        } else {
596:                            errors.addAll(attribute
597:                                    .validateRuleData(fieldValues));
598:                            searchRows = attribute.getRuleRows();
599:                        }
600:                        for (Iterator iterator = searchRows.iterator(); iterator
601:                                .hasNext();) {
602:                            Row row = (Row) iterator.next();
603:                            for (Iterator iterator2 = row.getFields()
604:                                    .iterator(); iterator2.hasNext();) {
605:                                Field field = (Field) iterator2.next();
606:                                if (fieldValues.get(field.getPropertyName()) != null) {
607:                                    String attributeParam = (String) fieldValues
608:                                            .get(field.getPropertyName());
609:                                    if (!attributeParam.equals("")) {
610:                                        if (ruleAttribute
611:                                                .getType()
612:                                                .equals(
613:                                                        EdenConstants.RULE_XML_ATTRIBUTE_TYPE)) {
614:                                            attributes.put(field
615:                                                    .getPropertyName(),
616:                                                    attributeParam.trim());
617:                                        } else if (!Utilities.isEmpty(field
618:                                                .getDefaultLookupableName())) {
619:                                            attributes
620:                                                    .put(
621:                                                            field
622:                                                                    .getDefaultLookupableName(),
623:                                                            attributeParam
624:                                                                    .trim());
625:                                        } else {
626:                                            attributes.put(field
627:                                                    .getPropertyName(),
628:                                                    attributeParam.trim());
629:                                        }
630:                                    }
631:                                }
632:                                if (field.getFieldType().equals(Field.TEXT)
633:                                        || field.getFieldType().equals(
634:                                                Field.DROPDOWN)
635:                                        || field.getFieldType().equals(
636:                                                Field.DROPDOWN_REFRESH)
637:                                        || field.getFieldType().equals(
638:                                                Field.RADIO)) {
639:                                    if (ruleAttribute
640:                                            .getType()
641:                                            .equals(
642:                                                    EdenConstants.RULE_XML_ATTRIBUTE_TYPE)) {
643:                                        myColumns
644:                                                .getColumns()
645:                                                .add(
646:                                                        new KeyLabelPair(
647:                                                                field
648:                                                                        .getPropertyName(),
649:                                                                ruleTemplateAttribute
650:                                                                        .getRuleTemplateAttributeId()
651:                                                                        + ""));
652:                                    } else if (!Utilities.isEmpty(field
653:                                            .getDefaultLookupableName())) {
654:                                        myColumns
655:                                                .getColumns()
656:                                                .add(
657:                                                        new KeyLabelPair(
658:                                                                field
659:                                                                        .getDefaultLookupableName(),
660:                                                                ruleTemplateAttribute
661:                                                                        .getRuleTemplateAttributeId()
662:                                                                        + ""));
663:                                    } else {
664:                                        myColumns
665:                                                .getColumns()
666:                                                .add(
667:                                                        new KeyLabelPair(
668:                                                                field
669:                                                                        .getPropertyName(),
670:                                                                ruleTemplateAttribute
671:                                                                        .getRuleTemplateAttributeId()
672:                                                                        + ""));
673:                                    }
674:                                }
675:                            }
676:                        }
677:                    }
678:                }
679:
680:                if (networkIdParam != null && !"".equals(networkIdParam.trim())) {
681:                    try {
682:                        WorkflowUser user = getUserService()
683:                                .getWorkflowUser(
684:                                        new AuthenticationUserId(networkIdParam
685:                                                .trim()));
686:                        workflowId = user.getWorkflowUserId().getWorkflowId();
687:                    } catch (EdenUserNotFoundException e) {
688:                        errors.add(new WorkflowServiceErrorImpl("User Invalid",
689:                                "routetemplate.ruleservice.user.invalid"));
690:                    }
691:                }
692:                if (roleNameParam != null && !"".equals(roleNameParam)) {
693:                    roleNameParam = roleNameParam.replace('*', '%');
694:                    roleNameParam = "%" + roleNameParam.trim() + "%";
695:                }
696:
697:                if (!Utilities.isEmpty(ruleDescription)) {
698:                    ruleDescription = ruleDescription.replace('*', '%');
699:                    ruleDescription = "%" + ruleDescription.trim() + "%";
700:                }
701:
702:                if (!errors.isEmpty()) {
703:                    throw new WorkflowServiceErrorException(
704:                            "RuleBaseValues validation errors", errors);
705:                }
706:
707:                Iterator rules = getRuleService().search(docTypeSearchName,
708:                        ruleId, ruleTemplateId, ruleDescription, workgroupId,
709:                        workflowId, roleNameParam, isDelegateRule, isActive,
710:                        attributes).iterator();
711:                List displayList = new ArrayList();
712:
713:                while (rules.hasNext()) {
714:                    RuleBaseValues record = (RuleBaseValues) rules.next();
715:
716:                    if (Utilities.isEmpty(record.getDescription())) {
717:                        record
718:                                .setDescription(EdenConstants.HTML_NON_BREAKING_SPACE);
719:                    }
720:
721:                    if (ruleTemplateNameParam != null
722:                            && !ruleTemplateNameParam.trim().equals("")
723:                            || ruleTemplateIdParam != null
724:                            && !"".equals(ruleTemplateIdParam)
725:                            && !"null".equals(ruleTemplateIdParam)) {
726:                        MyColumns myNewColumns = new MyColumns();
727:                        for (Iterator iter = myColumns.getColumns().iterator(); iter
728:                                .hasNext();) {
729:                            KeyLabelPair pair = (KeyLabelPair) iter.next();
730:                            KeyLabelPair newPair = new KeyLabelPair();
731:                            newPair.setKey(pair.getKey());
732:                            if (record.getRuleExtensionValue(new Long(pair
733:                                    .getLabel()), pair.getKey().toString()) != null) {
734:                                newPair.setLabel(record.getRuleExtensionValue(
735:                                        new Long(pair.getLabel()),
736:                                        pair.getKey().toString()).getValue());
737:                            } else {
738:                                newPair
739:                                        .setLabel(EdenConstants.HTML_NON_BREAKING_SPACE);
740:                            }
741:                            myNewColumns.getColumns().add(newPair);
742:                        }
743:                        record.setMyColumns(myNewColumns);
744:                    }
745:
746:                    StringBuffer returnUrl = new StringBuffer("<a href=\"");
747:                    returnUrl.append(fieldValues.get(BACK_LOCATION)).append(
748:                            "?methodToCall=refresh&docFormKey=").append(
749:                            fieldValues.get(DOC_FORM_KEY)).append("&");
750:                    if (!Utilities.isEmpty(ruleBaseValueIdReturn)) {
751:                        returnUrl.append(ruleBaseValueIdReturn);
752:                    } else {
753:                        returnUrl.append(RULE_ID_PROPERTY_NAME);
754:                    }
755:                    returnUrl.append("=").append(record.getRuleBaseValuesId())
756:                            .append("\">return value</a>");
757:                    record.setReturnUrl(returnUrl.toString());
758:
759:                    Boolean isDelegationWizardry = new Boolean(delegationWizard);
760:                    String destinationUrl = "<a href=\"Rule.do?methodToCall=report&currentRuleId="
761:                            + record.getRuleBaseValuesId() + "\">report</a> |";
762:                    if (!isDelegationWizardry.booleanValue()) {
763:                        destinationUrl += " <a href=\"Rule.do?methodToCall=edit&currentRuleId="
764:                                + record.getRuleBaseValuesId() + "\" >edit</a>";
765:                    } else {
766:                        destinationUrl += " <a href=\"DelegateRule.do?methodToCall=start"
767:                                + "&parentRule.getDocTypeName="
768:                                + record.getDocTypeName();
769:                        if (record.getRuleTemplate().getDelegationTemplateId() != null) {
770:                            destinationUrl += "&ruleCreationValues.ruleTemplateId="
771:                                    + record.getRuleTemplate()
772:                                            .getDelegationTemplateId();
773:                        }
774:                        if (record.getRuleTemplate().getDelegationTemplate() != null) {
775:                            destinationUrl += "&ruleCreationValues.ruleTemplateName="
776:                                    + record.getRuleTemplate()
777:                                            .getDelegationTemplate().getName();
778:                        }
779:                        destinationUrl += "&ruleCreationValues.ruleId="
780:                                + record.getRuleBaseValuesId() + "\" >next</a>";
781:                    }
782:                    record.setDestinationUrl(destinationUrl);
783:                    if (!Utilities.isEmpty(ruleDelegationOnly)
784:                            && ruleDelegationOnly.equals("true")) {
785:                        if (record.getRuleTemplate() != null
786:                                && record.getRuleTemplate()
787:                                        .getDelegationTemplate() != null) {
788:                            displayList.add(record);
789:                        }
790:                    } else {
791:                        displayList.add(record);
792:                    }
793:                }
794:                return displayList;
795:            }
796:
797:            public List getDefaultReturnType() {
798:                List returnTypes = new ArrayList();
799:                returnTypes.add(RULE_ID_PROPERTY_NAME);
800:                return returnTypes;
801:            }
802:
803:            public String getLookupInstructions() {
804:                return Utilities
805:                        .getApplicationConstant(EdenConstants.RULE_SEARCH_INSTRUCTION_KEY);
806:            }
807:
808:            public String getNoReturnParams(Map fieldConversions) {
809:                String ruleBaseValueIdReturn = (String) fieldConversions
810:                        .get(RULE_ID_PROPERTY_NAME);
811:                StringBuffer noReturnParams = new StringBuffer("&");
812:                if (!Utilities.isEmpty(ruleBaseValueIdReturn)) {
813:                    noReturnParams.append(ruleBaseValueIdReturn);
814:                } else {
815:                    noReturnParams.append(RULE_ID_PROPERTY_NAME);
816:                }
817:                noReturnParams.append("=");
818:
819:                return noReturnParams.toString();
820:            }
821:
822:            public String getTitle() {
823:                return title;
824:            }
825:
826:            public String getReturnLocation() {
827:                return returnLocation;
828:            }
829:
830:            public List getColumns() {
831:                return columns;
832:            }
833:
834:            public String getHtmlMenuBar() {
835:                String menuBar = "<a href=\"Rule.do\" >Create new Rule</a>";
836:                menuBar += " | <a href=\"DelegateRule.do\">Create Delegation</a>";
837:                return menuBar;
838:            }
839:
840:            public List getRows() {
841:                return rows;
842:            }
843:
844:            public ExportDataSet export(ExportFormat format,
845:                    Object exportCriteria) throws Exception {
846:                List searchResults = (List) exportCriteria;
847:                ExportDataSet dataSet = new ExportDataSet(format);
848:                dataSet.getRules().addAll(searchResults);
849:                return dataSet;
850:            }
851:
852:            public List getSupportedExportFormats() {
853:                return EdenConstants.STANDARD_FORMATS;
854:            }
855:
856:            private RuleTemplateService getRuleTemplateService() {
857:                return (RuleTemplateService) KEWServiceLocator
858:                        .getService(KEWServiceLocator.RULE_TEMPLATE_SERVICE);
859:            }
860:
861:            private WorkgroupService getWorkgroupService() {
862:                return (WorkgroupService) KEWServiceLocator
863:                        .getService(KEWServiceLocator.WORKGROUP_SRV);
864:            }
865:
866:            private UserService getUserService() {
867:                return (UserService) KEWServiceLocator
868:                        .getService(KEWServiceLocator.USER_SERVICE);
869:            }
870:
871:            private RuleService getRuleService() {
872:                return (RuleService) KEWServiceLocator
873:                        .getService(KEWServiceLocator.RULE_SERVICE);
874:            }
875:
876:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.