Search in sources :

Example 1 with InconsistentWorkflowException

use of alien4cloud.paas.wf.exception.InconsistentWorkflowException in project alien4cloud by alien4cloud.

the class AbstractWorkflowBuilder method removeEdge.

public void removeEdge(Workflow wf, String from, String to) {
    WorkflowStep fromStep = wf.getSteps().get(from);
    if (fromStep == null) {
        throw new InconsistentWorkflowException(String.format("Inconsistent workflow: a step nammed '%s' can not be found while it's referenced else where ...", from));
    }
    WorkflowStep toStep = wf.getSteps().get(to);
    if (toStep == null) {
        throw new InconsistentWorkflowException(String.format("Inconsistent workflow: a step nammed '%s' can not be found while it's referenced else where ...", to));
    }
    fromStep.removeFollowing(to);
    toStep.removePreceding(from);
}
Also used : InconsistentWorkflowException(alien4cloud.paas.wf.exception.InconsistentWorkflowException) NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep) RelationshipWorkflowStep(org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep)

Example 2 with InconsistentWorkflowException

use of alien4cloud.paas.wf.exception.InconsistentWorkflowException in project alien4cloud by alien4cloud.

the class AbstractWorkflowBuilder method connectStepFrom.

void connectStepFrom(Workflow wf, String stepId, String[] stepNames) {
    WorkflowStep to = wf.getSteps().get(stepId);
    if (to == null) {
        throw new InconsistentWorkflowException(String.format("Inconsistent workflow: a step nammed '%s' can not be found while it's referenced else where ...", stepId));
    }
    for (String preceding : stepNames) {
        WorkflowStep precedingStep = wf.getSteps().get(preceding);
        if (precedingStep == null) {
            throw new InconsistentWorkflowException(String.format("Inconsistent workflow: a step nammed '%s' can not be found while it's referenced else where ...", preceding));
        }
        WorkflowUtils.linkSteps(precedingStep, to);
    }
}
Also used : InconsistentWorkflowException(alien4cloud.paas.wf.exception.InconsistentWorkflowException) NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep) RelationshipWorkflowStep(org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep)

Example 3 with InconsistentWorkflowException

use of alien4cloud.paas.wf.exception.InconsistentWorkflowException in project alien4cloud by alien4cloud.

the class AbstractWorkflowBuilder method removeStep.

void removeStep(Workflow wf, String stepId, boolean force) {
    WorkflowStep step = wf.getSteps().remove(stepId);
    if (step == null) {
        throw new InconsistentWorkflowException(String.format("Inconsistent workflow: a step nammed '%s' can not be found while it's referenced else where ...", stepId));
    }
    if (!force && step.getActivity() instanceof DelegateWorkflowActivity) {
        throw new BadWorkflowOperationException("Native steps can not be removed from workflow");
    }
    if (step.getPrecedingSteps() != null) {
        if (step.getOnSuccess() != null) {
            // connect all preceding to all following
            for (String precedingId : step.getPrecedingSteps()) {
                WorkflowStep preceding = wf.getSteps().get(precedingId);
                for (String followingId : step.getOnSuccess()) {
                    WorkflowStep following = wf.getSteps().get(followingId);
                    WorkflowUtils.linkSteps(preceding, following);
                }
            }
        }
        for (Object precedingId : step.getPrecedingSteps().toArray()) {
            WorkflowStep preceding = wf.getSteps().get(precedingId);
            unlinkSteps(preceding, step);
        }
    }
    if (step.getOnSuccess() != null) {
        for (Object followingId : step.getOnSuccess().toArray()) {
            WorkflowStep following = wf.getSteps().get(followingId);
            unlinkSteps(step, following);
        }
    }
}
Also used : InconsistentWorkflowException(alien4cloud.paas.wf.exception.InconsistentWorkflowException) NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep) RelationshipWorkflowStep(org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) BadWorkflowOperationException(alien4cloud.paas.wf.exception.BadWorkflowOperationException) DelegateWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.DelegateWorkflowActivity)

Example 4 with InconsistentWorkflowException

use of alien4cloud.paas.wf.exception.InconsistentWorkflowException in project alien4cloud by alien4cloud.

the class AbstractWorkflowBuilder method connectStepTo.

void connectStepTo(Workflow wf, String stepId, String[] stepNames) {
    WorkflowStep from = wf.getSteps().get(stepId);
    if (from == null) {
        throw new InconsistentWorkflowException(String.format("Inconsistent workflow: a step nammed '%s' can not be found while it's referenced else where ...", stepId));
    }
    for (String following : stepNames) {
        WorkflowStep followingStep = wf.getSteps().get(following);
        WorkflowUtils.linkSteps(from, followingStep);
    }
}
Also used : InconsistentWorkflowException(alien4cloud.paas.wf.exception.InconsistentWorkflowException) NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep) RelationshipWorkflowStep(org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep)

Aggregations

InconsistentWorkflowException (alien4cloud.paas.wf.exception.InconsistentWorkflowException)4 NodeWorkflowStep (org.alien4cloud.tosca.model.workflow.NodeWorkflowStep)4 RelationshipWorkflowStep (org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep)4 WorkflowStep (org.alien4cloud.tosca.model.workflow.WorkflowStep)4 BadWorkflowOperationException (alien4cloud.paas.wf.exception.BadWorkflowOperationException)1 DelegateWorkflowActivity (org.alien4cloud.tosca.model.workflow.activities.DelegateWorkflowActivity)1