Search in sources :

Example 31 with CatalogCategory

use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.

the class CatalogCategoryFinder method getRootCategory.

public CatalogCategory getRootCategory(String tenant) {
    CatalogCategory root = null;
    if (StringUtils.isBlank(tenant)) {
        return root;
    }
    List<NamedElement> catalogCategoryIds = client.findBy(CatalogCategory.class, CatalogCategory.CATALOG_CATEGORY_ID, URI.create(CatalogCategory.NO_PARENT));
    List<CatalogCategory> tenantRootCategories = TenantUtils.filter(findByIds(toURIs(catalogCategoryIds)), tenant);
    if (tenantRootCategories != null && !tenantRootCategories.isEmpty()) {
        root = tenantRootCategories.get(0);
    }
    return root;
}
Also used : CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 32 with CatalogCategory

use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.

the class CatalogCategoryTest method createRoot.

private CatalogCategory createRoot(String tenant, String label) {
    CatalogCategory model = new CatalogCategory();
    model.setId(URIUtil.createId(CatalogCategory.class));
    model.setLabel(label);
    NamedURI parentId = new NamedURI(URI.create(CatalogCategory.NO_PARENT), "Home");
    model.setCatalogCategoryId(parentId);
    model.setDescription("my desc");
    model.setImage("my image");
    model.setTitle("my title");
    model.setTenant(tenant);
    return model;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory)

Example 33 with CatalogCategory

use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.

the class CatalogCategoryTest method testReparentCategory.

@Test
public void testReparentCategory() throws Exception {
    ModelClient modelClient = getModelClient();
    CatalogCategory parent1 = createCategory("Parent1");
    modelClient.save(parent1);
    CatalogCategory parent2 = createCategory("Parent2");
    modelClient.save(parent2);
    CatalogCategory child = createCategory("Child");
    setParent(parent1, child);
    modelClient.save(child);
    List<CatalogCategory> parent1Children = modelClient.catalogCategories().findSubCatalogCategories(parent1.getId());
    Assert.assertEquals(1, parent1Children.size());
    Assert.assertEquals(child.getId(), parent1Children.get(0).getId());
    List<CatalogCategory> parent2Children = modelClient.catalogCategories().findSubCatalogCategories(parent2.getId());
    Assert.assertEquals(0, parent2Children.size());
    setParent(parent2, child);
    modelClient.save(child);
    parent1Children = modelClient.catalogCategories().findSubCatalogCategories(parent1.getId());
    Assert.assertEquals(0, parent1Children.size());
    parent2Children = modelClient.catalogCategories().findSubCatalogCategories(parent2.getId());
    Assert.assertEquals(1, parent2Children.size());
    Assert.assertEquals(child.getId(), parent2Children.get(0).getId());
}
Also used : ModelClient(com.emc.sa.model.dao.ModelClient) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 34 with CatalogCategory

use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.

the class CatalogCategoryTest method testFindSubCatalogCategories.

@Test
public void testFindSubCatalogCategories() {
    _logger.info("Starting FindByLabel test");
    ModelClient modelClient = getModelClient();
    CatalogCategory root = createWithLabel("rooty");
    CatalogCategory catalogCategory = createWithLabel("asdf");
    catalogCategory.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
    modelClient.save(catalogCategory);
    catalogCategory = createWithLabel("asdf2");
    catalogCategory.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
    modelClient.save(catalogCategory);
    catalogCategory = createWithLabel("asdf3");
    catalogCategory.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
    modelClient.save(catalogCategory);
    modelClient.save(root);
    List<CatalogCategory> subCatalogCategories = modelClient.catalogCategories().findSubCatalogCategories(root.getId());
    Assert.assertNotNull(subCatalogCategories);
    Assert.assertEquals(3, subCatalogCategories.size());
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) ModelClient(com.emc.sa.model.dao.ModelClient) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 35 with CatalogCategory

use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.

the class CatalogServiceTest method testReparent.

@Test
public void testReparent() throws Exception {
    _logger.info("Starting reparent CatalogService test");
    ModelClient modelClient = getModelClient();
    CatalogCategory parent1 = createCategoryWithLabel("Parent 1");
    modelClient.save(parent1);
    CatalogCategory parent2 = createCategoryWithLabel("Parent 2");
    modelClient.save(parent2);
    CatalogService service = createWithLabel("Service");
    setParent(parent1, service);
    modelClient.save(service);
    List<CatalogService> parent1Children = modelClient.catalogServices().findByCatalogCategory(parent1.getId());
    Assert.assertEquals(1, parent1Children.size());
    Assert.assertEquals(service.getId(), parent1Children.get(0).getId());
    List<CatalogService> parent2Children = modelClient.catalogServices().findByCatalogCategory(parent2.getId());
    Assert.assertEquals(0, parent2Children.size());
    setParent(parent2, service);
    modelClient.save(service);
    parent1Children = modelClient.catalogServices().findByCatalogCategory(parent1.getId());
    Assert.assertEquals(0, parent1Children.size());
    parent2Children = modelClient.catalogServices().findByCatalogCategory(parent2.getId());
    Assert.assertEquals(1, parent2Children.size());
    Assert.assertEquals(service.getId(), parent2Children.get(0).getId());
}
Also used : ModelClient(com.emc.sa.model.dao.ModelClient) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Aggregations

CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)36 NamedURI (com.emc.storageos.db.client.model.NamedURI)12 CatalogCategoryMapper.createNewCatalogCategory (com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory)9 Path (javax.ws.rs.Path)9 BaseModelTest (com.emc.sa.model.BaseModelTest)7 ModelClient (com.emc.sa.model.dao.ModelClient)7 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7 URI (java.net.URI)7 Consumes (javax.ws.rs.Consumes)7 Produces (javax.ws.rs.Produces)7 Test (org.junit.Test)7 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)6 PUT (javax.ws.rs.PUT)4 CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)3 POST (javax.ws.rs.POST)3 CatalogACLInputFilter (com.emc.sa.api.utils.CatalogACLInputFilter)2 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)2 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)2 GET (javax.ws.rs.GET)2