Search in sources :

Example 1 with DAGTask

use of io.boomerang.mongo.model.next.DAGTask in project flow.service.workflow by boomerang-io.

the class FlowActivityServiceImpl method setupTaskOutputResults.

private void setupTaskOutputResults(TaskExecutionEntity task, TaskExecutionResponse response, List<TaskOutputResult> results) {
    if (task.getTemplateId() == null) {
        return;
    }
    Integer templateVersion = task.getTemplateRevision();
    FlowTaskTemplateEntity flowTaskTemplate = templateService.getTaskTemplateWithId(task.getTemplateId());
    String templateType = flowTaskTemplate.getNodetype();
    if ("templateTask".equals(templateType)) {
        List<Revision> revisions = flowTaskTemplate.getRevisions();
        if (revisions != null) {
            Optional<Revision> result = revisions.stream().parallel().filter(revision -> revision.getVersion().equals(templateVersion)).findAny();
            if (result.isPresent()) {
                Revision revision = result.get();
                List<TaskResult> taskResults = revision.getResults();
                if (taskResults != null) {
                    for (TaskResult resultItem : taskResults) {
                        extractOutputProperty(task, results, resultItem);
                    }
                }
            } else {
                Optional<Revision> latestRevision = revisions.stream().sorted(Comparator.comparingInt(Revision::getVersion).reversed()).findFirst();
                if (latestRevision.isPresent()) {
                    List<TaskResult> taskResults = latestRevision.get().getResults();
                    if (taskResults != null) {
                        for (TaskResult resultItem : taskResults) {
                            extractOutputProperty(task, results, resultItem);
                        }
                    }
                }
            }
        }
    } else {
        String activityId = task.getActivityId();
        ActivityEntity activity = workflowActivityService.findWorkflowActivtyById(activityId);
        String revisionId = activity.getWorkflowRevisionid();
        Optional<RevisionEntity> revisionEntity = this.revisionService.getRevision(revisionId);
        if (revisionEntity.isPresent()) {
            RevisionEntity revision = revisionEntity.get();
            List<DAGTask> tasks = revision.getDag().getTasks();
            DAGTask dagTask = tasks.stream().filter(x -> x.getTaskId().equals(task.getTaskId())).findFirst().orElse(null);
            if (dagTask != null) {
                dagTask.getResults();
                List<TaskResult> dagResults = dagTask.getResults();
                if (dagResults != null) {
                    for (TaskResult taskResult : dagResults) {
                        TaskOutputResult outputResult = new TaskOutputResult();
                        String key = taskResult.getName();
                        outputResult.setName(key);
                        outputResult.setDescription(taskResult.getDescription());
                        if (task.getOutputs() != null && task.getOutputs().containsKey(key)) {
                            outputResult.setValue(task.getOutputs().get(key));
                        }
                        results.add(outputResult);
                    }
                }
            }
        }
    }
    response.setResults(results);
}
Also used : TaskExecutionResponse(io.boomerang.model.TaskExecutionResponse) Arrays(java.util.Arrays) TeamEntity(io.boomerang.mongo.entity.TeamEntity) FlowWorkflowService(io.boomerang.mongo.service.FlowWorkflowService) TaskStatus(io.boomerang.mongo.model.TaskStatus) URLDecoder(java.net.URLDecoder) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) TaskType(io.boomerang.mongo.model.TaskType) ControllerRequestProperties(io.boomerang.service.refactor.ControllerRequestProperties) TaskOutputResult(io.boomerang.model.TaskOutputResult) KeyValuePair(io.boomerang.mongo.model.KeyValuePair) Revision(io.boomerang.mongo.model.Revision) Sort(io.boomerang.model.Sort) PropertyManager(io.boomerang.service.PropertyManager) FlowActivity(io.boomerang.model.FlowActivity) FlowTaskTemplateEntity(io.boomerang.mongo.entity.FlowTaskTemplateEntity) RevisionService(io.boomerang.mongo.service.RevisionService) Map(java.util.Map) Pageable(org.springframework.data.domain.Pageable) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) RestTemplate(org.springframework.web.client.RestTemplate) RevisionEntity(io.boomerang.mongo.entity.RevisionEntity) PrintWriter(java.io.PrintWriter) FlowUserEntity(io.boomerang.mongo.entity.FlowUserEntity) FlowTriggerEnum(io.boomerang.mongo.model.FlowTriggerEnum) ResponseExtractor(org.springframework.web.client.ResponseExtractor) MediaType(org.springframework.http.MediaType) FilterService(io.boomerang.service.FilterService) StreamingResponseBody(org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody) FlowTaskTemplateService(io.boomerang.mongo.service.FlowTaskTemplateService) Reader(java.io.Reader) Instant(java.time.Instant) Page(org.springframework.data.domain.Page) ParameterMapper(io.boomerang.util.ParameterMapper) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) PageableExecutionUtils(org.springframework.data.support.PageableExecutionUtils) ActionService(io.boomerang.service.ActionService) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TaskExecutionEntity(io.boomerang.mongo.entity.TaskExecutionEntity) WorkflowScope(io.boomerang.mongo.model.WorkflowScope) Optional(java.util.Optional) Lazy(org.springframework.context.annotation.Lazy) TaskResult(io.boomerang.model.controller.TaskResult) Pattern(java.util.regex.Pattern) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) BeanUtils(org.springframework.beans.BeanUtils) DateUtil(io.boomerang.util.DateUtil) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) LocalDateTime(java.time.LocalDateTime) ActivityEntity(io.boomerang.mongo.entity.ActivityEntity) HashMap(java.util.HashMap) ErrorResponse(io.boomerang.mongo.model.ErrorResponse) ControllerClient(io.boomerang.service.runner.misc.ControllerClient) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) Action(io.boomerang.model.teams.Action) FlowSettingsService(io.boomerang.mongo.service.FlowSettingsService) FlowWorkflowActivityService(io.boomerang.mongo.service.FlowWorkflowActivityService) Service(org.springframework.stereotype.Service) Qualifier(org.springframework.beans.factory.annotation.Qualifier) WorkflowEntity(io.boomerang.mongo.entity.WorkflowEntity) Direction(org.springframework.data.domain.Sort.Direction) TaskWorkspace(io.boomerang.model.controller.TaskWorkspace) LinkedList(java.util.LinkedList) OutputStream(java.io.OutputStream) Task(io.boomerang.model.Task) DAGTask(io.boomerang.mongo.model.next.DAGTask) Dag(io.boomerang.mongo.model.Dag) HttpMethod(org.springframework.http.HttpMethod) ListActivityResponse(io.boomerang.model.ListActivityResponse) InputStreamReader(java.io.InputStreamReader) Criteria(org.springframework.data.mongodb.core.query.Criteria) Query(org.springframework.data.mongodb.core.query.Query) RequestCallback(org.springframework.web.client.RequestCallback) FlowExecutionRequest(io.boomerang.model.FlowExecutionRequest) TimeUnit(java.util.concurrent.TimeUnit) ActivityTaskService(io.boomerang.mongo.service.ActivityTaskService) BufferedReader(java.io.BufferedReader) Comparator(java.util.Comparator) UserIdentityService(io.boomerang.service.UserIdentityService) LogManager(org.apache.logging.log4j.LogManager) InputStream(java.io.InputStream) TaskTemplateConfig(io.boomerang.mongo.model.TaskTemplateConfig) TaskOutputResult(io.boomerang.model.TaskOutputResult) ActivityEntity(io.boomerang.mongo.entity.ActivityEntity) DAGTask(io.boomerang.mongo.model.next.DAGTask) FlowTaskTemplateEntity(io.boomerang.mongo.entity.FlowTaskTemplateEntity) RevisionEntity(io.boomerang.mongo.entity.RevisionEntity) Revision(io.boomerang.mongo.model.Revision) TaskResult(io.boomerang.model.controller.TaskResult)

Example 2 with DAGTask

use of io.boomerang.mongo.model.next.DAGTask in project flow.service.workflow by boomerang-io.

the class TaskServiceImpl method createTaskList.

private List<Task> createTaskList(RevisionEntity revisionEntity, ActivityEntity activity) {
    // NOSONAR
    final Dag dag = revisionEntity.getDag();
    final List<Task> taskList = new LinkedList<>();
    for (final DAGTask dagTask : dag.getTasks()) {
        final Task newTask = new Task();
        newTask.setTaskId(dagTask.getTaskId());
        newTask.setTaskType(dagTask.getType());
        newTask.setTaskName(dagTask.getLabel());
        final String workFlowId = revisionEntity.getWorkFlowId();
        newTask.setWorkflowId(workFlowId);
        if (dagTask.getType() == TaskType.script || dagTask.getType() == TaskType.template || dagTask.getType() == TaskType.customtask) {
            TaskExecutionEntity task = taskActivityService.findByTaskIdAndActivityId(dagTask.getTaskId(), activity.getId());
            if (task != null) {
                newTask.setTaskActivityId(task.getId());
            }
            String templateId = dagTask.getTemplateId();
            final FlowTaskTemplateEntity flowTaskTemplate = templateService.getTaskTemplateWithId(templateId);
            newTask.setTemplateId(flowTaskTemplate.getId());
            Integer templateVersion = dagTask.getTemplateVersion();
            List<Revision> revisions = flowTaskTemplate.getRevisions();
            if (revisions != null) {
                Optional<Revision> result = revisions.stream().parallel().filter(revision -> revision.getVersion().equals(templateVersion)).findAny();
                if (result.isPresent()) {
                    Revision revision = result.get();
                    newTask.setRevision(revision);
                    newTask.setResults(revision.getResults());
                } else {
                    Optional<Revision> latestRevision = revisions.stream().sorted(Comparator.comparingInt(Revision::getVersion).reversed()).findFirst();
                    if (latestRevision.isPresent()) {
                        newTask.setRevision(latestRevision.get());
                        newTask.setResults(newTask.getRevision().getResults());
                    }
                }
            } else {
                throw new IllegalArgumentException("Invalid task template selected: " + templateId);
            }
            Map<String, String> properties = new HashMap<>();
            if (dagTask.getProperties() != null) {
                for (KeyValuePair property : dagTask.getProperties()) {
                    properties.put(property.getKey(), property.getValue());
                }
            }
            newTask.setInputs(properties);
            if (newTask.getResults() == null) {
                newTask.setResults(dagTask.getResults());
            }
        } else if (dagTask.getType() == TaskType.decision) {
            TaskExecutionEntity task = taskActivityService.findByTaskIdAndActivityId(dagTask.getTaskId(), activity.getId());
            if (task != null) {
                newTask.setTaskActivityId(task.getId());
            }
            newTask.setDecisionValue(dagTask.getDecisionValue());
        } else if (dagTask.getType() == TaskType.manual || dagTask.getType() == TaskType.runworkflow || dagTask.getType() == TaskType.runscheduledworkflow || dagTask.getType() == TaskType.setwfproperty || dagTask.getType() == TaskType.setwfstatus || dagTask.getType() == TaskType.acquirelock || dagTask.getType() == TaskType.releaselock) {
            TaskExecutionEntity task = taskActivityService.findByTaskIdAndActivityId(dagTask.getTaskId(), activity.getId());
            if (task != null) {
                newTask.setTaskActivityId(task.getId());
            }
            Map<String, String> properties = new HashMap<>();
            if (dagTask.getProperties() != null) {
                for (KeyValuePair property : dagTask.getProperties()) {
                    properties.put(property.getKey(), property.getValue());
                }
            }
            newTask.setInputs(properties);
        }
        final List<String> taskDepedancies = new LinkedList<>();
        for (Dependency dependency : dagTask.getDependencies()) {
            taskDepedancies.add(dependency.getTaskId());
        }
        newTask.setDetailedDepednacies(dagTask.getDependencies());
        newTask.setDependencies(taskDepedancies);
        taskList.add(newTask);
    }
    return taskList;
}
Also used : ApprovalEntity(io.boomerang.mongo.entity.ApprovalEntity) FlowWorkflowService(io.boomerang.mongo.service.FlowWorkflowService) TaskStatus(io.boomerang.mongo.model.TaskStatus) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) TaskType(io.boomerang.mongo.model.TaskType) KeyValuePair(io.boomerang.mongo.model.KeyValuePair) Revision(io.boomerang.mongo.model.Revision) StringUtils(org.apache.commons.lang3.StringUtils) PropertyManager(io.boomerang.service.PropertyManager) FlowTaskTemplateEntity(io.boomerang.mongo.entity.FlowTaskTemplateEntity) RevisionService(io.boomerang.mongo.service.RevisionService) Map(java.util.Map) RevisionEntity(io.boomerang.mongo.entity.RevisionEntity) WorkflowScheduleService(io.boomerang.service.crud.WorkflowScheduleService) TimeZone(java.util.TimeZone) FlowTaskTemplateService(io.boomerang.mongo.service.FlowTaskTemplateService) Collectors(java.util.stream.Collectors) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TaskExecutionEntity(io.boomerang.mongo.entity.TaskExecutionEntity) Dependency(io.boomerang.mongo.model.next.Dependency) RequestFlowExecution(io.boomerang.model.RequestFlowExecution) Optional(java.util.Optional) InternalTaskResponse(io.boomerang.mongo.model.internal.InternalTaskResponse) Lazy(org.springframework.context.annotation.Lazy) Async(org.springframework.scheduling.annotation.Async) ApprovalStatus(io.boomerang.model.ApprovalStatus) ActivityEntity(io.boomerang.mongo.entity.ActivityEntity) HashMap(java.util.HashMap) ErrorResponse(io.boomerang.mongo.model.ErrorResponse) ControllerClient(io.boomerang.service.runner.misc.ControllerClient) Calendar(java.util.Calendar) LockNotAvailableException(com.github.alturkovic.lock.exception.LockNotAvailableException) FlowWorkflowActivityService(io.boomerang.mongo.service.FlowWorkflowActivityService) Service(org.springframework.stereotype.Service) WorkflowEntity(io.boomerang.mongo.entity.WorkflowEntity) LinkedList(java.util.LinkedList) ManualType(io.boomerang.mongo.model.ManualType) SimpleRetryPolicy(org.springframework.retry.policy.SimpleRetryPolicy) Task(io.boomerang.model.Task) ApprovalService(io.boomerang.mongo.service.ApprovalService) DAGTask(io.boomerang.mongo.model.next.DAGTask) Dag(io.boomerang.mongo.model.Dag) Lock(com.github.alturkovic.lock.Lock) FlowActivityService(io.boomerang.service.crud.FlowActivityService) WorkflowSchedule(io.boomerang.model.WorkflowSchedule) ActivityTaskService(io.boomerang.mongo.service.ActivityTaskService) WorkflowScheduleType(io.boomerang.mongo.model.WorkflowScheduleType) FixedBackOffPolicy(org.springframework.retry.backoff.FixedBackOffPolicy) RetryTemplate(org.springframework.retry.support.RetryTemplate) Comparator(java.util.Comparator) LogManager(org.apache.logging.log4j.LogManager) InternalTaskRequest(io.boomerang.mongo.model.internal.InternalTaskRequest) Task(io.boomerang.model.Task) DAGTask(io.boomerang.mongo.model.next.DAGTask) KeyValuePair(io.boomerang.mongo.model.KeyValuePair) HashMap(java.util.HashMap) Dag(io.boomerang.mongo.model.Dag) Dependency(io.boomerang.mongo.model.next.Dependency) DAGTask(io.boomerang.mongo.model.next.DAGTask) LinkedList(java.util.LinkedList) TaskExecutionEntity(io.boomerang.mongo.entity.TaskExecutionEntity) FlowTaskTemplateEntity(io.boomerang.mongo.entity.FlowTaskTemplateEntity) Revision(io.boomerang.mongo.model.Revision)

Example 3 with DAGTask

use of io.boomerang.mongo.model.next.DAGTask in project flow.service.workflow by boomerang-io.

the class WorkflowServiceImpl method buildAvailableParamList.

private List<String> buildAvailableParamList(String workFlowId, RevisionEntity revision) {
    List<String> parameters = new ArrayList<>();
    WorkflowEntity workflow = workflowRepository.getWorkflow(workFlowId);
    if (flowSettingsService.getConfiguration("features", "globalParameters").getBooleanValue()) {
        Map<String, String> globalProperties = new HashMap<>();
        propertyManager.buildGlobalProperties(globalProperties);
        for (Map.Entry<String, String> globalProperty : globalProperties.entrySet()) {
            parameters.add("global.params." + globalProperty.getKey());
            parameters.add("params." + globalProperty.getKey());
        }
    }
    if (flowSettingsService.getConfiguration("features", "teamParameters").getBooleanValue() && workflow.getScope() != null && WorkflowScope.team.equals(workflow.getScope())) {
        Map<String, String> teamProperties = new HashMap<>();
        propertyManager.buildTeamProperties(teamProperties, workflow.getId());
        for (Map.Entry<String, String> teamProperty : teamProperties.entrySet()) {
            parameters.add("team.params." + teamProperty.getKey());
            parameters.add("params." + teamProperty.getKey());
        }
    }
    Map<String, String> workflowProperties = new HashMap<>();
    propertyManager.buildWorkflowProperties(workflowProperties, null, workflow.getId());
    for (Map.Entry<String, String> workflowProperty : workflowProperties.entrySet()) {
        parameters.add("workflow.params." + workflowProperty.getKey());
        parameters.add("params." + workflowProperty.getKey());
    }
    Map<String, String> systemProperties = new HashMap<>();
    propertyManager.buildSystemProperties(null, null, workflow.getId(), systemProperties);
    for (Map.Entry<String, String> systemProperty : systemProperties.entrySet()) {
        parameters.add("system.params." + systemProperty.getKey());
        parameters.add("params." + systemProperty.getKey());
    }
    if (revision != null) {
        Dag dag = revision.getDag();
        List<DAGTask> dagkTasks = dag.getTasks();
        if (dagkTasks != null) {
            for (DAGTask task : dagkTasks) {
                String taskName = task.getLabel();
                if (task.getTemplateId() != null) {
                    String templateId = task.getTemplateId();
                    FlowTaskTemplateEntity taskTemplate = templateService.getTaskTemplateWithId(templateId);
                    if (taskTemplate != null) {
                        if ("templateTask".equals(taskTemplate.getNodetype())) {
                            int revisionCount = taskTemplate.getRevisions().size();
                            Revision latestRevision = taskTemplate.getRevisions().stream().filter(x -> x.getVersion() == revisionCount).findFirst().orElse(null);
                            if (latestRevision != null) {
                                List<TaskResult> results = latestRevision.getResults();
                                if (results != null) {
                                    for (TaskResult result : results) {
                                        String key = "tasks." + taskName + ".results." + result.getName();
                                        parameters.add(key);
                                    }
                                }
                            }
                        } else {
                            List<TaskResult> results = task.getResults();
                            if (results != null) {
                                for (TaskResult result : results) {
                                    String key = "tasks." + taskName + ".results." + result.getName();
                                    parameters.add(key);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return parameters;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Dag(io.boomerang.mongo.model.Dag) WorkflowEntity(io.boomerang.mongo.entity.WorkflowEntity) DAGTask(io.boomerang.mongo.model.next.DAGTask) FlowTaskTemplateEntity(io.boomerang.mongo.entity.FlowTaskTemplateEntity) Revision(io.boomerang.mongo.model.Revision) FlowWorkflowRevision(io.boomerang.model.FlowWorkflowRevision) WorkflowRevision(io.boomerang.model.projectstormv5.WorkflowRevision) TaskResult(io.boomerang.model.controller.TaskResult) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with DAGTask

use of io.boomerang.mongo.model.next.DAGTask in project flow.service.workflow by boomerang-io.

the class DAGUtility method createTaskList.

private List<Task> createTaskList(RevisionEntity revisionEntity, ActivityEntity activity) {
    final Dag dag = revisionEntity.getDag();
    final List<Task> taskList = new LinkedList<>();
    for (final DAGTask dagTask : dag.getTasks()) {
        final Task newTask = new Task();
        newTask.setTaskId(dagTask.getTaskId());
        newTask.setTaskType(dagTask.getType());
        newTask.setTaskName(dagTask.getLabel());
        TaskExecutionEntity task = taskActivityService.findByTaskIdAndActivityId(dagTask.getTaskId(), activity.getId());
        if (task != null) {
            newTask.setTaskActivityId(task.getId());
        }
        final String workFlowId = revisionEntity.getWorkFlowId();
        newTask.setWorkflowId(workFlowId);
        if (dagTask.getType() == TaskType.script || dagTask.getType() == TaskType.template || dagTask.getType() == TaskType.customtask) {
            String templateId = dagTask.getTemplateId();
            final FlowTaskTemplateEntity flowTaskTemplate = templateService.getTaskTemplateWithId(templateId);
            newTask.setTemplateId(flowTaskTemplate.getId());
            Integer templateVersion = dagTask.getTemplateVersion();
            List<Revision> revisions = flowTaskTemplate.getRevisions();
            if (revisions != null) {
                Optional<Revision> result = revisions.stream().parallel().filter(revision -> revision.getVersion().equals(templateVersion)).findAny();
                if (result.isPresent()) {
                    Revision revision = result.get();
                    newTask.setRevision(revision);
                    newTask.setResults(revision.getResults());
                } else {
                    Optional<Revision> latestRevision = revisions.stream().sorted(Comparator.comparingInt(Revision::getVersion).reversed()).findFirst();
                    if (latestRevision.isPresent()) {
                        newTask.setRevision(latestRevision.get());
                        newTask.setResults(newTask.getRevision().getResults());
                    }
                }
            } else {
                throw new IllegalArgumentException("Invalid task template selected: " + templateId);
            }
            Map<String, String> properties = new HashMap<>();
            if (dagTask.getProperties() != null) {
                for (KeyValuePair property : dagTask.getProperties()) {
                    properties.put(property.getKey(), property.getValue());
                }
            }
            newTask.setInputs(properties);
            if (newTask.getResults() == null) {
                newTask.setResults(dagTask.getResults());
            }
        } else if (dagTask.getType() == TaskType.decision) {
            newTask.setDecisionValue(dagTask.getDecisionValue());
        }
        final List<String> taskDepedancies = new LinkedList<>();
        for (Dependency dependency : dagTask.getDependencies()) {
            taskDepedancies.add(dependency.getTaskId());
        }
        newTask.setDetailedDepednacies(dagTask.getDependencies());
        newTask.setDependencies(taskDepedancies);
        taskList.add(newTask);
    }
    return taskList;
}
Also used : TaskStatus(io.boomerang.mongo.model.TaskStatus) WorkflowExecutionCondition(io.boomerang.mongo.model.WorkflowExecutionCondition) TaskResult(io.boomerang.model.TaskResult) ActivityEntity(io.boomerang.mongo.entity.ActivityEntity) Autowired(org.springframework.beans.factory.annotation.Autowired) TaskType(io.boomerang.mongo.model.TaskType) HashMap(java.util.HashMap) KeyValuePair(io.boomerang.mongo.model.KeyValuePair) Revision(io.boomerang.mongo.model.Revision) Matcher(java.util.regex.Matcher) Pair(org.apache.commons.lang3.tuple.Pair) FlowTaskTemplateEntity(io.boomerang.mongo.entity.FlowTaskTemplateEntity) SingleSourcePaths(org.jgrapht.alg.interfaces.ShortestPathAlgorithm.SingleSourcePaths) Service(org.springframework.stereotype.Service) RevisionService(io.boomerang.mongo.service.RevisionService) Map(java.util.Map) LinkedList(java.util.LinkedList) RevisionEntity(io.boomerang.mongo.entity.RevisionEntity) GraphProcessor(io.boomerang.util.GraphProcessor) Iterator(java.util.Iterator) DefaultEdge(org.jgrapht.graph.DefaultEdge) Task(io.boomerang.model.Task) DAGTask(io.boomerang.mongo.model.next.DAGTask) Dag(io.boomerang.mongo.model.Dag) Set(java.util.Set) FlowTaskTemplateService(io.boomerang.mongo.service.FlowTaskTemplateService) Collectors(java.util.stream.Collectors) DijkstraShortestPath(org.jgrapht.alg.shortestpath.DijkstraShortestPath) List(java.util.List) ActivityTaskService(io.boomerang.mongo.service.ActivityTaskService) TaskExecutionEntity(io.boomerang.mongo.entity.TaskExecutionEntity) Dependency(io.boomerang.mongo.model.next.Dependency) Graph(org.jgrapht.Graph) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Comparator(java.util.Comparator) TopologicalOrderIterator(org.jgrapht.traverse.TopologicalOrderIterator) Task(io.boomerang.model.Task) DAGTask(io.boomerang.mongo.model.next.DAGTask) KeyValuePair(io.boomerang.mongo.model.KeyValuePair) HashMap(java.util.HashMap) Dag(io.boomerang.mongo.model.Dag) Dependency(io.boomerang.mongo.model.next.Dependency) DAGTask(io.boomerang.mongo.model.next.DAGTask) LinkedList(java.util.LinkedList) TaskExecutionEntity(io.boomerang.mongo.entity.TaskExecutionEntity) FlowTaskTemplateEntity(io.boomerang.mongo.entity.FlowTaskTemplateEntity) Revision(io.boomerang.mongo.model.Revision)

Example 5 with DAGTask

use of io.boomerang.mongo.model.next.DAGTask in project flow.service.workflow by boomerang-io.

the class ModelConverterV5 method convertToEntityModel.

public static RevisionEntity convertToEntityModel(WorkflowRevision revision) {
    RevisionEntity entity = new RevisionEntity();
    entity.setVersion(revision.getVersion());
    entity.setMarkdown(revision.getMarkdown());
    entity.setConfig(revision.getConfig());
    if (revision.getDag() == null) {
        return entity;
    }
    mapBaseData(revision, entity);
    List<Link> links = revision.getDag().getLinks();
    List<ConfigNodes> configNodes = revision.getConfig().getNodes();
    Dag dag = new Dag();
    entity.setDag(dag);
    List<DAGTask> tasks = new LinkedList<>();
    dag.setTasks(tasks);
    for (TaskNode node : revision.getDag().getNodes()) {
        DAGTask dagTask = new DAGTask();
        dagTask.setId(node.getNodeId());
        dagTask.setTemplateId(node.getTaskId());
        if ("startend".equals(node.getType())) {
            if ("Start".equals(node.getPassedName())) {
                dagTask.setType(TaskType.start);
            } else if ("End".equals(node.getPassedName())) {
                dagTask.setType(TaskType.end);
            }
        } else if (TEMPLATETASKNAME.equals(node.getType())) {
            dagTask.setType(TaskType.template);
        } else if (CUSTOMTASKNAME.equals(node.getType())) {
            dagTask.setType(TaskType.customtask);
        } else {
            dagTask.setType(TaskType.valueOf(node.getType()));
        }
        List<Dependency> dependencies = new LinkedList<>();
        dagTask.setDependencies(dependencies);
        List<Port> ports = node.getPorts();
        ConfigNodes config = configNodes.stream().parallel().filter(c -> node.getNodeId().equals(c.getNodeId())).findFirst().orElse(null);
        dagTask.setLabel(node.getTaskName());
        buildConfig(dagTask, config);
        caclulateDependncies(links, dependencies, ports);
        buildMetadataSection(node, dagTask);
        tasks.add(dagTask);
    }
    return entity;
}
Also used : TaskNode(io.boomerang.model.projectstormv5.TaskNode) Port(io.boomerang.model.projectstormv5.Port) RestDag(io.boomerang.model.projectstormv5.RestDag) Dag(io.boomerang.mongo.model.Dag) Dependency(io.boomerang.mongo.model.next.Dependency) ConfigNodes(io.boomerang.model.projectstormv5.ConfigNodes) DAGTask(io.boomerang.mongo.model.next.DAGTask) LinkedList(java.util.LinkedList) RevisionEntity(io.boomerang.mongo.entity.RevisionEntity) Link(io.boomerang.model.projectstormv5.Link)

Aggregations

DAGTask (io.boomerang.mongo.model.next.DAGTask)14 RevisionEntity (io.boomerang.mongo.entity.RevisionEntity)11 LinkedList (java.util.LinkedList)11 Dag (io.boomerang.mongo.model.Dag)10 FlowTaskTemplateEntity (io.boomerang.mongo.entity.FlowTaskTemplateEntity)9 Revision (io.boomerang.mongo.model.Revision)8 KeyValuePair (io.boomerang.mongo.model.KeyValuePair)7 Task (io.boomerang.model.Task)6 ActivityEntity (io.boomerang.mongo.entity.ActivityEntity)6 TaskExecutionEntity (io.boomerang.mongo.entity.TaskExecutionEntity)6 WorkflowEntity (io.boomerang.mongo.entity.WorkflowEntity)6 HashMap (java.util.HashMap)6 List (java.util.List)6 Map (java.util.Map)6 TaskStatus (io.boomerang.mongo.model.TaskStatus)5 Dependency (io.boomerang.mongo.model.next.Dependency)5 RevisionService (io.boomerang.mongo.service.RevisionService)5 Optional (java.util.Optional)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Service (org.springframework.stereotype.Service)5