Search in sources :

Example 26 with VnfResourceCustomization

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));
    }
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) Vnfs(org.onap.so.serviceinstancebeans.Vnfs) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) StringUtils(org.apache.commons.lang3.StringUtils) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) JavaDelegate(org.camunda.bpm.engine.delegate.JavaDelegate) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) Service(org.onap.so.db.catalog.beans.Service) Map(java.util.Map) Tenant(org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) NetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) UUID(java.util.UUID) Pair(org.javatuples.Pair) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) Objects(java.util.Objects) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) HashMap(java.util.HashMap) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException) ArrayList(java.util.ArrayList) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) VfModules(org.onap.so.serviceinstancebeans.VfModules) RouteTableReference(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) Logger(org.slf4j.Logger) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Project(org.onap.so.bpmn.servicedecomposition.bbobjects.Project) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Networks(org.onap.so.serviceinstancebeans.Networks) Component(org.springframework.stereotype.Component) Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) Resources(org.onap.so.serviceinstancebeans.Resources) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Example 27 with VnfResourceCustomization

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();
    }
}
Also used : VnfRecipe(org.onap.so.db.catalog.beans.VnfRecipe) QueryServiceMacroHolder(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceMacroHolder) NetworkRecipeRepository(org.onap.so.db.catalog.data.repository.NetworkRecipeRepository) Produces(javax.ws.rs.Produces) Path(javax.ws.rs.Path) VfModule(org.onap.so.db.catalog.beans.VfModule) LoggerFactory(org.slf4j.LoggerFactory) HttpStatus(org.apache.http.HttpStatus) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) VnfRecipeRepository(org.onap.so.db.catalog.data.repository.VnfRecipeRepository) QueryServiceNetworks(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) Service(org.onap.so.db.catalog.beans.Service) VFModuleRepository(org.onap.so.db.catalog.data.repository.VFModuleRepository) NetworkResourceRepository(org.onap.so.db.catalog.data.repository.NetworkResourceRepository) ProcessingFlagsRepository(org.onap.so.db.catalog.data.repository.ProcessingFlagsRepository) QueryServiceCsar(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar) GenericEntity(javax.ws.rs.core.GenericEntity) QueryServiceVnfs(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs) ProcessingFlags(org.onap.so.db.catalog.beans.ProcessingFlags) List(java.util.List) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) HttpHeaders(javax.ws.rs.core.HttpHeaders) Response(javax.ws.rs.core.Response) NetworkResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) VnfCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfCustomizationRepository) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) Recipe(org.onap.so.db.catalog.beans.Recipe) PathParam(javax.ws.rs.PathParam) QueryVfModule(org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule) GET(javax.ws.rs.GET) InstanceGroupRepository(org.onap.so.db.catalog.data.repository.InstanceGroupRepository) CatalogQuery(org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery) ArrayList(java.util.ArrayList) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) AllottedResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository) CatalogQueryExceptionCategory(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory) AllottedResourceRepository(org.onap.so.db.catalog.data.repository.AllottedResourceRepository) VnfResource(org.onap.so.db.catalog.beans.VnfResource) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) Logger(org.slf4j.Logger) ServiceMacroHolder(org.onap.so.db.catalog.rest.beans.ServiceMacroHolder) QueryResourceRecipe(org.onap.so.adapters.catalogdb.catalogrest.QueryResourceRecipe) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) VnfResourceRepository(org.onap.so.db.catalog.data.repository.VnfResourceRepository) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Component(org.springframework.stereotype.Component) ArRecipeRepository(org.onap.so.db.catalog.data.repository.ArRecipeRepository) ServiceRepository(org.onap.so.db.catalog.data.repository.ServiceRepository) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) PUT(javax.ws.rs.PUT) ToscaCsarRepository(org.onap.so.db.catalog.data.repository.ToscaCsarRepository) Transactional(org.springframework.transaction.annotation.Transactional) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) QueryServiceVnfs(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException)

Example 28 with VnfResourceCustomization

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();
}
Also used : VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Example 29 with VnfResourceCustomization

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());
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) Service(org.onap.so.db.catalog.beans.Service) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 30 with VnfResourceCustomization

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());
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) Service(org.onap.so.db.catalog.beans.Service) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Aggregations

VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)43 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)17 Service (org.onap.so.db.catalog.beans.Service)15 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)13 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)11 VnfResource (org.onap.so.db.catalog.beans.VnfResource)10 VfModule (org.onap.so.db.catalog.beans.VfModule)7 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)7 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)6 PnfResourceCustomization (org.onap.so.db.catalog.beans.PnfResourceCustomization)6 Transactional (org.springframework.transaction.annotation.Transactional)6 List (java.util.List)5 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)5 VnfcInstanceGroupCustomization (org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)4 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)4 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)4