use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class BBInputSetup method mapCatalogVfModule.
protected void mapCatalogVfModule(VfModule vfModule, ModelInfo modelInfo, Service service, String vnfModelCustomizationUUID) {
if (modelInfo.getModelCustomizationUuid() != null) {
modelInfo.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
}
VnfResourceCustomization vnfResourceCustomization = null;
for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) {
if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(vnfModelCustomizationUUID)) {
vnfResourceCustomization = resourceCust;
break;
}
}
VfModuleCustomization vfResourceCustomization = null;
if (vnfResourceCustomization != null) {
vfResourceCustomization = // Convert to steam
vnfResourceCustomization.getVfModuleCustomizations().stream().filter(// find
x -> modelInfo.getModelCustomizationId().equalsIgnoreCase(x.getModelCustomizationUUID())).findAny().orElse(null);
}
if (vfResourceCustomization == null) {
vfResourceCustomization = bbInputSetupUtils.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId());
}
if (vfResourceCustomization != null) {
vfModule.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization));
}
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class CatalogDbAdapterRest method serviceVnfsImpl.
public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName, String filter) {
QueryServiceVnfs qryResp = null;
int respStatus = HttpStatus.SC_OK;
List<VnfResourceCustomization> ret = new ArrayList<>();
Service service = null;
try {
if (vnfUuid != null && !"".equals(vnfUuid))
ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid);
else if (serviceModelUUID != null && !"".equals(serviceModelUUID))
service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID);
else if (smiUuid != null && !"".equals(smiUuid))
if (smVer != null && !"".equals(smVer))
service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, smiUuid);
else
service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid);
else if (smName != null && !"".equals(smName)) {
if (smVer != null && !"".equals(smVer))
service = serviceRepo.findByModelNameAndModelVersion(smName, smVer);
else
service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName);
} else {
throw (new Exception(NO_MATCHING_PARAMETERS));
}
if (service == null && ret.isEmpty()) {
respStatus = HttpStatus.SC_NOT_FOUND;
qryResp = new QueryServiceVnfs();
} else if (service == null && !ret.isEmpty()) {
if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) {
ret.forEach(vnfCustomization -> vnfCustomization.setResourceInput(null));
}
qryResp = new QueryServiceVnfs(ret);
} else if (service != null) {
ret = service.getVnfCustomizations();
if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) {
ret.forEach(vnfCustomization -> vnfCustomization.setResourceInput(null));
}
qryResp = new QueryServiceVnfs(ret);
}
logger.debug("serviceVnfs qryResp= {}", qryResp);
return respond(version, respStatus, isArray, qryResp);
} catch (Exception e) {
logger.error("Exception - queryServiceVnfs", e);
CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(new GenericEntity<CatalogQueryException>(excResp) {
}).build();
}
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class QueryServiceVnfs method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
boolean first = true;
int i = 1;
for (VnfResourceCustomization o : serviceVnfs) {
sb.append(i).append("\t");
if (!first)
sb.append("\n");
first = false;
sb.append(o);
}
return sb.toString();
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class BBInputSetupTest method testMapCatalogVolumeGroup.
@Test
public void testMapCatalogVolumeGroup() {
VolumeGroup volumeGroup = new VolumeGroup();
RequestDetails requestDetails = new RequestDetails();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
requestDetails.setModelInfo(modelInfo);
Service service = new Service();
VnfResourceCustomization resourceCust = new VnfResourceCustomization();
resourceCust.setModelCustomizationUUID("vnfModelCustomizationUUID");
service.getVnfCustomizations().add(resourceCust);
VfModuleCustomization vfResourceCust = new VfModuleCustomization();
vfResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
resourceCust.getVfModuleCustomizations().add(vfResourceCust);
doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfResourceCust);
SPY_bbInputSetup.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, "vnfModelCustomizationUUID");
assertEquals(modelInfoVfModule, volumeGroup.getModelInfoVfModule());
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class BBInputSetupTest method testMapCatalogVfModuleIfNoVfUnderVnf.
@Test
public void testMapCatalogVfModuleIfNoVfUnderVnf() {
String vnfModelCustomizationUUID = "vnfResourceCustUUID";
String vfModuleCustomizationUUID = "vfModelCustomizationUUID";
VfModule vfModule = new VfModule();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationUuid(vfModuleCustomizationUUID);
Service service = new Service();
VnfResourceCustomization vnfResourceCust = new VnfResourceCustomization();
vnfResourceCust.setModelCustomizationUUID(vnfModelCustomizationUUID);
VfModuleCustomization vfModuleCust = new VfModuleCustomization();
vfModuleCust.setModelCustomizationUUID(vfModuleCustomizationUUID);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
doReturn(vfModuleCust).when(SPY_bbInputSetupUtils).getVfModuleCustomizationByModelCuztomizationUUID(vfModuleCustomizationUUID);
doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfModuleCust);
SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
verify(SPY_bbInputSetupUtils, times(1)).getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId());
}
Aggregations