Search in sources :

Example 6 with NodeWorkflowStep

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

the class WorkflowGraphUtils method isStepEmpty.

public static boolean isStepEmpty(WorkflowStep step, TopologyContext topologyContext) {
    // No activity
    if (step.getActivity() == null) {
        return true;
    }
    // Inline activity is never empty
    if (step.getActivity() instanceof DelegateWorkflowActivity || step.getActivity() instanceof SetStateWorkflowActivity || step.getActivity() instanceof InlineWorkflowActivity) {
        return false;
    }
    CallOperationWorkflowActivity callOperationWorkflowActivity = (CallOperationWorkflowActivity) step.getActivity();
    NodeTemplate nodeTemplate = topologyContext.getTopology().getNodeTemplates().get(step.getTarget());
    String stepInterfaceName = ToscaNormativeUtil.getLongInterfaceName(callOperationWorkflowActivity.getInterfaceName());
    String stepOperationName = callOperationWorkflowActivity.getOperationName();
    if (step instanceof NodeWorkflowStep) {
        return !hasImplementation(nodeTemplate, NodeType.class, topologyContext, stepInterfaceName, stepOperationName);
    } else if (step instanceof RelationshipWorkflowStep) {
        RelationshipWorkflowStep relationshipWorkflowStep = (RelationshipWorkflowStep) step;
        RelationshipTemplate relationshipTemplate = nodeTemplate.getRelationships().get(relationshipWorkflowStep.getTargetRelationship());
        return !hasImplementation(relationshipTemplate, RelationshipType.class, topologyContext, stepInterfaceName, stepOperationName);
    } else {
        return false;
    }
}
Also used : InlineWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.InlineWorkflowActivity) NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) RelationshipTemplate(org.alien4cloud.tosca.model.templates.RelationshipTemplate) NodeType(org.alien4cloud.tosca.model.types.NodeType) SetStateWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.SetStateWorkflowActivity) NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep) RelationshipWorkflowStep(org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep) DelegateWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.DelegateWorkflowActivity) CallOperationWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.CallOperationWorkflowActivity)

Example 7 with NodeWorkflowStep

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

the class WorkflowUtils method createStateStep.

public static WorkflowStep createStateStep(Workflow wf, String nodeId, String stateName) {
    SetStateWorkflowActivity task = new SetStateWorkflowActivity();
    task.setStateName(stateName);
    NodeWorkflowStep step = new NodeWorkflowStep();
    step.setTarget(nodeId);
    step.setActivity(task);
    step.setName(buildStepName(wf, step, 0));
    return step;
}
Also used : SetStateWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.SetStateWorkflowActivity) NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep)

Example 8 with NodeWorkflowStep

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

the class WorkflowUtils method createDelegateWorkflowStep.

public static WorkflowStep createDelegateWorkflowStep(Workflow wf, String nodeId) {
    DelegateWorkflowActivity activity = new DelegateWorkflowActivity();
    activity.setDelegate(wf.getName());
    NodeWorkflowStep step = new NodeWorkflowStep();
    step.setTarget(nodeId);
    step.setActivity(activity);
    step.setName(buildStepName(wf, step, 0));
    return step;
}
Also used : NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep) DelegateWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.DelegateWorkflowActivity)

Example 9 with NodeWorkflowStep

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

the class WorkflowUtils method createOperationStep.

public static WorkflowStep createOperationStep(Workflow wf, String nodeId, String interfaceName, String operationName) {
    CallOperationWorkflowActivity task = new CallOperationWorkflowActivity();
    task.setInterfaceName(interfaceName);
    task.setOperationName(operationName);
    NodeWorkflowStep step = new NodeWorkflowStep();
    step.setTarget(nodeId);
    step.setActivity(task);
    step.setName(buildStepName(wf, step, 0));
    return step;
}
Also used : NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep) CallOperationWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.CallOperationWorkflowActivity)

Aggregations

NodeWorkflowStep (org.alien4cloud.tosca.model.workflow.NodeWorkflowStep)9 RelationshipWorkflowStep (org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep)6 WorkflowStep (org.alien4cloud.tosca.model.workflow.WorkflowStep)5 NodeType (org.alien4cloud.tosca.model.types.NodeType)2 CallOperationWorkflowActivity (org.alien4cloud.tosca.model.workflow.activities.CallOperationWorkflowActivity)2 DelegateWorkflowActivity (org.alien4cloud.tosca.model.workflow.activities.DelegateWorkflowActivity)2 SetStateWorkflowActivity (org.alien4cloud.tosca.model.workflow.activities.SetStateWorkflowActivity)2 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)1 Set (java.util.Set)1 Csar (org.alien4cloud.tosca.model.Csar)1 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)1 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)1 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)1 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)1 InlineWorkflowActivity (org.alien4cloud.tosca.model.workflow.activities.InlineWorkflowActivity)1 Test (org.junit.Test)1