Source Code Cross Referenced for SearchableAttributeProcessor.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » 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 » edu.iu.uis.eden.docsearch 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         *
004:         *
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         * http://www.opensource.org/licenses/ecl1.php
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.docsearch;
018:
019:        import java.io.StringReader;
020:        import java.util.ArrayList;
021:        import java.util.Iterator;
022:        import java.util.List;
023:
024:        import javax.xml.xpath.XPath;
025:        import javax.xml.xpath.XPathConstants;
026:        import javax.xml.xpath.XPathExpressionException;
027:
028:        import org.apache.log4j.Logger;
029:        import org.xml.sax.InputSource;
030:
031:        import edu.iu.uis.eden.KEWServiceLocator;
032:        import edu.iu.uis.eden.doctype.DocumentType;
033:        import edu.iu.uis.eden.exception.WorkflowRuntimeException;
034:        import edu.iu.uis.eden.routeheader.DocumentRouteHeaderValue;
035:        import edu.iu.uis.eden.routetemplate.xmlrouting.XPathHelper;
036:        import edu.iu.uis.eden.util.Utilities;
037:
038:        /**
039:         * Implementation of {@link SearchableAttributeProcessingService}.
040:         *
041:         * @author rkirkend
042:         */
043:        public class SearchableAttributeProcessor implements 
044:                SearchableAttributeProcessingService {
045:
046:            private static Logger LOG = Logger
047:                    .getLogger(SearchableAttribute.class);
048:
049:            private static final String DONT_INDEX = "doNotExecuteSearchableAttributeIndexing";
050:
051:            public void indexDocument(Long documentId) {
052:                LOG.debug("indexing document " + documentId
053:                        + " for document search");
054:                KEWServiceLocator.getRouteHeaderService().lockRouteHeader(
055:                        documentId, true);
056:                DocumentRouteHeaderValue document = KEWServiceLocator
057:                        .getRouteHeaderService().getRouteHeader(documentId);
058:                try {
059:                    if (shouldIndex(document)) {
060:                        KEWServiceLocator.getRouteHeaderService()
061:                                .clearRouteHeaderSearchValues(document);
062:                        document
063:                                .setSearchableAttributeValues(buildSearchableAttributeValues(
064:                                        document.getDocumentType(), document,
065:                                        document.getDocContent()));
066:                        KEWServiceLocator.getRouteHeaderService()
067:                                .saveRouteHeader(document);
068:                    }
069:                } catch (Exception e) {
070:                    String errorMsg = "Encountered an error when attempting to index searchable attributes, requeuing.";
071:                    LOG.error(errorMsg, e);
072:                    throw new WorkflowRuntimeException(errorMsg, e);
073:                }
074:            }
075:
076:            private List<SearchableAttributeValue> buildSearchableAttributeValues(
077:                    DocumentType docType, DocumentRouteHeaderValue document,
078:                    String docContent) {
079:                List<SearchableAttributeValue> searchableAttributeValues = new ArrayList<SearchableAttributeValue>();
080:
081:                for (Iterator iterator = docType.getSearchableAttributes()
082:                        .iterator(); iterator.hasNext();) {
083:                    SearchableAttribute searchableAttribute = (SearchableAttribute) iterator
084:                            .next();
085:                    List searchStorageValues = searchableAttribute
086:                            .getSearchStorageValues(docContent);
087:                    if (searchStorageValues != null) {
088:                        for (Iterator iterator2 = searchStorageValues
089:                                .iterator(); iterator2.hasNext();) {
090:                            SearchableAttributeValue searchableAttributeValue = (SearchableAttributeValue) iterator2
091:                                    .next();
092:                            searchableAttributeValue.setRouteHeader(document);
093:                            searchableAttributeValues
094:                                    .add(searchableAttributeValue);
095:                        }
096:                    }
097:                }
098:
099:                return searchableAttributeValues;
100:            }
101:
102:            protected boolean shouldIndex(DocumentRouteHeaderValue document)
103:                    throws XPathExpressionException {
104:                XPath xpath = XPathHelper.newXPath();
105:                String documentContent = document.getDocumentContent()
106:                        .getDocumentContent();
107:                if (Utilities.isEmpty(documentContent)) {
108:                    // returning true since the 'do not index' variable does not exist in the doc content xml since there is no doc content xml
109:                    return true;
110:                }
111:                return !(Boolean) xpath.evaluate("//" + DONT_INDEX,
112:                        new InputSource(new StringReader(document
113:                                .getDocumentContent().getDocumentContent())),
114:                        XPathConstants.BOOLEAN);
115:            }
116:
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.