Source Code Cross Referenced for AccountAttribute.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.List;
021:
022:        import javax.xml.namespace.QName;
023:        import javax.xml.xpath.XPath;
024:        import javax.xml.xpath.XPathConstants;
025:        import javax.xml.xpath.XPathExpressionException;
026:
027:        import org.kuali.core.workflow.WorkflowUtils;
028:        import org.kuali.rice.KNSServiceLocator;
029:        import org.w3c.dom.Node;
030:        import org.w3c.dom.NodeList;
031:
032:        import edu.iu.uis.eden.Id;
033:        import edu.iu.uis.eden.engine.RouteContext;
034:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
035:        import edu.iu.uis.eden.routeheader.DocumentContent;
036:        import edu.iu.uis.eden.routetemplate.AbstractRoleAttribute;
037:        import edu.iu.uis.eden.routetemplate.ResolvedQualifiedRole;
038:        import edu.iu.uis.eden.routetemplate.Role;
039:        import edu.iu.uis.eden.user.AuthenticationUserId;
040:        import edu.sampleu.travel.bo.TravelAccount;
041:
042:        /**
043:         * Resolves FO's using the accounts associated with the document XPath xpath =
044:         * KualiWorkflowUtils.getXPath(documentContent.getDocument()); List<String> qualifiers = new ArrayList<String>(); NodeList
045:         * accountNums = (NodeList)xstreamSafeEval(xpath, "//edu.sampleu.travel.workflow.bo.TravelAccount/number",
046:         * documentContent.getDocument(), XPathConstants.NODESET); for (int i = 0; i < accountNums.getLength(); i++) { Node accountNum =
047:         * accountNums.item(i); String accuntNumVal = accountNum.getNodeValue(); }
048:         */
049:        public class AccountAttribute extends AbstractRoleAttribute {
050:            private static final Role FISCAL_OFFICER_ROLE = new Role(
051:                    AccountAttribute.class, "FO", "Fiscal Officer");
052:            private static final List<Role> ROLES;
053:            static {
054:                List<Role> tmp = new ArrayList<Role>(1);
055:                tmp.add(FISCAL_OFFICER_ROLE);
056:                ROLES = Collections.unmodifiableList(tmp);
057:            }
058:
059:            public List<String> getQualifiedRoleNames(String roleName,
060:                    DocumentContent documentContent)
061:                    throws EdenUserNotFoundException {
062:                List<String> qualifiedRoleNames = new ArrayList<String>();
063:                XPath xpath = WorkflowUtils.getXPath(documentContent
064:                        .getDocument());
065:                NodeList accountNums = (NodeList) xstreamSafeEval(
066:                        xpath,
067:                        "/documentContent/applicationContent/org.kuali.core.workflow.KualiDocumentXmlMaterializer/document/travelAccounts/vector/default/elementData/edu.sampleu.travel.workflow.bo.TravelAccount/number",
068:                        documentContent.getDocument(), XPathConstants.NODESET);
069:                for (int i = 0; i < accountNums.getLength(); i++) {
070:                    Node accountNum = accountNums.item(i);
071:                    String accuntNumVal = accountNum.getTextContent();
072:                    qualifiedRoleNames.add(accuntNumVal);
073:                }
074:                return qualifiedRoleNames;
075:            }
076:
077:            public List<Role> getRoleNames() {
078:                return ROLES;
079:            }
080:
081:            public ResolvedQualifiedRole resolveQualifiedRole(
082:                    RouteContext routeContext, String roleName,
083:                    String qualifiedRole) throws EdenUserNotFoundException {
084:                String accountNum = qualifiedRole;
085:                TravelAccount account = new TravelAccount();
086:                account.setNumber(accountNum);
087:                account = (TravelAccount) KNSServiceLocator
088:                        .getBusinessObjectService().retrieve(account);
089:                if (account == null) {
090:                    throw new RuntimeException("Account " + accountNum
091:                            + " does not exist!");
092:                }
093:                ResolvedQualifiedRole qualRole = new ResolvedQualifiedRole();
094:                qualRole.setAnnotation("Account " + accountNum + " FO");
095:                qualRole.setQualifiedRoleLabel("Fiscal Officer Account "
096:                        + accountNum);
097:                List<Id> ids = new ArrayList<Id>();
098:                ids.add(new AuthenticationUserId(account.getFiscalOfficer()
099:                        .getUserName()));
100:                qualRole.setRecipients(ids);
101:                return qualRole;
102:            }
103:
104:            /**
105:             * This method will do a simple XPath.evaluate, while wrapping your xpathExpression with the xstreamSafe function. It assumes a
106:             * String result, and will return such. If an XPathExpressionException is thrown, this will be re-thrown within a
107:             * RuntimeException.
108:             * 
109:             * @param xpath A correctly initialized XPath instance.
110:             * @param xpathExpression Your XPath Expression that needs to be wrapped in an xstreamSafe wrapper and run.
111:             * @param item The document contents you will be searching within.
112:             * @return The string value of the xpath.evaluate().
113:             */
114:            public static final Object xstreamSafeEval(XPath xpath,
115:                    String xpathExpression, Object item, QName returnType) {
116:                String xstreamSafeXPath = new StringBuilder(
117:                        WorkflowUtils.XSTREAM_SAFE_PREFIX).append(
118:                        xpathExpression).append(
119:                        WorkflowUtils.XSTREAM_SAFE_SUFFIX).toString();
120:                try {
121:                    return xpath.evaluate(xstreamSafeXPath, item, returnType);
122:                } catch (XPathExpressionException e) {
123:                    throw new RuntimeException(
124:                            "XPathExpressionException occurred on xpath: "
125:                                    + xstreamSafeXPath, e);
126:                }
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.