use of org.kuali.kfs.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class IWantDocumentPresentationController method canEditDocumentOverview.
/*
* CU Customization (KFSPTS-2270): Added the ability to edit the document overview/description
* for enroute IWNT docs; we'll use KIM permissions to restrict this to select users.
*
* We restrict the editing of the doc overview to IWNT docs in enroute status at the
* OrganizationHierarchy node, and further restrict it to non-ad-hoc users.
*/
@Override
public boolean canEditDocumentOverview(Document document) {
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
return workflowDocument.isEnroute() && CollectionUtils.isNotEmpty(nodeNames) && nodeNames.contains("OrganizationHierarchy") && !SpringContext.getBean(FinancialSystemWorkflowHelperService.class).isAdhocApprovalRequestedForPrincipal(workflowDocument, GlobalVariables.getUserSession().getPrincipalId());
}
use of org.kuali.kfs.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class IWantDocumentPresentationController method getEditModes.
@Override
public Set<String> getEditModes(Document document) {
Set<String> editModes = super.getEditModes(document);
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
IWantDocument iWantDocument = (IWantDocument) document;
if (SpringContext.getBean(FinancialSystemWorkflowHelperService.class).isAdhocApprovalRequestedForPrincipal(workflowDocument, GlobalVariables.getUserSession().getPrincipalId())) {
editModes.add("completeOrder");
}
if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
editModes.add("wizard");
}
if (CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP.equalsIgnoreCase(iWantDocument.getStep())) {
editModes.add(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
// remove all others
editModes.remove(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
editModes.remove(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
editModes.remove(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
}
if (CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP.equalsIgnoreCase(iWantDocument.getStep())) {
editModes.add(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
// remove all others
editModes.remove(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
editModes.remove(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
editModes.remove(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
}
if (CUPurapConstants.IWantDocumentSteps.VENDOR_STEP.equalsIgnoreCase(iWantDocument.getStep())) {
editModes.add(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
// remove all others
editModes.remove(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
editModes.remove(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
editModes.remove(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
}
if (CUPurapConstants.IWantDocumentSteps.ROUTING_STEP.equalsIgnoreCase(iWantDocument.getStep())) {
editModes.add(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
// remove all others
editModes.remove(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
editModes.remove(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
editModes.remove(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
}
// KFSPTS-2527 only display create req and create DV buttons if neither REQ not DV has been created from I Want doc
if ((StringUtils.isBlank(iWantDocument.getReqsDocId()) && StringUtils.isBlank(iWantDocument.getDvDocId())) && !workflowDocument.isInitiated() && !workflowDocument.isSaved()) {
editModes.add(CUPurapConstants.IWNT_DOC_CREATE_REQ);
editModes.add(CUPurapConstants.IWNT_DOC_CREATE_DV);
}
editModes.add(CUPurapConstants.IWNT_DOC_USE_LOOKUPS);
return editModes;
}
use of org.kuali.kfs.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class GeneralLedgerTransferDocument method doRouteStatusChange.
@Override
public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
super.doRouteStatusChange(statusChangeEvent);
WorkflowDocument workflowDocument = getDocumentHeader().getWorkflowDocument();
if (statusChangeRequiringGeneralLedgerEntryDocumentNumberRemoval(workflowDocument, statusChangeEvent)) {
getGeneralLedgerTransferService().updateGeneralLedgerTransferEntry(getSourceAccountingLines(), null);
}
}
use of org.kuali.kfs.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.kfs.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class MaintenanceUtils method checkDocumentBlockingDocumentId.
public static void checkDocumentBlockingDocumentId(String blockingDocId, boolean throwExceptionIfLocked) {
// if we got nothing, then no docs are blocking, and we're done
if (StringUtils.isBlank(blockingDocId)) {
return;
}
if (MaintenanceUtils.LOG.isInfoEnabled()) {
MaintenanceUtils.LOG.info("Locking document found: docId = " + blockingDocId + ".");
}
// load the blocking locked document
WorkflowDocument lockedDocument = null;
try {
// occur, even though the exception would be caught here
if (KewApiServiceLocator.getWorkflowDocumentService().doesDocumentExist(blockingDocId)) {
/*
* CU Customization KFSPTS-23120 investigate NPE
* Moved the getPerson to a variable to more clearly see what aspect is causing the NPE
*/
try {
Person person = GlobalVariables.getUserSession().getPerson();
lockedDocument = KewApiServiceLocator.getWorkflowDocumentService().loadWorkflowDocument(blockingDocId, person);
} catch (NullPointerException npe) {
LOG.error("checkDocumentBlockingDocumentId, caught an NPE getting the locked document with blockingDocId: " + blockingDocId, npe);
throw npe;
}
}
} catch (Exception ex) {
// clean up the lock and notify the admins
MaintenanceUtils.LOG.error("Unable to retrieve locking document specified in the maintenance lock " + "table: " + blockingDocId, ex);
cleanOrphanLocks(blockingDocId, ex);
return;
}
if (lockedDocument == null) {
MaintenanceUtils.LOG.warn("Locking document header for " + blockingDocId + "came back null.");
cleanOrphanLocks(blockingDocId, null);
}
// if we can ignore the lock (see method notes), then exit cause we're done
if (lockCanBeIgnored(lockedDocument)) {
return;
}
// build the link URL for the blocking document
Map<String, String> parameters = new HashMap<>();
parameters.put(KRADConstants.PARAMETER_DOC_ID, blockingDocId);
parameters.put(KRADConstants.PARAMETER_COMMAND, KRADConstants.METHOD_DISPLAY_DOC_SEARCH_VIEW);
String blockingUrl = UrlFactory.parameterizeUrl(KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString(KFSConstants.APPLICATION_URL_KEY) + "/" + KRADConstants.DOC_HANDLER_ACTION, parameters);
if (MaintenanceUtils.LOG.isDebugEnabled()) {
MaintenanceUtils.LOG.debug("blockingUrl = '" + blockingUrl + "'");
MaintenanceUtils.LOG.debug("Maintenance record: " + lockedDocument.getApplicationDocumentId() + "is locked.");
}
String[] errorParameters = { blockingUrl, blockingDocId };
// ErrorMap instead.
if (throwExceptionIfLocked) {
// post an error about the locked document
GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_MAINTENANCE_LOCKED, errorParameters);
throw new ValidationException("Maintenance Record is locked by another document.");
} else {
// Post a warning about the locked document.
GlobalVariables.getMessageMap().putWarning(KRADConstants.GLOBAL_MESSAGES, WARNING_MAINTENANCE_LOCKED, errorParameters);
}
}
Aggregations