View Javadoc

1   /**
2    * Copyright 2005-2011 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 org.kuali.rice.core.api.uif.DataType;
19  import org.kuali.rice.core.api.uif.RemotableAttributeError;
20  import org.kuali.rice.core.api.uif.RemotableAttributeField;
21  import org.kuali.rice.kew.api.document.DocumentWithContent;
22  import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
23  import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory;
24  import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition;
25  import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
26  import org.kuali.rice.kew.api.extension.ExtensionDefinition;
27  import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute;
28  
29  import java.math.BigInteger;
30  import java.util.ArrayList;
31  import java.util.Collections;
32  import java.util.List;
33  
34  public class TestXMLSearchableAttributeLong implements SearchableAttribute {
35  
36      private static final long serialVersionUID = 1309952222293029643L;
37  
38      public static final String SEARCH_STORAGE_KEY = "testLongKey";
39      public static final BigInteger SEARCH_STORAGE_VALUE = BigInteger.valueOf(123456);
40  
41      @Override
42      public String generateSearchContent(ExtensionDefinition extensionDefinition,
43              String documentTypeName,
44              WorkflowAttributeDefinition attributeDefinition) {
45          return "TestXMLSearchableAttributeLong";
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.createIntegerAttribute(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.INTEGER);
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  }