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.math.BigDecimal; 030 import java.util.ArrayList; 031 import java.util.Collections; 032 import java.util.List; 033 034 public class TestXMLSearchableAttributeFloat implements SearchableAttribute { 035 036 private static final long serialVersionUID = -2656250483031095594L; 037 038 public static final String SEARCH_STORAGE_KEY = "testFloatKey"; 039 public static final BigDecimal SEARCH_STORAGE_VALUE = new BigDecimal("123456.3456"); 040 041 @Override 042 public String generateSearchContent(ExtensionDefinition extensionDefinition, 043 String documentTypeName, 044 WorkflowAttributeDefinition attributeDefinition) { 045 return "TestXMLSearchableAttributeFloat"; 046 } 047 048 @Override 049 public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, 050 DocumentWithContent documentWithContent) { 051 List<DocumentAttribute> savs = new ArrayList<DocumentAttribute>(); 052 savs.add(DocumentAttributeFactory.createDecimalAttribute(SEARCH_STORAGE_KEY, SEARCH_STORAGE_VALUE)); 053 return savs; 054 } 055 056 @Override 057 public List<RemotableAttributeField> getSearchFields(ExtensionDefinition extensionDefinition, 058 String documentTypeName) { 059 List<RemotableAttributeField> fields = new ArrayList<RemotableAttributeField>(); 060 RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create(SEARCH_STORAGE_KEY); 061 builder.setLongLabel("title"); 062 builder.setDataType(DataType.DOUBLE); 063 fields.add(builder.build()); 064 return fields; 065 } 066 067 @Override 068 public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition, 069 DocumentSearchCriteria documentSearchCriteria) { 070 return Collections.emptyList(); 071 } 072 073 }