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