View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.docsearch;
17  
18  import java.math.BigDecimal;
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
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.kew.api.document.DocumentWithContent;
27  import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
28  import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory;
29  import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition;
30  import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
31  import org.kuali.rice.kew.api.extension.ExtensionDefinition;
32  import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute;
33  
34  public class TestXMLSearchableAttributeFloat implements SearchableAttribute {
35  
36      private static final long serialVersionUID = -2656250483031095594L;
37  
38      public static final String SEARCH_STORAGE_KEY = "testFloatKey";
39      public static final BigDecimal SEARCH_STORAGE_VALUE = new BigDecimal("123456.3456");
40  
41      @Override
42      public String generateSearchContent(ExtensionDefinition extensionDefinition,
43              String documentTypeName,
44              WorkflowAttributeDefinition attributeDefinition) {
45          return "TestXMLSearchableAttributeFloat";
46      }
47  
48      @Override
49      public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition,
50              DocumentWithContent documentWithContent) {
51          List<DocumentAttribute> savs = new ArrayList<DocumentAttribute>();
52          savs.add(DocumentAttributeFactory.createDecimalAttribute(SEARCH_STORAGE_KEY, SEARCH_STORAGE_VALUE));
53          return savs;
54      }
55  
56      @Override
57      public List<RemotableAttributeField> getSearchFields(ExtensionDefinition extensionDefinition,
58              String documentTypeName) {
59          List<RemotableAttributeField> fields = new ArrayList<RemotableAttributeField>();
60          RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create(SEARCH_STORAGE_KEY);
61          builder.setLongLabel("title");
62          builder.setDataType(DataType.DOUBLE);
63  		fields.add(builder.build());
64          return fields;
65      }
66  
67      @Override
68      public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition,
69              DocumentSearchCriteria documentSearchCriteria) {
70          return Collections.emptyList();
71      }
72  
73  }