use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class BBInputSetup method getGBBALaCarteService.
protected GeneralBuildingBlock getGBBALaCarteService(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception {
Customer customer = getCustomerAndServiceSubscription(requestDetails, resourceId);
if (customer != null) {
Project project = null;
OwningEntity owningEntity = null;
if (requestDetails.getProject() != null)
project = mapperLayer.mapRequestProject(requestDetails.getProject());
if (requestDetails.getOwningEntity() != null)
owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity());
String modelVersionId = requestDetails.getModelInfo().getModelVersionId();
if (ModelType.vnf == requestDetails.getModelInfo().getModelType()) {
for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) {
if (ModelType.service == relatedInstanceList.getRelatedInstance().getModelInfo().getModelType()) {
modelVersionId = relatedInstanceList.getRelatedInstance().getModelInfo().getModelVersionId();
break;
}
}
}
Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId);
if (service == null) {
service = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId());
if (service == null) {
throw new Exception("Could not find service for model version Id: " + requestDetails.getModelInfo().getModelVersionId() + " and for model invariant Id: " + requestDetails.getModelInfo().getModelInvariantId());
}
}
ServiceInstance serviceInstance = this.getALaCarteServiceInstance(service, requestDetails, customer, project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()), executeBB.getBuildingBlock().getBpmnFlowName());
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails).setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction).setCustomer(customer).build();
return this.populateGBBWithSIAndAdditionalInfo(parameter);
} else {
throw new Exception("Could not find customer");
}
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class BBInputSetup method getALaCarteServiceInstance.
protected ServiceInstance getALaCarteServiceInstance(Service service, RequestDetails requestDetails, Customer customer, Project project, OwningEntity owningEntity, Map<ResourceKey, String> lookupKeyMap, String serviceInstanceId, boolean aLaCarte, String bbName) throws Exception {
ServiceInstance serviceInstance = this.getServiceInstanceHelper(requestDetails, customer, project, owningEntity, lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null;
if (customer != null && customer.getServiceSubscription() != null) {
serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(), customer.getServiceSubscription().getServiceType(), serviceInstanceId);
} else {
serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
}
if (serviceInstanceAAI != null && !serviceInstanceAAI.getModelVersionId().equalsIgnoreCase(service.getModelUUID())) {
Service tempService = this.bbInputSetupUtils.getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId());
if (tempService != null) {
serviceInstance.setModelInfoServiceInstance(mapperLayer.mapCatalogServiceIntoServiceInstance(tempService));
return serviceInstance;
} else {
throw new Exception("Could not find model of existing SI. Service Instance in AAI already exists with different model version id: " + serviceInstanceAAI.getModelVersionId());
}
}
serviceInstance.setModelInfoServiceInstance(mapperLayer.mapCatalogServiceIntoServiceInstance(service));
return serviceInstance;
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class BBInputSetup method mapCatalogVfModule.
protected void mapCatalogVfModule(VfModule vfModule, ModelInfo modelInfo, Service service, String vnfModelCustomizationUUID) {
if (modelInfo.getModelCustomizationUuid() != null) {
modelInfo.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
}
VnfResourceCustomization vnfResourceCustomization = null;
for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) {
if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(vnfModelCustomizationUUID)) {
vnfResourceCustomization = resourceCust;
break;
}
}
VfModuleCustomization vfResourceCustomization = null;
if (vnfResourceCustomization != null) {
vfResourceCustomization = // Convert to steam
vnfResourceCustomization.getVfModuleCustomizations().stream().filter(// find
x -> modelInfo.getModelCustomizationId().equalsIgnoreCase(x.getModelCustomizationUUID())).findAny().orElse(null);
}
if (vfResourceCustomization == null) {
vfResourceCustomization = bbInputSetupUtils.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId());
}
if (vfResourceCustomization != null) {
vfModule.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization));
}
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class BBInputSetup method getGBBMacro.
protected GeneralBuildingBlock getGBBMacro(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId, String vnfType) throws Exception {
String bbName = executeBB.getBuildingBlock().getBpmnFlowName();
String key = executeBB.getBuildingBlock().getKey();
if (requestAction.equalsIgnoreCase("deleteInstance") || requestAction.equalsIgnoreCase("unassignInstance") || requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("activateFabricConfiguration") || requestAction.equalsIgnoreCase("recreateInstance") || requestAction.equalsIgnoreCase("replaceInstance") || requestAction.equalsIgnoreCase("upgradeInstance") || requestAction.equalsIgnoreCase("healthCheck")) {
return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, requestAction, requestDetails.getCloudConfiguration());
}
String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
GeneralBuildingBlock gBB = this.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, serviceInstanceId);
RequestParameters requestParams = requestDetails.getRequestParameters();
Service service = null;
if (gBB != null && gBB.getServiceInstance() != null && gBB.getServiceInstance().getModelInfoServiceInstance() != null && gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid() != null) {
service = bbInputSetupUtils.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
} else {
throw new Exception("Could not get service instance for macro request");
}
if (requestParams != null && requestParams.getUserParams() != null) {
for (Map<String, Object> userParams : requestParams.getUserParams()) {
if (userParams.containsKey("service")) {
String input = mapper.writeValueAsString(userParams.get("service"));
return getGBBMacroUserParams(executeBB, requestDetails, lookupKeyMap, vnfType, bbName, key, gBB, requestParams, service, input);
}
}
}
if (requestAction.equalsIgnoreCase("deactivateInstance")) {
return gBB;
} else if (requestAction.equalsIgnoreCase("createInstance")) {
return getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap, bbName, key, gBB, service);
} else {
throw new IllegalArgumentException("No user params on requestAction: assignInstance. Please specify user params.");
}
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class QueryServiceInfo method JSON2.
@Override
public String JSON2(boolean isArray, boolean isEmbed) {
if (serviceInfo == null) {
return "\"serviceInfo\": null";
}
StringBuilder sb = new StringBuilder();
sb.append("\"serviceInfo\": ");
sb.append("\n");
Map<String, String> valueMap = new HashMap<>();
Service service = serviceInfo.getService();
put(valueMap, "ID", null == serviceInfo ? null : serviceInfo.getId());
put(valueMap, "SERVICE_INPUT", null == serviceInfo ? null : serviceInfo.getServiceInput());
put(valueMap, "SERVICE_PROPERTIES", null == serviceInfo ? null : serviceInfo.getServiceProperties());
String subitem = new QueryServiceArtifact(service.getServiceArtifactList()).JSON2(true, true);
valueMap.put("_SERVICEARTIFACT_", subitem.replaceAll("(?m)^", "\t\t"));
sb.append(this.setTemplate(TEMPLATE, valueMap));
sb.append("}");
return sb.toString();
}
Aggregations