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.service.impl;
 
 
 import java.util.List;
 import java.util.Map;

The ModuleService for KEW

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class KEWModuleService extends ModuleServiceBase {
 
 	protected DocumentTypeService docTypeService = null;

These are the "primary" keys for the DocTypeService. We are considering both name and documentTypeId to be unique.

 
 	public List<StringlistPrimaryKeyFieldNames(Class businessObjectInterfaceClass) {
 		if ( DocumentTypeEBO.class.isAssignableFrombusinessObjectInterfaceClass ) ) {
 			List<StringpkFields = new ArrayList<String>( 1 );
 			pkFields.add"documentTypeId" );
 			return pkFields;
 		}else if(DocumentSearchCriteriaEbo.class.isAssignableFrombusinessObjectInterfaceClass )){
 			List<StringpkFields = new ArrayList<String>( 1 );
 			pkFields.add"documentId" );
 			return pkFields;
 		}
 		return super.listPrimaryKeyFieldNames(businessObjectInterfaceClass);
 	}

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

 
 			Class<T> businessObjectClassMap<StringObjectfieldValues) {
 
 		if(DocumentTypeEBO.class.isAssignableFrom(businessObjectClass)){
 
             org.kuali.rice.kew.api.doctype.DocumentType fetchedDocumentType = null;
 
             if ( fieldValues.containsKey"name" ) ) {
                 fetchedDocumentType = getDocumentTypeService().getDocumentTypeByName((StringfieldValues.get("name"));
 			}else iffieldValues.containsKey"documentTypeId" ) ){
                 fetchedDocumentType = getDocumentTypeService().getDocumentTypeById(fieldValues.get("documentTypeId").toString());
 			}else if (fieldValues.containsKey"id" ) ) {
 				// assume it's a string and convert it to a long.
                 fetchedDocumentType = getDocumentTypeService().getDocumentTypeById(fieldValues.get("id").toString());
 			}
 
             if (fetchedDocumentType != null) {
                 // convert to EBO
                 return (T) DocumentType.from(fetchedDocumentType);
             } else {
                 return null;
             }
 
 		}else if(DocumentSearchCriteriaEbo.class.isAssignableFrombusinessObjectClass )){
 			if ( fieldValues.containsKey"documentId" ) ) {
                         fieldValues.get("documentId").toString()));
 			}
		}
		// otherwise, use the default implementation
		return super.getExternalizableBusinessObject(businessObjectClassfieldValues);
	}

Returns:
the docTypeService
	protected synchronized DocumentTypeService getDocumentTypeService() {
		if(this. == null){
			// the default
			this. = KewApiServiceLocator.getDocumentTypeService();
		}
		return this.;
	}

Parameters:
docTypeService the docTypeService to set
	public synchronized void setDocumentTypeService(DocumentTypeService docTypeService) {
		this. = docTypeService;
	}
            @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
            }
            
        };
	}
			Class inquiryBusinessObjectClassMap<StringString[]> parameters) {
		if ( DocumentTypeEBO.class.isAssignableFrominquiryBusinessObjectClass ) ) {
			int nonBlank = 0;
			boolean nameFound = false;
			//"name" is the only non-blank property passed in
			for(String keyparameters.keySet()){
				if("name".equals(key) && parameters.get(key) != null){
					nameFound=true;
				}else if(!"name".equals(key) && parameters.get(key) != null){
					nonBlank ++;
				}
			}
			if(nonBlank == 0 && nameFound == true){
				parameters.clear(); // clear out other parameters, including the name pass in
				DocumentTypeEBO dte = (DocumentTypeEBO) DocumentType.from(getDocumentTypeService().getDocumentTypeByName(parameters.get"name" )[0] ));
				String[] strArr = {dte.getDocumentTypeId().toString()};
				parameters.put("documentTypeId"strArr);
			}
		}
				inquiryBusinessObjectClassparameters);
	}

    
			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;
		}
	}
    public boolean goToCentralRiceForInquiry() {
        if (..equals(runMode)) {
            return true;
        } else {
            return false;
        }
    }
New to GrepCode? Check out our FAQ X