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 getCatalogService.
/**
* Get info for catalog category
*
* @param id the URN of a Catalog Category
* @prereq none
* @brief Show catalog category
* @return Catalog Category details
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
public CatalogServiceRestRep getCatalogService(@PathParam("id") URI id) {
CatalogService catalogService = queryResource(id);
ServiceDescriptor serviceDescriptor = getServiceDescriptor(catalogService);
List<CatalogServiceField> catalogServiceFields = catalogServiceManager.getCatalogServiceFields(catalogService.getId());
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 updateCatalogService.
/**
* Update catalog service
*
* @param param Catalog Service update parameters
* @param id the URN the catalog service
* @prereq none
* @brief Update Catalog Service
* @return No data returned in response body
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN })
public CatalogServiceRestRep updateCatalogService(@PathParam("id") URI id, CatalogServiceUpdateParam param) {
CatalogService catalogService = getCatalogServiceById(id, true);
List<CatalogServiceField> catalogServiceFields = catalogServiceManager.getCatalogServiceFields(id);
StorageOSUser user = getUserFromContext();
CatalogCategory parentCatalogCategory = catalogCategoryManager.getCatalogCategoryById(param.getCatalogCategory());
verifyAuthorizedInTenantOrg(uri(parentCatalogCategory.getTenant()), user);
validateParam(param, catalogService);
updateObject(catalogService, param, parentCatalogCategory);
List<CatalogServiceField> updatedCatalogServiceFields = updateObjectList(catalogService, catalogServiceFields, param.getCatalogServiceFields());
catalogServiceManager.updateCatalogService(catalogService, updatedCatalogServiceFields);
auditOpSuccess(OperationTypeEnum.UPDATE_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 CatalogServiceMapper method updateObjectList.
public static List<CatalogServiceField> updateObjectList(CatalogService catalogService, List<CatalogServiceField> existingCatalogServiceFields, List<CatalogServiceFieldParam> params) {
List<CatalogServiceField> updatedFields = Lists.newArrayList();
Map<String, CatalogServiceField> existingFields = toMap(existingCatalogServiceFields);
for (CatalogServiceFieldParam param : params) {
if (existingFields.keySet().contains(param.getName())) {
CatalogServiceField existingField = existingFields.get(param.getName());
updateObject(existingField, param);
updatedFields.add(existingField);
} else {
CatalogServiceField newField = createNewObject(catalogService, param);
updatedFields.add(newField);
}
}
return updatedFields;
}
use of com.emc.storageos.db.client.model.uimodels.CatalogServiceField in project coprhd-controller by CoprHD.
the class CatalogServiceMapper method createNewObject.
public static CatalogServiceField createNewObject(CatalogService catalogService, CatalogServiceFieldParam param) {
CatalogServiceField newObject = new CatalogServiceField();
newObject.setId(URIUtil.createId(CatalogServiceField.class));
newObject.setCatalogServiceId(new NamedURI(catalogService.getId(), catalogService.getLabel()));
newObject.setLabel(param.getName());
updateObject(newObject, param);
return newObject;
}
Aggregations