Search in sources :

Example 66 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class ControllerExecution method setControllerActorScopeAction.

/**
 * Setting Controller Actor, Scope and Action Variables in BuildingBlockExecution object
 *
 * @param execution - BuildingBlockExecution object
 */
public void setControllerActorScopeAction(BuildingBlockExecution execution) {
    ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
    BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
    String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow(() -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table "));
    String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(() -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
    String controllerActor;
    try {
        if (String.valueOf(scope).equals("pnf")) {
            Pnf pnf = getPnf(execution);
            String pnfModelUUID = pnf.getModelInfoPnf().getModelCustomizationUuid();
            PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(pnfModelUUID);
            controllerActor = Optional.ofNullable(pnfResourceCustomization.getControllerActor()).orElse("APPC");
            execution.setVariable(MSO_REQUEST_ID, execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId());
            execution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion());
            execution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName());
        } else if ("service".equalsIgnoreCase(scope)) {
            GeneralBuildingBlock gbb = execution.getGeneralBuildingBlock();
            ModelInfoServiceInstance modelInfoServiceInstance = gbb.getServiceInstance().getModelInfoServiceInstance();
            controllerActor = Optional.ofNullable(modelInfoServiceInstance.getControllerActor()).orElse("CDS");
        } else {
            GenericVnf genericVnf = getGenericVnf(execution);
            String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
            VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelUuid);
            controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC");
        }
        execution.setVariable(SCOPE, scope);
        execution.setVariable(ACTION, action);
        execution.setVariable(CONTROLLER_ACTOR, controllerActor);
        logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}", controllerActor, scope, action);
    } catch (Exception ex) {
        logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)

Aggregations

BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)66 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)64 Test (org.junit.Test)51 ArrayList (java.util.ArrayList)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)30 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)28 File (java.io.File)24 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)22 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)22 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)19 List (java.util.List)18 Service (org.onap.so.db.catalog.beans.Service)18 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)15 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)15 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)12 GenericVnf (org.onap.aai.domain.yang.GenericVnf)11 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)11 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)10 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)10