| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.service.impl; |
| 17 | |
|
| 18 | |
import org.kuali.rice.kew.docsearch.DocumentRouteHeaderEBO; |
| 19 | |
import org.kuali.rice.kew.doctype.bo.DocumentTypeEBO; |
| 20 | |
import org.kuali.rice.kew.doctype.service.DocumentTypeService; |
| 21 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
| 22 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 23 | |
import org.kuali.rice.krad.bo.ExternalizableBusinessObject; |
| 24 | |
import org.kuali.rice.krad.service.impl.ModuleServiceBase; |
| 25 | |
|
| 26 | |
import java.sql.Timestamp; |
| 27 | |
import java.util.ArrayList; |
| 28 | |
import java.util.List; |
| 29 | |
import java.util.Map; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | 0 | public class KEWModuleService extends ModuleServiceBase { |
| 38 | |
|
| 39 | 0 | protected DocumentTypeService docTypeService = null; |
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
@Override |
| 48 | |
public List<String> listPrimaryKeyFieldNames(Class businessObjectInterfaceClass) { |
| 49 | 0 | if ( DocumentTypeEBO.class.isAssignableFrom( businessObjectInterfaceClass ) ) { |
| 50 | 0 | List<String> pkFields = new ArrayList<String>( 1 ); |
| 51 | 0 | pkFields.add( "documentTypeId" ); |
| 52 | 0 | return pkFields; |
| 53 | 0 | }else if(DocumentRouteHeaderEBO.class.isAssignableFrom( businessObjectInterfaceClass )){ |
| 54 | 0 | List<String> pkFields = new ArrayList<String>( 1 ); |
| 55 | 0 | pkFields.add( "documentId" ); |
| 56 | 0 | return pkFields; |
| 57 | |
} |
| 58 | 0 | return super.listPrimaryKeyFieldNames(businessObjectInterfaceClass); |
| 59 | |
} |
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
@Override |
| 68 | |
public <T extends ExternalizableBusinessObject> T getExternalizableBusinessObject( |
| 69 | |
Class<T> businessObjectClass, Map<String, Object> fieldValues) { |
| 70 | 0 | if(DocumentTypeEBO.class.isAssignableFrom(businessObjectClass)){ |
| 71 | 0 | if ( fieldValues.containsKey( "name" ) ) { |
| 72 | 0 | return (T)getDocumentTypeService().findByName((String)fieldValues.get( "name" ) ); |
| 73 | 0 | }else if( fieldValues.containsKey( "documentTypeId" ) ){ |
| 74 | 0 | return (T)getDocumentTypeService().findById(fieldValues.get( "documentTypeId" ).toString()); |
| 75 | 0 | }else if (fieldValues.containsKey( "id" ) ) { |
| 76 | |
|
| 77 | 0 | return (T)getDocumentTypeService().findById(fieldValues.get( "id" ).toString()); |
| 78 | |
} |
| 79 | |
|
| 80 | 0 | }else if(DocumentRouteHeaderEBO.class.isAssignableFrom( businessObjectClass )){ |
| 81 | 0 | if ( fieldValues.containsKey( "documentId" ) ) { |
| 82 | 0 | return (T)createDocSearchCriteriaEBO(KEWServiceLocator.getRouteHeaderService().getRouteHeader(fieldValues.get( "documentId" ).toString())); |
| 83 | |
} |
| 84 | |
|
| 85 | |
} |
| 86 | |
|
| 87 | |
|
| 88 | 0 | return super.getExternalizableBusinessObject(businessObjectClass, fieldValues); |
| 89 | |
} |
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
protected DocumentTypeService getDocumentTypeService() { |
| 95 | 0 | if(this.docTypeService == null){ |
| 96 | |
|
| 97 | 0 | this.docTypeService = KEWServiceLocator.getDocumentTypeService(); |
| 98 | |
} |
| 99 | 0 | return this.docTypeService; |
| 100 | |
} |
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
public void setDocumentTypeService(DocumentTypeService docTypeService) { |
| 106 | 0 | this.docTypeService = docTypeService; |
| 107 | 0 | } |
| 108 | |
|
| 109 | |
private DocumentRouteHeaderEBO createDocSearchCriteriaEBO(final DocumentRouteHeaderValue routeHeaderValue){ |
| 110 | 0 | return new DocumentRouteHeaderEBO(){ |
| 111 | |
|
| 112 | |
public String getAppDocId() { |
| 113 | 0 | return routeHeaderValue.getAppDocId(); |
| 114 | |
} |
| 115 | |
|
| 116 | |
public Timestamp getDateCreated() { |
| 117 | 0 | return routeHeaderValue.getCreateDate(); |
| 118 | |
} |
| 119 | |
|
| 120 | |
public String getDocRouteStatus() { |
| 121 | |
|
| 122 | 0 | return routeHeaderValue.getDocRouteStatus(); |
| 123 | |
} |
| 124 | |
|
| 125 | |
public String getAppDocStatus() { |
| 126 | |
|
| 127 | 0 | return routeHeaderValue.getAppDocStatus(); |
| 128 | |
} |
| 129 | |
|
| 130 | |
public String getDocTitle() { |
| 131 | 0 | return routeHeaderValue.getDocTitle(); |
| 132 | |
} |
| 133 | |
|
| 134 | |
public String getDocTypeFullName() { |
| 135 | 0 | return routeHeaderValue.getDocumentType().getName(); |
| 136 | |
} |
| 137 | |
|
| 138 | |
public String getInitiator() { |
| 139 | 0 | return routeHeaderValue.getInitiatorPrincipal().getPrincipalName(); |
| 140 | |
} |
| 141 | |
|
| 142 | |
public String getDocumentId() { |
| 143 | |
|
| 144 | 0 | return routeHeaderValue.getDocumentId(); |
| 145 | |
} |
| 146 | |
|
| 147 | |
public void refresh() { |
| 148 | |
|
| 149 | |
|
| 150 | 0 | } |
| 151 | |
|
| 152 | |
}; |
| 153 | |
} |
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
@Override |
| 160 | |
public String getExternalizableBusinessObjectInquiryUrl( |
| 161 | |
Class inquiryBusinessObjectClass, Map<String, String[]> parameters) { |
| 162 | 0 | if ( DocumentTypeEBO.class.isAssignableFrom( inquiryBusinessObjectClass ) ) { |
| 163 | 0 | int nonBlank = 0; |
| 164 | 0 | boolean nameFound = false; |
| 165 | |
|
| 166 | 0 | for(String key: parameters.keySet()){ |
| 167 | 0 | if("name".equals(key) && parameters.get(key) != null){ |
| 168 | 0 | nameFound=true; |
| 169 | 0 | }else if(!"name".equals(key) && parameters.get(key) != null){ |
| 170 | 0 | nonBlank ++; |
| 171 | |
} |
| 172 | |
} |
| 173 | |
|
| 174 | 0 | if(nonBlank == 0 && nameFound == true){ |
| 175 | 0 | parameters.clear(); |
| 176 | 0 | DocumentTypeEBO dte = (DocumentTypeEBO)getDocumentTypeService().findByName(parameters.get( "name" )[0] ); |
| 177 | 0 | String[] strArr = {dte.getDocumentTypeId().toString()}; |
| 178 | 0 | parameters.put("documentTypeId", strArr); |
| 179 | |
} |
| 180 | |
|
| 181 | |
} |
| 182 | |
|
| 183 | 0 | return super.getExternalizableBusinessObjectInquiryUrl( |
| 184 | |
inquiryBusinessObjectClass, parameters); |
| 185 | |
} |
| 186 | |
|
| 187 | |
|
| 188 | |
|
| 189 | |
|
| 190 | |
|
| 191 | |
public List<List<String>> listAlternatePrimaryKeyFieldNames( |
| 192 | |
Class businessObjectInterfaceClass) { |
| 193 | 0 | if ( DocumentTypeEBO.class.isAssignableFrom( businessObjectInterfaceClass ) ) { |
| 194 | 0 | ArrayList<List<String>> retList = new ArrayList<List<String>>(); |
| 195 | 0 | ArrayList<String> keyList = new ArrayList<String>(); |
| 196 | |
|
| 197 | 0 | keyList.add("name"); |
| 198 | 0 | retList.add(keyList); |
| 199 | 0 | return retList; |
| 200 | |
}else{ |
| 201 | 0 | return null; |
| 202 | |
} |
| 203 | |
|
| 204 | |
} |
| 205 | |
} |
| 206 | |
|