Search in sources :

Example 1 with WFBulkRep

use of com.emc.vipr.model.catalog.WFBulkRep in project coprhd-controller by CoprHD.

the class WorkflowBuilder method getWFDirectories.

public static void getWFDirectories() {
    final List<Node> topLevelNodes = new ArrayList<Node>();
    prepareRootNodes(topLevelNodes);
    // get workflow directories and prepare nodes
    final WFBulkRep wfBulkRep = getCatalogClient().wfDirectories().getAll();
    String nodeParent;
    final Map<URI, WFDirectoryRestRep> fileParents = new HashMap<URI, WFDirectoryRestRep>();
    for (WFDirectoryRestRep wfDirectoryRestRep : wfBulkRep.getWfDirectories()) {
        if (null == wfDirectoryRestRep.getParent()) {
            nodeParent = MY_LIBRARY_ROOT;
        } else {
            nodeParent = wfDirectoryRestRep.getParent().getId().toString();
        }
        final Node node = new Node(wfDirectoryRestRep.getId().toString(), wfDirectoryRestRep.getName(), nodeParent, WFBuilderNodeTypes.FOLDER.toString());
        // add workflows that are under this node
        if (null != wfDirectoryRestRep.getWorkflows()) {
            for (URI u : wfDirectoryRestRep.getWorkflows()) {
                fileParents.put(u, wfDirectoryRestRep);
            }
        }
        topLevelNodes.add(node);
    }
    // Add primitives
    addPrimitivesByType(topLevelNodes, StepType.LOCAL_ANSIBLE.toString(), MY_LIBRARY_ROOT, fileParents);
    addPrimitivesByType(topLevelNodes, StepType.REMOTE_ANSIBLE.toString(), MY_LIBRARY_ROOT, fileParents);
    addPrimitivesByType(topLevelNodes, StepType.SHELL_SCRIPT.toString(), MY_LIBRARY_ROOT, fileParents);
    addPrimitivesByType(topLevelNodes, StepType.REST.toString(), MY_LIBRARY_ROOT, fileParents);
    addPrimitivesByType(topLevelNodes, StepType.VIPR_REST.toString(), VIPR_PRIMITIVE_ROOT, null);
    // Add workflows
    final CustomServicesWorkflowList customServicesWorkflowList = getCatalogClient().customServicesPrimitives().getWorkflows();
    if (null != customServicesWorkflowList && null != customServicesWorkflowList.getWorkflows()) {
        for (NamedRelatedResourceRep o : customServicesWorkflowList.getWorkflows()) {
            final String parent = fileParents.containsKey(o.getId()) ? fileParents.get(o.getId()).getId().toString() : MY_LIBRARY_ROOT;
            topLevelNodes.add(new Node(o.getId().toString(), o.getName(), parent, StepType.WORKFLOW.toString()));
        }
    }
    renderJSON(topLevelNodes);
}
Also used : HashMap(java.util.HashMap) WFBulkRep(com.emc.vipr.model.catalog.WFBulkRep) ArrayList(java.util.ArrayList) WFDirectoryRestRep(com.emc.vipr.model.catalog.WFDirectoryRestRep) CustomServicesWorkflowList(com.emc.storageos.model.customservices.CustomServicesWorkflowList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 2 with WFBulkRep

use of com.emc.vipr.model.catalog.WFBulkRep in project coprhd-controller by CoprHD.

the class WFDirectoryService method queryBulkResourceReps.

@Override
public WFBulkRep queryBulkResourceReps(List<URI> ids) {
    List<WFDirectoryRestRep> wfDirectoryRestReps = new ArrayList<>();
    List<WFDirectory> wfDirectories = wfDirectoryManager.getWFDirectories(ids);
    for (WFDirectory wfd : wfDirectories) {
        wfDirectoryRestReps.add(map(wfd));
    }
    return new WFBulkRep(wfDirectoryRestReps);
}
Also used : WFDirectory(com.emc.storageos.db.client.model.uimodels.WFDirectory) WFBulkRep(com.emc.vipr.model.catalog.WFBulkRep) ArrayList(java.util.ArrayList) WFDirectoryRestRep(com.emc.vipr.model.catalog.WFDirectoryRestRep)

Aggregations

WFBulkRep (com.emc.vipr.model.catalog.WFBulkRep)2 WFDirectoryRestRep (com.emc.vipr.model.catalog.WFDirectoryRestRep)2 ArrayList (java.util.ArrayList)2 WFDirectory (com.emc.storageos.db.client.model.uimodels.WFDirectory)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 CustomServicesWorkflowList (com.emc.storageos.model.customservices.CustomServicesWorkflowList)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1