From a490a2830aaa1345fd506df5dd4d913c67784da6 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 11 Dec 2018 19:40:51 -0500 Subject: Implement Enhancer Framework Interfaces Change-Id: Iff85dc50f87ab6d6f7d9ceb4a309ea6e4d55e362 Issue-ID: CCSDK-803 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../service/BluePrintEnhancerService.java | 9 +++--- .../service/ResourceDefinitionRepoDBService.java | 36 ++++++++++------------ 2 files changed, 22 insertions(+), 23 deletions(-) (limited to 'ms/controllerblueprints/modules/service/src/main/java') diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java index aaa45e143..91df33318 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java @@ -30,7 +30,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.*; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService; -import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService; +import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerServiceImpl; import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -46,9 +46,10 @@ import java.util.Map; * @author Brinda Santh DATE : 8/8/2018 */ +@Deprecated @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { +public class BluePrintEnhancerService extends BluePrintEnhancerServiceImpl { private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class); @@ -167,8 +168,8 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class); Preconditions.checkNotNull(resourceAssignments, "Failed to Processing Resource Mapping " + resourceAssignmentContent); - // Enhance Resource Assignment - resourceAssignmentEnhancerService.enhanceBluePrint(this, resourceAssignments); + // Enhance Resource Assignment TODO("Plug Resource Assignment Enhancer Service") + //resourceAssignmentEnhancerService.enhanceBluePrint(this, resourceAssignments); dataTypeProperties = new HashMap<>(); diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java index 16cc8415c..0af5d9d3e 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java @@ -31,7 +31,6 @@ import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionar import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository; import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository; import org.springframework.stereotype.Service; -import reactor.core.publisher.Mono; import java.util.Optional; @@ -55,54 +54,53 @@ public class ResourceDefinitionRepoDBService implements ResourceDefinitionRepoSe } @Override - public Mono getNodeType(@NotNull String nodeTypeName) throws BluePrintException { + public NodeType getNodeType(@NotNull String nodeTypeName) throws BluePrintException { return getModelType(nodeTypeName, NodeType.class); } @Override - public Mono getDataType(@NotNull String dataTypeName) throws BluePrintException { + public DataType getDataType(@NotNull String dataTypeName) throws BluePrintException { return getModelType(dataTypeName, DataType.class); } @Override - public Mono getArtifactType(@NotNull String artifactTypeName) throws BluePrintException { + public ArtifactType getArtifactType(@NotNull String artifactTypeName) throws BluePrintException { return getModelType(artifactTypeName, ArtifactType.class); } @Override - public Mono getRelationshipType(@NotNull String relationshipTypeName) throws BluePrintException { + public RelationshipType getRelationshipType(@NotNull String relationshipTypeName) throws BluePrintException { return getModelType(relationshipTypeName, RelationshipType.class); } @Override - public Mono getCapabilityDefinition(@NotNull String capabilityDefinitionName) throws BluePrintException { + public CapabilityDefinition getCapabilityDefinition(@NotNull String capabilityDefinitionName) throws BluePrintException { return getModelType(capabilityDefinitionName, CapabilityDefinition.class); } @NotNull @Override - public Mono getResourceDefinition(@NotNull String resourceDefinitionName) throws BluePrintException{ + public ResourceDefinition getResourceDefinition(@NotNull String resourceDefinitionName) throws BluePrintException { Optional dbResourceDictionary = resourceDictionaryRepository.findByName(resourceDefinitionName); - if(dbResourceDictionary.isPresent()){ - return Mono.just(dbResourceDictionary.get().getDefinition()); - }else{ + if (dbResourceDictionary.isPresent()) { + return dbResourceDictionary.get().getDefinition(); + } else { throw new BluePrintException(String.format("failed to get resource dictionary (%s) from repo", resourceDefinitionName)); } } - private Mono getModelType(String modelName, Class valueClass) throws BluePrintException { + private T getModelType(String modelName, Class valueClass) throws BluePrintException { Preconditions.checkArgument(StringUtils.isNotBlank(modelName), "Failed to get model from repo, model name is missing"); - return getModelDefinition(modelName).map(modelDefinition -> { - Preconditions.checkNotNull(modelDefinition, - String.format("Failed to get model content for model name (%s)", modelName)); - return JacksonUtils.readValue(modelDefinition, valueClass); - } - ); + JsonNode modelDefinition = getModelDefinition(modelName); + Preconditions.checkNotNull(modelDefinition, + String.format("Failed to get model content for model name (%s)", modelName)); + + return JacksonUtils.readValue(modelDefinition, valueClass); } - private Mono getModelDefinition(String modelName) throws BluePrintException { + private JsonNode getModelDefinition(String modelName) throws BluePrintException { JsonNode modelDefinition; Optional modelTypeDb = modelTypeRepository.findByModelName(modelName); if (modelTypeDb.isPresent()) { @@ -110,6 +108,6 @@ public class ResourceDefinitionRepoDBService implements ResourceDefinitionRepoSe } else { throw new BluePrintException(String.format("failed to get model definition (%s) from repo", modelName)); } - return Mono.just(modelDefinition); + return modelDefinition; } } -- cgit 1.2.3-korg