Search in sources :

Example 26 with Workflow

use of org.alien4cloud.tosca.model.workflow.Workflow in project alien4cloud by alien4cloud.

the class RemoveWorkflowProcessor method processWorkflowOperation.

@Override
protected void processWorkflowOperation(Csar csar, Topology topology, RemoveWorkflowOperation operation, Workflow workflow) {
    ensureNotStandard(workflow, "standard workflow <" + workflow.getName() + "> can not be removed");
    log.debug("removing workflow [ {} ] from topology [ {} ]", operation.getWorkflowName(), topology.getId());
    topology.getWorkflows().remove(operation.getWorkflowName());
    topology.getWorkflows().values().forEach(wf -> wf.getSteps().values().forEach(step -> {
        if (step.getActivity() instanceof InlineWorkflowActivity) {
            InlineWorkflowActivity inlineWorkflowActivity = (InlineWorkflowActivity) step.getActivity();
            if (inlineWorkflowActivity.getInline().equals(workflow.getName())) {
                throw new BadWorkflowOperationException("Workflow " + inlineWorkflowActivity.getInline() + " is inlined in workflow " + wf.getName() + " in step " + step.getName());
            }
        }
    }));
}
Also used : Component(org.springframework.stereotype.Component) Slf4j(lombok.extern.slf4j.Slf4j) RemoveWorkflowOperation(org.alien4cloud.tosca.editor.operations.workflow.RemoveWorkflowOperation) Csar(org.alien4cloud.tosca.model.Csar) InlineWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.InlineWorkflowActivity) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) BadWorkflowOperationException(alien4cloud.paas.wf.exception.BadWorkflowOperationException) EditionContextManager(org.alien4cloud.tosca.editor.EditionContextManager) Topology(org.alien4cloud.tosca.model.templates.Topology) InlineWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.InlineWorkflowActivity) BadWorkflowOperationException(alien4cloud.paas.wf.exception.BadWorkflowOperationException)

Example 27 with Workflow

use of org.alien4cloud.tosca.model.workflow.Workflow in project alien4cloud by alien4cloud.

the class AbstractWorkflowProcessor method process.

@Override
public void process(Csar csar, Topology topology, T operation) {
    Workflow workflow = workflowBuilderService.getWorkflow(operation.getWorkflowName(), topology);
    processWorkflowOperation(csar, topology, operation, workflow);
    if (!operation.getClass().getSimpleName().toString().equals(ReinitializeWorkflowOperation.class.getSimpleName().toString())) {
        workflow.setHasCustomModifications(true);
    }
}
Also used : ReinitializeWorkflowOperation(org.alien4cloud.tosca.editor.operations.workflow.ReinitializeWorkflowOperation) Workflow(org.alien4cloud.tosca.model.workflow.Workflow)

Example 28 with Workflow

use of org.alien4cloud.tosca.model.workflow.Workflow in project alien4cloud by alien4cloud.

the class GraphPathsTest method test1.

/**
 * a -- b
 */
@Test
public void test1() {
    Workflow wf = new Workflow();
    wf.setName(INSTALL);
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowUtils.linkSteps(a, b);
    List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
    log.info(paths.toString());
}
Also used : Path(alien4cloud.paas.wf.model.Path) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Test(org.junit.Test)

Example 29 with Workflow

use of org.alien4cloud.tosca.model.workflow.Workflow in project alien4cloud by alien4cloud.

the class GraphPathsTest method test2.

/**
 * -- a --
 * -- b --
 */
@Test
public void test2() {
    Workflow wf = new Workflow();
    wf.setName(INSTALL);
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
    log.info(paths.toString());
}
Also used : Path(alien4cloud.paas.wf.model.Path) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Test(org.junit.Test)

Example 30 with Workflow

use of org.alien4cloud.tosca.model.workflow.Workflow in project alien4cloud by alien4cloud.

the class GraphPathsTest method testComplexe.

/**
 * <pre>
 *     -- b --      -- e
 *    /        \   /
 * a             d
 *    \        /   \
 *     -- c --      -- f
 * </pre>
 */
@Test
public void testComplexe() {
    Workflow wf = new Workflow();
    wf.setName(INSTALL);
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowStep c = wf.addStep(new SimpleStep("c"));
    WorkflowStep d = wf.addStep(new SimpleStep("d"));
    WorkflowStep e = wf.addStep(new SimpleStep("e"));
    WorkflowStep f = wf.addStep(new SimpleStep("f"));
    WorkflowUtils.linkSteps(a, b);
    WorkflowUtils.linkSteps(a, c);
    WorkflowUtils.linkSteps(b, d);
    WorkflowUtils.linkSteps(c, d);
    WorkflowUtils.linkSteps(d, e);
    WorkflowUtils.linkSteps(d, f);
    List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
    log.info(paths.toString());
}
Also used : Path(alien4cloud.paas.wf.model.Path) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Test(org.junit.Test)

Aggregations

Workflow (org.alien4cloud.tosca.model.workflow.Workflow)46 WorkflowStep (org.alien4cloud.tosca.model.workflow.WorkflowStep)20 NotFoundException (alien4cloud.exception.NotFoundException)11 Test (org.junit.Test)10 Map (java.util.Map)7 Path (alien4cloud.paas.wf.model.Path)6 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)6 List (java.util.List)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)5 TopologyDTO (alien4cloud.topology.TopologyDTO)4 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)4 AlienUtils.safe (alien4cloud.utils.AlienUtils.safe)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Slf4j (lombok.extern.slf4j.Slf4j)4 Csar (org.alien4cloud.tosca.model.Csar)4 Topology (org.alien4cloud.tosca.model.templates.Topology)4 WorkflowUtils (alien4cloud.paas.wf.util.WorkflowUtils)3