use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class CuRequisitionAction method copy.
/**
* Overridden to guarantee that form of copied document is set to whatever the entry mode of the document is
* @see org.kuali.kfs.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy
* (org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionForward forward = null;
String docID = "docId";
if (request.getParameter(docID) == null) {
forward = super.copy(mapping, form, request, response);
} else {
// this is copy document from Procurement Gateway:
// use this url to call: http://localhost:8080/kfs-dev/purapRequisition.do?methodToCall=copy&docId=xxxx
String docId = request.getParameter(docID);
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
CuRequisitionDocument document = null;
document = (CuRequisitionDocument) getDocumentService().getByDocumentHeaderId(docId);
document.toCopyFromGateway();
kualiDocumentFormBase.setDocument(document);
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
kualiDocumentFormBase.setDocTypeName(workflowDocument.getDocumentTypeName());
SpringContext.getBean(SessionDocumentService.class).addDocumentToUserSession(GlobalVariables.getUserSession(), workflowDocument);
forward = mapping.findForward(RiceConstants.MAPPING_BASIC);
}
return forward;
}
use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class CuFinancialMaintenanceDocumentActionTest method createMockDocumentHeader.
protected DocumentHeader createMockDocumentHeader(DocumentStatus documentStatus) {
DocumentHeader documentHeader = mock(FinancialSystemDocumentHeader.class);
WorkflowDocument mockWorkflowDocument = createMockWorkflowDocument(documentStatus);
when(documentHeader.getWorkflowDocument()).thenReturn(mockWorkflowDocument);
return documentHeader;
}
use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherEmployeeInformationValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
LOG.debug("validate start");
boolean isValid = true;
CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) getAccountingDocumentForValidation();
DisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
if (!payeeDetail.isEmployee() || payeeDetail.isVendor() || !(document.getDocumentHeader().getWorkflowDocument().isInitiated() || document.getDocumentHeader().getWorkflowDocument().isSaved())) {
return true;
}
String employeeId = payeeDetail.getDisbVchrPayeeIdNumber();
Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(employeeId);
MessageMap errors = GlobalVariables.getMessageMap();
errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
boolean stateIsInitiated = workflowDocument.isInitiated() || workflowDocument.isSaved();
if (ObjectUtils.isNull(employee)) {
employee = SpringContext.getBean(PersonService.class).getPerson(employeeId);
} else {
if (!KFSConstants.EMPLOYEE_ACTIVE_STATUS.equals(employee.getEmployeeStatusCode()) && !CUKFSConstants.EMPLOYEE_RETIRED_STATUS.equals(employee.getEmployeeStatusCode())) {
// If employee is found, then check that employee is active or retired if the doc has not already been routed.
if (stateIsInitiated) {
String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_INACTIVE, label);
isValid = false;
}
}
}
// check existence of employee
if (employee == null) {
// If employee is not found, report existence error
String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_EXISTENCE, label);
isValid = false;
}
errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
return isValid;
}
use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class CuProcurementCardAccountingLineAuthorizer method determineEditPermissionByFieldName.
@Override
protected boolean determineEditPermissionByFieldName(AccountingDocument accountingDocument, AccountingLine accountingLine, String fieldName, Person currentUser, Set<String> currentNodes) {
WorkflowDocument workflowDocument = accountingDocument.getDocumentHeader().getWorkflowDocument();
List<ActionRequest> actionRequests = workflowDocument.getRootActionRequests();
Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
boolean isAddHocRoute = CollectionUtils.isNotEmpty(nodeNames) && nodeNames.contains(PurapWorkflowConstants.DOC_ADHOC_NODE_NAME);
if (!isAddHocRoute) {
for (ActionRequest actionRequest : actionRequests) {
isAddHocRoute = actionRequest.getActionTaken() == null && StringUtils.startsWith(actionRequest.getAnnotation(), "Ad Hoc Routed by") && StringUtils.equals(actionRequest.getPrincipalId(), currentUser.getPrincipalId());
if (isAddHocRoute) {
return false;
}
}
} else {
return false;
}
// 2. Check that the document is at AccountFullEdit route node
if (accountingDocument.getDocumentHeader() != null && accountingDocument.getDocumentHeader().getWorkflowDocument() != null) {
if (currentNodes != null && currentNodes.contains(RouteLevelNames.ACCOUNT_REVIEW_FULL_EDIT)) {
// 3. Check that the current user has the permission to edit the document, which means in this case he can edit the accounting line
if (getDocumentAuthorizer(accountingDocument).canEdit(accountingDocument, currentUser)) {
// since any user that can edit the accounting lines will be able to add/change it to any other account
return true;
}
}
}
return super.determineEditPermissionByFieldName(accountingDocument, accountingLine, fieldName, currentUser, currentNodes);
}
use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class CuProcurementCardDocumentPresentationController method canEditDocumentOverview.
@Override
public boolean canEditDocumentOverview(Document document) {
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
return workflowDocument.isEnroute() && CollectionUtils.isNotEmpty(nodeNames) && nodeNames.contains(KFSConstants.RouteLevelNames.ACCOUNT_REVIEW_FULL_EDIT) && workflowDocument.isApprovalRequested() && !workflowDocument.isAcknowledgeRequested();
}
Aggregations