use of org.apache.inlong.manager.workflow.definition.Element 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));
}
use of org.apache.inlong.manager.workflow.definition.Element in project incubator-inlong by apache.
the class ProcessorExecutorImpl method executeComplete.
@Override
public void executeComplete(Element element, WorkflowContext context) {
ElementProcessor processor = this.getProcessor(element.getClass());
context.setCurrentElement(element);
boolean completed = processor.complete(context);
if (!completed) {
return;
}
List<Element> nextElements = processor.next(element, context);
nextElements.forEach(next -> executeStart(next, context));
}
use of org.apache.inlong.manager.workflow.definition.Element 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);
}
}
use of org.apache.inlong.manager.workflow.definition.Element in project incubator-inlong by apache.
the class AbstractNextableElementProcessor method next.
@Override
public List<Element> next(T element, WorkflowContext context) {
WorkflowContext.ActionContext actionContext = context.getActionContext();
List<Element> nextElements = element.getNextList(actionContext.getAction(), context);
Preconditions.checkNotEmpty(nextElements, "not found next element ");
Element endEvent = nextElements.stream().filter(EndEvent.class::isInstance).findFirst().orElse(null);
if (endEvent == null) {
return nextElements;
}
List<Element> notEndEventElements = nextElements.stream().filter(ele -> !(ele instanceof EndEvent)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(notEndEventElements)) {
return Collections.singletonList(endEvent);
}
throw new WorkflowException("process definition error, find endEvent and not endEvent at the same time");
}
use of org.apache.inlong.manager.workflow.definition.Element in project incubator-inlong by apache.
the class LogableEventListener method buildEventLog.
protected WorkflowEventLogEntity buildEventLog(WorkflowContext context) {
WorkflowProcessEntity workflowProcessEntity = context.getProcessEntity();
Element currentElement = context.getCurrentElement();
WorkflowEventLogEntity logEntity = new WorkflowEventLogEntity();
logEntity.setProcessId(workflowProcessEntity.getId());
logEntity.setProcessName(workflowProcessEntity.getName());
logEntity.setProcessDisplayName(workflowProcessEntity.getDisplayName());
logEntity.setInlongGroupId(context.getProcessForm().getInlongGroupId());
logEntity.setElementName(currentElement.getName());
logEntity.setElementDisplayName(currentElement.getDisplayName());
logEntity.setEventType(event().getClass().getSimpleName());
logEntity.setEvent(event().name());
logEntity.setListener(eventListener.name());
logEntity.setStatus(EventStatus.EXECUTING.getStatus());
logEntity.setAsync(async() ? 1 : 0);
logEntity.setIp(NetworkUtils.getLocalIp());
logEntity.setStartTime(new Date());
return logEntity;
}
Aggregations