View Javadoc

1   /**
2    * Copyright 2005-2013 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.util.ArrayList;
19  import java.util.Collections;
20  import java.util.List;
21  
22  import org.kuali.rice.core.api.data.DataType;
23  import org.kuali.rice.core.api.uif.RemotableAttributeError;
24  import org.kuali.rice.core.api.uif.RemotableAttributeField;
25  import org.kuali.rice.kew.api.document.DocumentWithContent;
26  import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
27  import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory;
28  import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition;
29  import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
30  import org.kuali.rice.kew.api.extension.ExtensionDefinition;
31  import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute;
32  
33  public class TestXMLSearchableAttributeString implements SearchableAttribute {
34  
35      private static final long serialVersionUID = 7069672825797402460L;
36  
37      public static final String SEARCH_STORAGE_KEY = "givenname";
38      public static final String SEARCH_STORAGE_VALUE = "jack";
39  
40      @Override
41      public String generateSearchContent(ExtensionDefinition extensionDefinition,
42              String documentTypeName,
43              WorkflowAttributeDefinition attributeDefinition) {
44          return "TestXMLSearchableAttributeString";
45      }
46  
47      @Override
48      public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition,
49              DocumentWithContent documentWithContent) {
50          List<DocumentAttribute> savs = new ArrayList<DocumentAttribute>();
51          savs.add(DocumentAttributeFactory.createStringAttribute(SEARCH_STORAGE_KEY, SEARCH_STORAGE_VALUE));
52          return savs;
53      }
54  
55      @Override
56      public List<RemotableAttributeField> getSearchFields(ExtensionDefinition extensionDefinition,
57              String documentTypeName) {
58          List<RemotableAttributeField> fields = new ArrayList<RemotableAttributeField>();
59          RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create(SEARCH_STORAGE_KEY);
60          builder.setLongLabel("title");
61          builder.setDataType(DataType.STRING);
62  		fields.add(builder.build());
63          return fields;
64      }
65  
66      @Override
67      public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition,
68              DocumentSearchCriteria documentSearchCriteria) {
69          return Collections.emptyList();
70      }
71  
72  }