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