public DocumentModel getDocument() { return element.getDocument(); }
@Override public void removeRouteElement(DocumentRouteElement routeElement, CoreSession session) throws DocumentRouteNotLockedException { DocumentRoute parentRoute = routeElement.getDocumentRoute(session); if (!isLockedByCurrentUser(parentRoute, session)) { throw new DocumentRouteNotLockedException(); } session.removeDocument(routeElement.getDocument().getRef()); session.save();// the document will be queried later on }
protected List<DocumentRouteElement> getChildrenElement(CoreSession session, DocumentRouteElement element) { DocumentModelList children = session.getChildren(element.getDocument().getRef()); List<DocumentRouteElement> elements = new ArrayList<DocumentRouteElement>(); for (DocumentModel model : children) { elements.add(model.getAdapter(DocumentRouteElement.class)); } return elements; }
static public void fireEvent(CoreSession coreSession, DocumentRouteElement element, Map<String, Serializable> eventProperties, String eventName) { if (eventProperties == null) { eventProperties = new HashMap<String, Serializable>(); } eventProperties.put(DocumentRoutingConstants.DOCUMENT_ELEMENT_EVENT_CONTEXT_KEY, element); eventProperties.put(DocumentEventContext.CATEGORY_PROPERTY_KEY, DocumentRoutingConstants.ROUTING_CATEGORY); DocumentEventContext envContext = new DocumentEventContext(coreSession, coreSession.getPrincipal(), element.getDocument()); envContext.setProperties(eventProperties); getEventProducer().fireEvent(envContext.newEvent(eventName)); }
public String getTypeDescription(DocumentRouteTableElement localizable) { return depthFormatter(localizable.getDepth(), localizable.getElement().getDocument().getType()); }
Map<String, String> taskVariables = new HashMap<>(); taskVariables.put(DocumentRoutingConstants.TASK_ROUTE_INSTANCE_DOCUMENT_ID_KEY, routeInstance.getDocument().getId()); taskVariables.put(DocumentRoutingConstants.TASK_NODE_ID_KEY, node.getId()); taskVariables.put(DocumentRoutingConstants.OPERATION_STEP_DOCUMENT_KEY, node.getDocument().getId()); node.getTaskDocType(), node.getDocument().getTitle(), node.getId(), routeInstance.getDocument().getId(), new ArrayList<>(actors), node.hasMultipleTasks(), node.getTaskDirective(), null, dueDate, taskVariables, null, node.getWorkflowContextualInfo(session, true));
String posOfchildToRun = null; try { posOfchildToRun = (String) element.getDocument().getPropertyValue( DocumentRoutingConstants.STEP_TO_BE_EXECUTED_NEXT_PROPERTY_NAME); } catch (PropertyException e) {
@Override @Deprecated public void addRouteElementToRoute(DocumentRef parentDocumentRef, String sourceName, DocumentRouteElement routeElement, CoreSession session) throws DocumentRouteNotLockedException { DocumentRoute parentRoute = getParentRouteModel(parentDocumentRef, session); if (!isLockedByCurrentUser(parentRoute, session)) { throw new DocumentRouteNotLockedException(); } PathSegmentService pss = Framework.getService(PathSegmentService.class); DocumentModel docRouteElement = routeElement.getDocument(); DocumentModel parentDocument = session.getDocument(parentDocumentRef); docRouteElement.setPathInfo(parentDocument.getPathAsString(), pss.generatePathSegment(docRouteElement)); String lifecycleState = parentDocument.getCurrentLifeCycleState() .equals(DocumentRouteElement.ElementLifeCycleState.draft.name()) ? DocumentRouteElement.ElementLifeCycleState.draft.name() : DocumentRouteElement.ElementLifeCycleState.ready.name(); docRouteElement.putContextData(LifeCycleConstants.INITIAL_LIFECYCLE_STATE_OPTION_NAME, lifecycleState); docRouteElement = session.createDocument(docRouteElement); session.orderBefore(parentDocumentRef, docRouteElement.getName(), sourceName); session.save();// the new document will be queried later on }
@Override public void run(CoreSession session, DocumentRouteElement element) { if (element.isRunning()) { return; } else { element.setRunning(session); } if (!(element instanceof DocumentRouteStep)) { throw new RuntimeException("Method run should be overriden in parent class."); } EventFirer.fireEvent(session, element, null, DocumentRoutingConstants.Events.beforeStepRunning.name()); try (OperationContext context = new OperationContext(session)) { context.put(DocumentRoutingConstants.OPERATION_STEP_DOCUMENT_KEY, element); context.setInput(element.getAttachedDocuments(session)); if (!element.isDone()) { EventFirer.fireEvent(session, element, null, DocumentRoutingConstants.Events.stepWaiting.name()); } String chainId = getDocumentRoutingService().getOperationChainId(element.getDocument().getType()); getAutomationService().run(context, chainId); } catch (OperationException e) { throw new NuxeoException(e); } }
@Override public void undo(CoreSession session, DocumentRouteElement element) { EventFirer.fireEvent(session, element, null, DocumentRoutingConstants.Events.beforeUndoingStep.name()); try (OperationContext context = new OperationContext(session)) { context.put(DocumentRoutingConstants.OPERATION_STEP_DOCUMENT_KEY, element); context.setInput(element.getAttachedDocuments(session)); String operationChainId; String docType = element.getDocument().getType(); if (element.isDone()) { operationChainId = getDocumentRoutingService().getUndoFromDoneOperationChainId(docType); } else if (element.isRunning()) { operationChainId = getDocumentRoutingService().getUndoFromRunningOperationChainId(docType); } else { throw new RuntimeException("Trying to undo a step neither in done nor running state."); } getAutomationService().run(context, operationChainId); } catch (OperationException e) { throw new NuxeoException(e); } EventFirer.fireEvent(session, element, null, DocumentRoutingConstants.Events.afterUndoingStep.name()); }