Add modelType service reactive compatible. 98/74998/1
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 20 Dec 2018 16:16:31 +0000 (11:16 -0500)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 20 Dec 2018 16:16:31 +0000 (11:16 -0500)
Change-Id: I0058a8136fe9ad62781f3d4556d2b95d11507f3f
Issue-ID: CCSDK-864
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
18 files changed:
components/parent/pom.xml
ms/blueprintsprocessor/parent/pom.xml
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java [deleted file]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java [deleted file]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt [moved from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java with 60% similarity]
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
ms/controllerblueprints/parent/pom.xml

index 03656eb..1330279 100644 (file)
                 <artifactId>kotlinx-coroutines-core</artifactId>
                 <version>${kotlin.couroutines.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.jetbrains.kotlinx</groupId>
+                <artifactId>kotlinx-coroutines-reactor</artifactId>
+                <version>${kotlin.couroutines.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.jetbrains.kotlin</groupId>
                 <artifactId>kotlin-reflect</artifactId>
             <groupId>org.jetbrains.kotlinx</groupId>
             <artifactId>kotlinx-coroutines-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.jetbrains.kotlinx</groupId>
+            <artifactId>kotlinx-coroutines-reactor</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.fasterxml.jackson.module</groupId>
             <artifactId>jackson-module-kotlin</artifactId>
index 2266129..369b84b 100644 (file)
                 <artifactId>kotlinx-coroutines-core</artifactId>
                 <version>${kotlin.couroutines.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.jetbrains.kotlinx</groupId>
+                <artifactId>kotlinx-coroutines-reactor</artifactId>
+                <version>${kotlin.couroutines.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.jetbrains.kotlin</groupId>
                 <artifactId>kotlin-reflect</artifactId>
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java
deleted file mode 100644 (file)
index 925a6c4..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import com.google.common.base.Preconditions;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.validator.ModelTypeValidator;\r
-import org.springframework.stereotype.Service;\r
-import org.springframework.transaction.annotation.Transactional;\r
-\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * ModelTypeService.java Purpose: Provide ModelTypeService Service ModelTypeService\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-\r
-@Service\r
-@Transactional\r
-public class ModelTypeService {\r
-\r
-    private ModelTypeRepository modelTypeRepository;\r
-\r
-    /**\r
-     * This is a ModelTypeService, used to save and get the model types stored in database\r
-     *\r
-     * @param modelTypeRepository modelTypeRepository\r
-     */\r
-    public ModelTypeService(ModelTypeRepository modelTypeRepository) {\r
-        this.modelTypeRepository = modelTypeRepository;\r
-    }\r
-\r
-\r
-    /**\r
-     * This is a getModelTypeByName service\r
-     *\r
-     * @param modelTypeName modelTypeName\r
-     * @return ModelType\r
-     */\r
-    public ModelType getModelTypeByName(String modelTypeName) {\r
-        ModelType modelType = null;\r
-        Preconditions.checkArgument(StringUtils.isNotBlank(modelTypeName), "Model Name Information is missing.");\r
-        Optional<ModelType> modelTypeOption = modelTypeRepository.findByModelName(modelTypeName);\r
-        if (modelTypeOption.isPresent()) {\r
-            modelType = modelTypeOption.get();\r
-        }\r
-        return modelType;\r
-    }\r
-\r
-\r
-    /**\r
-     * This is a searchModelTypes service\r
-     *\r
-     * @param tags tags\r
-     * @return List<ModelType>\r
-     */\r
-    public List<ModelType> searchModelTypes(String tags) {\r
-        Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No Search Information provide");\r
-        return modelTypeRepository.findByTagsContainingIgnoreCase(tags);\r
-    }\r
-\r
-    /**\r
-     * This is a saveModel service\r
-     *\r
-     * @param modelType modelType\r
-     * @return ModelType\r
-     * @throws BluePrintException BluePrintException\r
-     */\r
-    public ModelType saveModel(ModelType modelType) throws BluePrintException {\r
-\r
-        Preconditions.checkNotNull(modelType, "Model Type Information is missing.");\r
-\r
-        ModelTypeValidator.validateModelType(modelType);\r
-\r
-        Optional<ModelType> dbModelType = modelTypeRepository.findByModelName(modelType.getModelName());\r
-        if (dbModelType.isPresent()) {\r
-            ModelType dbModel = dbModelType.get();\r
-            dbModel.setDescription(modelType.getDescription());\r
-            dbModel.setDefinition(modelType.getDefinition());\r
-            dbModel.setDefinitionType(modelType.getDefinitionType());\r
-            dbModel.setDerivedFrom(modelType.getDerivedFrom());\r
-            dbModel.setTags(modelType.getTags());\r
-            dbModel.setVersion(modelType.getVersion());\r
-            dbModel.setUpdatedBy(modelType.getUpdatedBy());\r
-            modelType = modelTypeRepository.save(dbModel);\r
-        } else {\r
-            modelType = modelTypeRepository.save(modelType);\r
-        }\r
-        return modelType;\r
-    }\r
-\r
-\r
-    /**\r
-     * This is a deleteByModelName service\r
-     *\r
-     * @param modelName modelName\r
-     */\r
-    public void deleteByModelName(String modelName) {\r
-        Preconditions.checkArgument(StringUtils.isNotBlank(modelName), "Model Name Information is missing.");\r
-        modelTypeRepository.deleteByModelName(modelName);\r
-\r
-    }\r
-\r
-    /**\r
-     * This is a getModelTypeByDefinitionType service\r
-     *\r
-     * @param definitionType definitionType\r
-     * @return List<ModelType>\r
-     */\r
-    public List<ModelType> getModelTypeByDefinitionType(String definitionType) {\r
-        Preconditions.checkArgument(StringUtils.isNotBlank(definitionType), "Model definitionType Information is missing.");\r
-        return modelTypeRepository.findByDefinitionType(definitionType);\r
-    }\r
-\r
-    /**\r
-     * This is a getModelTypeByDerivedFrom service\r
-     *\r
-     * @param derivedFrom derivedFrom\r
-     * @return List<ModelType>\r
-     */\r
-    public List<ModelType> getModelTypeByDerivedFrom(String derivedFrom) {\r
-        Preconditions.checkArgument(StringUtils.isNotBlank(derivedFrom), "Model derivedFrom Information is missing.");\r
-        return modelTypeRepository.findByDerivedFrom(derivedFrom);\r
-    }\r
-\r
-\r
-}\r
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
deleted file mode 100644 (file)
index eacc902..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import com.google.common.base.Preconditions;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator;\r
-import org.springframework.stereotype.Service;\r
-\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * ResourceDictionaryService.java Purpose: Provide DataDictionaryService Service\r
- * DataDictionaryService\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Service\r
-public class ResourceDictionaryService {\r
-\r
-    private ResourceDictionaryRepository resourceDictionaryRepository;\r
-\r
-    private ResourceDefinitionValidationService resourceDictionaryValidationService;\r
-\r
-    /**\r
-     * This is a DataDictionaryService, used to save and get the Resource Mapping stored in database\r
-     *\r
-     * @param dataDictionaryRepository            dataDictionaryRepository\r
-     * @param resourceDictionaryValidationService resourceDictionaryValidationService\r
-     */\r
-    public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,\r
-                                     ResourceDefinitionValidationService resourceDictionaryValidationService) {\r
-        this.resourceDictionaryRepository = dataDictionaryRepository;\r
-        this.resourceDictionaryValidationService = resourceDictionaryValidationService;\r
-    }\r
-\r
-    /**\r
-     * This is a getDataDictionaryByName service\r
-     *\r
-     * @param name name\r
-     * @return DataDictionary\r
-     * @throws BluePrintException BluePrintException\r
-     */\r
-    public ResourceDictionary getResourceDictionaryByName(String name) throws BluePrintException {\r
-        Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");\r
-        Optional<ResourceDictionary> resourceDictionaryDb = resourceDictionaryRepository.findByName(name);\r
-        if (resourceDictionaryDb.isPresent()) {\r
-            return resourceDictionaryDb.get();\r
-        } else {\r
-            throw new BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name));\r
-        }\r
-    }\r
-\r
-    /**\r
-     * This is a searchResourceDictionaryByNames service\r
-     *\r
-     * @param names names\r
-     * @return List<ResourceDictionary>\r
-     */\r
-    public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names) {\r
-        Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide");\r
-        return resourceDictionaryRepository.findByNameIn(names);\r
-    }\r
-\r
-    /**\r
-     * This is a searchResourceDictionaryByTags service\r
-     *\r
-     * @param tags tags\r
-     * @return List<ResourceDictionary>\r
-     */\r
-    public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) {\r
-        Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide");\r
-        return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags);\r
-    }\r
-\r
-    /**\r
-     * This is a saveDataDictionary service\r
-     *\r
-     * @param resourceDictionary resourceDictionary\r
-     * @return DataDictionary\r
-     */\r
-    public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) throws BluePrintException {\r
-        Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");\r
-        Preconditions.checkNotNull(resourceDictionary.getDefinition(), "Resource Dictionary definition information is missing");\r
-\r
-        ResourceDefinition resourceDefinition = resourceDictionary.getDefinition();\r
-        Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content");\r
-        // Validate the Resource Definitions\r
-        resourceDictionaryValidationService.validate(resourceDefinition);\r
-\r
-        resourceDictionary.setTags(resourceDefinition.getTags());\r
-        resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());\r
-        // Set the Property Definitions\r
-        PropertyDefinition propertyDefinition = resourceDefinition.getProperty();\r
-        resourceDictionary.setDescription(propertyDefinition.getDescription());\r
-        resourceDictionary.setDataType(propertyDefinition.getType());\r
-        if (propertyDefinition.getEntrySchema() != null) {\r
-            resourceDictionary.setEntrySchema(propertyDefinition.getEntrySchema().getType());\r
-        }\r
-\r
-        ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);\r
-\r
-        Optional<ResourceDictionary> dbResourceDictionaryData =\r
-                resourceDictionaryRepository.findByName(resourceDictionary.getName());\r
-        if (dbResourceDictionaryData.isPresent()) {\r
-            ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get();\r
-\r
-            dbResourceDictionary.setName(resourceDictionary.getName());\r
-            dbResourceDictionary.setDefinition(resourceDictionary.getDefinition());\r
-            dbResourceDictionary.setDescription(resourceDictionary.getDescription());\r
-            dbResourceDictionary.setTags(resourceDictionary.getTags());\r
-            dbResourceDictionary.setUpdatedBy(resourceDictionary.getUpdatedBy());\r
-            dbResourceDictionary.setDataType(resourceDictionary.getDataType());\r
-            dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());\r
-            resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);\r
-        } else {\r
-            resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);\r
-        }\r
-\r
-        return resourceDictionary;\r
-    }\r
-\r
-    /**\r
-     * This is a deleteResourceDictionary service\r
-     *\r
-     * @param name name\r
-     */\r
-    public void deleteResourceDictionary(String name) {\r
-        Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");\r
-        resourceDictionaryRepository.deleteByName(name);\r
-    }\r
-\r
-    /**\r
-     * This is a getResourceSourceMapping service\r
-     */\r
-    public ResourceSourceMapping getResourceSourceMapping() {\r
-        return ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();\r
-    }\r
-}\r
index 33c7ae4..65a135c 100644 (file)
@@ -84,7 +84,7 @@ public class ModelType implements Serializable {
 \r
     @Override\r
     public String toString() {\r
-        return "[" + "modelName = " + modelName +\r
+        return "[" + "modelName = " + modelName +\r
                 ", derivedFrom = " + derivedFrom +\r
                 ", definitionType = " + definitionType +\r
                 ", description = " + description +\r
index 69c2092..12ed0a5 100644 (file)
@@ -18,8 +18,8 @@
 package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
 \r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;\r
 import org.springframework.http.MediaType;\r
 import org.springframework.web.bind.annotation.*;\r
 \r
@@ -29,18 +29,18 @@ import java.util.List;
  * {@inheritDoc}\r
  */\r
 @Deprecated\r
-@RestController\r
-@RequestMapping(value = "/api/v1/model-type")\r
+//@RestController\r
+//@RequestMapping(value = "/api/v1/model-type")\r
 public class ModelTypeRest {\r
 \r
-    private ModelTypeService modelTypeService;\r
+    private ModelTypeHandler modelTypeService;\r
 \r
     /**\r
      * This is a ModelTypeResourceImpl, used to save and get the model types stored in database\r
      *\r
      * @param modelTypeService Model Type Service\r
      */\r
-    public ModelTypeRest(ModelTypeService modelTypeService) {\r
+    public ModelTypeRest(ModelTypeHandler modelTypeService) {\r
         this.modelTypeService = modelTypeService;\r
     }\r
 \r
index 5044204..8b7a957 100644 (file)
@@ -19,8 +19,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
 \r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler;\r
 import org.springframework.http.MediaType;\r
 import org.springframework.web.bind.annotation.*;\r
 \r
@@ -35,51 +35,51 @@ import java.util.List;
 public class ResourceDictionaryRest {\r
 \r
 \r
-    private ResourceDictionaryService resourceDictionaryService;\r
+    private ResourceDictionaryHandler resourceDictionaryHandler;\r
 \r
     /**\r
      * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database\r
      *\r
-     * @param dataDictionaryService Data Dictionary Service\r
+     * @param resourceDictionaryHandler Data Dictionary Handler\r
      */\r
-    public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) {\r
-        this.resourceDictionaryService = dataDictionaryService;\r
+    public ResourceDictionaryRest(ResourceDictionaryHandler resourceDictionaryHandler) {\r
+        this.resourceDictionaryHandler = resourceDictionaryHandler;\r
     }\r
 \r
     @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException {\r
-        return resourceDictionaryService.saveResourceDictionary(dataDictionary);\r
+        return resourceDictionaryHandler.saveResourceDictionary(dataDictionary);\r
     }\r
 \r
     @DeleteMapping(path = "/{name}")\r
     public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) {\r
-        resourceDictionaryService.deleteResourceDictionary(name);\r
+        resourceDictionaryHandler.deleteResourceDictionary(name);\r
     }\r
 \r
     @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
-        return resourceDictionaryService.getResourceDictionaryByName(name);\r
+        return resourceDictionaryHandler.getResourceDictionaryByName(name);\r
     }\r
 \r
     @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names) {\r
-        return resourceDictionaryService.searchResourceDictionaryByNames(names);\r
+        return resourceDictionaryHandler.searchResourceDictionaryByNames(names);\r
     }\r
 \r
     @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) {\r
-        return resourceDictionaryService.searchResourceDictionaryByTags(tags);\r
+        return resourceDictionaryHandler.searchResourceDictionaryByTags(tags);\r
 \r
     }\r
 \r
     @GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     ResourceSourceMapping getResourceSourceMapping() {\r
-        return resourceDictionaryService.getResourceSourceMapping();\r
+        return resourceDictionaryHandler.getResourceSourceMapping();\r
     }\r
 \r
 }\r
index 50e19b2..c818410 100644 (file)
@@ -94,8 +94,8 @@ open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRe
     private fun getModelDefinition(modelName: String): JsonNode {
         val modelDefinition: JsonNode
         val modelTypeDb = modelTypeRepository.findByModelName(modelName)
-        if (modelTypeDb.isPresent) {
-            modelDefinition = modelTypeDb.get().definition
+        if (modelTypeDb != null) {
+            modelDefinition = modelTypeDb.definition
         } else {
             throw BluePrintException(String.format("failed to get model definition (%s) from repo", modelName))
         }
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt
new file mode 100644 (file)
index 0000000..db82849
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.controller
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.*
+
+@RestController
+@RequestMapping(value = arrayOf("/api/v1/model-type"))
+open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) {
+
+    @GetMapping(path = arrayOf("/{name}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+    fun getModelTypeByName(@PathVariable(value = "name") name: String): ModelType? {
+        return modelTypeHandler.getModelTypeByName(name)
+    }
+
+    @GetMapping(path = arrayOf("/search/{tags}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+    fun searchModelTypes(@PathVariable(value = "tags") tags: String): List<ModelType> {
+        return modelTypeHandler.searchModelTypes(tags)
+    }
+
+    @GetMapping(path = arrayOf("/by-definition/{definitionType}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+    @ResponseBody
+    fun getModelTypeByDefinitionType(@PathVariable(value = "definitionType") definitionType: String): List<ModelType> {
+        return modelTypeHandler.getModelTypeByDefinitionType(definitionType)
+    }
+
+    @PostMapping(path = arrayOf(""), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE), consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+    @ResponseBody
+    @Throws(BluePrintException::class)
+    fun saveModelType(@RequestBody modelType: ModelType): ModelType {
+        return modelTypeHandler.saveModel(modelType)
+    }
+
+    @DeleteMapping(path = arrayOf("/{name}"))
+    fun deleteModelTypeByName(@PathVariable(value = "name") name: String) {
+        modelTypeHandler.deleteByModelName(name)
+    }
+}
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt
new file mode 100644 (file)
index 0000000..8099d07
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.handler
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ModelTypeValidator
+import org.springframework.stereotype.Service
+
+@Service
+open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository) {
+
+    private val log = EELFManager.getInstance().getLogger(ModelTypeHandler::class.java)!!
+
+    /**
+     * This is a getModelTypeByName service
+     *
+     * @param modelTypeName modelTypeName
+     * @return ModelType
+     */
+    fun getModelTypeByName(modelTypeName: String): ModelType? {
+        log.info("Searching : $modelTypeName")
+        check(modelTypeName.isNotBlank()) { "Model Name Information is missing." }
+        return modelTypeRepository.findByModelName(modelTypeName)
+    }
+
+
+    /**
+     * This is a searchModelTypes service
+     *
+     * @param tags tags
+     * @return List<ModelType>
+    </ModelType> */
+    fun searchModelTypes(tags: String): List<ModelType> {
+        check(tags.isNotBlank()) { "No Search Information provide" }
+        return modelTypeRepository.findByTagsContainingIgnoreCase(tags)
+    }
+
+    /**
+     * This is a saveModel service
+     *
+     * @param modelType modelType
+     * @return ModelType
+     * @throws BluePrintException BluePrintException
+     */
+    @Throws(BluePrintException::class)
+    open fun saveModel(modelType: ModelType): ModelType {
+        lateinit var dbModel: ModelType
+        ModelTypeValidator.validateModelType(modelType)
+        val dbModelType: ModelType? = modelTypeRepository.findByModelName(modelType.modelName)
+        if (dbModelType != null) {
+            dbModel = dbModelType
+            dbModel.description = modelType.description
+            dbModel.definition = modelType.definition
+            dbModel.definitionType = modelType.definitionType
+            dbModel.derivedFrom = modelType.derivedFrom
+            dbModel.tags = modelType.tags
+            dbModel.version = modelType.version
+            dbModel.updatedBy = modelType.updatedBy
+            dbModel = modelTypeRepository.save(dbModel)
+        } else {
+            dbModel = modelTypeRepository.save(modelType)
+        }
+        return dbModel
+    }
+
+
+    /**
+     * This is a deleteByModelName service
+     *
+     * @param modelName modelName
+     */
+    open fun deleteByModelName(modelName: String) {
+        check(modelName.isNotBlank()) { "Model Name Information is missing." }
+        modelTypeRepository.deleteByModelName(modelName)
+
+    }
+
+    /**
+     * This is a getModelTypeByDefinitionType service
+     *
+     * @param definitionType definitionType
+     * @return List<ModelType>
+    */
+    fun getModelTypeByDefinitionType(definitionType: String): List<ModelType> {
+        check(definitionType.isNotBlank()) { "Model definitionType Information is missing." }
+        return modelTypeRepository.findByDefinitionType(definitionType)
+    }
+
+    /**
+     * This is a getModelTypeByDerivedFrom service
+     *
+     * @param derivedFrom derivedFrom
+     * @return List<ModelType>
+    */
+    fun getModelTypeByDerivedFrom(derivedFrom: String): List<ModelType> {
+        check(derivedFrom.isNotBlank()) { "Model derivedFrom Information is missing." }
+        return modelTypeRepository.findByDerivedFrom(derivedFrom)
+    }
+}
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
new file mode 100644 (file)
index 0000000..c249314
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.handler
+
+import com.google.common.base.Preconditions
+import org.apache.commons.collections.CollectionUtils
+import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator
+import org.springframework.stereotype.Service
+
+@Service
+class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository,
+                                private val resourceDictionaryValidationService: ResourceDefinitionValidationService) {
+
+
+    /**
+     * This is a getDataDictionaryByName service
+     *
+     * @param name name
+     * @return DataDictionary
+     * @throws BluePrintException BluePrintException
+     */
+    @Throws(BluePrintException::class)
+    fun getResourceDictionaryByName(name: String): ResourceDictionary {
+        Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.")
+        val resourceDictionaryDb = resourceDictionaryRepository.findByName(name)
+        return if (resourceDictionaryDb.isPresent) {
+            resourceDictionaryDb.get()
+        } else {
+            throw BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name))
+        }
+    }
+
+    /**
+     * This is a searchResourceDictionaryByNames service
+     *
+     * @param names names
+     * @return List<ResourceDictionary>
+    </ResourceDictionary> */
+    fun searchResourceDictionaryByNames(names: List<String>): List<ResourceDictionary> {
+        Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide")
+        return resourceDictionaryRepository.findByNameIn(names)
+    }
+
+    /**
+     * This is a searchResourceDictionaryByTags service
+     *
+     * @param tags tags
+     * @return List<ResourceDictionary>
+    </ResourceDictionary> */
+    fun searchResourceDictionaryByTags(tags: String): List<ResourceDictionary> {
+        Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide")
+        return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags)
+    }
+
+    /**
+     * This is a saveDataDictionary service
+     *
+     * @param resourceDictionary resourceDictionary
+     * @return DataDictionary
+     */
+    @Throws(BluePrintException::class)
+    fun saveResourceDictionary(resourceDictionary: ResourceDictionary): ResourceDictionary {
+        var resourceDictionary = resourceDictionary
+
+        val resourceDefinition = resourceDictionary.definition
+        Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content")
+        // Validate the Resource Definitions
+        resourceDictionaryValidationService.validate(resourceDefinition)
+
+        resourceDictionary.tags = resourceDefinition.tags
+        resourceDefinition.updatedBy = resourceDictionary.updatedBy
+        // Set the Property Definitions
+        val propertyDefinition = resourceDefinition.property
+        resourceDictionary.description = propertyDefinition.description
+        resourceDictionary.dataType = propertyDefinition.type
+        if (propertyDefinition.entrySchema != null) {
+            resourceDictionary.entrySchema = propertyDefinition.entrySchema!!.type
+        }
+
+        ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary)
+
+        val dbResourceDictionaryData = resourceDictionaryRepository.findByName(resourceDictionary.name)
+        if (dbResourceDictionaryData.isPresent) {
+            val dbResourceDictionary = dbResourceDictionaryData.get()
+
+            dbResourceDictionary.name = resourceDictionary.name
+            dbResourceDictionary.definition = resourceDictionary.definition
+            dbResourceDictionary.description = resourceDictionary.description
+            dbResourceDictionary.tags = resourceDictionary.tags
+            dbResourceDictionary.updatedBy = resourceDictionary.updatedBy
+            dbResourceDictionary.dataType = resourceDictionary.dataType
+            dbResourceDictionary.entrySchema = resourceDictionary.entrySchema
+            resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary)
+        } else {
+            resourceDictionary = resourceDictionaryRepository.save(resourceDictionary)
+        }
+
+        return resourceDictionary
+    }
+
+    /**
+     * This is a deleteResourceDictionary service
+     *
+     * @param name name
+     */
+    fun deleteResourceDictionary(name: String) {
+        check(name.isNotBlank()) { "Resource dictionary name is missing." }
+        resourceDictionaryRepository.deleteByName(name)
+    }
+
+    /**
+     * This is a getResourceSourceMapping service
+     */
+    fun getResourceSourceMapping(): ResourceSourceMapping {
+        return ResourceSourceMappingFactory.getRegisterSourceMapping()
+    }
+}
\ No newline at end of file
index 31b1a16..51bbca7 100644 (file)
@@ -25,14 +25,14 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
 import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
 import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler
 import org.springframework.stereotype.Service
 import java.io.File
 import java.nio.charset.Charset
 
 @Service
-open class ModelTypeLoadService(private val modelTypeService: ModelTypeService) {
+open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) {
 
     private val log = EELFManager.getInstance().getLogger(ModelTypeLoadService::class.java)
     private val updateBySystem = "System"
@@ -100,7 +100,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService)
             modelType.version = dataType.version
             modelType.updatedBy = updateBySystem
             modelType.tags = (dataKey + "," + dataType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
-            modelTypeService.saveModel(modelType)
+            modelTypeHandler.saveModel(modelType)
             log.trace("DataType(${file.name}) loaded successfully ")
         } catch (e: Exception) {
             errorBuilder.appendln("Couldn't load DataType(${file.name}: ${e.message}")
@@ -124,7 +124,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService)
             modelType.version = artifactType.version
             modelType.updatedBy = updateBySystem
             modelType.tags = (dataKey + "," + artifactType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
-            modelTypeService.saveModel(modelType)
+            modelTypeHandler.saveModel(modelType)
             log.trace("ArtifactType(${file.name}) loaded successfully ")
         } catch (e: Exception) {
             errorBuilder.appendln("Couldn't load ArtifactType(${file.name}: ${e.message}")
@@ -148,7 +148,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService)
             modelType.version = nodeType.version
             modelType.updatedBy = updateBySystem
             modelType.tags = (nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + "," + nodeType.derivedFrom)
-            modelTypeService.saveModel(modelType)
+            modelTypeHandler.saveModel(modelType)
             log.trace("NodeType(${file.name}) loaded successfully ")
         } catch (e: Exception) {
             errorBuilder.appendln("Couldn't load NodeType(${file.name}: ${e.message}")
index 4bb8a2f..8100cac 100644 (file)
@@ -25,14 +25,14 @@ import org.apache.commons.lang3.text.StrBuilder
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
-import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler
 import org.springframework.stereotype.Service
 import java.io.File
 import java.nio.charset.Charset
 
 @Service
-open class ResourceDictionaryLoadService(private val resourceDictionaryService: ResourceDictionaryService) {
+open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
 
     private val log = EELFManager.getInstance().getLogger(ResourceDictionaryLoadService::class.java)
 
@@ -92,7 +92,7 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryService:
                 } else {
                     resourceDictionary.tags = resourceDefinition.tags
                 }
-                resourceDictionaryService.saveResourceDictionary(resourceDictionary)
+                resourceDictionaryHandler.saveResourceDictionary(resourceDictionary)
 
                 log.trace("Resource dictionary(${file.name}) loaded successfully ")
             } else {
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
-import org.springframework.data.jpa.repository.JpaRepository;\r
-import org.springframework.stereotype.Repository;\r
-\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-\r
-/**\r
- * ModelTypeRepository.java Purpose: Provide Configuration Generator ModelTypeRepository\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Repository\r
-public interface ModelTypeRepository extends JpaRepository<ModelType, String> {\r
-\r
-\r
-    /**\r
-     * This is a findByModelName method\r
-     * \r
-     * @param modelName Model Name\r
-     * @return Optional<ModelType>\r
-     */\r
-    Optional<ModelType> findByModelName(String modelName);\r
-\r
-    /**\r
-     * This is a findByModelNameIn method\r
-     *\r
-     * @param modelNames Model Names\r
-     * @return List<ModelType>\r
-     */\r
-    List<ModelType> findByModelNameIn(List<String> modelNames);\r
-\r
-    /**\r
-     * This is a findByDerivedFrom method\r
-     * \r
-     * @param derivedFrom Derived From\r
-     * @return List<ModelType>\r
-     */\r
-    List<ModelType> findByDerivedFrom(String derivedFrom);\r
-\r
-\r
-    /**\r
-     * This is a findByDerivedFromIn method\r
-     * \r
-     * @param derivedFroms Derived Froms\r
-     * @return List<ModelType>\r
-     */\r
-    @SuppressWarnings("unused")\r
-    List<ModelType> findByDerivedFromIn(List<String> derivedFroms);\r
-\r
-    /**\r
-     * This is a findByDefinitionType method\r
-     * \r
-     * @param definitionType Definition Type\r
-     * @return List<ModelType>\r
-     */\r
-    List<ModelType> findByDefinitionType(String definitionType);\r
-\r
-    /**\r
-     * This is a findByDefinitionTypeIn method\r
-     * \r
-     * @param definitionTypes Definition Types\r
-     * @return List<ModelType>\r
-     */\r
-    @SuppressWarnings("unused")\r
-    List<ModelType> findByDefinitionTypeIn(List<String> definitionTypes);\r
-\r
-\r
-    /**\r
-     * This is a findByTagsContainingIgnoreCase method\r
-     * \r
-     * @param tags Tags\r
-     * @return Optional<ModelType>\r
-     */\r
-    List<ModelType> findByTagsContainingIgnoreCase(String tags);\r
-\r
-\r
-    /**\r
-     * This is a deleteByModelName method\r
-     * \r
-     * @param modelName ModelName\r
-     */\r
-    void deleteByModelName(String modelName);\r
-\r
-\r
-\r
-}\r
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.repository
+
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.stereotype.Repository
+import javax.transaction.Transactional
+
+@Repository
+interface ModelTypeRepository : JpaRepository<ModelType, String> {
+    /**
+     * This is a findByModelName method
+     *
+     * @param modelName Model Name
+     * @return Optional<ModelType>
+     */
+    fun findByModelName(modelName: String): ModelType?
+    /**
+     * This is a findByModelNameIn method
+     *
+     * @param modelNames Model Names
+     * @return List<ModelType>
+     */
+    fun findByModelNameIn(modelNames: List<String>): List<ModelType>
+    /**
+     * This is a findByDerivedFrom method
+     *
+     * @param derivedFrom Derived From
+     * @return List<ModelType>
+    */
+    fun findByDerivedFrom(derivedFrom: String): List<ModelType>
+    /**
+     * This is a findByDerivedFromIn method
+     *
+     * @param derivedFroms Derived Froms
+     * @return List<ModelType>
+    */
+    fun findByDerivedFromIn(derivedFroms: List<String>): List<ModelType>
+
+    /**
+     * This is a findByDefinitionType method
+     *
+     * @param definitionType Definition Type
+     * @return List<ModelType>
+     */
+    fun findByDefinitionType(definitionType: String): List<ModelType>
+    /**
+     * This is a findByDefinitionTypeIn method
+     *
+     * @param definitionTypes Definition Types
+     * @return List<ModelType>
+    */
+    fun findByDefinitionTypeIn(definitionTypes: List<String>): List<ModelType>
+
+    /**
+     * This is a findByTagsContainingIgnoreCase method
+     *
+     * @param tags Tags
+     * @return Optional<ModelType>
+     */
+    fun findByTagsContainingIgnoreCase(tags: String): List<ModelType>
+
+    /**
+     * This is a deleteByModelName method
+     *
+     * @param modelName ModelName
+     */
+    @Transactional
+    fun deleteByModelName(modelName: String)
+}
index 8e258ab..e2bb4c5 100644 (file)
@@ -25,9 +25,11 @@ import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;
 import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestTest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.annotation.Commit;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.transaction.annotation.Propagation;
@@ -43,11 +45,12 @@ import java.util.List;
 public class ModelTypeServiceTest {
     private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
     @Autowired
-    ModelTypeService modelTypeService;
+    private ModelTypeHandler modelTypeHandler;
 
     String modelName = "test-datatype";
 
     @Test
+    @Commit
     public void test01SaveModelType() throws Exception {
         log.info("**************** test01SaveModelType  ********************");
 
@@ -62,18 +65,18 @@ public class ModelTypeServiceTest {
         modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
                 + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
         modelType.setUpdatedBy("xxxxxx@xxx.com");
-        modelType = modelTypeService.saveModel(modelType);
+        modelType = modelTypeHandler.saveModel(modelType);
         log.info("Saved Mode {}", modelType.toString());
         Assert.assertNotNull("Failed to get Saved ModelType", modelType);
         Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName());
 
-        ModelType dbModelType = modelTypeService.getModelTypeByName(modelType.getModelName());
+        ModelType dbModelType = modelTypeHandler.getModelTypeByName(modelType.getModelName());
         Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",
                 dbModelType);
 
         // Model Update
         modelType.setUpdatedBy("bs2796@xxx.com");
-        modelType = modelTypeService.saveModel(modelType);
+        modelType = modelTypeHandler.saveModel(modelType);
         Assert.assertNotNull("Failed to get Saved ModelType", modelType);
         Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());
 
@@ -85,7 +88,7 @@ public class ModelTypeServiceTest {
 
         String tags = "test-datatype";
 
-        List<ModelType> dbModelTypes = modelTypeService.searchModelTypes(tags);
+        List<ModelType> dbModelTypes = modelTypeHandler.searchModelTypes(tags);
         Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);
         Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0);
 
@@ -94,17 +97,17 @@ public class ModelTypeServiceTest {
     @Test
     public void test03GetModelType() throws Exception {
         log.info("************************* test03GetModelType  *********************************");
-        ModelType dbModelType = modelTypeService.getModelTypeByName(modelName);
+        ModelType dbModelType = modelTypeHandler.getModelTypeByName(modelName);
         Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType);
         Assert.assertNotNull("Failed to get Id for api call  getModelByName ", dbModelType.getModelName());
 
         List<ModelType> dbDatatypeModelTypes =
-                modelTypeService.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+                modelTypeHandler.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
         Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes);
         Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0);
 
         List<ModelType> dbModelTypeByDerivedFroms =
-                modelTypeService.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
+                modelTypeHandler.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
         Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms);
         Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size() > 0);
 
@@ -114,10 +117,10 @@ public class ModelTypeServiceTest {
     public void test04DeleteModelType() throws Exception {
         log.info(
                 "************************ test03DeleteModelType  ***********************");
-        ModelType dbResourceMapping = modelTypeService.getModelTypeByName(modelName);
+        ModelType dbResourceMapping = modelTypeHandler.getModelTypeByName(modelName);
         Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping);
         Assert.assertNotNull("Failed to get Id for api call  getModelByName ", dbResourceMapping.getModelName());
 
-        modelTypeService.deleteByModelName(dbResourceMapping.getModelName());
+        modelTypeHandler.deleteByModelName(dbResourceMapping.getModelName());
     }
 }
\ No newline at end of file
index c714749..d283377 100644 (file)
 \r
 package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
 \r
-import org.apache.commons.io.FileUtils;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
 import org.junit.*;\r
 import org.junit.runner.RunWith;\r
 import org.junit.runners.MethodSorters;\r
 import org.onap.ccsdk.apps.controllerblueprints.TestApplication;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.boot.test.context.SpringBootTest;\r
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;\r
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;\r
+import org.springframework.test.annotation.Commit;\r
 import org.springframework.test.context.ContextConfiguration;\r
 import org.springframework.test.context.junit4.SpringRunner;\r
 \r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
 import java.util.List;\r
 \r
 @RunWith(SpringRunner.class)\r
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)\r
+@DataJpaTest\r
 @ContextConfiguration(classes = {TestApplication.class})\r
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
 public class ModelTypeRestTest {\r
     private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);\r
     @Autowired\r
-    ModelTypeRest modelTypeRest;\r
+    ModelTypeController modelTypeController;\r
 \r
     String modelName = "test-datatype";\r
 \r
-    @Before\r
-    public void setUp() {\r
-\r
-    }\r
-\r
-\r
-    @After\r
-    public void tearDown() {\r
-    }\r
-\r
     @Test\r
+    @Commit\r
     public void test01SaveModelType() throws Exception {\r
         log.info("**************** test01SaveModelType  ********************");\r
 \r
@@ -73,18 +62,18 @@ public class ModelTypeRestTest {
         modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","\r
                 + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
         modelType.setUpdatedBy("xxxxxx@xxx.com");\r
-        modelType = modelTypeRest.saveModelType(modelType);\r
+        modelType = modelTypeController.saveModelType(modelType);\r
         log.info("Saved Mode {}", modelType.toString());\r
         Assert.assertNotNull("Failed to get Saved ModelType", modelType);\r
         Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName());\r
 \r
-        ModelType dbModelType = modelTypeRest.getModelTypeByName(modelType.getModelName());\r
+        ModelType dbModelType = modelTypeController.getModelTypeByName(modelType.getModelName());\r
         Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",\r
                 dbModelType);\r
 \r
         // Model Update\r
         modelType.setUpdatedBy("bs2796@xxx.com");\r
-        modelType = modelTypeRest.saveModelType(modelType);\r
+        modelType = modelTypeController.saveModelType(modelType);\r
         Assert.assertNotNull("Failed to get Saved ModelType", modelType);\r
         Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());\r
 \r
@@ -96,7 +85,7 @@ public class ModelTypeRestTest {
 \r
         String tags = "test-datatype";\r
 \r
-        List<ModelType> dbModelTypes = modelTypeRest.searchModelTypes(tags);\r
+        List<ModelType> dbModelTypes = modelTypeController.searchModelTypes(tags);\r
         Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);\r
         Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0);\r
 \r
@@ -105,25 +94,26 @@ public class ModelTypeRestTest {
     @Test\r
     public void test03GetModelType() throws Exception {\r
         log.info("************************* test03GetModelType  *********************************");\r
-        ModelType dbModelType = modelTypeRest.getModelTypeByName(modelName);\r
-        Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType);\r
+        ModelType dbModelType = modelTypeController.getModelTypeByName(modelName);\r
+        Assert.assertNotNull("Failed to get response for api call getModelByName " + modelName, dbModelType);\r
         Assert.assertNotNull("Failed to get Id for api call  getModelByName ", dbModelType.getModelName());\r
 \r
         List<ModelType> dbDatatypeModelTypes =\r
-                modelTypeRest.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
+                modelTypeController.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
         Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes);\r
         Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0);\r
     }\r
 \r
     @Test\r
+    @Commit\r
     public void test04DeleteModelType() throws Exception {\r
         log.info(\r
                 "************************ test03DeleteModelType  ***********************");\r
-        ModelType dbResourceMapping = modelTypeRest.getModelTypeByName(modelName);\r
+        ModelType dbResourceMapping = modelTypeController.getModelTypeByName(modelName);\r
         Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping);\r
         Assert.assertNotNull("Failed to get Id for api call  getModelByName ", dbResourceMapping.getModelName());\r
 \r
-        modelTypeRest.deleteModelTypeByName(dbResourceMapping.getModelName());\r
+        modelTypeController.deleteModelTypeByName(dbResourceMapping.getModelName());\r
     }\r
 \r
 \r
index 675d2c2..9c02d4c 100644 (file)
@@ -29,6 +29,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
 import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;\r
 import com.att.eelf.configuration.EELFLogger;\r
@@ -52,7 +53,7 @@ public class ServiceTemplateRestTest {
 \r
     private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateRestTest.class);\r
     @Autowired\r
-    ModelTypeRest modelTypeRest;\r
+    ModelTypeController modelTypeRest;\r
 \r
     @Autowired\r
     private ServiceTemplateRest serviceTemplateRest;\r
index b913431..38a879a 100644 (file)
                 <artifactId>kotlinx-couroutines-core</artifactId>
                 <version>${kotlin.couroutines.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.jetbrains.kotlinx</groupId>
+                <artifactId>kotlinx-coroutines-reactor</artifactId>
+                <version>${kotlin.couroutines.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.jetbrains.kotlin</groupId>
                 <artifactId>kotlin-reflect</artifactId>