Search in sources :

Example 1 with CustomServicesPrimitiveList

use of com.emc.storageos.model.customservices.CustomServicesPrimitiveList in project coprhd-controller by CoprHD.

the class WorkflowBuilder method addPrimitivesByType.

private static void addPrimitivesByType(final List<Node> topLevelNodes, final String type, String parentDefault, final Map<URI, WFDirectoryRestRep> fileParents) {
    final CustomServicesPrimitiveList primitiveList = getCatalogClient().customServicesPrimitives().getPrimitivesByType(type);
    if (null == primitiveList || null == primitiveList.getPrimitives()) {
        return;
    }
    final List<String> categories = new ArrayList<String>();
    final List<String> services = new ArrayList<String>();
    final List<CustomServicesPrimitiveRestRep> primitives = getCatalogClient().customServicesPrimitives().getByIds(primitiveList.getPrimitives());
    for (final CustomServicesPrimitiveRestRep primitive : primitives) {
        final String parent = (fileParents != null && fileParents.containsKey(primitive.getId())) ? fileParents.get(primitive.getId()).getId().toString() : parentDefault;
        final Node node;
        if (StepType.VIPR_REST.toString().equals(type)) {
            final String[] folders = primitive.getName().split("/");
            final String service;
            if (folders.length == 3) {
                if (!categories.contains(folders[0])) {
                    topLevelNodes.add(new Node(folders[0], folders[0], parent, WFBuilderNodeTypes.FOLDER.toString()));
                    categories.add(folders[0]);
                }
                if (!services.contains(folders[1])) {
                    topLevelNodes.add(new Node(folders[1], folders[1], folders[0], WFBuilderNodeTypes.FOLDER.toString()));
                    services.add(folders[1]);
                }
                service = folders[1];
            } else {
                service = parent;
            }
            node = new Node(primitive.getId().toString(), primitive.getFriendlyName(), service, type);
        } else {
            node = new Node(primitive.getId().toString(), primitive.getName(), parent, type);
        }
        node.data = primitive;
        topLevelNodes.add(node);
    }
}
Also used : CustomServicesPrimitiveRestRep(com.emc.storageos.model.customservices.CustomServicesPrimitiveRestRep) CustomServicesPrimitiveList(com.emc.storageos.model.customservices.CustomServicesPrimitiveList) ArrayList(java.util.ArrayList)

Example 2 with CustomServicesPrimitiveList

use of com.emc.storageos.model.customservices.CustomServicesPrimitiveList in project coprhd-controller by CoprHD.

the class CustomServicesPrimitiveService method getPrimitives.

/**
 * Get the list of primitives that can be used for creating
 * custom services workflows
 *
 * @prereq none
 *
 * @brief Get list of primitives
 *
 * @return PrimitiveList
 */
@GET
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CustomServicesPrimitiveList getPrimitives(@QueryParam("type") final String type) {
    final Set<String> types = (type == null) ? daos.getTypes() : Collections.singleton(type);
    final List<URI> list = new ArrayList<URI>();
    for (final String primitiveType : types) {
        final CustomServicesPrimitiveDAO<?> dao = getDAO(primitiveType, false);
        final List<URI> ids = dao.list();
        for (final URI id : ids) {
            list.add(id);
        }
    }
    return new CustomServicesPrimitiveList(list);
}
Also used : CustomServicesPrimitiveList(com.emc.storageos.model.customservices.CustomServicesPrimitiveList) ArrayList(java.util.ArrayList) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

CustomServicesPrimitiveList (com.emc.storageos.model.customservices.CustomServicesPrimitiveList)2 ArrayList (java.util.ArrayList)2 CustomServicesPrimitiveRestRep (com.emc.storageos.model.customservices.CustomServicesPrimitiveRestRep)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1