001 /** 002 * Copyright 2005-2013 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.joda.time.DateTime; 019 import org.kuali.rice.core.api.uif.AttributeLookupSettings; 020 import org.kuali.rice.core.api.uif.DataType; 021 import org.kuali.rice.core.api.uif.RemotableAttributeError; 022 import org.kuali.rice.core.api.uif.RemotableAttributeField; 023 import org.kuali.rice.core.api.uif.RemotableAttributeLookupSettings; 024 import org.kuali.rice.kew.api.document.DocumentWithContent; 025 import org.kuali.rice.kew.api.document.attribute.DocumentAttribute; 026 import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory; 027 import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition; 028 import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria; 029 import org.kuali.rice.kew.api.extension.ExtensionDefinition; 030 import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute; 031 032 import java.util.ArrayList; 033 import java.util.Collections; 034 import java.util.List; 035 036 public class TestXMLSearchableAttributeDateTime implements SearchableAttribute { 037 038 private static final long serialVersionUID = 1479059967548234181L; 039 040 public static final String SEARCH_STORAGE_KEY = "testDateTimeKey"; 041 public static final Long SEARCH_STORAGE_VALUE_IN_MILLS = (new Long("1173995646535")); 042 public static final DateTime SEARCH_STORAGE_VALUE = new DateTime(SEARCH_STORAGE_VALUE_IN_MILLS.longValue()); 043 044 @Override 045 public String generateSearchContent(ExtensionDefinition extensionDefinition, 046 String documentTypeName, 047 WorkflowAttributeDefinition attributeDefinition) { 048 return "TestXMLSearchableAttributeDateTime"; 049 } 050 051 @Override 052 public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, 053 DocumentWithContent documentWithContent) { 054 List<DocumentAttribute> savs = new ArrayList<DocumentAttribute>(); 055 savs.add(DocumentAttributeFactory.createDateTimeAttribute(SEARCH_STORAGE_KEY, SEARCH_STORAGE_VALUE)); 056 return savs; 057 } 058 059 @Override 060 public List<RemotableAttributeField> getSearchFields(ExtensionDefinition extensionDefinition, 061 String documentTypeName) { 062 List<RemotableAttributeField> fields = new ArrayList<RemotableAttributeField>(); 063 RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create(SEARCH_STORAGE_KEY); 064 builder.setLongLabel("title"); 065 builder.setDataType(DataType.DATE); 066 067 RemotableAttributeLookupSettings.Builder settings = RemotableAttributeLookupSettings.Builder.create(); 068 settings.setRanged(true); 069 settings.setUpperBoundInclusive(false); 070 071 // test result table column visibility 072 // see: DocumentSearchResultAttributeVisibilityTest 073 settings.setInResults(false); 074 075 builder.setAttributeLookupSettings(settings); 076 fields.add(builder.build()); 077 return fields; 078 } 079 080 @Override 081 public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition, 082 DocumentSearchCriteria documentSearchCriteria) { 083 return Collections.emptyList(); 084 } 085 086 }