Source Code Cross Referenced for KualiPayeeTaxIdAttribute.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » workflow » attribute » 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 » org.kuali.workflow.attribute 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-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 org.kuali.workflow.attribute;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collections;
020:        import java.util.List;
021:        import java.util.Map;
022:
023:        import javax.xml.xpath.XPath;
024:        import javax.xml.xpath.XPathExpressionException;
025:
026:        import org.apache.commons.lang.StringUtils;
027:        import org.apache.log4j.Logger;
028:        import org.kuali.core.bo.user.PersonTaxId;
029:        import org.kuali.core.bo.user.UniversalUser;
030:        import org.kuali.core.exceptions.UserNotFoundException;
031:        import org.kuali.core.service.UniversalUserService;
032:        import org.kuali.core.util.FieldUtils;
033:        import org.kuali.core.workflow.attribute.WorkflowLookupableImpl;
034:        import org.kuali.kfs.context.SpringContext;
035:        import org.kuali.module.financial.bo.Payee;
036:        import org.kuali.workflow.KualiWorkflowUtils;
037:
038:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
039:        import edu.iu.uis.eden.doctype.DocumentType;
040:        import edu.iu.uis.eden.lookupable.Field;
041:        import edu.iu.uis.eden.lookupable.Row;
042:        import edu.iu.uis.eden.plugin.attributes.WorkflowAttribute;
043:        import edu.iu.uis.eden.routeheader.DocumentContent;
044:
045:        /**
046:         * This class...
047:         */
048:        public class KualiPayeeTaxIdAttribute implements  WorkflowAttribute {
049:
050:            private static Logger LOG = Logger
051:                    .getLogger(KualiPayeeTaxIdAttribute.class);
052:
053:            private static final String PAYEE_TAX_ID = "taxIdNumber";
054:            private static final String PAYEE_TAX_ID_KEY = "payee_review_tax_id";
055:            private static final String MAINTAINABLE_PREFIX = "//newMaintainableObject/businessObject";
056:            private static final String PAYEE_MAINTENANCE_DOC_TYPE = "KualiPayeeMaintenanceDocument";
057:
058:            private boolean required;
059:            private String payeeTaxId;
060:            private List rows;
061:
062:            /**
063:             * Constructs a KualiPayeeTaxIdAttribute.java.
064:             */
065:            public KualiPayeeTaxIdAttribute() {
066:                rows = new ArrayList();
067:                required = false;
068:
069:                List fields = new ArrayList();
070:                org.kuali.core.web.ui.Field kualiPayeeTaxId;
071:                kualiPayeeTaxId = FieldUtils.getPropertyField(Payee.class,
072:                        PAYEE_TAX_ID, false);
073:                fields.add(new Field(kualiPayeeTaxId.getFieldLabel(),
074:                        KualiWorkflowUtils.getHelpUrl(kualiPayeeTaxId),
075:                        Field.TEXT, true, PAYEE_TAX_ID_KEY, kualiPayeeTaxId
076:                                .getPropertyValue(), kualiPayeeTaxId
077:                                .getFieldValidValues(), WorkflowLookupableImpl
078:                                .getLookupableImplName(Payee.class),
079:                        PAYEE_TAX_ID_KEY));
080:                rows.add(new Row(fields));
081:            }
082:
083:            public KualiPayeeTaxIdAttribute(String payeeTaxId) {
084:                this ();
085:                this .payeeTaxId = payeeTaxId;
086:            }
087:
088:            /**
089:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#isMatch(edu.iu.uis.eden.routeheader.DocumentContent, java.util.List)
090:             */
091:            public boolean isMatch(DocumentContent docContent,
092:                    List ruleExtensions) {
093:
094:                // only Payee Maintenance documents will route on this rule.
095:                DocumentType documentType = docContent.getRouteContext()
096:                        .getDocument().getDocumentType();
097:                if (!PAYEE_MAINTENANCE_DOC_TYPE.equalsIgnoreCase(documentType
098:                        .getName())) {
099:                    return false;
100:                }
101:
102:                // extract the payeeTaxId from the XML doc
103:                String docPayeeTaxId = getPayeeTaxIdFromDocContent(
104:                        documentType, docContent);
105:                if (StringUtils.isBlank(docPayeeTaxId)) {
106:                    return false; // no taxId found, nothing to see here
107:                }
108:
109:                // see if the payeeTaxId is in the DB table
110:                return isTaxIdInEmployeesTable(docPayeeTaxId);
111:            }
112:
113:            /**
114:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#getRuleRows()
115:             */
116:            public List getRuleRows() {
117:                // Since this rule only matches if a value on the PayeeMaintenance document is present
118:                // in the Employees table, there is no UI component to enter matching values.
119:                return Collections.EMPTY_LIST;
120:            }
121:
122:            /**
123:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#getRoutingDataRows()
124:             */
125:            public List getRoutingDataRows() {
126:                return rows;
127:            }
128:
129:            /**
130:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#getDocContent()
131:             */
132:            public String getDocContent() {
133:                return KualiWorkflowUtils.XML_REPORT_DOC_CONTENT_PREFIX
134:                        + "<taxIdNumber>" + this .payeeTaxId + "</taxIdNumber>"
135:                        + KualiWorkflowUtils.XML_REPORT_DOC_CONTENT_SUFFIX;
136:            }
137:
138:            /**
139:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#getRuleExtensionValues()
140:             */
141:            public List getRuleExtensionValues() {
142:                return Collections.EMPTY_LIST;
143:            }
144:
145:            /**
146:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#validateRoutingData(java.util.Map)
147:             */
148:            public List validateRoutingData(Map paramMap) {
149:                List errors = new ArrayList();
150:                this .payeeTaxId = (String) paramMap.get(PAYEE_TAX_ID_KEY);
151:                if (!this .payeeTaxId.matches("[/d]{9}")) {
152:                    errors
153:                            .add(new WorkflowServiceErrorImpl(
154:                                    "Payee TaxID must be exactly nine characters, all numbers.  Do not use dashes or spaces.",
155:                                    ""));
156:                }
157:                return errors;
158:            }
159:
160:            /**
161:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#validateRuleData(java.util.Map)
162:             */
163:            public List validateRuleData(Map paramMap) {
164:                return Collections.EMPTY_LIST;
165:            }
166:
167:            /**
168:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#setRequired(boolean)
169:             */
170:            public void setRequired(boolean required) {
171:                this .required = required;
172:            }
173:
174:            /**
175:             * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#isRequired()
176:             */
177:            public boolean isRequired() {
178:                return required;
179:            }
180:
181:            /**
182:             * Extracts the PayeeTaxId from the document contents passed in.
183:             * 
184:             * @param docType
185:             * @param docContent
186:             * @return
187:             */
188:            protected String getPayeeTaxIdFromDocContent(DocumentType docType,
189:                    DocumentContent docContent) {
190:                String payeeTaxId = "";
191:                XPath xpath = KualiWorkflowUtils.getXPath(docContent
192:                        .getDocument());
193:
194:                // updated to work for the test, a little less typesafe
195:                String xpathExpression = KualiWorkflowUtils.XSTREAM_SAFE_PREFIX
196:                        + MAINTAINABLE_PREFIX
197:                        + "/taxIdNumber"
198:                        + KualiWorkflowUtils.XSTREAM_SAFE_SUFFIX
199:                        + " | /"
200:                        + KualiWorkflowUtils.XML_REPORT_DOC_CONTENT_XPATH_PREFIX
201:                        + "/taxIdNumber";
202:
203:                // extract the payeeTaxId value
204:                try {
205:                    payeeTaxId = xpath.evaluate(xpathExpression, docContent
206:                            .getDocument());
207:                } catch (XPathExpressionException e) {
208:                    throw new RuntimeException(
209:                            "Error evaluating xpath expression ["
210:                                    + xpathExpression
211:                                    + "] to locate PayeeTaxId.", e);
212:                }
213:                return payeeTaxId;
214:            }
215:
216:            /**
217:             * Given the taxId passed in, this method tests whether anyone with that taxId is present in the employees database, and returns
218:             * the result of that search.
219:             * 
220:             * @param payeeTaxId A String containing the payeeTaxId to test for.
221:             * @return True if the payeeTaxId is found for any employee in the system, False otherwise.
222:             */
223:            protected static boolean isTaxIdInEmployeesTable(String payeeTaxId) {
224:                if (StringUtils.isBlank(payeeTaxId)) {
225:                    throw new IllegalArgumentException(
226:                            "A blank or null payeeTaxId parameter has been passed in.");
227:                }
228:                UniversalUser user = null;
229:                try {
230:                    user = SpringContext.getBean(UniversalUserService.class)
231:                            .getUniversalUser(new PersonTaxId(payeeTaxId));
232:                } catch (UserNotFoundException e) {
233:                }
234:                return user != null;
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.