Source Code Cross Referenced for MatrixValidator.java in  » ERP-CRM-Financial » sakai » org » theospi » portfolio » matrix » control » 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 » sakai » org.theospi.portfolio.matrix.control 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/matrix/tool/src/java/org/theospi/portfolio/matrix/control/MatrixValidator.java $
003:         * $Id: MatrixValidator.java 21737 2007-02-19 20:25:58Z chmaurer@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2005, 2006, 2007 The Sakai Foundation.
007:         *
008:         * Licensed under the Educational Community License, Version 1.0 (the "License");
009:         * you may not use this file except in compliance with the License.
010:         * You may obtain a copy of the License at
011:         *
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         *
014:         * Unless required by applicable law or agreed to in writing, software
015:         * distributed under the License is distributed on an "AS IS" BASIS,
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:         * See the License for the specific language governing permissions and
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.theospi.portfolio.matrix.control;
021:
022:        import org.sakaiproject.metaobj.security.AuthenticationManager;
023:        import org.springframework.validation.Errors;
024:        import org.theospi.portfolio.matrix.model.CriterionTransport;
025:        import org.theospi.portfolio.matrix.model.LevelTransport;
026:        import org.theospi.portfolio.matrix.model.Scaffolding;
027:        import org.theospi.portfolio.matrix.model.ScaffoldingCell;
028:        import org.theospi.portfolio.matrix.model.ScaffoldingUploadForm;
029:        import org.theospi.utils.mvc.impl.ValidatorBase;
030:
031:        /**
032:         * Created by IntelliJ IDEA.
033:         * User: John Ellis
034:         * Date: Apr 23, 2004
035:         * Time: 2:37:33 PM
036:         * To change this template use File | Settings | File Templates.
037:         */
038:        public class MatrixValidator extends ValidatorBase {
039:
040:            private AuthenticationManager authManager;
041:
042:            /**
043:             * Return whether or not this object can validate objects
044:             * of the given class.
045:             */
046:            public boolean supports(Class clazz) {
047:                if (MatrixFormBean.class.isAssignableFrom(clazz))
048:                    return true;
049:                else if (ScaffoldingUploadForm.class.isAssignableFrom(clazz))
050:                    return true;
051:                else if (Scaffolding.class.isAssignableFrom(clazz))
052:                    return true;
053:                else if (ScaffoldingCell.class.isAssignableFrom(clazz))
054:                    return true;
055:                else if (LevelTransport.class.isAssignableFrom(clazz))
056:                    return true;
057:                else if (CriterionTransport.class.isAssignableFrom(clazz))
058:                    return true;
059:                else if (CellAndNodeForm.class.isAssignableFrom(clazz))
060:                    return true;
061:                else if (MatrixGridBean.class.isAssignableFrom(clazz))
062:                    return true;
063:                else
064:                    return false;
065:            }
066:
067:            /**
068:             * Validate a presentation object, which must be of a class for which
069:             * the supports() method returned true.
070:             *
071:             * @param obj    Populated object to validate
072:             * @param errors Errors object we're building. May contain
073:             *               errors for this field relating to types.
074:             */
075:            public void validate(Object obj, Errors errors) {
076:                //if (obj instanceof ScaffoldingUploadForm) 
077:                //   validateScaffoldingImport((ScaffoldingUploadForm)obj, errors);
078:                if (obj instanceof  CriterionTransport)
079:                    validateCriterion((CriterionTransport) obj, errors);
080:                else if (obj instanceof  LevelTransport)
081:                    validateLevel((LevelTransport) obj, errors);
082:                else if (obj instanceof  Scaffolding) {
083:                    Scaffolding scaffolding = (Scaffolding) obj;
084:                    if (scaffolding.isValidate())
085:                        validateScaffolding(scaffolding, errors);
086:                } else if (obj instanceof  ScaffoldingCell) {
087:                    ScaffoldingCell scaffoldingCell = (ScaffoldingCell) obj;
088:                    if (scaffoldingCell.isValidate())
089:                        validateScaffoldingCell(scaffoldingCell, errors);
090:                } else if (obj instanceof  CellAndNodeForm)
091:                    validateCellAttachment((CellAndNodeForm) obj, errors);
092:                else if (obj instanceof  MatrixGridBean)
093:                    validateScaffolding(
094:                            ((MatrixGridBean) obj).getScaffolding(), errors);
095:            }
096:
097:            /* 
098:             private void validateScaffoldingImport(ScaffoldingUploadForm obj, Errors errors) {
099:                RepositoryNode node = (RepositoryNode)getRepositoryManager().getRootNode(getAuthManager().getAgent());
100:                if (node.hasChild(obj.getDisplayName())) {
101:                   errors.rejectValue("displayName", "duplicate", "duplicate");
102:                }
103:                if (!obj.getUploadedScaffoldingForm().getContentType().equals("text/xml")) {
104:                   errors.rejectValue("uploadedScaffoldingForm", "invalid file", "invalid file");
105:                }
106:             }
107:             */
108:
109:            protected void validateCellAttachment(CellAndNodeForm form,
110:                    Errors errors) {
111:                if (form.getNode_id() == null || form.getNode_id().equals("")) {
112:                    errors.rejectValue("node_id", "error.required", "required");
113:                }
114:            }
115:
116:            protected void validateScaffoldingCell(
117:                    ScaffoldingCell scaffoldingCell, Errors errors) {
118:                if (scaffoldingCell.getInitialStatus() == null
119:                        || scaffoldingCell.getInitialStatus().equals("")) {
120:                    errors.rejectValue("initialStatus", "error.required",
121:                            "required");
122:                }
123:                if (scaffoldingCell.getTitle() == null
124:                        || scaffoldingCell.getTitle().trim().equals("")) {
125:                    errors.rejectValue("title", "error.required", "required");
126:                }
127:            }
128:
129:            protected void validateCriterion(CriterionTransport criterion,
130:                    Errors errors) {
131:                if (criterion.getDescription() == null
132:                        || criterion.getDescription().trim().equals("")) {
133:                    errors.rejectValue("description", "error.required",
134:                            "required");
135:                }
136:            }
137:
138:            protected void validateLevel(LevelTransport level, Errors errors) {
139:                if (level.getDescription() == null
140:                        || level.getDescription().trim().equals("")) {
141:                    errors.rejectValue("description", "error.required",
142:                            "required");
143:                }
144:            }
145:
146:            protected void validateScaffolding(Scaffolding scaffolding,
147:                    Errors errors) {
148:                if (scaffolding.getTitle() == null
149:                        || scaffolding.getTitle().trim().equals("")) {
150:                    errors.rejectValue("title", "error.required", "required");
151:                }
152:                if (scaffolding.getLevels() == null
153:                        || scaffolding.getLevels().size() == 0) {
154:                    errors.rejectValue("levels", "error.required", "required");
155:                }
156:                if (scaffolding.getCriteria() == null
157:                        || scaffolding.getCriteria().size() == 0) {
158:                    errors
159:                            .rejectValue("criteria", "error.required",
160:                                    "required");
161:                }
162:            }
163:
164:            /*
165:            private String stripHtml(String input) {
166:               return input.replaceAll("<[\\w/]+[^<>]*>", "");     
167:            }
168:             */
169:            /**
170:             * @return Returns the authManager.
171:             */
172:            public AuthenticationManager getAuthManager() {
173:                return authManager;
174:            }
175:
176:            /**
177:             * @param authManager The authManager to set.
178:             */
179:            public void setAuthManager(AuthenticationManager authManager) {
180:                this.authManager = authManager;
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.