Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.impl.service;
 
 
 import java.util.List;
 import java.util.Map;
 
 
     protected DocumentTypeService docTypeService = null;

    
This overridden method calls the DocumentTypeService instead of the underlying KNS service. Allows you to search on name and docTypeId

 
     @Override
             Class<T> businessObjectClassMap<StringObjectfieldValues) {
         if(DocumentTypeEBO.class.isAssignableFrom(businessObjectClass)){
             if ( fieldValues.containsKey"name" ) ) {
                 return (T) DocumentType.from(getDocumentTypeService().getDocumentTypeByName((StringfieldValues.get(
                         "name")));
             } else iffieldValues.containsKey"documentTypeId" ) ){
                 return (T) DocumentType.from(getDocumentTypeService().getDocumentTypeById(fieldValues.get("documentTypeId").toString()));
             } else if (fieldValues.containsKey"id" ) ) {
                 // assume it's a string and convert it to a long.
                 return (T) DocumentType.from(getDocumentTypeService().getDocumentTypeById(fieldValues.get("id").toString()));
             }
 
         } else if(DocumentSearchCriteriaEbo.class.isAssignableFrombusinessObjectClass )) {
             if ( fieldValues.containsKey"documentId" ) ) {
                 return (T)createDocumentSearchEbo(KewApiServiceLocator.getWorkflowDocumentService().getDocument(
                         fieldValues.get("documentId").toString()));
             }
 
         }
 
         return null;
     }
 
         return new DocumentSearchCriteriaEbo(){
 
             @Override
             public String getApplicationDocumentId() {
                 return doc.getApplicationDocumentId();
             }
 
             @Override
             public DocumentStatus getStatus() {
                 return doc.getStatus();
             }
 
             @Override
             public String getApplicationDocumentStatus() {
                 return doc.getApplicationDocumentStatus();
             }
 
             @Override
             public String getTitle() {
                 return doc.getTitle();
            }
            @Override
            public String getDocumentTypeName() {
                return doc.getDocumentTypeName();
            }
            @Override
            public String getInitiatorPrincipalId() {
                return doc.getInitiatorPrincipalId();
            }
            @Override
            public String getDocumentId() {
                return doc.getDocumentId();
            }
            @Override
            public DateTime getDateCreated() {
                return doc.getDateCreated();
            }
            @Override
            public void refresh() {
                // do nothing
            }
        };
    }
    @Override
            Class<T> businessObjectClassMap<StringObjectfieldValues) {
        if (!fieldValues.isEmpty()) {
            throw new IllegalStateException("fieldValues must be empty");
        }
        List<T> ebos = new ArrayList<T>();
        if(DocumentTypeEBO.class.isAssignableFrom(businessObjectClass)){
            for (org.kuali.rice.kew.api.doctype.DocumentType docType : docTypes) {
                ebos.add((T)DocumentType.from(docType));
            }
            return ebos;
        }
        return Collections.emptyList();
    }
    @Override
    public boolean isExternalizableBusinessObjectLookupable(Class boClass) {
        return isExternalizable(boClass);
    }
    @Override
    public boolean isExternalizableBusinessObjectInquirable(Class boClass) {
        return isExternalizable(boClass);
    }
    @Override
    public boolean isExternalizable(Class boClazz) {
        if (boClazz == null) {
            return false;
        }
        if(DocumentTypeEBO.class.isAssignableFrom(boClazz)) {
            return true;
        } else if(DocumentSearchCriteriaEbo.class.isAssignableFrom(boClazz)) {
            return true;
        }
        return ExternalizableBusinessObject.class.isAssignableFrom(boClazz);
    }
    @Override
    public List<StringlistPrimaryKeyFieldNames(Class boClass) {
        if ( DocumentTypeEBO.class.isAssignableFromboClass ) ) {
            List<StringpkFields = new ArrayList<String>( 1 );
            pkFields.add"documentTypeId" );
            return pkFields;
        }else if(DocumentSearchCriteriaEbo.class.isAssignableFromboClass )){
            List<StringpkFields = new ArrayList<String>( 1 );
            pkFields.add"documentId" );
            return pkFields;
        }
        return Collections.emptyList();
    }

    
            Class businessObjectInterfaceClass) {
        if ( DocumentTypeEBO.class.isAssignableFrombusinessObjectInterfaceClass ) ) {
            ArrayList<List<String>> retList = new ArrayList<List<String>>();
            ArrayList<StringkeyList = new ArrayList<String>();
            keyList.add("name");
            retList.add(keyList);
            return retList;
        }else{
            return null;
        }
    }

    

Returns:
the docTypeService
    protected synchronized DocumentTypeService getDocumentTypeService() {
        if(this. == null){
            // the default
            this. = KewApiServiceLocator.getDocumentTypeService();
        }
        return this.;
    }
New to GrepCode? Check out our FAQ X