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