aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-20 11:16:31 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-20 11:16:31 -0500
commitd35235fd2ec0c9108594150c4f710622d59efc8a (patch)
treea43d95cf909bb39d76fd35905c56872111869968 /ms
parentf882ac09e274f3bfdd7fa59da75745457cd92ef5 (diff)
Add modelType service reactive compatible.
Change-Id: I0058a8136fe9ad62781f3d4556d2b95d11507f3f Issue-ID: CCSDK-864 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/parent/pom.xml5
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java148
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java165
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java10
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java22
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt56
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt116
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt138
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt10
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt6
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java)192
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java23
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java46
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java3
-rw-r--r--ms/controllerblueprints/parent/pom.xml5
17 files changed, 465 insertions, 486 deletions
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index 22661294..369b84b4 100644
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -81,6 +81,11 @@
<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>
<version>${kotlin.version}</version>
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
index 925a6c49..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang3.StringUtils;
-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;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ModelTypeService.java Purpose: Provide ModelTypeService Service ModelTypeService
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-@Service
-@Transactional
-public class ModelTypeService {
-
- private ModelTypeRepository modelTypeRepository;
-
- /**
- * This is a ModelTypeService, used to save and get the model types stored in database
- *
- * @param modelTypeRepository modelTypeRepository
- */
- public ModelTypeService(ModelTypeRepository modelTypeRepository) {
- this.modelTypeRepository = modelTypeRepository;
- }
-
-
- /**
- * This is a getModelTypeByName service
- *
- * @param modelTypeName modelTypeName
- * @return ModelType
- */
- public ModelType getModelTypeByName(String modelTypeName) {
- ModelType modelType = null;
- Preconditions.checkArgument(StringUtils.isNotBlank(modelTypeName), "Model Name Information is missing.");
- Optional<ModelType> modelTypeOption = modelTypeRepository.findByModelName(modelTypeName);
- if (modelTypeOption.isPresent()) {
- modelType = modelTypeOption.get();
- }
- return modelType;
- }
-
-
- /**
- * This is a searchModelTypes service
- *
- * @param tags tags
- * @return List<ModelType>
- */
- public List<ModelType> searchModelTypes(String tags) {
- Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No Search Information provide");
- return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
- }
-
- /**
- * This is a saveModel service
- *
- * @param modelType modelType
- * @return ModelType
- * @throws BluePrintException BluePrintException
- */
- public ModelType saveModel(ModelType modelType) throws BluePrintException {
-
- Preconditions.checkNotNull(modelType, "Model Type Information is missing.");
-
- ModelTypeValidator.validateModelType(modelType);
-
- Optional<ModelType> dbModelType = modelTypeRepository.findByModelName(modelType.getModelName());
- if (dbModelType.isPresent()) {
- ModelType dbModel = dbModelType.get();
- dbModel.setDescription(modelType.getDescription());
- dbModel.setDefinition(modelType.getDefinition());
- dbModel.setDefinitionType(modelType.getDefinitionType());
- dbModel.setDerivedFrom(modelType.getDerivedFrom());
- dbModel.setTags(modelType.getTags());
- dbModel.setVersion(modelType.getVersion());
- dbModel.setUpdatedBy(modelType.getUpdatedBy());
- modelType = modelTypeRepository.save(dbModel);
- } else {
- modelType = modelTypeRepository.save(modelType);
- }
- return modelType;
- }
-
-
- /**
- * This is a deleteByModelName service
- *
- * @param modelName modelName
- */
- public void deleteByModelName(String modelName) {
- Preconditions.checkArgument(StringUtils.isNotBlank(modelName), "Model Name Information is missing.");
- modelTypeRepository.deleteByModelName(modelName);
-
- }
-
- /**
- * This is a getModelTypeByDefinitionType service
- *
- * @param definitionType definitionType
- * @return List<ModelType>
- */
- public List<ModelType> getModelTypeByDefinitionType(String definitionType) {
- Preconditions.checkArgument(StringUtils.isNotBlank(definitionType), "Model definitionType Information is missing.");
- return modelTypeRepository.findByDefinitionType(definitionType);
- }
-
- /**
- * This is a getModelTypeByDerivedFrom service
- *
- * @param derivedFrom derivedFrom
- * @return List<ModelType>
- */
- public List<ModelType> getModelTypeByDerivedFrom(String derivedFrom) {
- Preconditions.checkArgument(StringUtils.isNotBlank(derivedFrom), "Model derivedFrom Information is missing.");
- return modelTypeRepository.findByDerivedFrom(derivedFrom);
- }
-
-
-}
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
index eacc9025..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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;
-
-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.core.data.PropertyDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
-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;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ResourceDictionaryService.java Purpose: Provide DataDictionaryService Service
- * DataDictionaryService
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Service
-public class ResourceDictionaryService {
-
- private ResourceDictionaryRepository resourceDictionaryRepository;
-
- private ResourceDefinitionValidationService resourceDictionaryValidationService;
-
- /**
- * This is a DataDictionaryService, used to save and get the Resource Mapping stored in database
- *
- * @param dataDictionaryRepository dataDictionaryRepository
- * @param resourceDictionaryValidationService resourceDictionaryValidationService
- */
- public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,
- ResourceDefinitionValidationService resourceDictionaryValidationService) {
- this.resourceDictionaryRepository = dataDictionaryRepository;
- this.resourceDictionaryValidationService = resourceDictionaryValidationService;
- }
-
- /**
- * This is a getDataDictionaryByName service
- *
- * @param name name
- * @return DataDictionary
- * @throws BluePrintException BluePrintException
- */
- public ResourceDictionary getResourceDictionaryByName(String name) throws BluePrintException {
- Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");
- Optional<ResourceDictionary> resourceDictionaryDb = resourceDictionaryRepository.findByName(name);
- if (resourceDictionaryDb.isPresent()) {
- return resourceDictionaryDb.get();
- } else {
- throw new BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name));
- }
- }
-
- /**
- * This is a searchResourceDictionaryByNames service
- *
- * @param names names
- * @return List<ResourceDictionary>
- */
- public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names) {
- Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide");
- return resourceDictionaryRepository.findByNameIn(names);
- }
-
- /**
- * This is a searchResourceDictionaryByTags service
- *
- * @param tags tags
- * @return List<ResourceDictionary>
- */
- public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) {
- Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide");
- return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags);
- }
-
- /**
- * This is a saveDataDictionary service
- *
- * @param resourceDictionary resourceDictionary
- * @return DataDictionary
- */
- public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) throws BluePrintException {
- Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");
- Preconditions.checkNotNull(resourceDictionary.getDefinition(), "Resource Dictionary definition information is missing");
-
- ResourceDefinition resourceDefinition = resourceDictionary.getDefinition();
- Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content");
- // Validate the Resource Definitions
- resourceDictionaryValidationService.validate(resourceDefinition);
-
- resourceDictionary.setTags(resourceDefinition.getTags());
- resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());
- // Set the Property Definitions
- PropertyDefinition propertyDefinition = resourceDefinition.getProperty();
- resourceDictionary.setDescription(propertyDefinition.getDescription());
- resourceDictionary.setDataType(propertyDefinition.getType());
- if (propertyDefinition.getEntrySchema() != null) {
- resourceDictionary.setEntrySchema(propertyDefinition.getEntrySchema().getType());
- }
-
- ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);
-
- Optional<ResourceDictionary> dbResourceDictionaryData =
- resourceDictionaryRepository.findByName(resourceDictionary.getName());
- if (dbResourceDictionaryData.isPresent()) {
- ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get();
-
- dbResourceDictionary.setName(resourceDictionary.getName());
- dbResourceDictionary.setDefinition(resourceDictionary.getDefinition());
- dbResourceDictionary.setDescription(resourceDictionary.getDescription());
- dbResourceDictionary.setTags(resourceDictionary.getTags());
- dbResourceDictionary.setUpdatedBy(resourceDictionary.getUpdatedBy());
- dbResourceDictionary.setDataType(resourceDictionary.getDataType());
- dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());
- resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);
- } else {
- resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);
- }
-
- return resourceDictionary;
- }
-
- /**
- * This is a deleteResourceDictionary service
- *
- * @param name name
- */
- public void deleteResourceDictionary(String name) {
- Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");
- resourceDictionaryRepository.deleteByName(name);
- }
-
- /**
- * This is a getResourceSourceMapping service
- */
- public ResourceSourceMapping getResourceSourceMapping() {
- return ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java
index 33c7ae42..65a135c1 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java
@@ -84,7 +84,7 @@ public class ModelType implements Serializable {
@Override
public String toString() {
- return "[" + ", modelName = " + modelName +
+ return "[" + "modelName = " + modelName +
", derivedFrom = " + derivedFrom +
", definitionType = " + definitionType +
", description = " + description +
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
index 69c20925..12ed0a57 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
@@ -18,8 +18,8 @@
package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-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.http.MediaType;
import org.springframework.web.bind.annotation.*;
@@ -29,18 +29,18 @@ import java.util.List;
* {@inheritDoc}
*/
@Deprecated
-@RestController
-@RequestMapping(value = "/api/v1/model-type")
+//@RestController
+//@RequestMapping(value = "/api/v1/model-type")
public class ModelTypeRest {
- private ModelTypeService modelTypeService;
+ private ModelTypeHandler modelTypeService;
/**
* This is a ModelTypeResourceImpl, used to save and get the model types stored in database
*
* @param modelTypeService Model Type Service
*/
- public ModelTypeRest(ModelTypeService modelTypeService) {
+ public ModelTypeRest(ModelTypeHandler modelTypeService) {
this.modelTypeService = modelTypeService;
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
index 50442042..8b7a9577 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
@@ -19,8 +19,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
-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.http.MediaType;
import org.springframework.web.bind.annotation.*;
@@ -35,51 +35,51 @@ import java.util.List;
public class ResourceDictionaryRest {
- private ResourceDictionaryService resourceDictionaryService;
+ private ResourceDictionaryHandler resourceDictionaryHandler;
/**
* This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database
*
- * @param dataDictionaryService Data Dictionary Service
+ * @param resourceDictionaryHandler Data Dictionary Handler
*/
- public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) {
- this.resourceDictionaryService = dataDictionaryService;
+ public ResourceDictionaryRest(ResourceDictionaryHandler resourceDictionaryHandler) {
+ this.resourceDictionaryHandler = resourceDictionaryHandler;
}
@PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException {
- return resourceDictionaryService.saveResourceDictionary(dataDictionary);
+ return resourceDictionaryHandler.saveResourceDictionary(dataDictionary);
}
@DeleteMapping(path = "/{name}")
public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) {
- resourceDictionaryService.deleteResourceDictionary(name);
+ resourceDictionaryHandler.deleteResourceDictionary(name);
}
@GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
- return resourceDictionaryService.getResourceDictionaryByName(name);
+ return resourceDictionaryHandler.getResourceDictionaryByName(name);
}
@PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names) {
- return resourceDictionaryService.searchResourceDictionaryByNames(names);
+ return resourceDictionaryHandler.searchResourceDictionaryByNames(names);
}
@GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) {
- return resourceDictionaryService.searchResourceDictionaryByTags(tags);
+ return resourceDictionaryHandler.searchResourceDictionaryByTags(tags);
}
@GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ResourceSourceMapping getResourceSourceMapping() {
- return resourceDictionaryService.getResourceSourceMapping();
+ return resourceDictionaryHandler.getResourceSourceMapping();
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
index 50e19b2f..c818410f 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
@@ -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
index 00000000..db82849e
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt
@@ -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
index 00000000..8099d07f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt
@@ -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
index 00000000..c2493148
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
@@ -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
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
index 31b1a16b..51bbca7d 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
@@ -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}")
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
index 4bb8a2f3..8100cac3 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
@@ -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 {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt
index 27823ef3..990cc651 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt
@@ -1,107 +1,85 @@
-/*
- * 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 java.util.List;
-import java.util.Optional;
-
-
-/**
- * ModelTypeRepository.java Purpose: Provide Configuration Generator ModelTypeRepository
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Repository
-public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
-
-
- /**
- * This is a findByModelName method
- *
- * @param modelName Model Name
- * @return Optional<ModelType>
- */
- Optional<ModelType> findByModelName(String modelName);
-
- /**
- * This is a findByModelNameIn method
- *
- * @param modelNames Model Names
- * @return List<ModelType>
- */
- List<ModelType> findByModelNameIn(List<String> modelNames);
-
- /**
- * This is a findByDerivedFrom method
- *
- * @param derivedFrom Derived From
- * @return List<ModelType>
- */
- List<ModelType> findByDerivedFrom(String derivedFrom);
-
-
- /**
- * This is a findByDerivedFromIn method
- *
- * @param derivedFroms Derived Froms
- * @return List<ModelType>
- */
- @SuppressWarnings("unused")
- List<ModelType> findByDerivedFromIn(List<String> derivedFroms);
-
- /**
- * This is a findByDefinitionType method
- *
- * @param definitionType Definition Type
- * @return List<ModelType>
- */
- List<ModelType> findByDefinitionType(String definitionType);
-
- /**
- * This is a findByDefinitionTypeIn method
- *
- * @param definitionTypes Definition Types
- * @return List<ModelType>
- */
- @SuppressWarnings("unused")
- List<ModelType> findByDefinitionTypeIn(List<String> definitionTypes);
-
-
- /**
- * This is a findByTagsContainingIgnoreCase method
- *
- * @param tags Tags
- * @return Optional<ModelType>
- */
- List<ModelType> findByTagsContainingIgnoreCase(String tags);
-
-
- /**
- * This is a deleteByModelName method
- *
- * @param modelName ModelName
- */
- void deleteByModelName(String modelName);
-
-
-
-}
+/*
+ * 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)
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
index 8e258ab6..e2bb4c5f 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
@@ -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
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
index c7147490..d283377b 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
@@ -17,48 +17,37 @@
package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-import org.apache.commons.io.FileUtils;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
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.controller.ModelTypeController;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+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 java.io.File;
-import java.nio.charset.Charset;
import java.util.List;
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@DataJpaTest
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ModelTypeRestTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
@Autowired
- ModelTypeRest modelTypeRest;
+ ModelTypeController modelTypeController;
String modelName = "test-datatype";
- @Before
- public void setUp() {
-
- }
-
-
- @After
- public void tearDown() {
- }
-
@Test
+ @Commit
public void test01SaveModelType() throws Exception {
log.info("**************** test01SaveModelType ********************");
@@ -73,18 +62,18 @@ public class ModelTypeRestTest {
modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setUpdatedBy("xxxxxx@xxx.com");
- modelType = modelTypeRest.saveModelType(modelType);
+ modelType = modelTypeController.saveModelType(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 = modelTypeRest.getModelTypeByName(modelType.getModelName());
+ ModelType dbModelType = modelTypeController.getModelTypeByName(modelType.getModelName());
Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",
dbModelType);
// Model Update
modelType.setUpdatedBy("bs2796@xxx.com");
- modelType = modelTypeRest.saveModelType(modelType);
+ modelType = modelTypeController.saveModelType(modelType);
Assert.assertNotNull("Failed to get Saved ModelType", modelType);
Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());
@@ -96,7 +85,7 @@ public class ModelTypeRestTest {
String tags = "test-datatype";
- List<ModelType> dbModelTypes = modelTypeRest.searchModelTypes(tags);
+ List<ModelType> dbModelTypes = modelTypeController.searchModelTypes(tags);
Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);
Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0);
@@ -105,25 +94,26 @@ public class ModelTypeRestTest {
@Test
public void test03GetModelType() throws Exception {
log.info("************************* test03GetModelType *********************************");
- ModelType dbModelType = modelTypeRest.getModelTypeByName(modelName);
- Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType);
+ ModelType dbModelType = modelTypeController.getModelTypeByName(modelName);
+ Assert.assertNotNull("Failed to get response for api call getModelByName " + modelName, dbModelType);
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName());
List<ModelType> dbDatatypeModelTypes =
- modelTypeRest.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelTypeController.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);
}
@Test
+ @Commit
public void test04DeleteModelType() throws Exception {
log.info(
"************************ test03DeleteModelType ***********************");
- ModelType dbResourceMapping = modelTypeRest.getModelTypeByName(modelName);
+ ModelType dbResourceMapping = modelTypeController.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());
- modelTypeRest.deleteModelTypeByName(dbResourceMapping.getModelName());
+ modelTypeController.deleteModelTypeByName(dbResourceMapping.getModelName());
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
index 675d2c24..9c02d4cf 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
@@ -29,6 +29,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
import com.att.eelf.configuration.EELFLogger;
@@ -52,7 +53,7 @@ public class ServiceTemplateRestTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateRestTest.class);
@Autowired
- ModelTypeRest modelTypeRest;
+ ModelTypeController modelTypeRest;
@Autowired
private ServiceTemplateRest serviceTemplateRest;
diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml
index b9134318..38a879ab 100644
--- a/ms/controllerblueprints/parent/pom.xml
+++ b/ms/controllerblueprints/parent/pom.xml
@@ -114,6 +114,11 @@
<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>
<version>${kotlin.version}</version>