Search in sources :

Example 1 with RemoveWorkflowOperation

use of org.alien4cloud.tosca.editor.operations.workflow.RemoveWorkflowOperation 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)

Aggregations

BadWorkflowOperationException (alien4cloud.paas.wf.exception.BadWorkflowOperationException)1 Slf4j (lombok.extern.slf4j.Slf4j)1 EditionContextManager (org.alien4cloud.tosca.editor.EditionContextManager)1 RemoveWorkflowOperation (org.alien4cloud.tosca.editor.operations.workflow.RemoveWorkflowOperation)1 Csar (org.alien4cloud.tosca.model.Csar)1 Topology (org.alien4cloud.tosca.model.templates.Topology)1 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)1 InlineWorkflowActivity (org.alien4cloud.tosca.model.workflow.activities.InlineWorkflowActivity)1 Component (org.springframework.stereotype.Component)1