Search in sources :

Example 1 with CatalogServiceField

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

the class CatalogServiceManagerImpl method getCatalogServicesWithFields.

public List<CatalogServiceAndFields> getCatalogServicesWithFields(List<URI> ids) {
    List<CatalogServiceAndFields> catalogServicesWithFields = new ArrayList<CatalogServiceAndFields>();
    if (ids == null) {
        return null;
    }
    for (URI id : ids) {
        CatalogService catalogService = client.catalogServices().findById(id);
        if (catalogService != null) {
            List<CatalogServiceField> fields = getCatalogServiceFields(catalogService.getId());
            SortedIndexUtils.sort(fields);
            CatalogServiceAndFields catalogServiceWithFields = new CatalogServiceAndFields();
            catalogServiceWithFields.setCatalogService(catalogService);
            catalogServiceWithFields.setCatalogServiceFields(fields);
            catalogServicesWithFields.add(catalogServiceWithFields);
        }
    }
    return catalogServicesWithFields;
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) ArrayList(java.util.ArrayList) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CatalogServiceAndFields(com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)

Example 2 with CatalogServiceField

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

the class CatalogServiceFieldTest method testPersistObject.

@Test
public void testPersistObject() throws Exception {
    _logger.info("Starting persist CatalogServiceField test");
    CatalogServiceField model = create("foo", "my value");
    model.setId(URIUtil.createId(CatalogServiceField.class));
    model.setOverride(true);
    save(model);
    model = findById(model.getId());
    Assert.assertNotNull(model);
    Assert.assertEquals("foo", model.getLabel());
    Assert.assertEquals("my value", model.getValue());
    Assert.assertTrue(model.getOverride());
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 3 with CatalogServiceField

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

the class CatalogServiceService method createCatalogService.

/**
 * Creates a new catalog service
 *
 * @param createParam
 *            the parameter to create a new catalog service
 * @prereq none
 * @brief Create Catalog Service
 * @return none
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN })
@Path("")
public CatalogServiceRestRep createCatalogService(CatalogServiceCreateParam createParam) {
    StorageOSUser user = getUserFromContext();
    CatalogCategory parentCatalogCategory = catalogCategoryManager.getCatalogCategoryById(createParam.getCatalogCategory());
    verifyAuthorizedInTenantOrg(uri(parentCatalogCategory.getTenant()), user);
    validateParam(createParam, null);
    CatalogService catalogService = createNewObject(createParam, parentCatalogCategory);
    List<CatalogServiceField> catalogServiceFields = createNewObjectList(catalogService, createParam.getCatalogServiceFields());
    catalogServiceManager.createCatalogService(catalogService, catalogServiceFields);
    auditOpSuccess(OperationTypeEnum.CREATE_CATALOG_SERVICE, catalogService.auditParameters());
    // Refresh Objects
    catalogService = catalogServiceManager.getCatalogServiceById(catalogService.getId());
    catalogServiceFields = catalogServiceManager.getCatalogServiceFields(catalogService.getId());
    ServiceDescriptor serviceDescriptor = getServiceDescriptor(catalogService);
    return map(catalogService, serviceDescriptor, catalogServiceFields);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with CatalogServiceField

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

the class CatalogServiceService method queryBulkResourceReps.

private CatalogServiceBulkRep queryBulkResourceReps(List<URI> ids, CatalogServiceFilter filter) {
    List<CatalogServiceRestRep> catalogServiceRestReps = new ArrayList<CatalogServiceRestRep>();
    List<CatalogServiceAndFields> catalogServicesWithFields = catalogServiceManager.getCatalogServicesWithFields(ids);
    Map<String, ServiceDescriptor> descriptors = getServiceDescriptors();
    for (CatalogServiceAndFields catalogServiceAndField : catalogServicesWithFields) {
        if ((filter == null) || filter.isAccessible(catalogServiceAndField.getCatalogService())) {
            CatalogService service = catalogServiceAndField.getCatalogService();
            ServiceDescriptor descriptor = descriptors.get(service.getBaseService());
            List<CatalogServiceField> serviceFields = catalogServiceAndField.getCatalogServiceFields();
            catalogServiceRestReps.add(map(service, descriptor, serviceFields));
        }
    }
    catalogServiceRestReps = SortedIndexUtils.createSortedList(catalogServiceRestReps.iterator());
    return new CatalogServiceBulkRep(catalogServiceRestReps);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) CatalogServiceBulkRep(com.emc.vipr.model.catalog.CatalogServiceBulkRep) ArrayList(java.util.ArrayList) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) CatalogServiceAndFields(com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)

Example 5 with CatalogServiceField

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

the class CatalogServiceMapper method map.

public static CatalogServiceRestRep map(CatalogService from, ServiceDescriptor descriptor, List<CatalogServiceField> catalogServiceFields) {
    if (from == null) {
        return null;
    }
    CatalogServiceRestRep to = new CatalogServiceRestRep();
    mapDataObjectFields(from, to);
    if (from.getCatalogCategoryId() != null) {
        to.setCatalogCategory(toRelatedResource(ResourceTypeEnum.CATALOG_CATEGORY, from.getCatalogCategoryId().getURI()));
    }
    if (from.getDefaultExecutionWindowId() != null) {
        to.setDefaultExecutionWindow(toRelatedResource(ResourceTypeEnum.EXECUTION_WINDOW, from.getDefaultExecutionWindowId().getURI()));
    }
    if (from.getApprovalRequired() != null) {
        to.setApprovalRequired(from.getApprovalRequired());
    }
    if (from.getExecutionWindowRequired() != null) {
        to.setExecutionWindowRequired(from.getExecutionWindowRequired());
    }
    to.setBaseService(from.getBaseService());
    to.setDescription(from.getDescription());
    to.setImage(from.getImage());
    to.setMaxSize(from.getMaxSize());
    to.setTitle(from.getTitle());
    to.setSortedIndex(from.getSortedIndex());
    if (descriptor != null) {
        to.setServiceDescriptor(ServiceDescriptorMapper.map(descriptor));
    }
    if (catalogServiceFields != null) {
        for (CatalogServiceField catalogServiceField : catalogServiceFields) {
            CatalogServiceFieldRestRep catalogServiceFieldRestRep = new CatalogServiceFieldRestRep();
            mapDataObjectFields(catalogServiceField, catalogServiceFieldRestRep);
            catalogServiceFieldRestRep.setOverride(catalogServiceField.getOverride());
            catalogServiceFieldRestRep.setValue(catalogServiceField.getValue());
            catalogServiceFieldRestRep.setSortedIndex(catalogServiceField.getSortedIndex());
            to.getCatalogServiceFields().add(catalogServiceFieldRestRep);
        }
    }
    if (from.getRecurringAllowed() != null) {
        to.setRecurringAllowed(from.getRecurringAllowed());
    }
    return to;
}
Also used : CatalogServiceFieldRestRep(com.emc.vipr.model.catalog.CatalogServiceFieldRestRep) CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Aggregations

CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)13 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)6 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)5 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)4 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 CatalogServiceAndFields (com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)2 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 CatalogServiceFieldParam (com.emc.vipr.model.catalog.CatalogServiceFieldParam)2 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Consumes (javax.ws.rs.Consumes)2 BaseModelTest (com.emc.sa.model.BaseModelTest)1 CatalogServiceBulkRep (com.emc.vipr.model.catalog.CatalogServiceBulkRep)1 CatalogServiceFieldRestRep (com.emc.vipr.model.catalog.CatalogServiceFieldRestRep)1 Map (java.util.Map)1