diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java')
-rw-r--r-- | bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java | 166 |
1 files changed, 84 insertions, 82 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java index 0c519ef29f..bbca10be0f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java @@ -25,7 +25,6 @@ package org.onap.so.bpmn.infrastructure.aai.groovyflows; import java.util.HashMap; import java.util.Map; import java.util.Optional; - import org.onap.aai.domain.yang.OwningEntities; import org.onap.aai.domain.yang.OwningEntity; import org.onap.so.client.aai.AAIObjectPlurals; @@ -37,85 +36,88 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AAICreateResources { - - private static final Logger logger = LoggerFactory.getLogger(AAICreateResources.class); - - public void createAAIProject (String projectName, String serviceInstance){ - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI); - - } - - public void createAAIOwningEntity(String owningEntityId, String owningEntityName,String serviceInstance){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - Map<String, String> hashMap= new HashMap<>(); - hashMap.put("owning-entity-name", owningEntityName); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(owningEntityURI, Optional.of(hashMap)).connect(owningEntityURI, serviceInstanceURI); - } - - public boolean existsOwningEntity(String owningEntityId){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - return aaiRC.exists(owningEntityURI); - } - - protected OwningEntities getOwningEntityName(String owningEntityName){ - - AAIResourcesClient aaiRC = new AAIResourcesClient(); - return aaiRC.get(OwningEntities.class, - AAIUriFactory - .createResourceUri(AAIObjectPlurals.OWNING_ENTITY) - .queryParam("owning-entity-name", owningEntityName)) - .orElseGet(() -> { - logger.debug("No Owning Entity matched by name"); - return null; - }); - - } - - public Optional<OwningEntity> getOwningEntityNames(String owningEntityName) throws Exception{ - OwningEntity owningEntity = null; - OwningEntities owningEntities = null; - owningEntities = getOwningEntityName(owningEntityName); - - if (owningEntities == null) { - return Optional.empty(); - } else if (owningEntities.getOwningEntity().size() > 1) { - throw new Exception("Multiple OwningEntities Returned"); - } else { - owningEntity = owningEntities.getOwningEntity().get(0); - } - return Optional.of(owningEntity); - } - - public void connectOwningEntityandServiceInstance (String owningEntityId, String serviceInstance){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.connect(owningEntityURI, serviceInstanceURI); - } - - public void createAAIPlatform(String platformName,String vnfId){ - AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF,vnfId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI); - } - - public void createAAILineOfBusiness(String lineOfBusiness,String vnfId){ - AAIResourceUri lineOfBusinessURI = AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF,vnfId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI); - } - public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId){ - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId,serviceType,serviceInstanceId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(serviceInstanceURI, Optional.empty()); - } - + + private static final Logger logger = LoggerFactory.getLogger(AAICreateResources.class); + + public void createAAIProject(String projectName, String serviceInstance) { + AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI); + + } + + public void createAAIOwningEntity(String owningEntityId, String owningEntityName, String serviceInstance) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + Map<String, String> hashMap = new HashMap<>(); + hashMap.put("owning-entity-name", owningEntityName); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(owningEntityURI, Optional.of(hashMap)).connect(owningEntityURI, serviceInstanceURI); + } + + public boolean existsOwningEntity(String owningEntityId) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + return aaiRC.exists(owningEntityURI); + } + + protected OwningEntities getOwningEntityName(String owningEntityName) { + + AAIResourcesClient aaiRC = new AAIResourcesClient(); + return aaiRC.get(OwningEntities.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY) + .queryParam("owning-entity-name", owningEntityName)).orElseGet(() -> { + logger.debug("No Owning Entity matched by name"); + return null; + }); + + } + + public Optional<OwningEntity> getOwningEntityNames(String owningEntityName) throws Exception { + OwningEntity owningEntity = null; + OwningEntities owningEntities = null; + owningEntities = getOwningEntityName(owningEntityName); + + if (owningEntities == null) { + return Optional.empty(); + } else if (owningEntities.getOwningEntity().size() > 1) { + throw new Exception("Multiple OwningEntities Returned"); + } else { + owningEntity = owningEntities.getOwningEntity().get(0); + } + return Optional.of(owningEntity); + } + + public void connectOwningEntityandServiceInstance(String owningEntityId, String serviceInstance) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.connect(owningEntityURI, serviceInstanceURI); + } + + public void createAAIPlatform(String platformName, String vnfId) { + AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); + AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI); + } + + public void createAAILineOfBusiness(String lineOfBusiness, String vnfId) { + AAIResourceUri lineOfBusinessURI = + AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); + AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI); + } + + public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId) { + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustomerId, serviceType, serviceInstanceId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(serviceInstanceURI, Optional.empty()); + } + } |