Search in sources :

Example 1 with NextableElement

use of org.apache.inlong.manager.workflow.definition.NextableElement in project incubator-inlong by apache.

the class ProcessorExecutorImpl method executeSkipAndNext.

private void executeSkipAndNext(Element element, WorkflowContext context) {
    if (!(element instanceof SkippableElement)) {
        throw new WorkflowException("element not instance of skip element " + element.getDisplayName());
    }
    if (!(element instanceof NextableElement)) {
        throw new WorkflowException("element not instance of nextable element " + element.getDisplayName());
    }
    ElementProcessor processor = this.getProcessor(element.getClass());
    if (!(processor instanceof SkipableElementProcessor)) {
        throw new WorkflowException("element processor not instance of skip processor " + element.getDisplayName());
    }
    // Execute skip logic
    SkipableElementProcessor skipableProcessor = (SkipableElementProcessor) processor;
    skipableProcessor.skip(element, context);
    // Execute next
    context.getActionContext().setAction(((NextableElement) element).defaultNextAction());
    List<Element> nextElements = processor.next(element, context);
    nextElements.forEach(next -> executeStart(next, context));
}
Also used : SkipableElementProcessor(org.apache.inlong.manager.workflow.processor.SkipableElementProcessor) NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException) Element(org.apache.inlong.manager.workflow.definition.Element) NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) SkippableElement(org.apache.inlong.manager.workflow.definition.SkippableElement) SkippableElement(org.apache.inlong.manager.workflow.definition.SkippableElement) ElementProcessor(org.apache.inlong.manager.workflow.processor.ElementProcessor) SkipableElementProcessor(org.apache.inlong.manager.workflow.processor.SkipableElementProcessor)

Example 2 with NextableElement

use of org.apache.inlong.manager.workflow.definition.NextableElement in project incubator-inlong by apache.

the class WorkflowQueryServiceImpl method addNext.

private void addNext(NextableElement nextableElement, ElementDTO elementDTO, WorkflowContext context, Map<String, TaskStatus> nameToStatusMap) {
    for (Element element : nextableElement.getNextList(context)) {
        ElementDTO nextElement = new ElementDTO();
        nextElement.setName(element.getName());
        nextElement.setDisplayName(element.getDisplayName());
        if (element instanceof UserTask) {
            nextElement.setApprovers(((UserTask) element).getApproverAssign().assign(context));
            nextElement.setStatus(nameToStatusMap.get(element.getName()));
        }
        elementDTO.getNext().add(nextElement);
        if (!(element instanceof NextableElement)) {
            continue;
        }
        addNext((NextableElement) element, nextElement, context, nameToStatusMap);
    }
}
Also used : NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) ElementDTO(org.apache.inlong.manager.common.pojo.workflow.ElementDTO) Element(org.apache.inlong.manager.workflow.definition.Element) NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) UserTask(org.apache.inlong.manager.workflow.definition.UserTask)

Aggregations

Element (org.apache.inlong.manager.workflow.definition.Element)2 NextableElement (org.apache.inlong.manager.workflow.definition.NextableElement)2 WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)1 ElementDTO (org.apache.inlong.manager.common.pojo.workflow.ElementDTO)1 SkippableElement (org.apache.inlong.manager.workflow.definition.SkippableElement)1 UserTask (org.apache.inlong.manager.workflow.definition.UserTask)1 ElementProcessor (org.apache.inlong.manager.workflow.processor.ElementProcessor)1 SkipableElementProcessor (org.apache.inlong.manager.workflow.processor.SkipableElementProcessor)1