aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java207
1 files changed, 107 insertions, 100 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
index 3032b66e6d..e391349d2c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
@@ -23,7 +23,6 @@
package org.onap.so.client.orchestration;
import java.util.Optional;
-
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
@@ -43,112 +42,120 @@ import org.springframework.stereotype.Component;
@Component
public class AAIServiceInstanceResources {
- private static final Logger logger = LoggerFactory.getLogger(AAIServiceInstanceResources
- .class);
-
- @Autowired
- private InjectionHelper injectionHelper;
-
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
-
- public boolean existsServiceInstance(ServiceInstance serviceInstance) {
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- return injectionHelper.getAaiClient().exists(serviceInstanceURI);
- }
-
- public void createServiceInstance(ServiceInstance serviceInstance, Customer customer) {
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- customer.getGlobalCustomerId(), customer.getServiceSubscription().getServiceType(), serviceInstance.getServiceInstanceId());
- serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance);
- injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(AAIServiceInstance));
- }
+ private static final Logger logger = LoggerFactory.getLogger(AAIServiceInstanceResources.class);
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ public boolean existsServiceInstance(ServiceInstance serviceInstance) {
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ return injectionHelper.getAaiClient().exists(serviceInstanceURI);
+ }
+
+ public void createServiceInstance(ServiceInstance serviceInstance, Customer customer) {
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, customer.getGlobalCustomerId(),
+ customer.getServiceSubscription().getServiceType(), serviceInstance.getServiceInstanceId());
+ serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance =
+ aaiObjectMapper.mapServiceInstance(serviceInstance);
+ injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(AAIServiceInstance));
+ }
/**
* Create ServiceSubscription in A&AI
+ *
* @param customer
*/
- public void createServiceSubscription(Customer customer) {
+ public void createServiceSubscription(Customer customer) {
AAIResourceUri serviceSubscriptionURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION,
- customer.getGlobalCustomerId(),customer.getServiceSubscription().getServiceType());
- org.onap.aai.domain.yang.ServiceSubscription serviceSubscription = aaiObjectMapper.mapServiceSubscription(customer.getServiceSubscription());
- injectionHelper.getAaiClient().createIfNotExists(serviceSubscriptionURI , Optional.of(serviceSubscription));
+ customer.getGlobalCustomerId(), customer.getServiceSubscription().getServiceType());
+ org.onap.aai.domain.yang.ServiceSubscription serviceSubscription =
+ aaiObjectMapper.mapServiceSubscription(customer.getServiceSubscription());
+ injectionHelper.getAaiClient().createIfNotExists(serviceSubscriptionURI, Optional.of(serviceSubscription));
+ }
+
+ public void deleteServiceInstance(ServiceInstance serviceInstance) {
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().delete(serviceInstanceURI);
+ }
+
+ public void createProject(Project project) {
+ AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName());
+ org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
+ injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject));
+ }
+
+ public void createProjectandConnectServiceInstance(Project project, ServiceInstance serviceInstance) {
+ AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName());
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
+ injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject)).connect(projectURI,
+ serviceInstanceURI);
+ }
+
+ public void createOwningEntity(OwningEntity owningEntity) {
+ AAIResourceUri owningEntityURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId());
+ org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity);
+ injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity));
+ }
+
+ public boolean existsOwningEntity(OwningEntity owningEntity) {
+ AAIResourceUri owningEntityUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId());
+ return injectionHelper.getAaiClient().exists(owningEntityUri);
+ }
+
+ public boolean existsOwningEntityName(String owningEntityName) {
+ AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY)
+ .queryParam("owning-entity-name", owningEntityName);
+ AAIResourcesClient aaiRC = injectionHelper.getAaiClient();
+ return aaiRC.exists(owningEntityUri);
+ }
+
+ public void connectOwningEntityandServiceInstance(OwningEntity owningEntity, ServiceInstance serviceInstance) {
+ AAIResourceUri owningEntityURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId());
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().connect(owningEntityURI, serviceInstanceURI);
+ }
+
+ public void createOwningEntityandConnectServiceInstance(OwningEntity owningEntity,
+ ServiceInstance serviceInstance) {
+ AAIResourceUri owningEntityURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId());
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity);
+ injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity))
+ .connect(owningEntityURI, serviceInstanceURI);
+ }
+
+ public void updateOrchestrationStatusServiceInstance(ServiceInstance serviceInstance,
+ OrchestrationStatus orchestrationStatus) {
+ ServiceInstance copiedServiceInstance = serviceInstance.shallowCopyId();
+
+ copiedServiceInstance.setOrchestrationStatus(orchestrationStatus);
+ copiedServiceInstance.setServiceInstanceName(serviceInstance.getServiceInstanceName());
+ serviceInstance.setOrchestrationStatus(orchestrationStatus);
+ updateServiceInstance(copiedServiceInstance);
+ }
+
+ public void updateServiceInstance(ServiceInstance serviceInstance) {
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance =
+ aaiObjectMapper.mapServiceInstance(serviceInstance);
+ injectionHelper.getAaiClient().update(serviceInstanceURI, AAIServiceInstance);
}
- public void deleteServiceInstance(ServiceInstance serviceInstance) {
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- injectionHelper.getAaiClient().delete(serviceInstanceURI);
- }
-
- public void createProject(Project project) {
- AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName());
- org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
- injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject));
- }
-
- public void createProjectandConnectServiceInstance(Project project, ServiceInstance serviceInstance) {
- AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName());
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
- injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject)).connect(projectURI, serviceInstanceURI);
- }
-
- public void createOwningEntity(OwningEntity owningEntity) {
- AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY,
- owningEntity.getOwningEntityId());
- org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity);
- injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity));
- }
-
- public boolean existsOwningEntity(OwningEntity owningEntity) {
- AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY,
- owningEntity.getOwningEntityId());
- return injectionHelper.getAaiClient().exists(owningEntityUri);
- }
-
- public boolean existsOwningEntityName(String owningEntityName) {
- AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY).queryParam("owning-entity-name", owningEntityName);
- AAIResourcesClient aaiRC = injectionHelper.getAaiClient();
- return aaiRC.exists(owningEntityUri);
- }
-
- public void connectOwningEntityandServiceInstance(OwningEntity owningEntity, ServiceInstance serviceInstance) {
- AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY,
- owningEntity.getOwningEntityId());
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- injectionHelper.getAaiClient().connect(owningEntityURI, serviceInstanceURI);
- }
-
- public void createOwningEntityandConnectServiceInstance(OwningEntity owningEntity,
- ServiceInstance serviceInstance) {
- AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY,
- owningEntity.getOwningEntityId());
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity);
- injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity)).connect(owningEntityURI,
- serviceInstanceURI);
- }
-
- public void updateOrchestrationStatusServiceInstance(ServiceInstance serviceInstance, OrchestrationStatus orchestrationStatus){
- ServiceInstance copiedServiceInstance = serviceInstance.shallowCopyId();
-
- copiedServiceInstance.setOrchestrationStatus(orchestrationStatus);
- copiedServiceInstance.setServiceInstanceName(serviceInstance.getServiceInstanceName());
- serviceInstance.setOrchestrationStatus(orchestrationStatus);
- updateServiceInstance(copiedServiceInstance);
- }
-
- public void updateServiceInstance(ServiceInstance serviceInstance) {
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
- org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance);
- injectionHelper.getAaiClient().update(serviceInstanceURI, AAIServiceInstance);
- }
-
}