use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuRequisitionDocument method isB2BTotalAmountForAutoPO.
protected boolean isB2BTotalAmountForAutoPO() {
boolean returnValue = false;
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
String autoPOAmountString = new String(parameterService.getParameterValueAsString(RequisitionDocument.class, CUPurapParameterConstants.B2B_TOTAL_AMOUNT_FOR_AUTO_PO));
KualiDecimal autoPOAmount = new KualiDecimal(autoPOAmountString);
// KFSPTS-1625
String routedBy = getRoutedByPrincipalId();
if (StringUtils.isBlank(routedBy)) {
routedBy = this.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
}
if (KimApiServiceLocator.getPermissionService().hasPermission(routedBy, CUKFSConstants.ParameterNamespaces.PURCHASING, CUPurapConstants.B2B_HIGHER_LIMIT_PERMISSION)) {
String paramVal = parameterService.getParameterValueAsString(RequisitionDocument.class, CUPurapParameterConstants.B2B_TOTAL_AMOUNT_FOR_SUPER_USER_AUTO_PO);
if (StringUtils.isNotBlank(paramVal)) {
autoPOAmount = new KualiDecimal(paramVal);
}
}
RequisitionDocument document = null;
try {
document = (RequisitionDocument) (SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(this.getDocumentNumber()));
} catch (WorkflowException we) {
}
KualiDecimal totalAmount = document.getFinancialSystemDocumentHeader().getFinancialDocumentTotalAmount();
if (ObjectUtils.isNotNull(autoPOAmount) && ObjectUtils.isNotNull(totalAmount) && (autoPOAmount.compareTo(totalAmount) >= 0)) {
returnValue = true;
} else {
returnValue = false;
}
return returnValue;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuRequisitionDocument method getRoutedByPrincipalId.
public String getRoutedByPrincipalId() {
DocumentService documentService = SpringContext.getBean(DocumentService.class);
RequisitionDocument document = null;
String principalId = null;
try {
document = (RequisitionDocument) documentService.getByDocumentHeaderId(this.getDocumentNumber());
principalId = document.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId();
} catch (WorkflowException we) {
}
return principalId;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuRequisitionAction method createReqFromIWantDoc.
/**
* Creates a requisition document based on information from an I Want document.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings("deprecation")
public ActionForward createReqFromIWantDoc(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String iWantDocumentNumber = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
RequisitionForm requisitionForm = (RequisitionForm) form;
IWantDocument iWantDocument = (IWantDocument) getDocumentService().getByDocumentHeaderId(iWantDocumentNumber);
if (iWantDocument == null) {
throw new WorkflowException("Could not find IWantDocument with ID '" + iWantDocumentNumber + "'");
}
// Make sure the user is authorized to create the req in this manner.
TransactionalDocumentPresentationController pControl = (TransactionalDocumentPresentationController) getDocumentHelperService().getDocumentPresentationController(iWantDocument);
TransactionalDocumentAuthorizer authorizer = (TransactionalDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(iWantDocument);
Set<String> iwntEditModes = authorizer.getEditModes(iWantDocument, GlobalVariables.getUserSession().getPerson(), pControl.getEditModes(iWantDocument));
if (!iwntEditModes.contains(CUPurapConstants.IWNT_DOC_CREATE_REQ)) {
throw new AuthorizationException(GlobalVariables.getUserSession().getPrincipalId(), CUPurapConstants.IWNT_DOC_CREATE_REQ, CuRequisitionDocument.class.getSimpleName(), "user is not authorized to create requisitions from IWantDocument '" + iWantDocumentNumber + "'", Collections.<String, Object>emptyMap());
}
// Do not allow the req to be created if the IWNT doc is already associated with another req.
if (iWantDocument != null && (StringUtils.isNotBlank(iWantDocument.getReqsDocId()) || StringUtils.isNotBlank(iWantDocument.getDvDocId()))) {
throw new WorkflowException("Cannot create requisition from IWantDocument '" + iWantDocumentNumber + "' because a DV or Requisition has already been created from that document");
}
IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
createDocument(requisitionForm);
RequisitionDocument requisitionDocument = requisitionForm.getRequisitionDocument();
iWantDocumentService.setUpRequisitionDetailsFromIWantDoc(iWantDocument, requisitionDocument, requisitionForm);
// Set the requisition doc ID reference on the IWantDocument.
iWantDocument.setReqsDocId(requisitionDocument.getDocumentNumber());
SpringContext.getBean(PurapService.class).saveDocumentNoValidation(iWantDocument);
return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuRelatedDocumentDerivedRoleTypeServiceImpl method getRoleMembersFromDerivedRole.
@Override
public List<RoleMembership> getRoleMembersFromDerivedRole(String namespaceCode, String roleName, Map<String, String> qualification) {
List<RoleMembership> members = new ArrayList<RoleMembership>();
if (qualification != null && !qualification.isEmpty()) {
if (SOURCE_DOCUMENT_ROUTER_ROLE_NAME.equals(roleName)) {
try {
PurchasingAccountsPayableDocument document = (PurchasingAccountsPayableDocument) getDocumentService().getByDocumentHeaderId(qualification.get(KFSPropertyConstants.DOCUMENT_NUMBER));
if (document != null) {
PurchasingAccountsPayableDocument sourceDocument = document.getPurApSourceDocumentIfPossible();
if (sourceDocument != null && StringUtils.isNotBlank(sourceDocument.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId())) {
Map<String, String> roleQualifier = new HashMap<String, String>(1);
roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, sourceDocument.getDocumentNumber());
Builder roleMember = RoleMembership.Builder.create(null, null, sourceDocument.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId(), KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, roleQualifier);
members.add(roleMember.build());
}
}
} catch (WorkflowException e) {
throw new RuntimeException("Unable to load document in getPrincipalIdsFromApplicationRole", e);
}
} else if (SENSITIVE_RELATED_DOCUMENT_INITATOR_OR_REVIEWER_ROLE_NAME.equals(roleName)) {
// KFSUPGRADE-346
if (!qualification.containsKey(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER)) {
Map<String, String> tempQualification = new HashMap<String, String>(1);
tempQualification.put(KFSPropertyConstants.DOCUMENT_NUMBER, qualification.get("documentNumber"));
for (String principalId : getRoleService().getRoleMemberPrincipalIds(KRADConstants.KUALI_RICE_WORKFLOW_NAMESPACE, RouteLogDerivedRoleTypeServiceImpl.INITIATOR_OR_REVIEWER_ROLE_NAME, tempQualification)) {
Builder roleMember = RoleMembership.Builder.create(null, null, principalId, KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, tempQualification);
members.add(roleMember.build());
}
} else {
for (String documentId : getPurapService().getRelatedDocumentIds(new Integer(qualification.get(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER)))) {
Map<String, String> tempQualification = new HashMap<String, String>(1);
tempQualification.put(KFSPropertyConstants.DOCUMENT_NUMBER, documentId);
for (String principalId : getRoleService().getRoleMemberPrincipalIds(KRADConstants.KUALI_RICE_WORKFLOW_NAMESPACE, RouteLogDerivedRoleTypeServiceImpl.INITIATOR_OR_REVIEWER_ROLE_NAME, tempQualification)) {
Builder roleMember = RoleMembership.Builder.create(null, null, principalId, KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, tempQualification);
members.add(roleMember.build());
}
}
}
}
}
return members;
}
Aggregations