Source Code Cross Referenced for ParameterEvaluatorImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » kfs » service » impl » 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.kfs.service.impl 
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 org.kuali.kfs.service.impl;
017:
018:        import java.util.List;
019:
020:        import org.kuali.core.bo.Parameter;
021:        import org.kuali.core.service.DataDictionaryService;
022:        import org.kuali.core.util.GlobalVariables;
023:        import org.kuali.kfs.KFSKeyConstants;
024:        import org.kuali.kfs.context.SpringContext;
025:        import org.kuali.kfs.service.ParameterEvaluator;
026:
027:        public class ParameterEvaluatorImpl implements  ParameterEvaluator {
028:            private Parameter parameter;
029:            private boolean constraintIsAllow;
030:            private String constrainedValue;
031:            private List<String> values;
032:
033:            /**
034:             * If the constraint is allow and the constrainedValue is in the list of allowed values specified by the parameter this will
035:             * return true, and if the constraint is deny and the constrainedValue is not in the list of denied values specified by the
036:             * parameter this method will return true.
037:             * 
038:             * @return boolean indicating whether the constrained value adheres to the restriction specified by the combination of the
039:             *         parameter constraint and the parameter value
040:             */
041:            public boolean evaluationSucceeds() {
042:                if (constraintIsAllow()) {
043:                    return values.contains(constrainedValue);
044:                } else {
045:                    return !values.contains(constrainedValue);
046:                }
047:            }
048:
049:            /**
050:             * @see org.kuali.kfs.service.ParameterEvaluator#evaluateAndAddError(java.lang.Class businessObjectOrDocumentClass,
051:             *      java.lang.String constrainedPropertyName)
052:             */
053:            public boolean evaluateAndAddError(
054:                    Class businessObjectOrDocumentClass,
055:                    String constrainedPropertyName) {
056:                return evaluateAndAddError(businessObjectOrDocumentClass,
057:                        constrainedPropertyName, constrainedPropertyName);
058:            }
059:
060:            /**
061:             * This method uses the evaluationSucceeds method to evaluate the constrainedValue. If evaluation does not succeed, it adds an
062:             * error to GlobalVariables.getErrorMap(). The businessObjectOrDocumentClass, nameOfConstrainedProperty and
063:             * userEditablePropertyName are used to retrieve the appropriate labels from the DataDictionary.
064:             * 
065:             * @param businessObjectOrDocumentClass
066:             * @param userEditableFieldToHighlight
067:             * @param nameOfconstrainedProperty
068:             * @return boolean indicating whether evaluation succeeded (see evaluationSucceeds)
069:             */
070:            public boolean evaluateAndAddError(
071:                    Class businessObjectOrDocumentClass,
072:                    String constrainedPropertyName,
073:                    String userEditablePropertyName) {
074:                if (!evaluationSucceeds()) {
075:                    GlobalVariables
076:                            .getErrorMap()
077:                            .putError(
078:                                    userEditablePropertyName,
079:                                    KFSKeyConstants.ERROR_DOCUMENT_INVALID_VALUE,
080:                                    new String[] {
081:                                            SpringContext
082:                                                    .getBean(
083:                                                            DataDictionaryService.class)
084:                                                    .getAttributeLabel(
085:                                                            businessObjectOrDocumentClass,
086:                                                            constrainedPropertyName),
087:                                            constrainedValue,
088:                                            toStringForMessage(),
089:                                            constraintIsAllow() ? "allowed"
090:                                                    : "not allowed",
091:                                            getParameterValuesForMessage(),
092:                                            SpringContext
093:                                                    .getBean(
094:                                                            DataDictionaryService.class)
095:                                                    .getAttributeLabel(
096:                                                            businessObjectOrDocumentClass,
097:                                                            userEditablePropertyName) });
098:                    return false;
099:                }
100:                return true;
101:            }
102:
103:            /**
104:             * @see org.kuali.kfs.service.ParameterEvaluator#constraintIsAllow()
105:             */
106:            public boolean constraintIsAllow() {
107:                return constraintIsAllow;
108:            }
109:
110:            /**
111:             * This method uses the List toString method and eliminates the [].
112:             * 
113:             * @return user-friendly String representation of Parameter values
114:             */
115:            public String getParameterValuesForMessage() {
116:                return values.toString().replace("[", "").replace("]", "");
117:            }
118:
119:            /**
120:             * @see org.kuali.kfs.service.ParameterEvaluator#getValue()
121:             */
122:            public String getValue() {
123:                return parameter.getParameterValue();
124:            }
125:
126:            public String toString() {
127:                return new StringBuffer("ParameterEvaluator").append(
128:                        "\n\tParameter: ").append("module=").append(
129:                        parameter.getParameterNamespaceCode()).append(
130:                        ", component=").append(
131:                        parameter.getParameterDetailTypeCode()).append(
132:                        ", name=").append(parameter.getParameterName()).append(
133:                        ", value=").append(parameter.getParameterValue())
134:                        .append("\n\tConstraint Is Allow: ").append(
135:                                constraintIsAllow).append(
136:                                "\n\tConstrained Value: ").append(
137:                                constrainedValue).append("\n\tValues: ")
138:                        .append(values.toString()).toString();
139:            }
140:
141:            private String toStringForMessage() {
142:                return new StringBuffer("parameter ").append(
143:                        parameter.getParameterName()).append(" (module: ")
144:                        .append(parameter.getParameterNamespaceCode()).append(
145:                                " / component: ").append(
146:                                parameter.getParameterDetailTypeCode()).append(
147:                                ")").toString();
148:            }
149:
150:            private String getModuleAndComponent() {
151:                return parameter.getParameterNamespaceCode() + ": "
152:                        + parameter.getParameterDetailTypeCode();
153:            }
154:
155:            public void setConstrainedValue(String constrainedValue) {
156:                this .constrainedValue = constrainedValue;
157:            }
158:
159:            public void setConstraintIsAllow(boolean constraintIsAllow) {
160:                this .constraintIsAllow = constraintIsAllow;
161:            }
162:
163:            public void setParameter(Parameter parameter) {
164:                this .parameter = parameter;
165:            }
166:
167:            public void setValues(List<String> values) {
168:                this.values = values;
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.