Search in sources :

Example 1 with WorkflowStepRestRep

use of com.emc.storageos.model.workflow.WorkflowStepRestRep in project coprhd-controller by CoprHD.

the class WorkflowMapper method map.

public static WorkflowStepRestRep map(WorkflowStep from, List<URI> childWorkflows) {
    if (from == null) {
        return null;
    }
    WorkflowStepRestRep to = new WorkflowStepRestRep();
    mapDataObjectFields(from, to);
    to.setControllerName(from.getControllerName());
    to.setDescription(from.getDescription());
    to.setSystemType(from.getSystemType());
    to.setExecuteMethod(from.getExecuteMethod());
    to.setMessage(from.getMessage());
    to.setState(from.getState());
    to.setStepGroup(from.getStepGroup());
    to.setStepId(from.getStepId());
    to.setWaitFor(from.getWaitFor());
    if (false == from.getSystemId().equals(URIUtil.NULL_URI)) {
        to.setSystem(from.getSystemId().toString());
    } else {
        to.setSystem("");
    }
    to.setWorkflow(toRelatedResource(ResourceTypeEnum.WORKFLOW, from.getWorkflowId()));
    to.setStartTime(from.getStartTime());
    to.setEndTime(from.getEndTime());
    for (URI childWorkflow : childWorkflows) {
        to.getChildWorkflows().add(toRelatedResource(ResourceTypeEnum.WORKFLOW, childWorkflow));
    }
    return to;
}
Also used : WorkflowStepRestRep(com.emc.storageos.model.workflow.WorkflowStepRestRep) URI(java.net.URI)

Example 2 with WorkflowStepRestRep

use of com.emc.storageos.model.workflow.WorkflowStepRestRep in project coprhd-controller by CoprHD.

the class TaskUtils method getWorkflowSteps.

@Util
public static List<WorkflowStep> getWorkflowSteps(URI workflowId) {
    List<WorkflowStepRestRep> workflowSteps = getViprClient().workflows().getSteps(workflowId);
    // Order Workflow steps by date started, not started tasks will sink to the bottom of the list
    Collections.sort(workflowSteps, new Comparator<WorkflowStepRestRep>() {

        @Override
        public int compare(WorkflowStepRestRep o1, WorkflowStepRestRep o2) {
            if (o1.getStartTime() == null && o2.getStartTime() == null) {
                // If both steps not started yet, then just order on creation time
                return o1.getCreationTime().compareTo(o2.getCreationTime());
            }
            if (o1.getStartTime() == null && o2.getStartTime() != null) {
                return 1;
            }
            if (o1.getStartTime() != null && o2.getStartTime() == null) {
                return -1;
            }
            return o1.getStartTime().compareTo(o2.getStartTime());
        }
    });
    // Get the names of all resources
    Map<String, DataObjectRestRep> systemObjects = Maps.newHashMap();
    for (WorkflowStepRestRep step : workflowSteps) {
        ResourceType type = ResourceType.fromResourceId(step.getSystem());
        DataObjectRestRep dataObject = null;
        switch(type) {
            case STORAGE_SYSTEM:
                dataObject = getViprClient().storageSystems().get(uri(step.getSystem()));
                break;
            case PROTECTION_SYSTEM:
                dataObject = getViprClient().protectionSystems().get(uri(step.getSystem()));
                break;
            case NETWORK_SYSTEM:
                dataObject = getViprClient().networkSystems().get(uri(step.getSystem()));
                break;
            case COMPUTE_SYSTEM:
                dataObject = getViprClient().computeSystems().get(uri(step.getSystem()));
                break;
        }
        if (dataObject != null) {
            systemObjects.put(step.getSystem(), dataObject);
        }
    }
    List<WorkflowStep> steps = Lists.newArrayList();
    for (WorkflowStepRestRep workflowStep : workflowSteps) {
        steps.add(new WorkflowStep(workflowStep, systemObjects));
    }
    return steps;
}
Also used : WorkflowStepRestRep(com.emc.storageos.model.workflow.WorkflowStepRestRep) DataObjectRestRep(com.emc.storageos.model.DataObjectRestRep) ResourceType(com.emc.sa.util.ResourceType) URIUtil(com.emc.storageos.db.client.URIUtil) Util(play.mvc.Util)

Example 3 with WorkflowStepRestRep

use of com.emc.storageos.model.workflow.WorkflowStepRestRep in project coprhd-controller by CoprHD.

the class WorkflowMapper method map.

public static WorkflowStepRestRep map(WorkflowStep from) {
    if (from == null) {
        return null;
    }
    WorkflowStepRestRep to = new WorkflowStepRestRep();
    mapDataObjectFields(from, to);
    to.setControllerName(from.getControllerName());
    to.setDescription(from.getDescription());
    to.setSystemType(from.getSystemType());
    to.setExecuteMethod(from.getExecuteMethod());
    to.setMessage(from.getMessage());
    to.setState(from.getState());
    to.setStepGroup(from.getStepGroup());
    to.setStepId(from.getStepId());
    to.setWaitFor(from.getWaitFor());
    to.setSystem(from.getSystemId().toString());
    to.setWorkflow(toRelatedResource(ResourceTypeEnum.WORKFLOW, from.getWorkflowId()));
    to.setStartTime(from.getStartTime());
    to.setEndTime(from.getEndTime());
    return to;
}
Also used : WorkflowStepRestRep(com.emc.storageos.model.workflow.WorkflowStepRestRep)

Aggregations

WorkflowStepRestRep (com.emc.storageos.model.workflow.WorkflowStepRestRep)3 ResourceType (com.emc.sa.util.ResourceType)1 URIUtil (com.emc.storageos.db.client.URIUtil)1 DataObjectRestRep (com.emc.storageos.model.DataObjectRestRep)1 URI (java.net.URI)1 Util (play.mvc.Util)1