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.math.BigInteger;
019import java.util.ArrayList;
020import java.util.Collections;
021import java.util.List;
022
023import org.kuali.rice.core.api.data.DataType;
024import org.kuali.rice.core.api.uif.RemotableAttributeError;
025import org.kuali.rice.core.api.uif.RemotableAttributeField;
026import org.kuali.rice.kew.api.document.DocumentWithContent;
027import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
028import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory;
029import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition;
030import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
031import org.kuali.rice.kew.api.extension.ExtensionDefinition;
032import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute;
033
034public class TestXMLSearchableAttributeLong implements SearchableAttribute {
035
036    private static final long serialVersionUID = 1309952222293029643L;
037
038    public static final String SEARCH_STORAGE_KEY = "testLongKey";
039    public static final BigInteger SEARCH_STORAGE_VALUE = BigInteger.valueOf(123456);
040
041    @Override
042    public String generateSearchContent(ExtensionDefinition extensionDefinition,
043            String documentTypeName,
044            WorkflowAttributeDefinition attributeDefinition) {
045        return "TestXMLSearchableAttributeLong";
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.createIntegerAttribute(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.INTEGER);
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}