001 /** 002 * Copyright 2005-2011 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 */ 016 package org.kuali.rice.kew.docsearch; 017 018 import org.kuali.rice.core.api.uif.DataType; 019 import org.kuali.rice.core.api.uif.RemotableAttributeError; 020 import org.kuali.rice.core.api.uif.RemotableAttributeField; 021 import org.kuali.rice.kew.api.document.DocumentWithContent; 022 import org.kuali.rice.kew.api.document.attribute.DocumentAttribute; 023 import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory; 024 import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition; 025 import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria; 026 import org.kuali.rice.kew.api.extension.ExtensionDefinition; 027 import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute; 028 029 import java.util.ArrayList; 030 import java.util.Collections; 031 import java.util.List; 032 033 public class TestXMLSearchableAttributeString implements SearchableAttribute { 034 035 private static final long serialVersionUID = 7069672825797402460L; 036 037 public static final String SEARCH_STORAGE_KEY = "givenname"; 038 public static final String SEARCH_STORAGE_VALUE = "jack"; 039 040 @Override 041 public String generateSearchContent(ExtensionDefinition extensionDefinition, 042 String documentTypeName, 043 WorkflowAttributeDefinition attributeDefinition) { 044 return "TestXMLSearchableAttributeString"; 045 } 046 047 @Override 048 public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, 049 DocumentWithContent documentWithContent) { 050 List<DocumentAttribute> savs = new ArrayList<DocumentAttribute>(); 051 savs.add(DocumentAttributeFactory.createStringAttribute(SEARCH_STORAGE_KEY, SEARCH_STORAGE_VALUE)); 052 return savs; 053 } 054 055 @Override 056 public List<RemotableAttributeField> getSearchFields(ExtensionDefinition extensionDefinition, 057 String documentTypeName) { 058 List<RemotableAttributeField> fields = new ArrayList<RemotableAttributeField>(); 059 RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create(SEARCH_STORAGE_KEY); 060 builder.setLongLabel("title"); 061 builder.setDataType(DataType.STRING); 062 fields.add(builder.build()); 063 return fields; 064 } 065 066 @Override 067 public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition, 068 DocumentSearchCriteria documentSearchCriteria) { 069 return Collections.emptyList(); 070 } 071 072 }