1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.docsearch;
17
18 import java.util.ArrayList;
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.joda.time.DateTime;
23 import org.kuali.rice.core.api.data.DataType;
24 import org.kuali.rice.core.api.uif.RemotableAttributeError;
25 import org.kuali.rice.core.api.uif.RemotableAttributeField;
26 import org.kuali.rice.core.api.uif.RemotableAttributeLookupSettings;
27 import org.kuali.rice.kew.api.document.DocumentWithContent;
28 import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
29 import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory;
30 import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition;
31 import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
32 import org.kuali.rice.kew.api.extension.ExtensionDefinition;
33 import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute;
34
35 public class TestXMLSearchableAttributeDateTime implements SearchableAttribute {
36
37 private static final long serialVersionUID = 1479059967548234181L;
38
39 public static final String SEARCH_STORAGE_KEY = "testDateTimeKey";
40
41
42 public static final Long SEARCH_STORAGE_VALUE_IN_MILLS = (new Long("1173995647000"));
43 public static final DateTime SEARCH_STORAGE_VALUE = new DateTime(SEARCH_STORAGE_VALUE_IN_MILLS.longValue());
44
45 @Override
46 public String generateSearchContent(ExtensionDefinition extensionDefinition,
47 String documentTypeName,
48 WorkflowAttributeDefinition attributeDefinition) {
49 return "TestXMLSearchableAttributeDateTime";
50 }
51
52 @Override
53 public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition,
54 DocumentWithContent documentWithContent) {
55 List<DocumentAttribute> savs = new ArrayList<DocumentAttribute>();
56 savs.add(DocumentAttributeFactory.createDateTimeAttribute(SEARCH_STORAGE_KEY, SEARCH_STORAGE_VALUE));
57 return savs;
58 }
59
60 @Override
61 public List<RemotableAttributeField> getSearchFields(ExtensionDefinition extensionDefinition,
62 String documentTypeName) {
63 List<RemotableAttributeField> fields = new ArrayList<RemotableAttributeField>();
64 RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create(SEARCH_STORAGE_KEY);
65 builder.setLongLabel("title");
66 builder.setDataType(DataType.DATE);
67
68 RemotableAttributeLookupSettings.Builder settings = RemotableAttributeLookupSettings.Builder.create();
69 settings.setRanged(true);
70 settings.setUpperBoundInclusive(false);
71
72
73
74 settings.setInResults(false);
75
76 builder.setAttributeLookupSettings(settings);
77 fields.add(builder.build());
78 return fields;
79 }
80
81 @Override
82 public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition,
83 DocumentSearchCriteria documentSearchCriteria) {
84 return Collections.emptyList();
85 }
86
87 }