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