use of org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization in project so by onap.
the class ToscaResourceInstaller method createServiceProxy.
protected ServiceProxyResourceCustomization createServiceProxy(IEntityDetails spEntity, Service service, ToscaResourceStructure toscaResourceStructure) {
Metadata spMetadata = spEntity.getMetadata();
ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
spCustomizationResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
spCustomizationResource.setModelInstanceName(spEntity.getName());
spCustomizationResource.setToscaNodeType(spEntity.getToscaType());
String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
spCustomizationResource.setSourceService(sourceService);
spCustomizationResource.setToscaNodeType(spEntity.getToscaType());
serviceProxyCustomizationSet.add(spCustomizationResource);
toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
return spCustomizationResource;
}
use of org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization in project so by onap.
the class ToscaResourceInstaller method processServiceProxyAndConfiguration.
protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
List<IEntityDetails> spEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
List<IEntityDetails> configEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<>();
List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<>();
ServiceProxyResourceCustomization serviceProxy = null;
if (spEntityList != null) {
for (IEntityDetails spEntity : spEntityList) {
serviceProxy = createServiceProxy(spEntity, service, toscaResourceStruct);
serviceProxyList.add(serviceProxy);
for (IEntityDetails configEntity : configEntityList) {
List<RequirementAssignment> requirements = configEntity.getRequirements();
for (RequirementAssignment requirement : requirements) {
if (requirement.getNodeTemplateName().equals(spEntity.getName())) {
ConfigurationResourceCustomization configurationResource = createConfiguration(configEntity, toscaResourceStruct, serviceProxy, service, configurationResourceList);
Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream().filter(configurationResourceCustomization -> configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID())).filter(configurationResourceCustomization -> configurationResourceCustomization.getModelInstanceName().equals(configurationResource.getModelInstanceName())).findFirst();
if (!matchingObject.isPresent()) {
configurationResourceList.add(configurationResource);
}
break;
}
}
}
}
}
service.setConfigurationCustomizations(configurationResourceList);
service.setServiceProxyCustomizations(serviceProxyList);
}
use of org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization in project so by onap.
the class BBInputSetup method getServiceProxy.
protected ServiceProxy getServiceProxy(Service service) {
if (!service.getServiceProxyCustomizations().isEmpty()) {
ServiceProxyResourceCustomization serviceProxyCatalog = getServiceProxyResourceCustomization(service);
ServiceProxy serviceProxy = new ServiceProxy();
serviceProxy.setModelInfoServiceProxy(mapperLayer.mapServiceProxyCustomizationToServiceProxy(serviceProxyCatalog));
Service sourceService = serviceProxyCatalog.getSourceService();
ServiceInstance sourceServiceShell = new ServiceInstance();
sourceServiceShell.setModelInfoServiceInstance(mapperLayer.mapCatalogServiceIntoServiceInstance(sourceService));
serviceProxy.setServiceInstance(sourceServiceShell);
serviceProxy.setType(sourceService.getServiceType());
return serviceProxy;
} else {
return null;
}
}
use of org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization in project so by onap.
the class QueryServiceProxyCustomization method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
boolean first = true;
int i = 1;
for (ServiceProxyResourceCustomization o : serviceProxyResourceCustomizationList) {
sb.append(i).append("\t");
if (!first)
sb.append("\n");
first = false;
sb.append(o);
}
return sb.toString();
}
use of org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization in project so by onap.
the class QueryServiceProxyCustomization method JSON2.
@Override
public String JSON2(boolean isArray, boolean isEmbed) {
StringBuilder sb = new StringBuilder();
if (!isEmbed && isArray)
sb.append("{ ");
if (isArray)
sb.append("\"serviceProxy\": [");
Map<String, String> valueMap = new HashMap<>();
String sep = "";
boolean first = true;
if (this.serviceProxyResourceCustomizationList != null) {
for (ServiceProxyResourceCustomization o : serviceProxyResourceCustomizationList) {
if (first)
sb.append("\n");
first = false;
boolean arNull = o == null;
put(valueMap, "MODEL_CUSTOMIZATION_UUID", arNull ? null : o.getModelCustomizationUUID());
put(valueMap, "MODEL_INSTANCE_NAME", arNull ? null : o.getModelInstanceName());
put(valueMap, "MODEL_UUID", arNull ? null : o.getModelUUID());
put(valueMap, "MODEL_INVARIANT_UUID", arNull ? null : o.getModelInvariantUUID());
put(valueMap, "MODEL_VERSION", arNull ? null : o.getModelVersion());
put(valueMap, "MODEL_NAME", arNull ? null : o.getModelName());
put(valueMap, "TOSCA_NODE_TYPE", arNull ? null : o.getToscaNodeType());
put(valueMap, "DESCRIPTION", arNull ? null : o.getDescription());
put(valueMap, "SOURCE_SERVICE_MODEL_UUID", (String) (arNull ? null : o.getSourceService() == null ? null : o.getSourceService().getModelUUID()));
sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
sep = ",\n";
}
}
if (!first)
sb.append("\n");
if (isArray)
sb.append("]");
if (!isEmbed && isArray)
sb.append("}");
return sb.toString();
}
Aggregations