001/** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kew.docsearch; 017 018import java.util.ArrayList; 019import java.util.Collections; 020import java.util.List; 021 022import org.kuali.rice.core.api.data.DataType; 023import org.kuali.rice.core.api.uif.RemotableAttributeError; 024import org.kuali.rice.core.api.uif.RemotableAttributeField; 025import org.kuali.rice.kew.api.document.DocumentWithContent; 026import org.kuali.rice.kew.api.document.attribute.DocumentAttribute; 027import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory; 028import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition; 029import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria; 030import org.kuali.rice.kew.api.extension.ExtensionDefinition; 031import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute; 032 033public class MockSearchableAttribute implements SearchableAttribute { 034 035 public static final String SEARCH_CONTENT = "<mockContent>MockSearchableAttribute Search Content</mockContent>"; 036 037 @Override 038 public String generateSearchContent(ExtensionDefinition extensionDefinition, 039 String documentTypeName, 040 WorkflowAttributeDefinition attributeDefinition) { 041 return SEARCH_CONTENT; 042 } 043 044 @Override 045 public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, 046 DocumentWithContent documentWithContent) { 047 List<DocumentAttribute> savs = new ArrayList<DocumentAttribute>(); 048 savs.add(DocumentAttributeFactory.createStringAttribute("MockSearchableAttributeKey", "MockSearchableAttributeValue")); 049 return savs; 050 } 051 052 @Override 053 public List<RemotableAttributeField> getSearchFields(ExtensionDefinition extensionDefinition, 054 String documentTypeName) { 055 List<RemotableAttributeField> fields = new ArrayList<RemotableAttributeField>(); 056 RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create("MockSearchableAttributeKey"); 057 builder.setLongLabel("title"); 058 builder.setDataType(DataType.STRING); 059 fields.add(builder.build()); 060 return fields; 061 } 062 063 @Override 064 public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition, 065 DocumentSearchCriteria documentSearchCriteria) { 066 return Collections.emptyList(); 067 } 068 069}