Source Code Cross Referenced for CustomSearchAttributesTest.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.util.Arrays;
020:        import java.util.Iterator;
021:        import java.util.List;
022:
023:        import org.junit.Test;
024:        import org.kuali.workflow.test.WorkflowTestCase;
025:
026:        import edu.iu.uis.eden.KEWServiceLocator;
027:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
028:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
029:        import edu.iu.uis.eden.clientapp.vo.WorkflowAttributeDefinitionVO;
030:        import edu.iu.uis.eden.docsearch.xml.DocumentSearchXMLResultProcessor;
031:        import edu.iu.uis.eden.docsearch.xml.DocumentSearchXMLResultProcessorImpl;
032:        import edu.iu.uis.eden.doctype.DocumentType;
033:        import edu.iu.uis.eden.doctype.DocumentTypeService;
034:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
035:        import edu.iu.uis.eden.lookupable.Column;
036:        import edu.iu.uis.eden.lookupable.Field;
037:        import edu.iu.uis.eden.lookupable.Row;
038:        import edu.iu.uis.eden.routetemplate.RuleAttribute;
039:        import edu.iu.uis.eden.user.AuthenticationUserId;
040:        import edu.iu.uis.eden.user.UserService;
041:        import edu.iu.uis.eden.user.WorkflowUser;
042:        import edu.iu.uis.eden.util.ClassLoaderUtils;
043:
044:        /**
045:         *
046:         * @author delyea
047:         */
048:        public class CustomSearchAttributesTest extends WorkflowTestCase {
049:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
050:                    .getLogger(CustomSearchAttributesTest.class);
051:
052:            protected void loadTestData() throws Exception {
053:                loadXmlFile("SearchAttributeConfig.xml");
054:            }
055:
056:            private SearchAttributeCriteriaComponent createSearchAttributeCriteriaComponent(
057:                    String key, String value, DocumentType docType) {
058:                SearchAttributeCriteriaComponent sacc = new SearchAttributeCriteriaComponent(
059:                        key, value, key);
060:                Field field = getFieldByFormKey(docType, key);
061:                if (field != null) {
062:                    sacc.setSearchableAttributeValue(DocSearchUtils
063:                            .getSearchableAttributeValueByDataTypeString(field
064:                                    .getFieldDataType()));
065:                    sacc.setRangeSearch(field.isMemberOfRange());
066:                    sacc.setAllowWildcards(field.isAllowingWildcards());
067:                    sacc.setAutoWildcardBeginning(field
068:                            .isAutoWildcardAtBeginning());
069:                    sacc.setAutoWildcardEnd(field.isAutoWildcardAtEnding());
070:                    sacc.setCaseSensitive(field.isCaseSensitive());
071:                    sacc.setSearchInclusive(field.isInclusive());
072:                    sacc.setSearchable(field.isSearchable());
073:                    sacc.setCanHoldMultipleValues(Field.MULTI_VALUE_FIELD_TYPES
074:                            .contains(field.getFieldType()));
075:                }
076:                return sacc;
077:            }
078:
079:            private Field getFieldByFormKey(DocumentType docType, String formKey) {
080:                if (docType == null) {
081:                    return null;
082:                }
083:                for (SearchableAttribute searchableAttribute : docType
084:                        .getSearchableAttributes()) {
085:                    for (Row row : searchableAttribute.getSearchingRows()) {
086:                        for (Field field : row.getFields()) {
087:                            if (field.getPropertyName().equals(formKey)) {
088:                                return field;
089:                            }
090:                        }
091:                    }
092:                }
093:                return null;
094:            }
095:
096:            @Test
097:            public void testCustomDocumentSearchGeneratorUse() throws Exception {
098:                DocumentType docType = ((DocumentTypeService) KEWServiceLocator
099:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
100:                        .findByName("SearchDocType");
101:                assertTrue(
102:                        "The document search Generator class should be of type CustomDocumentSearchGenerator",
103:                        (ClassLoaderUtils.unwrapFromProxy(docType
104:                                .getDocumentSearchGenerator()) instanceof  StandardDocumentSearchGenerator));
105:                docType = ((DocumentTypeService) KEWServiceLocator
106:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
107:                        .findByName("SearchDocType_DefaultCustomProcessor");
108:                LOG
109:                        .error("testCustomDocumentSearchGeneratorUse() Class name is "
110:                                + docType.getDocumentSearchGenerator()
111:                                        .getClass().getName());
112:                assertTrue(
113:                        "The document search Generator class should be of type CustomDocumentSearchGenerator",
114:                        (ClassLoaderUtils.unwrapFromProxy(docType
115:                                .getDocumentSearchGenerator()) instanceof  CustomDocumentSearchGenerator));
116:            }
117:
118:            @Test
119:            public void testCustomDocumentSearchResultProcessorOverrideUse()
120:                    throws Exception {
121:                DocumentType docType = ((DocumentTypeService) KEWServiceLocator
122:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
123:                        .findByName("SearchDocType");
124:                assertTrue(
125:                        "The document search processor class should be of type StandardDocumentSearchResultProcessor",
126:                        (ClassLoaderUtils.unwrapFromProxy(docType
127:                                .getDocumentSearchResultProcessor()) instanceof  StandardDocumentSearchResultProcessor));
128:
129:                docType = ((DocumentTypeService) KEWServiceLocator
130:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
131:                        .findByName("SearchDocType_DefaultCustomProcessor");
132:                assertTrue(
133:                        "The document search processor class should be of type DocumentSearchXMLResultProcessorImpl",
134:                        (ClassLoaderUtils.unwrapFromProxy(docType
135:                                .getDocumentSearchResultProcessor()) instanceof  DocumentSearchXMLResultProcessorImpl));
136:
137:                docType = ((DocumentTypeService) KEWServiceLocator
138:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
139:                        .findByName("SearchDocType2");
140:                assertTrue(
141:                        "The document search processor class should be of type CustomSearchResultProcessor",
142:                        (ClassLoaderUtils.unwrapFromProxy(docType
143:                                .getDocumentSearchResultProcessor()) instanceof  CustomSearchResultProcessor));
144:            }
145:
146:            @Test
147:            public void testSearchXMLResultProcessorFunction() throws Exception {
148:                RuleAttribute ruleAttribute = KEWServiceLocator
149:                        .getRuleAttributeService().findByName(
150:                                "XMLResultProcessorDetails");
151:                DocumentSearchXMLResultProcessorImpl docSearchResult = new DocumentSearchXMLResultProcessorImpl();
152:                docSearchResult.setRuleAttribute(ruleAttribute);
153:
154:                List<Column> columns = docSearchResult
155:                        .getCustomDisplayColumns();
156:                for (Iterator iter = columns.iterator(); iter.hasNext();) {
157:                    Column column = (Column) iter.next();
158:                    if (DocumentSearchResult.PROPERTY_NAME_DOC_TYPE_LABEL
159:                            .equals(column.getKey())) {
160:                        assertEquals(
161:                                "Attribute xml is not populating column 'sortable' value correctly",
162:                                "true", column.getSortable());
163:                        assertEquals(
164:                                "Attribute xml is not populating column 'title' value correctly",
165:                                "", column.getColumnTitle());
166:                    } else if (DocumentSearchResult.PROPERTY_NAME_DOCUMENT_TITLE
167:                            .equals(column.getKey())) {
168:                        assertEquals(
169:                                "Attribute xml is not populating column 'sortable' value correctly",
170:                                "false", column.getSortable());
171:                        assertEquals(
172:                                "Attribute xml is not populating column 'title' value correctly",
173:                                null, column.getColumnTitle());
174:                    } else if (DocumentSearchResult.PROPERTY_NAME_INITIATOR
175:                            .equals(column.getKey())) {
176:                        assertEquals(
177:                                "Attribute xml is not populating column 'sortable' value correctly",
178:                                null, column.getSortable());
179:                        assertEquals(
180:                                "Attribute xml is not populating column 'title' value correctly",
181:                                "Initiator Dude", column.getColumnTitle());
182:                    } else if (DocumentSearchResult.PROPERTY_NAME_ROUTE_STATUS_DESC
183:                            .equals(column.getKey())) {
184:                        assertEquals(
185:                                "Attribute xml is not populating column 'sortable' value correctly",
186:                                null, column.getSortable());
187:                        assertEquals(
188:                                "Attribute xml is not populating column 'title' value correctly",
189:                                null, column.getColumnTitle());
190:                    } else if (TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY
191:                            .equals(column.getKey())) {
192:                        assertEquals(
193:                                "Attribute xml is not populating column 'sortable' value correctly",
194:                                "false", column.getSortable());
195:                        assertEquals(
196:                                "Attribute xml is not populating column 'title' value correctly",
197:                                null, column.getColumnTitle());
198:                    } else {
199:                        fail("Key value of custom column should never be anything except already checked values but is '"
200:                                + column.getKey() + "'");
201:                    }
202:                }
203:
204:                assertEquals(
205:                        "Value of 'show all standard fields' should be default",
206:                        DocumentSearchXMLResultProcessor.DEFAULT_SHOW_ALL_STANDARD_FIELDS_VALUE,
207:                        docSearchResult.getShowAllStandardFields());
208:                assertEquals(
209:                        "Value of 'override searchable attributes' should be default",
210:                        DocumentSearchXMLResultProcessor.DEFAULT_OVERRIDE_SEARCHABLE_ATTRIBUTES_VALUE,
211:                        docSearchResult.getOverrideSearchableAttributes());
212:            }
213:
214:            private DocumentSearchResultComponents performSearch(
215:                    String documentTypeName, String userNetworkId)
216:                    throws EdenUserNotFoundException {
217:                DocumentType docType = ((DocumentTypeService) KEWServiceLocator
218:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
219:                        .findByName(documentTypeName);
220:                DocumentSearchService docSearchService = (DocumentSearchService) KEWServiceLocator
221:                        .getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);
222:                UserService userService = (UserService) KEWServiceLocator
223:                        .getService(KEWServiceLocator.USER_SERVICE);
224:                WorkflowUser user = userService
225:                        .getWorkflowUser(new AuthenticationUserId(userNetworkId));
226:
227:                DocSearchCriteriaVO criteria = new DocSearchCriteriaVO();
228:                criteria.setDocTypeFullName(documentTypeName);
229:                criteria
230:                        .addSearchableAttribute(createSearchAttributeCriteriaComponent(
231:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
232:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE,
233:                                docType));
234:                return docSearchService.getList(user, criteria);
235:            }
236:
237:            private void parseList(List<Column> columns,
238:                    List<String> columnsRequired, List<String> columnsNotAllowed) {
239:                // check to see if column should be excluded but is not
240:                for (Iterator iterator = columnsNotAllowed.iterator(); iterator
241:                        .hasNext();) {
242:                    String disallowedColumnKey = (String) iterator.next();
243:                    for (Iterator iter = columns.iterator(); iter.hasNext();) {
244:                        Column currentColumn = (Column) iter.next();
245:                        if (disallowedColumnKey.equals(currentColumn.getKey())) {
246:                            fail("The column with key '"
247:                                    + currentColumn.getKey()
248:                                    + "' should not be in the list of columns to be displayed but was");
249:                        }
250:                    }
251:                }
252:
253:                // check to see if column should be in list but is not
254:                for (int i = 0; i < columnsRequired.size(); i++) {
255:                    String requiredColumnKey = columnsRequired.get(i);
256:                    Column testColumn = columns.get(i);
257:                    if (!(requiredColumnKey.equals(testColumn.getKey()))) {
258:                        fail("The column with key '"
259:                                + requiredColumnKey
260:                                + "' should be in the list of columns to be displayed (at location "
261:                                + i + ") but was not");
262:                    }
263:                }
264:            }
265:
266:            @Test
267:            public void testCustomDocumentSearchXMLResultProcessor()
268:                    throws Exception {
269:                String searchableAttributeKey_Shown = "givenname";
270:                String searchableAttributeKey_Hidden = "givenname_hidden";
271:                /*    - test showAllStandard = *blank* && overrideSearchAtt = *blank* (default way of doing search) - XMLResultProcessorDefault
272:                 *        - search attr xml hidden && search proc attr shown = shown
273:                 *        - search attr xml shown && search proc attr hidden = hidden
274:                 *        - standard fields = hidden 
275:                 */
276:                String documentTypeName = "SearchDocType_DefaultCustomProcessor";
277:                String userNetworkId = "rkirkend";
278:                DocumentSearchResultComponents result = performSearch(
279:                        documentTypeName, userNetworkId);
280:                /*  columns that should be shown
281:                 *    - routeHeaderId
282:                 *    - doctypelabel
283:                 *    - givenname_hidden
284:                 *    - doc title
285:                 *    - init
286:                 *    - docroutestat
287:                 *    - routeLog
288:                 *    
289:                 *  columns that should not be shown
290:                 *    - givenname
291:                 *    - create date
292:                 */
293:                parseList(
294:                        result.getColumns(),
295:                        Arrays
296:                                .asList(new String[] {
297:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID,
298:                                        DocumentSearchResult.PROPERTY_NAME_DOC_TYPE_LABEL,
299:                                        searchableAttributeKey_Hidden,
300:                                        DocumentSearchResult.PROPERTY_NAME_DOCUMENT_TITLE,
301:                                        DocumentSearchResult.PROPERTY_NAME_INITIATOR,
302:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_STATUS_DESC,
303:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_LOG }),
304:                        Arrays
305:                                .asList(new String[] {
306:                                        DocumentSearchResult.PROPERTY_NAME_DATE_CREATED,
307:                                        searchableAttributeKey_Shown }));
308:
309:                /*    - test showAllStandard = false && overrideSearchAtt = true - XMLResultProcessorAllCustom
310:                 *        - search attr xml hidden && search proc attr shown = shown
311:                 *        - search attr xml shown && search proc attr hidden = hidden
312:                 *        - standard fields = hidden 
313:                 */
314:                documentTypeName = "SearchDocType_AllCustomProcessor";
315:                result = performSearch(documentTypeName, userNetworkId);
316:                /*  columns that should be shown
317:                 *    - routeHeaderId
318:                 *    - doctypelabel
319:                 *    - doc title
320:                 *    - init
321:                 *    - givenname_hidden
322:                 *    - docroutestat
323:                 *    - routeLog
324:                 *    
325:                 *  columns that should not be shown
326:                 *    - givenname
327:                 *    - create date
328:                 */
329:                parseList(
330:                        result.getColumns(),
331:                        Arrays
332:                                .asList(new String[] {
333:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID,
334:                                        DocumentSearchResult.PROPERTY_NAME_DOC_TYPE_LABEL,
335:                                        DocumentSearchResult.PROPERTY_NAME_DOCUMENT_TITLE,
336:                                        DocumentSearchResult.PROPERTY_NAME_INITIATOR,
337:                                        searchableAttributeKey_Hidden,
338:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_STATUS_DESC,
339:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_LOG }),
340:                        Arrays
341:                                .asList(new String[] {
342:                                        DocumentSearchResult.PROPERTY_NAME_DATE_CREATED,
343:                                        searchableAttributeKey_Shown }));
344:
345:                /*    - test showAllStandard = true && overrideSearchAtt = true - XMLResultProcessorSearchAttributeCustom
346:                 *        - search attr xml hidden && search proc attr shown = shown
347:                 *        - search attr xml shown && search proc attr hidden = hidden
348:                 *        - standard fields = shown 
349:                 *        - check order with standard fields before search fields
350:                 */
351:                documentTypeName = "SearchDocType_SearchAttCustomProcessor";
352:                result = performSearch(documentTypeName, userNetworkId);
353:                /*  columns that should be shown
354:                 *    - routeHeaderId
355:                 *    - docTypeLabel
356:                 *    - documentTitle
357:                 *    - docRouteStatusCodeDesc
358:                 *    - initiator
359:                 *    - dateCreated
360:                 *    - givenname_hidden
361:                 *    - routeLog
362:                 *    
363:                 *  columns that should not be shown
364:                 *    - givenname
365:                 */
366:                parseList(result.getColumns(), Arrays.asList(new String[] {
367:                        DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID,
368:                        DocumentSearchResult.PROPERTY_NAME_DOC_TYPE_LABEL,
369:                        DocumentSearchResult.PROPERTY_NAME_DOCUMENT_TITLE,
370:                        DocumentSearchResult.PROPERTY_NAME_ROUTE_STATUS_DESC,
371:                        DocumentSearchResult.PROPERTY_NAME_INITIATOR,
372:                        DocumentSearchResult.PROPERTY_NAME_DATE_CREATED,
373:                        searchableAttributeKey_Hidden,
374:                        DocumentSearchResult.PROPERTY_NAME_ROUTE_LOG }), Arrays
375:                        .asList(new String[] { searchableAttributeKey_Shown }));
376:
377:                /*    - test showAllStandard = false && overrideSearchAtt = false - XMLResultProcessorStandardCustom
378:                 *        - search attr xml hidden && search proc attr show = hidden
379:                 *        - search attr xml shown && search proc attr hidden = shown
380:                 *        - standard fields = hidden 
381:                 *        - check order with search fields after custom standard fields
382:                 */
383:                documentTypeName = "SearchDocType_StandardCustomProcessor";
384:                result = performSearch(documentTypeName, userNetworkId);
385:                /*  columns that should be shown
386:                 *    - routeHeaderId
387:                 *    - doc title
388:                 *    - doctypelabel
389:                 *    - docroutestat
390:                 *    - init
391:                 *    - givenname
392:                 *    - routeLog
393:                 *    
394:                 *  columns that should not be shown
395:                 *    - givenname_hidden
396:                 *    - create date
397:                 */
398:                parseList(
399:                        result.getColumns(),
400:                        Arrays
401:                                .asList(new String[] {
402:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID,
403:                                        DocumentSearchResult.PROPERTY_NAME_DOCUMENT_TITLE,
404:                                        DocumentSearchResult.PROPERTY_NAME_DOC_TYPE_LABEL,
405:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_STATUS_DESC,
406:                                        DocumentSearchResult.PROPERTY_NAME_INITIATOR,
407:                                        searchableAttributeKey_Shown,
408:                                        DocumentSearchResult.PROPERTY_NAME_ROUTE_LOG }),
409:                        Arrays
410:                                .asList(new String[] {
411:                                        DocumentSearchResult.PROPERTY_NAME_DATE_CREATED,
412:                                        searchableAttributeKey_Hidden }));
413:
414:                /*    - test showAllStandard = true && overrideSearchAtt = false (default way of doing search) - XMLResultProcessorNormalCustom
415:                 *        - search attr xml hidden && search proc attr show = hidden
416:                 *        - search attr xml shown && search proc attr hidden = shown
417:                 *        - standard fields = shown 
418:                 *        - check order with standard fields before search fields
419:                 */
420:                documentTypeName = "SearchDocType_NormalCustomProcessor";
421:                result = performSearch(documentTypeName, userNetworkId);
422:                /*  columns that should be shown
423:                 *    - routeHeaderId
424:                 *    - docTypeLabel
425:                 *    - documentTitle
426:                 *    - docRouteStatusCodeDesc
427:                 *    - initiator
428:                 *    - dateCreated
429:                 *    - givenname
430:                 *    - routeLog
431:                 *    
432:                 *  columns that should not be shown
433:                 *    - givenname_hidden
434:                 */
435:                parseList(result.getColumns(), Arrays.asList(new String[] {
436:                        DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID,
437:                        DocumentSearchResult.PROPERTY_NAME_DOC_TYPE_LABEL,
438:                        DocumentSearchResult.PROPERTY_NAME_DOCUMENT_TITLE,
439:                        DocumentSearchResult.PROPERTY_NAME_ROUTE_STATUS_DESC,
440:                        DocumentSearchResult.PROPERTY_NAME_INITIATOR,
441:                        DocumentSearchResult.PROPERTY_NAME_DATE_CREATED,
442:                        searchableAttributeKey_Shown,
443:                        DocumentSearchResult.PROPERTY_NAME_ROUTE_LOG }), Arrays
444:                        .asList(new String[] { searchableAttributeKey_Hidden }));
445:            }
446:
447:            /**
448:             * Tests function of adding extra document type names to search including using searchable attributes
449:             * that may or may not exist on all the document type names being searched on.
450:             * 
451:             * @throws Exception
452:             */
453:            @Test
454:            public void testSearchOnExtraDocType() throws Exception {
455:                String userNetworkId = "rkirkend";
456:                DocumentSearchService docSearchService = (DocumentSearchService) KEWServiceLocator
457:                        .getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);
458:                UserService userService = (UserService) KEWServiceLocator
459:                        .getService(KEWServiceLocator.USER_SERVICE);
460:                WorkflowUser user = userService
461:                        .getWorkflowUser(new AuthenticationUserId(userNetworkId));
462:
463:                String documentTypeName1 = "SearchDocType_DefaultCustomProcessor";
464:                WorkflowDocument workDoc_Matching1 = new WorkflowDocument(
465:                        new NetworkIdVO(userNetworkId), documentTypeName1);
466:                DocumentType docType1 = ((DocumentTypeService) KEWServiceLocator
467:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
468:                        .findByName(documentTypeName1);
469:                WorkflowAttributeDefinitionVO stringXMLDef1 = new WorkflowAttributeDefinitionVO(
470:                        "SearchableAttributeVisible");
471:                stringXMLDef1.addProperty(
472:                        TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
473:                        TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE);
474:                workDoc_Matching1.addSearchableDefinition(stringXMLDef1);
475:                workDoc_Matching1.routeDocument("");
476:
477:                String documentTypeName2 = "SearchDocType_DefaultCustomProcessor_2";
478:                WorkflowDocument workDoc_Matching2 = new WorkflowDocument(
479:                        new NetworkIdVO(userNetworkId), documentTypeName2);
480:                DocumentType docType2 = ((DocumentTypeService) KEWServiceLocator
481:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
482:                        .findByName(documentTypeName2);
483:                WorkflowAttributeDefinitionVO stringXMLDef2 = new WorkflowAttributeDefinitionVO(
484:                        "SearchableAttributeVisible");
485:                stringXMLDef2.addProperty(
486:                        TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
487:                        TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE);
488:                workDoc_Matching2.addSearchableDefinition(stringXMLDef2);
489:                workDoc_Matching2.routeDocument("");
490:
491:                // do search with attribute using doc type 1... make sure both docs are returned
492:                DocSearchCriteriaVO criteria = new DocSearchCriteriaVO();
493:                criteria.setDocTypeFullName(documentTypeName1);
494:                criteria
495:                        .addSearchableAttribute(createSearchAttributeCriteriaComponent(
496:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
497:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE,
498:                                docType1));
499:                DocumentSearchResultComponents result = docSearchService
500:                        .getList(user, criteria);
501:                assertEquals("Search results should have one document.", 2,
502:                        result.getSearchResults().size());
503:
504:                // do search with attribute using doc type 2... make sure both docs are returned
505:                criteria = new DocSearchCriteriaVO();
506:                criteria.setDocTypeFullName(documentTypeName2);
507:                criteria
508:                        .addSearchableAttribute(createSearchAttributeCriteriaComponent(
509:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
510:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE,
511:                                docType2));
512:                result = docSearchService.getList(user, criteria);
513:                assertEquals("Search results should have one document.", 2,
514:                        result.getSearchResults().size());
515:
516:                // do search without attribute using doc type 1... make sure both docs are returned
517:                criteria = new DocSearchCriteriaVO();
518:                criteria.setDocTypeFullName(documentTypeName1);
519:                result = docSearchService.getList(user, criteria);
520:                assertEquals("Search results should have one document.", 2,
521:                        result.getSearchResults().size());
522:
523:                // do search without attribute using doc type 2... make sure both docs are returned
524:                criteria = new DocSearchCriteriaVO();
525:                criteria.setDocTypeFullName(documentTypeName2);
526:                result = docSearchService.getList(user, criteria);
527:                assertEquals("Search results should have one document.", 2,
528:                        result.getSearchResults().size());
529:
530:                String documentTypeName3 = "SearchDocType_DefaultCustomProcessor_3";
531:                WorkflowDocument workDoc_Matching3 = new WorkflowDocument(
532:                        new NetworkIdVO(userNetworkId), documentTypeName3);
533:                DocumentType docType3 = ((DocumentTypeService) KEWServiceLocator
534:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE))
535:                        .findByName(documentTypeName3);
536:                WorkflowAttributeDefinitionVO stringXMLDef3 = new WorkflowAttributeDefinitionVO(
537:                        "SearchableAttributeVisible");
538:                stringXMLDef3.addProperty(
539:                        TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
540:                        TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE);
541:                workDoc_Matching3.addSearchableDefinition(stringXMLDef3);
542:                workDoc_Matching3.routeDocument("");
543:
544:                // do search with attribute using doc type 3... make sure 1 doc is returned
545:                criteria = new DocSearchCriteriaVO();
546:                criteria.setDocTypeFullName(documentTypeName3);
547:                criteria
548:                        .addSearchableAttribute(createSearchAttributeCriteriaComponent(
549:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
550:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE,
551:                                docType3));
552:                result = docSearchService.getList(user, criteria);
553:                assertEquals("Search results should have one document.", 1,
554:                        result.getSearchResults().size());
555:
556:                // do search without attribute using doc type 3... make sure 1 doc is returned
557:                criteria = new DocSearchCriteriaVO();
558:                criteria.setDocTypeFullName(documentTypeName3);
559:                result = docSearchService.getList(user, criteria);
560:                assertEquals("Search results should have one document.", 1,
561:                        result.getSearchResults().size());
562:
563:                WorkflowDocument workDoc_NonMatching2 = new WorkflowDocument(
564:                        new NetworkIdVO(userNetworkId), documentTypeName2);
565:                WorkflowAttributeDefinitionVO stringXMLDef1a = new WorkflowAttributeDefinitionVO(
566:                        "SearchableAttributeVisible");
567:                // TODO delyea - adding underscore below invalidates via REGEX but doesn't blow up on route or addSearchable?
568:                String searchAttributeValue = TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE
569:                        + "nonMatching";
570:                stringXMLDef1a.addProperty(
571:                        TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
572:                        searchAttributeValue);
573:                workDoc_NonMatching2.addSearchableDefinition(stringXMLDef1a);
574:                workDoc_NonMatching2.routeDocument("");
575:
576:                // do search with attribute using doc type 1... make sure 1 doc is returned
577:                criteria = new DocSearchCriteriaVO();
578:                criteria.setDocTypeFullName(documentTypeName1);
579:                criteria
580:                        .addSearchableAttribute(createSearchAttributeCriteriaComponent(
581:                                TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY,
582:                                searchAttributeValue, docType1));
583:                result = docSearchService.getList(user, criteria);
584:                assertEquals("Search results should have one document.", 1,
585:                        result.getSearchResults().size());
586:
587:                // do search without attribute using doc type 1... make sure all 3 docs are returned
588:                criteria = new DocSearchCriteriaVO();
589:                criteria.setDocTypeFullName(documentTypeName1);
590:                result = docSearchService.getList(user, criteria);
591:                assertEquals("Search results should have one document.", 3,
592:                        result.getSearchResults().size());
593:            }
594:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.