Search in sources :

Example 1 with WFDirectoryRestRep

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

the class WorkflowBuilder method createWFDir.

public static void createWFDir(String name, String parent) throws URISyntaxException {
    WFDirectoryParam param = new WFDirectoryParam();
    param.setName(name);
    // Ignoring root parent
    URI parentURI = null;
    if (null != parent) {
        parentURI = MY_LIBRARY_ROOT.equals(parent) ? null : new URI(parent);
    }
    param.setParent(parentURI);
    WFDirectoryRestRep wfDirectoryRestRep = getCatalogClient().wfDirectories().create(param);
    renderJSON(wfDirectoryRestRep);
}
Also used : WFDirectoryRestRep(com.emc.vipr.model.catalog.WFDirectoryRestRep) URI(java.net.URI) WFDirectoryParam(com.emc.vipr.model.catalog.WFDirectoryParam)

Example 2 with WFDirectoryRestRep

use of com.emc.vipr.model.catalog.WFDirectoryRestRep 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 3 with WFDirectoryRestRep

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

the class WFDirectoryService method map.

private WFDirectoryRestRep map(WFDirectory from) {
    WFDirectoryRestRep to = new WFDirectoryRestRep();
    mapDataObjectFields(from, to);
    if (null != from.getParent()) {
        if (from.getParent().equals(getRootLevelParentId())) {
            // Removing the dummy parent Id that was set during create
            to.setParent(null);
        } else {
            to.setParent(new RelatedResourceRep(from.getParent(), new RestLinkRep("self", RestLinkFactory.newLink(ResourceTypeEnum.WF_DIRECTORY, from.getParent()))));
        }
    }
    if (null != from.getWorkflows()) {
        to.setWorkflows(StringSetUtil.stringSetToUriList(from.getWorkflows()));
    }
    return to;
}
Also used : NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) RestLinkRep(com.emc.storageos.model.RestLinkRep) WFDirectoryRestRep(com.emc.vipr.model.catalog.WFDirectoryRestRep)

Example 4 with WFDirectoryRestRep

use of com.emc.vipr.model.catalog.WFDirectoryRestRep 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

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