Search in sources :

Example 1 with ModelType

use of org.onap.so.serviceinstancebeans.ModelType in project so by onap.

the class BBInputSetup method populateObjectsOnAssignAndCreateFlows.

protected void populateObjectsOnAssignAndCreateFlows(BBInputSetupParameter parameter) throws Exception {
    parameter.setModelInfo(parameter.getRequestDetails().getModelInfo());
    parameter.setInstanceName(parameter.getRequestDetails().getRequestInfo().getInstanceName());
    parameter.setProductFamilyId(parameter.getRequestDetails().getRequestInfo().getProductFamilyId());
    ModelType modelType = parameter.getModelInfo().getModelType();
    parameter.setRelatedInstanceList(parameter.getRequestDetails().getRelatedInstanceList());
    parameter.setPlatform(parameter.getRequestDetails().getPlatform());
    parameter.setLineOfBusiness(parameter.getRequestDetails().getLineOfBusiness());
    String applicationId = "";
    if (parameter.getRequestDetails().getRequestInfo().getApplicationId() != null) {
        applicationId = parameter.getRequestDetails().getRequestInfo().getApplicationId();
        parameter.setApplicationId(applicationId);
    }
    if (modelType.equals(ModelType.network)) {
        parameter.getLookupKeyMap().put(ResourceKey.NETWORK_ID, parameter.getResourceId());
        this.populateL3Network(parameter);
    } else if (modelType.equals(ModelType.vnf)) {
        parameter.getLookupKeyMap().put(ResourceKey.GENERIC_VNF_ID, parameter.getResourceId());
        this.populateGenericVnf(parameter);
    } else if (modelType.equals(ModelType.volumeGroup) || (modelType.equals(ModelType.vfModule) && (parameter.getBbName().equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString()) || parameter.getBbName().startsWith(CREATEVOLUME)))) {
        parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, parameter.getResourceId());
        this.populateVolumeGroup(parameter);
    } else if (modelType.equals(ModelType.vfModule)) {
        populateVfModuleOnAssignAndCreateFlows(parameter);
    } else if (modelType.equals(ModelType.instanceGroup)) {
        parameter.getLookupKeyMap().put(ResourceKey.INSTANCE_GROUP_ID, parameter.getResourceId());
        this.populateInstanceGroup(parameter);
    } else {
        return;
    }
}
Also used : ModelType(org.onap.so.serviceinstancebeans.ModelType)

Example 2 with ModelType

use of org.onap.so.serviceinstancebeans.ModelType in project so by onap.

the class RequestHandlerUtils method setInstanceIdAndName.

protected void setInstanceIdAndName(InfraActiveRequests infraActiveRequest, InfraActiveRequests currentActiveRequest) throws ApiException {
    String requestScope = infraActiveRequest.getRequestScope();
    try {
        ModelType type = ModelType.valueOf(requestScope);
        String instanceName = type.getName(infraActiveRequest);
        if (instanceName == null && type.equals(ModelType.vfModule)) {
            logger.error("vfModule for requestId: {} being resumed does not have an instanceName.", infraActiveRequest.getRequestId());
            ValidateException validateException = new ValidateException.Builder("vfModule for requestId: " + infraActiveRequest.getRequestId() + " being resumed does not have an instanceName.", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).build();
            updateStatus(currentActiveRequest, Status.FAILED, validateException.getMessage());
            throw validateException;
        }
        if (instanceName != null) {
            type.setName(currentActiveRequest, instanceName);
        }
        type.setId(currentActiveRequest, type.getId(infraActiveRequest));
    } catch (IllegalArgumentException e) {
        logger.error("requestScope \"{}\" does not match a ModelType enum. Unable to set instanceId and instanceName from the original request.", requestScope);
    }
}
Also used : ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) ModelType(org.onap.so.serviceinstancebeans.ModelType)

Example 3 with ModelType

use of org.onap.so.serviceinstancebeans.ModelType in project so by onap.

the class BBInputSetup method getGBB.

protected GeneralBuildingBlock getGBB(ExecuteBuildingBlock executeBB, Map<ResourceKey, String> lookupKeyMap, String requestAction, boolean aLaCarte, String resourceId, String vnfType) throws Exception {
    String requestId = executeBB.getRequestId();
    this.populateLookupKeyMapWithIds(executeBB.getWorkflowResourceIds(), lookupKeyMap);
    RequestDetails requestDetails = executeBB.getRequestDetails();
    if (requestDetails == null) {
        requestDetails = bbInputSetupUtils.getRequestDetails(requestId);
    }
    if (requestDetails.getModelInfo() == null) {
        return this.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId);
    } else {
        ModelType modelType = requestDetails.getModelInfo().getModelType();
        if (aLaCarte && modelType.equals(ModelType.service)) {
            return this.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId);
        } else if (aLaCarte && !modelType.equals(ModelType.service)) {
            return this.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
        } else {
            return this.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
        }
    }
}
Also used : ModelType(org.onap.so.serviceinstancebeans.ModelType) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails)

Example 4 with ModelType

use of org.onap.so.serviceinstancebeans.ModelType in project so by onap.

the class ResumeOrchestrationRequest method setInstanceIdMap.

protected HashMap<String, String> setInstanceIdMap(InfraActiveRequests infraActiveRequest, String requestScope) {
    HashMap<String, String> instanceIdMap = new HashMap<>();
    ModelType type;
    try {
        type = ModelType.valueOf(requestScope);
        instanceIdMap.put(type.name() + "InstanceId", type.getId(infraActiveRequest));
    } catch (IllegalArgumentException e) {
        logger.error("requestScope \"{}\" does not match a ModelType enum.", requestScope);
    }
    return instanceIdMap;
}
Also used : HashMap(java.util.HashMap) ModelType(org.onap.so.serviceinstancebeans.ModelType)

Example 5 with ModelType

use of org.onap.so.serviceinstancebeans.ModelType in project so by onap.

the class ResumeOrchestrationRequest method getInstanceName.

protected String getInstanceName(InfraActiveRequests infraActiveRequest, String requestScope, InfraActiveRequests currentActiveRequest) throws ValidateException, RequestDbFailureException {
    ModelType type;
    String instanceName = "";
    try {
        type = ModelType.valueOf(requestScope);
        instanceName = type.getName(infraActiveRequest);
    } catch (IllegalArgumentException e) {
        logger.error("requestScope \"{}\" does not match a ModelType enum.", requestScope);
        ValidateException validateException = new ValidateException.Builder("requestScope: \"" + requestScope + "\" from request: " + infraActiveRequest.getRequestId() + " does not match a ModelType enum.", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).build();
        requestHandlerUtils.updateStatus(currentActiveRequest, Status.FAILED, validateException.getMessage());
        throw validateException;
    }
    return instanceName;
}
Also used : ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) ModelType(org.onap.so.serviceinstancebeans.ModelType)

Aggregations

ModelType (org.onap.so.serviceinstancebeans.ModelType)12 Test (org.junit.Test)5 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)3 ValidationException (org.onap.so.exceptions.ValidationException)2 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 RequestClientParameter (org.onap.so.apihandler.common.RequestClientParameter)1 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)1 RequestDbFailureException (org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException)1 BpmnRequestBuilder (org.onap.so.apihandlerinfra.infra.rest.BpmnRequestBuilder)1 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)1 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)1 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)1 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)1 RelatedInstance (org.onap.so.serviceinstancebeans.RelatedInstance)1 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)1 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)1 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)1 RequestReferences (org.onap.so.serviceinstancebeans.RequestReferences)1