Search in sources :

Example 1 with AAIRestClientI

use of org.onap.aaiclient.client.aai.AAIRestClientI in project so by onap.

the class ServiceLevelRequestDispatcher method getAndSetPnfNameFromServiceInstance.

private void getAndSetPnfNameFromServiceInstance(final String serviceInstanceId, final String serviceType, final String globalSubscriberId, DelegateExecution delegateExecution) {
    AAIRestClientI restClient = new AAIRestClientImpl();
    Optional<ServiceInstance> optionalSi = restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
    optionalSi.ifPresentOrElse(serviceInstance -> {
        final List<String> pnfNameList = serviceInstance.getRelationshipList().getRelationship().stream().filter(x -> x.getRelatedTo().contains("pnf")).flatMap(x -> x.getRelationshipData().stream()).filter(data -> data.getRelationshipKey().contains("pnf.pnf-name")).map(x -> x.getRelationshipValue()).collect(Collectors.toList());
        if (pnfNameList == null || pnfNameList.size() == 0) {
            logger.warn("Unable to find the PNF for service instance id: " + serviceInstance.getServiceInstanceId());
            return;
        }
        delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME_LIST, pnfNameList);
        delegateExecution.setVariable(ServiceLevelConstants.PNF_SIZE, pnfNameList.size());
        delegateExecution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.PNF);
    }, () -> {
        throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
    });
}
Also used : ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) AAIRestClientI(org.onap.aaiclient.client.aai.AAIRestClientI) Logger(org.slf4j.Logger) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) Relationship(org.onap.aai.domain.yang.Relationship) JsonUtils(org.onap.so.bpmn.core.json.JsonUtils) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Component(org.springframework.stereotype.Component) List(java.util.List) JavaDelegate(org.camunda.bpm.engine.delegate.JavaDelegate) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Optional(java.util.Optional) ExecutionVariableNames(org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames) Collector(java.util.stream.Collector) AAIRestClientImpl(org.onap.aaiclient.client.aai.AAIRestClientImpl) AAIRestClientImpl(org.onap.aaiclient.client.aai.AAIRestClientImpl) AAIRestClientI(org.onap.aaiclient.client.aai.AAIRestClientI) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance)

Example 2 with AAIRestClientI

use of org.onap.aaiclient.client.aai.AAIRestClientI in project so by onap.

the class UpdateServiceInstanceInAai method getAndSetServiceInstance.

private void getAndSetServiceInstance(final String serviceInstanceId, final String serviceType, final String globalSubscriberId, String modelVersionId) {
    AAIRestClientI restClient = new AAIRestClientImpl();
    Optional<ServiceInstance> optionalSi = restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
    if (!optionalSi.isPresent()) {
    // throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
    }
    ServiceInstance serviceInstance = optionalSi.get();
    serviceInstance.setModelVersionId(modelVersionId);
    restClient.updateServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, serviceInstance);
}
Also used : AAIRestClientImpl(org.onap.aaiclient.client.aai.AAIRestClientImpl) AAIRestClientI(org.onap.aaiclient.client.aai.AAIRestClientI) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance)

Aggregations

ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)2 AAIRestClientI (org.onap.aaiclient.client.aai.AAIRestClientI)2 AAIRestClientImpl (org.onap.aaiclient.client.aai.AAIRestClientImpl)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Collector (java.util.stream.Collector)1 Collectors (java.util.stream.Collectors)1 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)1 JavaDelegate (org.camunda.bpm.engine.delegate.JavaDelegate)1 Relationship (org.onap.aai.domain.yang.Relationship)1 JsonUtils (org.onap.so.bpmn.core.json.JsonUtils)1 ExecutionVariableNames (org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames)1 ExceptionBuilder (org.onap.so.client.exception.ExceptionBuilder)1 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1