Source Code Cross Referenced for PurApDocumentSearchGenerator.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » workflow » module » purap » docsearch » 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.module.purap.docsearch 
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.workflow.module.purap.docsearch;
017:
018:        import java.util.ArrayList;
019:        import java.util.HashMap;
020:        import java.util.HashSet;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:        import java.util.Set;
025:
026:        import org.kuali.core.bo.user.UniversalUser;
027:        import org.kuali.core.bo.user.UuId;
028:        import org.kuali.core.exceptions.UserNotFoundException;
029:        import org.kuali.core.service.UniversalUserService;
030:        import org.kuali.kfs.context.SpringContext;
031:        import org.kuali.kfs.service.ParameterService;
032:        import org.kuali.kfs.service.impl.ParameterConstants;
033:        import org.kuali.module.purap.PurapParameterConstants;
034:
035:        import edu.iu.uis.eden.WorkflowServiceError;
036:        import edu.iu.uis.eden.docsearch.DocSearchCriteriaVO;
037:        import edu.iu.uis.eden.docsearch.SearchAttributeCriteriaComponent;
038:        import edu.iu.uis.eden.docsearch.StandardDocumentSearchGenerator;
039:        import edu.iu.uis.eden.user.WorkflowUser;
040:
041:        /**
042:         * This class...
043:         */
044:        public abstract class PurApDocumentSearchGenerator extends
045:                StandardDocumentSearchGenerator {
046:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
047:                    .getLogger(PurApDocumentSearchGenerator.class);
048:
049:            private Map<String, SearchAttributeCriteriaComponent> searchComponentsByFormKey;
050:
051:            public Map<String, SearchAttributeCriteriaComponent> getSearchComponentsByFormKey() {
052:                if (searchComponentsByFormKey.isEmpty()) {
053:                    this .generateSearchComponentsByFormKeyMap();
054:                }
055:                return searchComponentsByFormKey;
056:            }
057:
058:            public void setSearchComponentsByFormKey(
059:                    Map<String, SearchAttributeCriteriaComponent> searchComponentsByFormKey) {
060:                this .searchComponentsByFormKey = searchComponentsByFormKey;
061:            }
062:
063:            protected Map generateSearchComponentsByFormKeyMap() {
064:                Map criteriaMap = new HashMap();
065:                for (Iterator iter = getCriteria().getSearchableAttributes()
066:                        .iterator(); iter.hasNext();) {
067:                    SearchAttributeCriteriaComponent component = (SearchAttributeCriteriaComponent) iter
068:                            .next();
069:                    criteriaMap.put(component.getFormKey(), component);
070:                }
071:                this .searchComponentsByFormKey = criteriaMap;
072:                return criteriaMap;
073:            }
074:
075:            public abstract List<String> getSpecificSearchCriteriaFormFieldNames();
076:
077:            public abstract List<String> getGeneralSearchUserRequiredFormFieldNames();
078:
079:            public abstract List<String> getSearchAttributeFormFieldNamesToIgnore();
080:
081:            public abstract String getErrorMessageForNonSpecialUserInvalidCriteria();
082:
083:            public boolean isSpecialAccessSearchUser(WorkflowUser workflowUser) {
084:                String uuid = workflowUser.getUuId().getUuId();
085:                try {
086:                    String searchSpecialAccess = getSpecialAccessSearchUserWorkgroupName();
087:                    UniversalUser currentUser = SpringContext.getBean(
088:                            UniversalUserService.class).getUniversalUser(
089:                            new UuId(uuid));
090:                    return currentUser.isMember(searchSpecialAccess);
091:                } catch (UserNotFoundException e) {
092:                    String errorMessage = "Error attempting to find user with UUID '"
093:                            + uuid + "'";
094:                    LOG.error(errorMessage, e);
095:                    throw new RuntimeException(errorMessage, e);
096:                }
097:            }
098:
099:            public String getSpecialAccessSearchUserWorkgroupName() {
100:                return SpringContext
101:                        .getBean(ParameterService.class)
102:                        .getParameterValue(
103:                                ParameterConstants.PURCHASING_DOCUMENT.class,
104:                                PurapParameterConstants.Workgroups.SEARCH_SPECIAL_ACCESS);
105:            }
106:
107:            /**
108:             * @see edu.iu.uis.eden.docsearch.StandardDocumentSearchGenerator#clearSearch(edu.iu.uis.eden.docsearch.DocSearchCriteriaVO)
109:             */
110:            @Override
111:            public DocSearchCriteriaVO clearSearch(
112:                    DocSearchCriteriaVO searchCriteria) {
113:                DocSearchCriteriaVO docSearchCriteriaVO = new DocSearchCriteriaVO();
114:                docSearchCriteriaVO.setDocTypeFullName(searchCriteria
115:                        .getDocTypeFullName());
116:                return docSearchCriteriaVO;
117:            }
118:
119:            /**
120:             * @see edu.iu.uis.eden.docsearch.StandardDocumentSearchGenerator#performPreSearchConditions(edu.iu.uis.eden.user.WorkflowUser,
121:             *      edu.iu.uis.eden.docsearch.DocSearchCriteriaVO)
122:             */
123:            @Override
124:            public List<WorkflowServiceError> performPreSearchConditions(
125:                    WorkflowUser user, DocSearchCriteriaVO searchCriteria) {
126:                this .setCriteria(searchCriteria);
127:                this .generateSearchComponentsByFormKeyMap();
128:                List<WorkflowServiceError> errors = super 
129:                        .performPreSearchConditions(user, searchCriteria);
130:                if (isStandardCriteriaConsideredEmpty()
131:                        && isSearchAttributeCriteriaConsideredEmpty()) {
132:                    // error out for empty criteria
133:                    addErrorMessageToList(
134:                            errors,
135:                            "The search criteria entered is not sufficient to search for documents of this type.");
136:                }
137:                /*
138:                 * Error out if all of following are true: 1) standard search criteria are empty 2) search criteria does not contain at
139:                 * least one 'specific criteria element' (ie: doc id or purap id) 3) user is not special-access user as defined by each
140:                 * document 4) criteria is missing one or more required criteria elements of a non-special-access user search
141:                 */
142:                else if ((isStandardCriteriaConsideredEmpty())
143:                        && (!isSpecialAccessSearchUser(user))
144:                        && (!containsAllGeneralSearchUserRequiredFields())
145:                        && (!containsOneOrMoreSpecificSearchCriteriaFields())) {
146:                    // error out for non special user with invalid criteria
147:                    addErrorMessageToList(errors,
148:                            getErrorMessageForNonSpecialUserInvalidCriteria());
149:                }
150:                return errors;
151:            }
152:
153:            protected boolean isSearchAttributeCriteriaConsideredEmpty() {
154:                Set<String> formFieldNamesToIgnore = new HashSet(
155:                        getSearchAttributeFormFieldNamesToIgnore());
156:                List<String> formKeyFieldsToUse = new ArrayList<String>();
157:                for (Iterator iter = getSearchComponentsByFormKey().keySet()
158:                        .iterator(); iter.hasNext();) {
159:                    String formKey = (String) iter.next();
160:                    if (formFieldNamesToIgnore.contains(formKey)) {
161:                        continue;
162:                    }
163:                    formKeyFieldsToUse.add(formKey);
164:                }
165:                // returns true if it finds a non-blank attribute with one of the given form key field names
166:                return !this .containsSearchCriteriaForListFormFieldNames(
167:                        formKeyFieldsToUse, false);
168:            }
169:
170:            protected boolean isStandardCriteriaConsideredEmpty() {
171:                return getCriteria().isStandardCriteriaConsideredEmpty(true);
172:            }
173:
174:            protected boolean containsAllGeneralSearchUserRequiredFields() {
175:                return this .containsSearchCriteriaForListFormFieldNames(
176:                        getGeneralSearchUserRequiredFormFieldNames(), true);
177:            }
178:
179:            public boolean containsOneOrMoreSpecificSearchCriteriaFields() {
180:                return this .containsSearchCriteriaForListFormFieldNames(
181:                        getSpecificSearchCriteriaFormFieldNames(), false);
182:            }
183:
184:            private boolean containsSearchCriteriaForListFormFieldNames(
185:                    List<String> listOfFormFieldNames, boolean checkForAllInList) {
186:                for (String formKey : listOfFormFieldNames) {
187:                    SearchAttributeCriteriaComponent component = getSearchComponentsByFormKey()
188:                            .get(formKey);
189:                    if (component == null) {
190:                        throw new RuntimeException(
191:                                "Criteria Component for search using form key '"
192:                                        + formKey
193:                                        + "' cannot be found in search criteria searchable attributes");
194:                    }
195:                    if (component.isNonBlankValueGiven()) {
196:                        if (!checkForAllInList) {
197:                            // checking for at least one element of list that is filled in and we found one
198:                            return true;
199:                        }
200:                    } else {
201:                        if (checkForAllInList) {
202:                            // checking to make sure all list elements are filled in and at least one is not
203:                            return false;
204:                        }
205:                    }
206:                }
207:                if (checkForAllInList) {
208:                    // checking to make sure all list elements are filled in and they are
209:                    return true;
210:                } else {
211:                    // checking for at least one element of list that is filled in and we found none
212:                    return false;
213:                }
214:            }
215:
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.