Search in sources :

Example 11 with CatalogServiceField

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

the class CatalogBuilder method createService.

public CatalogService createService(ServiceDef def, NamedURI parentId) {
    ServiceDescriptor descriptor = descriptors.getDescriptor(Locale.getDefault(), def.baseService);
    String label = StringUtils.defaultString(getMessage(getLabel(def)), descriptor.getTitle());
    String title = StringUtils.defaultString(getMessage(def.title), descriptor.getTitle());
    String description = StringUtils.defaultString(getMessage(def.description), descriptor.getDescription());
    CatalogService service = new CatalogService();
    service.setBaseService(def.baseService);
    service.setLabel(StringUtils.deleteWhitespace(label));
    service.setTitle(title);
    service.setDescription(description);
    service.setImage(def.image);
    service.setCatalogCategoryId(parentId);
    service.setSortedIndex(sortedIndexCounter++);
    log.info("Create new service" + def.baseService);
    if (AllowRecurringSchedulerMigration.RECURRING_ALLOWED_CATALOG_SERVICES.contains(def.baseService) || AllowRecurringSchedulerForApplicationServicesMigration.RECURRING_ALLOWED_CATALOG_SERVICES.contains(def.baseService)) {
        service.setRecurringAllowed(true);
    }
    models.save(service);
    if (def.lockFields != null) {
        for (Map.Entry<String, String> lockField : def.lockFields.entrySet()) {
            CatalogServiceField field = new CatalogServiceField();
            field.setLabel(lockField.getKey());
            field.setValue(lockField.getValue());
            field.setCatalogServiceId(new NamedURI(service.getId(), service.getLabel()));
            models.save(field);
        }
    }
    return service;
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) NamedURI(com.emc.storageos.db.client.model.NamedURI) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) Map(java.util.Map)

Example 12 with CatalogServiceField

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

the class CatalogServiceManagerImpl method deleteCatalogService.

public void deleteCatalogService(CatalogService catalogService) {
    CatalogCategory parentCatalogCategory = catalogCategoryManager.getCatalogCategoryById(catalogService.getCatalogCategoryId().getURI());
    URI tenantId = uri(parentCatalogCategory.getTenant());
    if (isServiceUsedForOrders(tenantId, catalogService)) {
        URI deletedCategoryURI = URI.create(CatalogCategory.DELETED_CATEGORY);
        String deletedCategoryLabel = CatalogCategory.DELETED_CATEGORY;
        catalogService.setCatalogCategoryId(new NamedURI(deletedCategoryURI, deletedCategoryLabel));
        client.save(catalogService);
    } else {
        List<CatalogServiceField> serviceFields = getCatalogServiceFields(catalogService.getId());
        log.debug(String.format("Deleting Service Fields: %s", catalogService.getTitle()));
        client.delete(serviceFields);
        log.info(String.format("Deleting Service: %s", catalogService.getTitle()));
        client.delete(catalogService);
    }
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) NamedURI(com.emc.storageos.db.client.model.NamedURI) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 13 with CatalogServiceField

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

the class CatalogServiceFieldTest method create.

protected static CatalogServiceField create(String label, String value) {
    CatalogServiceField model = new CatalogServiceField();
    model.setLabel("foo");
    model.setValue("my value");
    return model;
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField)

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