Search in sources :

Example 6 with CatalogCategoryRestRep

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

the class CatalogCategoryMapper method map.

public static CatalogCategoryRestRep map(CatalogCategory from) {
    if (from == null) {
        return null;
    }
    CatalogCategoryRestRep to = new CatalogCategoryRestRep();
    mapDataObjectFields(from, to);
    if (from.getTenant() != null) {
        to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, uri(from.getTenant())));
    }
    if (from.getCatalogCategoryId() != null && isParent(from.getCatalogCategoryId()) == false) {
        to.setCatalogCategory(toRelatedResource(ResourceTypeEnum.CATALOG_CATEGORY, from.getCatalogCategoryId().getURI()));
    }
    to.setTitle(from.getTitle());
    to.setDescription(from.getDescription());
    to.setImage(from.getImage());
    to.setSortedIndex(from.getSortedIndex());
    to.setVersion(from.getVersion());
    return to;
}
Also used : CatalogCategoryRestRep(com.emc.vipr.model.catalog.CatalogCategoryRestRep)

Example 7 with CatalogCategoryRestRep

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

the class ApiMapperUtils method newCategoryInfo.

public static CategoryInfo newCategoryInfo(CatalogCategoryRestRep category) {
    CategoryInfo it = new CategoryInfo();
    it.setId(category.getId().toString());
    it.setLink(Link.newSelfLink(categoryUrl(category.getId().toString())));
    it.setInactive(category.getInactive());
    it.setName(category.getName());
    it.setTitle(category.getTitle());
    it.setDescription(category.getDescription());
    it.setImage(category.getImage());
    List<CatalogCategoryRestRep> subCatalogCategories = CatalogCategoryUtils.getCatalogCategories(category);
    for (CatalogCategoryRestRep subCatalogCategory : subCatalogCategories) {
        it.getSubCategories().add(newNamedReference(subCatalogCategory));
    }
    List<CatalogServiceRestRep> catalogServices = CatalogServiceUtils.getCatalogServices(category);
    for (CatalogServiceRestRep catalogService : catalogServices) {
        it.getServices().add(newServiceInfo(catalogService));
    }
    return it;
}
Also used : CategoryInfo(com.emc.vipr.model.catalog.CategoryInfo) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) CatalogCategoryRestRep(com.emc.vipr.model.catalog.CatalogCategoryRestRep)

Example 8 with CatalogCategoryRestRep

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

the class CatalogCategories method getRootCatalogCategory.

public CatalogCategoryRestRep getRootCatalogCategory(URI tenantId) {
    UriBuilder builder = client.uriBuilder(PathConstants.CATALOG_CATEGORY_URL);
    if (tenantId != null) {
        builder.queryParam(TENANT_ID_PARAM, tenantId);
    }
    CatalogCategoryRestRep catalogCategory = client.getURI(CatalogCategoryRestRep.class, builder.build());
    return catalogCategory;
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) CatalogCategoryRestRep(com.emc.vipr.model.catalog.CatalogCategoryRestRep)

Example 9 with CatalogCategoryRestRep

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

the class CatalogCategories method listByTenant.

@Override
public List<NamedRelatedResourceRep> listByTenant(URI tenantId) {
    CatalogCategoryRestRep rootCatalogCategory = getRootCatalogCategory(asString(tenantId));
    UriBuilder uriBuilder = client.uriBuilder(PathConstants.CATALOG_SUB_CATEGORIES_URL);
    if (tenantId != null) {
        uriBuilder = uriBuilder.queryParam(SearchConstants.TENANT_ID_PARAM, tenantId);
    }
    CatalogCategoryList response = client.getURI(CatalogCategoryList.class, uriBuilder.build(rootCatalogCategory.getId()));
    return ResourceUtils.defaultList(response.getCatalogCategories());
}
Also used : CatalogCategoryList(com.emc.vipr.model.catalog.CatalogCategoryList) UriBuilder(javax.ws.rs.core.UriBuilder) CatalogCategoryRestRep(com.emc.vipr.model.catalog.CatalogCategoryRestRep)

Example 10 with CatalogCategoryRestRep

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

the class CatalogApi method invokeByPath.

public static void invokeByPath(String sp1, String sp2, String sp3, String sp4, String sp5) {
    CatalogCategoryRestRep catalog = CatalogCategoryUtils.getRootCategory();
    DataObjectRestRep results = findCategoryOrService(catalog, sp1, sp2, sp3, sp4, sp5);
    if (results != null && results instanceof CatalogServiceRestRep) {
        CatalogServiceRestRep catalogService = (CatalogServiceRestRep) results;
        runCatalogService(catalogService.getId().toString());
    } else {
        notFound();
    }
}
Also used : DataObjectRestRep(com.emc.storageos.model.DataObjectRestRep) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) CatalogCategoryRestRep(com.emc.vipr.model.catalog.CatalogCategoryRestRep)

Aggregations

CatalogCategoryRestRep (com.emc.vipr.model.catalog.CatalogCategoryRestRep)20 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)6 DataObjectRestRep (com.emc.storageos.model.DataObjectRestRep)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 CatalogCategoryList (com.emc.vipr.model.catalog.CatalogCategoryList)1 CategoryInfo (com.emc.vipr.model.catalog.CategoryInfo)1