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);
}
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);
}
Aggregations