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.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 MockSearchableAttribute implements SearchableAttribute {
34  
35      public static final String SEARCH_CONTENT = "<mockContent>MockSearchableAttribute Search Content</mockContent>";
36  
37      @Override
38      public String generateSearchContent(ExtensionDefinition extensionDefinition,
39              String documentTypeName,
40              WorkflowAttributeDefinition attributeDefinition) {
41          return SEARCH_CONTENT;
42      }
43  
44      @Override
45      public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition,
46              DocumentWithContent documentWithContent) {
47          List<DocumentAttribute> savs = new ArrayList<DocumentAttribute>();
48          savs.add(DocumentAttributeFactory.createStringAttribute("MockSearchableAttributeKey", "MockSearchableAttributeValue"));
49          return savs;
50      }
51  
52      @Override
53      public List<RemotableAttributeField> getSearchFields(ExtensionDefinition extensionDefinition,
54              String documentTypeName) {
55          List<RemotableAttributeField> fields = new ArrayList<RemotableAttributeField>();
56          RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create("MockSearchableAttributeKey");
57          builder.setLongLabel("title");
58          builder.setDataType(DataType.STRING);
59  		fields.add(builder.build());
60          return fields;
61      }
62  
63      @Override
64      public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition,
65              DocumentSearchCriteria documentSearchCriteria) {
66          return Collections.emptyList();
67      }
68  
69  }