Search in sources :

Example 6 with AllottedResourceCustomization

use of org.onap.so.db.catalog.beans.AllottedResourceCustomization in project so by onap.

the class CatalogDbAdapterRest method serviceAllottedResourcesImpl.

public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) {
    QueryAllottedResourceCustomization qryResp;
    int respStatus = HttpStatus.SC_OK;
    String uuid = "";
    List<AllottedResourceCustomization> ret = new ArrayList<>();
    Service service = null;
    try {
        if (smUuid != null && !"".equals(smUuid)) {
            uuid = smUuid;
            service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
        } else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
            uuid = serviceModelInvariantUuid;
            if (smVer != null && !"".equals(smVer)) {
                service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, uuid);
            } else {
                service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
            }
        } else if (aUuid != null && !"".equals(aUuid)) {
            uuid = aUuid;
            ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
        } else {
            throw (new Exception(NO_MATCHING_PARAMETERS));
        }
        if (service != null)
            ret = service.getAllottedCustomizations();
        if (ret == null || ret.isEmpty()) {
            logger.debug("AllottedResourceCustomization not found");
            respStatus = HttpStatus.SC_NOT_FOUND;
            qryResp = new QueryAllottedResourceCustomization();
        } else {
            qryResp = new QueryAllottedResourceCustomization(ret);
            logger.debug("AllottedResourceCustomization qryResp= {}", qryResp);
        }
        return respond(version, respStatus, isArray, qryResp);
    } catch (Exception e) {
        logger.error("Exception - queryAllottedResourceCustomization", 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 : ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization)

Example 7 with AllottedResourceCustomization

use of org.onap.so.db.catalog.beans.AllottedResourceCustomization in project so by onap.

the class ToscaResourceInstaller method createAllottedResource.

protected AllottedResourceCustomization createAllottedResource(IEntityDetails arEntity, ToscaResourceStructure toscaResourceStructure, Service service) {
    AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo.findOneByModelCustomizationUUID(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
    if (allottedResourceCustomization == null) {
        AllottedResource allottedResource = findExistingAllottedResource(service, arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
        if (allottedResource == null)
            allottedResource = createAR(arEntity);
        toscaResourceStructure.setAllottedResource(allottedResource);
        allottedResourceCustomization = createAllottedResourceCustomization(arEntity, toscaResourceStructure);
        allottedResourceCustomization.setAllottedResource(allottedResource);
        allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
    }
    return allottedResourceCustomization;
}
Also used : AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization)

Example 8 with AllottedResourceCustomization

use of org.onap.so.db.catalog.beans.AllottedResourceCustomization in project so by onap.

the class ToscaResourceStructureTest method toscaResourceStructureBeanTest.

@Test
public void toscaResourceStructureBeanTest() {
    artifactInfo = mock(ArtifactInfoImpl.class);
    sdcCsarHelper = mock(SdcCsarHelperImpl.class);
    toscaResourceStructure = new ToscaResourceStructure();
    toscaResourceStructure.setHeatTemplateUUID("heatTemplateUUID");
    toscaResourceStructure.setAllottedList(new ArrayList<NodeTemplate>());
    toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
    toscaResourceStructure.setServiceMetadata(new Metadata(new HashMap<>()));
    toscaResourceStructure.setCatalogService(new Service());
    toscaResourceStructure.setNetworkTypes(new ArrayList<>());
    toscaResourceStructure.setVfTypes(new ArrayList<>());
    toscaResourceStructure.setCatalogResourceCustomization(new AllottedResourceCustomization());
    toscaResourceStructure.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
    toscaResourceStructure.setCatalogNetworkResource(new NetworkResource());
    toscaResourceStructure.setCatalogVfModule(new VfModule());
    toscaResourceStructure.setVnfResourceCustomization(new VnfResourceCustomization());
    toscaResourceStructure.setVfModuleCustomization(new VfModuleCustomization());
    toscaResourceStructure.setAllottedResource(new AllottedResource());
    toscaResourceStructure.setAllottedResourceCustomization(new AllottedResourceCustomization());
    toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
    toscaResourceStructure.setHeatFilesUUID("heatFilesUUID");
    toscaResourceStructure.setToscaArtifact(artifactInfo);
    toscaResourceStructure.setToscaCsar(new ToscaCsar());
    toscaResourceStructure.setVolHeatTemplateUUID("volHeatTemplateUUID");
    toscaResourceStructure.setEnvHeatTemplateUUID("envHeatTemplateUUID");
    toscaResourceStructure.setServiceVersion("serviceVersion");
    toscaResourceStructure.setWorkloadPerformance("workloadPerformance");
    toscaResourceStructure.setVfModule(new VfModule());
    toscaResourceStructure.setTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
    toscaResourceStructure.setSuccessfulDeployment();
    assertEquals("heatTemplateUUID", toscaResourceStructure.getHeatTemplateUUID());
    assertThat(toscaResourceStructure.getAllottedList(), sameBeanAs(new ArrayList<NodeTemplate>()));
    assertEquals(sdcCsarHelper, toscaResourceStructure.getSdcCsarHelper());
    assertThat(toscaResourceStructure.getServiceMetadata(), sameBeanAs(new Metadata(new HashMap<>())));
    assertThat(toscaResourceStructure.getCatalogService(), sameBeanAs(new Service()));
    assertThat(toscaResourceStructure.getNetworkTypes(), sameBeanAs(new ArrayList<>()));
    assertThat(toscaResourceStructure.getVfTypes(), sameBeanAs(new ArrayList<>()));
    assertThat(toscaResourceStructure.getCatalogResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
    assertThat(toscaResourceStructure.getCatalogNetworkResourceCustomization(), sameBeanAs(new NetworkResourceCustomization()));
    assertThat(toscaResourceStructure.getCatalogNetworkResource(), sameBeanAs(new NetworkResource()));
    assertThat(toscaResourceStructure.getCatalogVfModule(), sameBeanAs(new VfModule()));
    assertThat(toscaResourceStructure.getVnfResourceCustomization(), sameBeanAs(new VnfResourceCustomization()));
    assertThat(toscaResourceStructure.getVfModuleCustomization(), sameBeanAs(new VfModuleCustomization()));
    assertThat(toscaResourceStructure.getAllottedResource(), sameBeanAs(new AllottedResource()));
    assertThat(toscaResourceStructure.getAllottedResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
    assertThat(toscaResourceStructure.getCatalogTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
    assertEquals("heatFilesUUID", toscaResourceStructure.getHeatFilesUUID());
    assertEquals(artifactInfo, toscaResourceStructure.getToscaArtifact());
    assertThat(toscaResourceStructure.getToscaCsar(), sameBeanAs(new ToscaCsar()));
    assertEquals("volHeatTemplateUUID", toscaResourceStructure.getVolHeatTemplateUUID());
    assertEquals("envHeatTemplateUUID", toscaResourceStructure.getEnvHeatTemplateUUID());
    assertEquals("serviceVersion", toscaResourceStructure.getServiceVersion());
    assertEquals("workloadPerformance", toscaResourceStructure.getWorkloadPerformance());
    assertThat(toscaResourceStructure.getVfModule(), sameBeanAs(new VfModule()));
    assertThat(toscaResourceStructure.getTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
    assertEquals(true, toscaResourceStructure.isDeployedSuccessfully());
}
Also used : ArtifactInfoImpl(org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl) HashMap(java.util.HashMap) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) VfModule(org.onap.so.db.catalog.beans.VfModule) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) NodeTemplate(org.onap.sdc.toscaparser.api.NodeTemplate) TempNetworkHeatTemplateLookup(org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup) SdcCsarHelperImpl(org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Aggregations

AllottedResourceCustomization (org.onap.so.db.catalog.beans.AllottedResourceCustomization)8 AllottedResource (org.onap.so.db.catalog.beans.AllottedResource)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 IEntityDetails (org.onap.sdc.tosca.parser.api.IEntityDetails)2 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)2 Service (org.onap.so.db.catalog.beans.Service)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 HashSet (java.util.HashSet)1 Transactional (javax.transaction.Transactional)1 EntityQuery (org.onap.sdc.tosca.parser.elements.queries.EntityQuery)1 TopologyTemplateQuery (org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery)1 SdcCsarHelperImpl (org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl)1 CapabilityAssignment (org.onap.sdc.toscaparser.api.CapabilityAssignment)1 NodeTemplate (org.onap.sdc.toscaparser.api.NodeTemplate)1 CatalogQueryException (org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException)1 QueryAllottedResourceCustomization (org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization)1 BaseTest (org.onap.so.asdc.BaseTest)1