aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2018-08-09 20:47:29 +0000
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-10 18:48:54 +0000
commitaa7486577fb66e85a5bb220438946579695b27b8 (patch)
treefe93c4ce0441b82d9b185b5be4e93255cc2cdbac /ms/controllerblueprints/modules/service/src
parent3db41eeb5c71efe3153ab5761a7b0ad091a56399 (diff)
Controller Blueprints MS
Creating the base directory structure for Controller Blueprints MicroService Change-Id: I1ccf7fc76446048af3b2822f9155bb634657aee3 Issue-ID: CCSDK-410 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src')
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java211
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java100
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java207
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java339
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java247
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java67
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java325
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java178
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java169
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java116
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java140
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java33
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java63
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java42
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java187
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java291
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java175
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java171
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java170
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java207
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java53
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java95
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java90
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java43
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java98
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java68
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java179
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java116
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java125
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java87
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java126
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java91
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java134
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java94
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java124
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java200
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java88
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java123
-rw-r--r--ms/controllerblueprints/modules/service/src/main/resources/service_template/default_netconf.json890
-rw-r--r--ms/controllerblueprints/modules/service/src/main/resources/sql/data.sql0
-rw-r--r--ms/controllerblueprints/modules/service/src/main/resources/sql/schema-local.sql87
-rw-r--r--ms/controllerblueprints/modules/service/src/main/resources/sql/schema.sql82
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java61
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java69
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestApplication.java34
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java36
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SchemaGeneratorServiceTest.java50
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceTemplateValidationTest.java56
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java172
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java130
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java113
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java155
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtilsTest.java33
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/application.properties67
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json345
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json824
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json11
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json19
58 files changed, 8606 insertions, 0 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java
new file mode 100644
index 00000000..6b09c81f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java
@@ -0,0 +1,211 @@
+/*
+ * 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;
+
+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.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AutoResourceMappingService.java Purpose: Provide Automapping of Resource Assignments AutoResourceMappingService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class AutoResourceMappingService {
+
+ private static Logger log = LoggerFactory.getLogger(AutoResourceMappingService.class);
+
+ private ResourceDictionaryRepository dataDictionaryRepository;
+
+ /**
+ * This is a AutoResourceMappingService constructor
+ *
+ * @param dataDictionaryRepository
+ *
+ */
+ public AutoResourceMappingService(ResourceDictionaryRepository dataDictionaryRepository) {
+ this.dataDictionaryRepository = dataDictionaryRepository;
+ }
+
+ /**
+ * This is a autoMap service to map the template keys automatically to Dictionary fields.
+ *
+ * @param resourceAssignments
+ * @return AutoMapResponse
+ */
+ public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {
+ AutoMapResponse autoMapResponse = new AutoMapResponse();
+ try {
+ if (CollectionUtils.isNotEmpty(resourceAssignments)) {
+
+ // Create the Dictionary definitions for the ResourceAssignment Names
+ Map<String, ResourceDictionary> dictionaryMap = getDictionaryDefinitions(resourceAssignments);
+
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName())
+ && StringUtils.isBlank(resourceAssignment.getDictionaryName())) {
+
+ populateDictionaryMapping(dictionaryMap, resourceAssignment);
+
+ log.info("Mapped Resource : {}", resourceAssignment);
+
+ } else {
+ // Do nothins
+ }
+ }
+ }
+ List<ResourceDictionary> dictionaries = getDictionaryDefinitionsList(resourceAssignments);
+ List<ResourceAssignment> resourceAssignmentsFinal = getAllAutomapResourceAssignments(resourceAssignments);
+ autoMapResponse.setDataDictionaries(dictionaries);
+ autoMapResponse.setResourceAssignments(resourceAssignmentsFinal);
+ } catch (Exception e) {
+ log.error(String.format("Failed in auto process %s", e.getMessage()));
+ throw new BluePrintException(e.getMessage(), e);
+ }
+ return autoMapResponse;
+ }
+
+ private void populateDictionaryMapping(Map<String, ResourceDictionary> dictionaryMap, ResourceAssignment resourceAssignment) {
+ ResourceDictionary dbDataDictionary = dictionaryMap.get(resourceAssignment.getName());
+ if (dbDataDictionary != null && StringUtils.isNotBlank(dbDataDictionary.getDefinition())) {
+
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValue(dbDataDictionary.getDefinition(), DictionaryDefinition.class);
+
+ if (dictionaryDefinition != null && StringUtils.isNotBlank(dictionaryDefinition.getName())
+ && StringUtils.isBlank(resourceAssignment.getDictionaryName())) {
+
+ resourceAssignment.setDictionaryName(dbDataDictionary.getName());
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
+ }
+ }
+ }
+
+ private Map<String, ResourceDictionary> getDictionaryDefinitions(List<ResourceAssignment> resourceAssignments) {
+ Map<String, ResourceDictionary> dictionaryMap = new HashMap<>();
+ List<String> names = new ArrayList<>();
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName())) {
+ names.add(resourceAssignment.getName());
+ }
+ }
+ if (CollectionUtils.isNotEmpty(names)) {
+
+ List<ResourceDictionary> dictionaries = dataDictionaryRepository.findByNameIn(names);
+ if (CollectionUtils.isNotEmpty( dictionaries)) {
+ for (ResourceDictionary dataDictionary : dictionaries) {
+ if (dataDictionary != null && StringUtils.isNotBlank(dataDictionary.getName())) {
+ dictionaryMap.put(dataDictionary.getName(), dataDictionary);
+ }
+ }
+ }
+ }
+ return dictionaryMap;
+
+ }
+
+ private List<ResourceDictionary> getDictionaryDefinitionsList(List<ResourceAssignment> resourceAssignments) {
+ List<ResourceDictionary> dictionaries = null;
+ List<String> names = new ArrayList<>();
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) {
+
+ if (!names.contains(resourceAssignment.getDictionaryName())) {
+ names.add(resourceAssignment.getDictionaryName());
+ }
+
+ if (resourceAssignment.getDependencies() != null && !resourceAssignment.getDependencies().isEmpty()) {
+ List<String> dependencyNames = resourceAssignment.getDependencies();
+ for (String dependencyName : dependencyNames) {
+ if (StringUtils.isNotBlank(dependencyName) && !names.contains(dependencyName)) {
+ names.add(dependencyName);
+ }
+ }
+ }
+ }
+ }
+ if (CollectionUtils.isNotEmpty(names)) {
+ dictionaries = dataDictionaryRepository.findByNameIn(names);
+ }
+ return dictionaries;
+
+ }
+
+ private List<ResourceAssignment> getAllAutomapResourceAssignments(List<ResourceAssignment> resourceAssignments) {
+ List<ResourceDictionary> dictionaries = null;
+ List<String> names = new ArrayList<>();
+ List<ResourceAssignment> resourceAssignmentsWithDepencies = resourceAssignments;
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) {
+ if (resourceAssignment.getDependencies() != null && !resourceAssignment.getDependencies().isEmpty()) {
+ List<String> dependencieNames = resourceAssignment.getDependencies();
+ for (String dependencieName : dependencieNames) {
+ if (StringUtils.isNotBlank(dependencieName) && !names.contains(dependencieName)
+ && !checkAssignmentsExists(resourceAssignmentsWithDepencies, dependencieName)) {
+ names.add(dependencieName);
+ }
+ }
+ }
+ }
+ }
+
+ if (!names.isEmpty()) {
+ dictionaries = dataDictionaryRepository.findByNameIn(names);
+ }
+ if (dictionaries != null) {
+ for (ResourceDictionary resourcedictionary : dictionaries) {
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValue(resourcedictionary.getDefinition(), DictionaryDefinition.class);
+ PropertyDefinition property = new PropertyDefinition();
+ property.setRequired(true);
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName(resourcedictionary.getName());
+ resourceAssignment.setDictionaryName(resourcedictionary
+ .getName());
+ resourceAssignment.setVersion(0);
+ resourceAssignment.setProperty(property);
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
+ resourceAssignmentsWithDepencies.add(resourceAssignment);
+ }
+ }
+ return resourceAssignmentsWithDepencies;
+
+ }
+
+
+ public boolean checkAssignmentsExists(List<ResourceAssignment> resourceAssignmentsWithDepencies, String resourceName) {
+ return resourceAssignmentsWithDepencies.stream().anyMatch(names -> names.getName().equalsIgnoreCase(resourceName));
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java
new file mode 100644
index 00000000..a2e5b104
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+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.core.data.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;
+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.repository.ModelTypeRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.Optional;
+
+/**
+ * BluePrintEnhancerRepoDBService
+ *
+ * @author Brinda Santh
+ */
+@Service
+public class BluePrintEnhancerRepoDBService implements BluePrintEnhancerRepoService {
+
+ private ModelTypeRepository modelTypeRepository;
+
+ public BluePrintEnhancerRepoDBService(ModelTypeRepository modelTypeRepository) {
+ this.modelTypeRepository = modelTypeRepository;
+ }
+
+
+ @Override
+ public NodeType getNodeType(String nodeTypeName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(nodeTypeName), "NodeType name is missing");
+ String content = getModelDefinitions(nodeTypeName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "NodeType content is missing");
+ return JacksonUtils.readValue(content, NodeType.class);
+ }
+
+
+ @Override
+ public DataType getDataType(String dataTypeName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(dataTypeName), "DataType name is missing");
+ String content = getModelDefinitions(dataTypeName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "DataType content is missing");
+ return JacksonUtils.readValue(content, DataType.class);
+ }
+
+
+ @Override
+ public ArtifactType getArtifactType(String artifactTypeName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(artifactTypeName), "ArtifactType name is missing");
+ String content = getModelDefinitions(artifactTypeName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "ArtifactType content is missing");
+ return JacksonUtils.readValue(content, ArtifactType.class);
+ }
+
+
+ @Override
+ public RelationshipType getRelationshipType(String relationshipTypeName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(relationshipTypeName), "RelationshipType name is missing");
+ String content = getModelDefinitions(relationshipTypeName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "RelationshipType content is missing");
+ return JacksonUtils.readValue(content, RelationshipType.class);
+ }
+
+
+ @Override
+ public CapabilityDefinition getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(capabilityDefinitionName), "CapabilityDefinition name is missing");
+ String content = getModelDefinitions(capabilityDefinitionName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "CapabilityDefinition content is missing");
+ return JacksonUtils.readValue(content, CapabilityDefinition.class);
+ }
+
+ private String getModelDefinitions(String modelName) throws BluePrintException {
+ String modelDefinition = null;
+ Optional<ModelType> modelTypedb = modelTypeRepository.findByModelName(modelName);
+ if (modelTypedb.isPresent()) {
+ modelDefinition = modelTypedb.get().getDefinition();
+ } else {
+ throw new BluePrintException(String.format("failed to get model definition (%s) from repo", modelName));
+ }
+ return modelDefinition;
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
new file mode 100644
index 00000000..afd12f21
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
@@ -0,0 +1,207 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * BluePrintEnhancerService
+ *
+ * @author Brinda Santh DATE : 8/8/2018
+ */
+
+@Service
+public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
+
+ private static Logger log = LoggerFactory.getLogger(BluePrintEnhancerService.class);
+
+ private HashMap<String, DataType> recipeDataTypes = new HashMap<>();
+
+ public BluePrintEnhancerService(BluePrintEnhancerRepoService bluePrintEnhancerRepoDBService) {
+ super(bluePrintEnhancerRepoDBService);
+ }
+
+ @Override
+ public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) {
+ super.enrichTopologyTemplate(serviceTemplate);
+
+ // Update the Recipe Inputs and DataTypes
+ populateRecipeInputs(serviceTemplate);
+ }
+
+
+ @Override
+ public void enrichNodeTemplate(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate) throws BluePrintException {
+ super.enrichNodeTemplate(nodeTemplateName, nodeTemplate);
+
+ String nodeTypeName = nodeTemplate.getType();
+ log.info("*** Enriching NodeType: {}", nodeTypeName);
+ // Get NodeType from Repo and Update Service Template
+ NodeType nodeType = super.populateNodeType(nodeTypeName);
+
+ // Enrich NodeType
+ super.enrichNodeType(nodeTypeName, nodeType);
+
+ // Custom for Artifact Population
+ if (StringUtils.isNotBlank(nodeType.getDerivedFrom())
+ && ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT.equalsIgnoreCase(nodeType.getDerivedFrom())) {
+ populateArtifactTemplateMappingDataType(nodeTemplateName, nodeTemplate);
+ }
+
+ //Enrich Node Template Artifacts
+ super.enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate);
+
+ }
+
+
+ private void populateArtifactTemplateMappingDataType(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)
+ throws BluePrintException {
+ log.info("****** Processing Artifact Node Template : {}", nodeTemplateName);
+
+ if (nodeTemplate.getProperties() != null) {
+
+ if (!nodeTemplate.getProperties().containsKey(ConfigModelConstant.PROPERTY_RECIPE_NAMES)) {
+ throw new BluePrintException("Node Template (" + nodeTemplateName + ") doesn't have "
+ + ConfigModelConstant.PROPERTY_RECIPE_NAMES + " property.");
+ }
+
+ // Modified for ONAP converted Object to JsonNode
+ JsonNode recipeNames = nodeTemplate.getProperties().get(ConfigModelConstant.PROPERTY_RECIPE_NAMES);
+
+ log.info("Processing Receipe Names : {} ", recipeNames);
+
+ if (recipeNames != null && recipeNames.isArray() && recipeNames.size() > 0) {
+
+ Map<String, PropertyDefinition> mappingProperties =
+ getCapabilityMappingProperties(nodeTemplateName, nodeTemplate);
+
+ for (JsonNode recipeNameNode : recipeNames) {
+ String recipeName = recipeNameNode.textValue();
+ processRecipe(nodeTemplateName, mappingProperties, recipeName);
+ }
+ }
+ }
+ }
+
+ private void processRecipe(@NotNull String nodeTemplateName, Map<String, PropertyDefinition> mappingProperties, String recipeName) {
+ if (StringUtils.isNotBlank(recipeName)) {
+ DataType recipeDataType = this.recipeDataTypes.get(recipeName);
+ if (recipeDataType == null) {
+ log.info("DataType not present for the recipe({})" , recipeName);
+ recipeDataType = new DataType();
+ recipeDataType.setVersion("1.0.0");
+ recipeDataType.setDescription(
+ "This is Dynamic Data type definition generated from resource mapping for the config template name "
+ + nodeTemplateName + ".");
+ recipeDataType.setDerivedFrom(ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC);
+ Map<String, PropertyDefinition> dataTypeProperties = new HashMap<>();
+ recipeDataType.setProperties(dataTypeProperties);
+ } else {
+ log.info("DataType Already present for the recipe({})" , recipeName);
+ }
+
+ // Merge all the Recipe Properties
+ mergeDataTypeProperties(recipeDataType, mappingProperties);
+
+ // Overwrite Recipe DataType
+ this.recipeDataTypes.put(recipeName, recipeDataType);
+
+ }
+ }
+
+ private Map<String, PropertyDefinition> getCapabilityMappingProperties(String nodeTemplateName,
+ NodeTemplate nodeTemplate) {
+
+ Map<String, PropertyDefinition> dataTypeProperties = null;
+ if (nodeTemplate != null) {
+ CapabilityAssignment capability =
+ nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);
+
+ if (capability != null && capability.getProperties() != null) {
+
+ String resourceAssignmentContent = JacksonUtils
+ .getJson(capability.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING));
+
+ List<ResourceAssignment> resourceAssignments =
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);
+
+ Preconditions.checkNotNull(resourceAssignments, "Failed to Processing Resource Mapping " + resourceAssignmentContent);
+ dataTypeProperties = new HashMap<>();
+
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null
+ // && Boolean.valueOf(resourceAssignment.getInputParameter())
+ && resourceAssignment.getProperty() != null
+ && StringUtils.isNotBlank(resourceAssignment.getName())) {
+
+ // Enrich the Property Definition
+ super.enrichPropertyDefinition(resourceAssignment.getName(), resourceAssignment.getProperty());
+
+ dataTypeProperties.put(resourceAssignment.getName(), resourceAssignment.getProperty());
+
+ }
+ }
+
+ }
+ }
+ return dataTypeProperties;
+ }
+
+ private void mergeDataTypeProperties(DataType dataType, Map<String, PropertyDefinition> mergeProperties) {
+ if (dataType != null && dataType.getProperties() != null && mergeProperties != null) {
+ // Add the Other Template Properties
+ mergeProperties.forEach((mappingKey, propertyDefinition) -> {
+ dataType.getProperties().put(mappingKey, propertyDefinition);
+ });
+ }
+ }
+
+ private void populateRecipeInputs(ServiceTemplate serviceTemplate) {
+ if (this.recipeDataTypes != null && !this.recipeDataTypes.isEmpty()) {
+ this.recipeDataTypes.forEach((recipeName, recipeDataType) -> {
+ String dataTypePrifix = recipeName.replace("-action", "") + "-request";
+ String dataTypeName = "dt-" + dataTypePrifix;
+
+ serviceTemplate.getDataTypes().put(dataTypeName, recipeDataType);
+
+ PropertyDefinition customInputProperty = new PropertyDefinition();
+ customInputProperty.setDescription("This is Dynamic Data type for the receipe " + recipeName + ".");
+ customInputProperty.setRequired(Boolean.FALSE);
+ customInputProperty.setType(dataTypeName);
+ serviceTemplate.getTopologyTemplate().getInputs().put(dataTypePrifix, customInputProperty);
+
+ });
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java
new file mode 100644
index 00000000..7e96f2f8
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java
@@ -0,0 +1,339 @@
+/*
+ * 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;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+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.service.common.ApplicationConstants;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ServiceTemplateCreateService.java Purpose: Provide Service Template Create Service processing
+ * ServiceTemplateCreateService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class ConfigModelCreateService {
+
+ private static Logger log = LoggerFactory.getLogger(ConfigModelCreateService.class);
+
+ private ConfigModelRepository configModelRepository;
+ private ConfigModelValidatorService configModelValidatorService;
+
+ /**
+ * This is a ConfigModelCreateService
+ *
+ * @param configModelRepository ConfigModelRepository
+ * @param configModelValidatorService ConfigModelValidatorService
+ */
+ public ConfigModelCreateService(ConfigModelRepository configModelRepository,
+ ConfigModelValidatorService configModelValidatorService) {
+ this.configModelRepository = configModelRepository;
+ this.configModelValidatorService = configModelValidatorService;
+ }
+
+ /**
+ * This is a createInitialServiceTemplateContent method
+ *
+ * @param templateName templateName
+ * @return String
+ * @throws BluePrintException BluePrintException
+ */
+ public String createInitialServiceTemplateContent(String templateName) throws BluePrintException {
+ String serviceTemplateContent = null;
+ if (StringUtils.isNotBlank(templateName)) {
+ try {
+ serviceTemplateContent = IOUtils.toString(ConfigModelCreateService.class.getClassLoader()
+ .getResourceAsStream("service_template/" + templateName + ".json"), Charset.defaultCharset());
+ } catch (IOException e) {
+ throw new BluePrintException(e.getMessage(), e);
+ }
+
+ }
+ return serviceTemplateContent;
+ }
+
+ /**
+ * This is a createInitialServiceTemplate method
+ *
+ * @param templateName templateName
+ * @return ServiceTemplate
+ * @throws BluePrintException BluePrintException
+ */
+ public ServiceTemplate createInitialServiceTemplate(String templateName) throws BluePrintException {
+ ServiceTemplate serviceTemplate = null;
+ if (StringUtils.isNotBlank(templateName)) {
+ try {
+ String serviceTemplateContent = IOUtils.toString(ConfigModelCreateService.class.getClassLoader()
+ .getResourceAsStream("service_template/" + templateName + ".json"), Charset.defaultCharset());
+ if (StringUtils.isNotBlank(serviceTemplateContent)) {
+ serviceTemplate = JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+ }
+ } catch (IOException e) {
+ throw new BluePrintException(e.getMessage(), e);
+ }
+
+ }
+ return serviceTemplate;
+ }
+
+ /**
+ * This is a saveConfigModel method
+ *
+ * @param configModel configModel
+ * @return ConfigModel
+ * @throws BluePrintException BluePrintException
+ */
+ public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
+
+ if (configModel != null) {
+ String artifactName = configModel.getArtifactName();
+ String artifactVersion = configModel.getArtifactVersion();
+ String author = configModel.getUpdatedBy();
+ // configModel.setTags(artifactName);
+
+ if (StringUtils.isBlank(author)) {
+ throw new BluePrintException("Artifact Author is missing in the Service Template");
+ }
+
+ if (StringUtils.isBlank(artifactName)) {
+ throw new BluePrintException("Artifact Name is missing in the Service Template");
+ }
+
+ if (StringUtils.isBlank(artifactVersion)) {
+ throw new BluePrintException("Artifact Version is missing in the Service Template");
+ }
+ ConfigModel updateConfigModel = null;
+
+ Optional<ConfigModel> dbConfigModelOptional = Optional.empty();
+
+ if (configModel.getId() != null) {
+ log.info("Searching for config model id : {}", configModel.getId());
+ dbConfigModelOptional = configModelRepository.findById(configModel.getId());
+ }
+
+ if (!dbConfigModelOptional.isPresent()) {
+ log.info("Searching for config model name :"
+ + configModel.getArtifactName() + ", version " + configModel.getArtifactVersion());
+ dbConfigModelOptional = configModelRepository.findByArtifactNameAndArtifactVersion(
+ configModel.getArtifactName(), configModel.getArtifactVersion());
+ }
+
+ if (dbConfigModelOptional.isPresent()) {
+ updateConfigModel = dbConfigModelOptional.get();
+ log.info("Processing for config model id : {} with config model content count : {}"
+ , updateConfigModel.getId(), updateConfigModel.getConfigModelContents().size());
+ } else {
+ ConfigModel tempConfigModel = new ConfigModel();
+ tempConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
+ tempConfigModel.setArtifactName(artifactName);
+ tempConfigModel.setArtifactVersion(artifactVersion);
+ tempConfigModel.setUpdatedBy(author);
+ tempConfigModel.setPublished(ApplicationConstants.ACTIVE_N);
+ tempConfigModel.setTags(artifactName);
+ configModelRepository.saveAndFlush(tempConfigModel);
+ updateConfigModel = tempConfigModel;
+ }
+
+ Long dbConfigModelId = updateConfigModel.getId();
+
+ if (dbConfigModelId == null) {
+ throw new BluePrintException("failed to get the initial saved config model id.");
+ }
+
+ log.info("Processing for config model id : {}", dbConfigModelId);
+
+ deleteConfigModelContent(dbConfigModelId);
+
+ addConfigModelContent(dbConfigModelId, configModel);
+
+ // Populate Content model types
+ updateConfigModel = updateConfigModel(dbConfigModelId, artifactName, artifactVersion, author);
+
+
+ return updateConfigModel;
+ } else {
+ throw new BluePrintException("Config model information is missing");
+ }
+
+ }
+
+ private void deleteConfigModelContent(Long dbConfigModelId) {
+ if (dbConfigModelId != null) {
+ ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
+ if (dbConfigModel != null && CollectionUtils.isNotEmpty(dbConfigModel.getConfigModelContents())) {
+ dbConfigModel.getConfigModelContents().clear();
+ log.debug("Configuration Model content deleting : {}", dbConfigModel.getConfigModelContents());
+ configModelRepository.saveAndFlush(dbConfigModel);
+ }
+
+ }
+ }
+
+ private void addConfigModelContent(Long dbConfigModelId, ConfigModel configModel) {
+ if (dbConfigModelId != null && configModel != null
+ && CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) {
+ ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
+ if (dbConfigModel != null) {
+ for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) {
+ if (configModelContent != null) {
+ configModelContent.setId(null);
+ configModelContent.setConfigModel(dbConfigModel);
+ dbConfigModel.getConfigModelContents().add(configModelContent);
+ log.debug("Configuration Model content adding : {}", configModelContent);
+ }
+ }
+ configModelRepository.saveAndFlush(dbConfigModel);
+ }
+
+ }
+ }
+
+ private ConfigModel updateConfigModel(Long dbConfigModelId, String artifactName, String artifactVersion,
+ String author) throws BluePrintException {
+
+ ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
+ if (dbConfigModel != null) {
+ // Populate tags from metadata
+ String tags = getConfigModelTags(dbConfigModel);
+ if (StringUtils.isBlank(tags)) {
+ throw new BluePrintException("Failed to populate tags for the config model name " + artifactName);
+ }
+ dbConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
+ dbConfigModel.setArtifactName(artifactName);
+ dbConfigModel.setArtifactVersion(artifactVersion);
+ dbConfigModel.setUpdatedBy(author);
+ dbConfigModel.setPublished(ApplicationConstants.ACTIVE_N);
+ dbConfigModel.setTags(tags);
+ configModelRepository.saveAndFlush(dbConfigModel);
+
+ log.info("Config model ({}) saved successfully.", dbConfigModel.getId());
+ }
+ return dbConfigModel;
+ }
+
+ private List<String> getValidContentTypes() {
+ List<String> valids = new ArrayList<>();
+ valids.add(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
+ valids.add(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
+ return valids;
+
+ }
+
+ private String getConfigModelTags(ConfigModel configModel) throws BluePrintException {
+ String tags = null;
+ if (CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) {
+
+ for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) {
+ if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) {
+
+ if (!getValidContentTypes().contains(configModelContent.getContentType())) {
+ throw new BluePrintException(configModelContent.getContentType()
+ + " is not a valid content type, It should be any one of this "
+ + getValidContentTypes());
+ }
+
+ if (configModelContent.getContentType().equals(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON)) {
+ ServiceTemplate serviceTemplate =
+ JacksonUtils.readValue(configModelContent.getContent(), ServiceTemplate.class);
+ Preconditions.checkNotNull(serviceTemplate, "failed to transform service template content");
+ if (serviceTemplate.getMetadata() != null) {
+ serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR,
+ configModel.getUpdatedBy());
+ serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_VERSION,
+ configModel.getArtifactVersion());
+ serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_NAME,
+ configModel.getArtifactName());
+ }
+ tags = String.valueOf(serviceTemplate.getMetadata());
+ } else {
+ // Do Nothing
+ }
+ }
+ }
+ }
+ return tags;
+ }
+
+ /**
+ * This is a publishConfigModel method
+ *
+ * @param id id
+ * @return ConfigModel
+ * @throws BluePrintException BluePrintException
+ */
+ public ConfigModel publishConfigModel(Long id) throws BluePrintException {
+ ConfigModel dbConfigModel = null;
+ if (id != null) {
+ Optional<ConfigModel> dbConfigModelOptional = configModelRepository.findById(id);
+ if (dbConfigModelOptional.isPresent()) {
+ dbConfigModel = dbConfigModelOptional.get();
+ List<ConfigModelContent> configModelContents = dbConfigModel.getConfigModelContents();
+ if (configModelContents != null && !configModelContents.isEmpty()) {
+ for (ConfigModelContent configModelContent : configModelContents) {
+ if (configModelContent.getContentType()
+ .equals(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON)) {
+ ServiceTemplate serviceTemplate = JacksonUtils
+ .readValue(configModelContent.getContent(), ServiceTemplate.class);
+ if (serviceTemplate != null) {
+ validateServiceTemplate(serviceTemplate);
+ }
+ }
+ }
+ }
+ dbConfigModel.setPublished(ApplicationConstants.ACTIVE_Y);
+ configModelRepository.save(dbConfigModel);
+ log.info("Config model ({}) published successfully.", id);
+
+ }
+
+ }
+ return dbConfigModel;
+ }
+
+ /**
+ * This is a validateServiceTemplate method
+ *
+ * @param serviceTemplate Service Template
+ * @return ServiceTemplate
+ * @throws BluePrintException BluePrintException
+ */
+ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ return this.configModelValidatorService.validateServiceTemplate(serviceTemplate);
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java
new file mode 100644
index 00000000..feee3a3e
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java
@@ -0,0 +1,247 @@
+/*
+ * 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;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+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.service.common.ApplicationConstants;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ConfigModelService.java Purpose: Provide Service Template Service processing ConfigModelService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class ConfigModelService {
+
+ private static Logger log = LoggerFactory.getLogger(ConfigModelService.class);
+
+ private ConfigModelRepository configModelRepository;
+ private ConfigModelContentRepository configModelContentRepository;
+ private ConfigModelCreateService configModelCreateService;
+
+ /**
+ * This is a ConfigModelService constructor.
+ *
+ * @param configModelRepository
+ * @param configModelContentRepository
+ * @param configModelCreateService
+ */
+ public ConfigModelService(ConfigModelRepository configModelRepository,
+ ConfigModelContentRepository configModelContentRepository,
+ ConfigModelCreateService configModelCreateService) {
+ this.configModelRepository = configModelRepository;
+ this.configModelContentRepository = configModelContentRepository;
+ this.configModelCreateService = configModelCreateService;
+ }
+
+ /**
+ * This is a getInitialConfigModel method
+ *
+ * @param templateName
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ public ConfigModel getInitialConfigModel(String templateName) throws BluePrintException {
+ ConfigModel configModel = null;
+ if (StringUtils.isNotBlank(templateName)) {
+ configModel = new ConfigModel();
+ configModel.setArtifactName(templateName);
+ configModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
+ configModel.setUpdatedBy("xxxxx@xxx.com");
+ ConfigModelContent configModelContent = new ConfigModelContent();
+ configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
+ configModelContent.setName(templateName);
+ String content = this.configModelCreateService.createInitialServiceTemplateContent(templateName);
+ configModelContent.setContent(content);
+
+ List<ConfigModelContent> configModelContents = new ArrayList<>();
+ configModelContents.add(configModelContent);
+
+ configModel.setConfigModelContents(configModelContents);
+ }
+ return configModel;
+ }
+
+ /**
+ * This is a saveConfigModel method
+ *
+ * @param configModel
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
+ return this.configModelCreateService.saveConfigModel(configModel);
+ }
+
+ /**
+ * This is a publishConfigModel method
+ *
+ * @param id
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ public ConfigModel publishConfigModel(Long id) throws BluePrintException {
+ return this.configModelCreateService.publishConfigModel(id);
+ }
+
+ /**
+ * This is a searchConfigModels method
+ *
+ * @param tags
+ * @return ConfigModel
+ */
+ public List<ConfigModel> searchConfigModels(String tags) {
+ List<ConfigModel> models = configModelRepository.findByTagsContainingIgnoreCase(tags);
+ if (models != null) {
+ for (ConfigModel configModel : models) {
+ configModel.setConfigModelContents(null);
+ }
+ }
+ return models;
+ }
+
+ /**
+ * This is a getConfigModelByNameAndVersion method
+ *
+ * @param name
+ * @param version
+ * @return ConfigModel
+ */
+ public ConfigModel getConfigModelByNameAndVersion(String name, String version) {
+ ConfigModel configModel = null;
+ Optional<ConfigModel> dbConfigModel = null;
+ if (StringUtils.isNotBlank(version)) {
+ dbConfigModel = configModelRepository.findByArtifactNameAndArtifactVersion(name, version);
+ } else {
+ dbConfigModel = configModelRepository.findTopByArtifactNameOrderByArtifactVersionDesc(name);
+ }
+ if (dbConfigModel.isPresent()) {
+ configModel = dbConfigModel.get();
+ }
+ return configModel;
+ }
+
+ /**
+ * This is a getConfigModel method
+ *
+ * @param id
+ * @return ConfigModel
+ */
+ public ConfigModel getConfigModel(Long id) {
+ ConfigModel configModel = null;
+ if (id != null) {
+ Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
+ if (dbConfigModel.isPresent()) {
+ configModel = dbConfigModel.get();
+ }
+ }
+ return configModel;
+ }
+
+ /**
+ * This method returns clone of the given model id, by masking the other unrelated fields
+ *
+ * @param id
+ * @return
+ */
+
+ public ConfigModel getCloneConfigModel(Long id) {
+
+ ConfigModel configModel = null;
+ ConfigModel cloneConfigModel = null;
+ if (id != null) {
+ Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
+ if (dbConfigModel.isPresent()) {
+ configModel = dbConfigModel.get();
+ cloneConfigModel = configModel;
+ cloneConfigModel.setUpdatedBy("xxxxx@xxx.com");
+ cloneConfigModel.setArtifactName("XXXX");
+ cloneConfigModel.setPublished("XXXX");
+ cloneConfigModel.setPublished("XXXX");
+ cloneConfigModel.setUpdatedBy("XXXX");
+ cloneConfigModel.setId(null);
+ cloneConfigModel.setTags(null);
+ cloneConfigModel.setCreatedDate(new Date());
+ List<ConfigModelContent> configModelContents = cloneConfigModel.getConfigModelContents();
+
+ if (CollectionUtils.isNotEmpty(configModelContents)) {
+ for (ConfigModelContent configModelContent : configModelContents) {
+ if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) {
+ configModelContent.setId(null);
+ configModelContent.setCreationDate(new Date());
+
+ if (ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON
+ .equalsIgnoreCase(configModelContent.getContentType())) {
+ ServiceTemplate serviceTemplate = JacksonUtils
+ .readValue(configModelContent.getContent(), ServiceTemplate.class);
+ if (serviceTemplate != null && serviceTemplate.getMetadata() != null) {
+ serviceTemplate.getMetadata()
+ .put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR, "XXXX");
+ serviceTemplate.getMetadata()
+ .put(BluePrintConstants.METADATA_TEMPLATE_VERSION, "1.0.0");
+ serviceTemplate.getMetadata()
+ .put(BluePrintConstants.METADATA_TEMPLATE_NAME, "XXXXXX");
+
+ configModelContent.setContent(JacksonUtils.getJson(serviceTemplate));
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+ return cloneConfigModel;
+ }
+
+ /**
+ * This is a deleteConfigModel method
+ *
+ * @param id
+ */
+
+ @Transactional
+ public void deleteConfigModel(Long id) {
+ Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
+ if (dbConfigModel.isPresent()) {
+ configModelContentRepository.deleteByConfigModel(dbConfigModel.get());
+ configModelRepository.delete(dbConfigModel.get());
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java
new file mode 100644
index 00000000..21b00f8c
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+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.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ServiceTemplateValidator;
+import org.springframework.stereotype.Service;
+
+/**
+ * ServiceTemplateValidatorService.java Purpose: Provide Service to Validate Service Model Template
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class ConfigModelValidatorService {
+
+ /**
+ * This is a validateServiceTemplate
+ *
+ * @param serviceTemplateContent
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ public ServiceTemplate validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(serviceTemplateContent), "Service Template Content is (" + serviceTemplateContent + ") not Defined.");
+ ServiceTemplate serviceTemplate =
+ JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+ return validateServiceTemplate(serviceTemplate);
+ }
+
+ /**
+ * This is a enhanceServiceTemplate
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ @SuppressWarnings("squid:S00112")
+ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ Preconditions.checkNotNull(serviceTemplate, "Service Template is not defined.");
+ ServiceTemplateValidator validator = new ServiceTemplateValidator();
+ validator.validateServiceTemplate(serviceTemplate);
+ return serviceTemplate;
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java
new file mode 100644
index 00000000..9ab319cb
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java
@@ -0,0 +1,325 @@
+/*
+ * 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;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.StrBuilder;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+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.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.List;
+
+/**
+ * DataBaseInitService.java Purpose: Provide DataBaseInitService Service
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Component
+@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true", matchIfMissing = false)
+public class DataBaseInitService {
+
+ private static Logger log = LoggerFactory.getLogger(DataBaseInitService.class);
+ @Value("${blueprints.load.path}")
+ private String modelLoadPath;
+ private ModelTypeService modelTypeService;
+ private ResourceDictionaryService resourceDictionaryService;
+ private ConfigModelService configModelService;
+
+ private String dataTypePath;
+ private String nodeTypePath;
+ private String artifactTypePath;
+ private String resourceDictionaryPath;
+ private String bluePrintsPath;
+
+ @Autowired
+ private ResourcePatternResolver resourceLoader;
+
+ /**
+ * This is a DataBaseInitService, used to load the initial data
+ *
+ * @param modelTypeService
+ * @param resourceDictionaryService
+ * @param configModelService
+ */
+ public DataBaseInitService(ModelTypeService modelTypeService, ResourceDictionaryService resourceDictionaryService,
+ ConfigModelService configModelService) {
+ this.modelTypeService = modelTypeService;
+ this.resourceDictionaryService = resourceDictionaryService;
+ this.configModelService = configModelService;
+ log.info("DataBaseInitService started...");
+
+ }
+
+ @PostConstruct
+ private void initDatabase() {
+ log.info("loading Blueprints from DIR : {}", modelLoadPath);
+ dataTypePath = modelLoadPath + "/model_type/data_type";
+ nodeTypePath = modelLoadPath + "/model_type/node_type";
+ artifactTypePath = modelLoadPath + "/model_type/artifact_type";
+ resourceDictionaryPath = modelLoadPath + "/resource_dictionary";
+ bluePrintsPath = modelLoadPath + "/blueprints";
+
+ log.info("loading dataTypePath from DIR : {}", dataTypePath);
+ log.info("loading nodeTypePath from DIR : {}", nodeTypePath);
+ log.info("loading artifactTypePath from DIR : {}", artifactTypePath);
+ log.info("loading resourceDictionaryPath from DIR : {}", resourceDictionaryPath);
+ log.info("loading bluePrintsPath from DIR : {}", bluePrintsPath);
+
+ loadModelType();
+ loadResourceDictionary();
+ loadBlueprints();
+ }
+
+ private void loadModelType() {
+ log.info(" *************************** loadModelType **********************");
+ try {
+ Resource[] dataTypefiles = getPathResources(dataTypePath, ".json");
+ StrBuilder errorBuilder = new StrBuilder();
+ if (dataTypefiles != null) {
+ for (Resource file : dataTypefiles) {
+ if (file != null) {
+ loadDataType(file, errorBuilder);
+ }
+ }
+ }
+
+ Resource[] nodeTypefiles = getPathResources(nodeTypePath, ".json");
+ if (nodeTypefiles != null) {
+ for (Resource file : nodeTypefiles) {
+ if (file != null) {
+ loadNodeType(file, errorBuilder);
+ }
+ }
+ }
+
+ Resource[] artifactTypefiles = getPathResources(artifactTypePath, ".json");
+ if (artifactTypefiles != null) {
+ for (Resource file : artifactTypefiles) {
+ if (file != null) {
+ loadArtifactType(file, errorBuilder);
+ }
+ }
+ }
+
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+ } catch (Exception e) {
+ log.error("Failed in Data type loading", e);
+ }
+ }
+
+ private void loadResourceDictionary() {
+ log.info(
+ " *************************** loadResourceDictionary **********************");
+ try {
+ Resource[] dataTypefiles = getPathResources(resourceDictionaryPath, ".json");
+ if (dataTypefiles != null) {
+ StrBuilder errorBuilder = new StrBuilder();
+ String fileName = null;
+ for (Resource file : dataTypefiles) {
+ try {
+ fileName = file.getFilename();
+ log.trace("Loading : {}", fileName);
+ String definitionContent = getResourceContent(file);
+ DictionaryDefinition dictionaryDefinition =
+ JacksonUtils.readValue(definitionContent, DictionaryDefinition.class);
+ if (dictionaryDefinition != null) {
+ ResourceDictionary resourceDictionary = new ResourceDictionary();
+ resourceDictionary.setResourcePath(dictionaryDefinition.getResourcePath());
+ resourceDictionary.setName(dictionaryDefinition.getName());
+ resourceDictionary.setDefinition(definitionContent);
+
+ if (dictionaryDefinition.getValidValues() != null)
+ resourceDictionary
+ .setValidValues(String.valueOf(dictionaryDefinition.getValidValues()));
+
+ if (dictionaryDefinition.getSampleValue() != null)
+ resourceDictionary
+ .setValidValues(String.valueOf(dictionaryDefinition.getSampleValue()));
+
+ resourceDictionary.setResourceType(dictionaryDefinition.getResourceType());
+ resourceDictionary.setDataType(dictionaryDefinition.getDataType());
+ resourceDictionary.setEntrySchema(dictionaryDefinition.getEntrySchema());
+ resourceDictionary.setDescription(dictionaryDefinition.getDescription());
+ resourceDictionary.setUpdatedBy(dictionaryDefinition.getUpdatedBy());
+ if (StringUtils.isBlank(dictionaryDefinition.getTags())) {
+ resourceDictionary.setTags(
+ dictionaryDefinition.getName() + ", " + dictionaryDefinition.getUpdatedBy()
+ + ", " + dictionaryDefinition.getResourceType() + ", "
+ + dictionaryDefinition.getUpdatedBy());
+
+ } else {
+ resourceDictionary.setTags(dictionaryDefinition.getTags());
+ }
+ resourceDictionaryService.saveResourceDictionary(resourceDictionary);
+
+ log.trace(" Loaded successfully : {}", file.getFilename());
+ } else {
+ throw new BluePrintException("couldn't get dictionary from content information");
+ }
+ } catch (Exception e) {
+ errorBuilder.appendln("Dictionary loading Errors : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+
+ }
+ } catch (Exception e) {
+ log.error(
+ "Failed in Resource dictionary loading", e);
+ }
+ }
+
+ private void loadBlueprints() {
+ log.info("*************************** loadServiceTemplate **********************");
+ try {
+ List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(bluePrintsPath);
+ if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) {
+ StrBuilder errorBuilder = new StrBuilder();
+ for (String fileName : serviceTemplateDirs) {
+ try {
+ String bluePrintPath = this.bluePrintsPath.concat("/").concat(fileName);
+ log.debug("***** Loading service template : {}", bluePrintPath);
+ ConfigModel configModel = ConfigModelUtils.getConfigModel(bluePrintPath);
+
+ configModel = this.configModelService.saveConfigModel(configModel);
+
+ log.info("Publishing : {}", configModel.getId());
+
+ this.configModelService.publishConfigModel(configModel.getId());
+
+ log.info("Loaded service template successfully: {}", fileName);
+
+ } catch (Exception e) {
+ errorBuilder.appendln("load config model " + fileName + " error : " + e.getMessage());
+ }
+ }
+
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+ }
+ } catch (Exception e) {
+ log.error("Failed in Service Template loading", e);
+ }
+ }
+
+ private void loadNodeType(Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Node Type : {}", file.getFilename());
+ String nodeKey = file.getFilename().replace(".json", "");
+ String definitionContent = getResourceContent(file);
+ NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
+ modelType.setDerivedFrom(nodeType.getDerivedFrom());
+ modelType.setDescription(nodeType.getDescription());
+ modelType.setDefinition(definitionContent);
+ modelType.setModelName(nodeKey);
+ modelType.setVersion(nodeType.getVersion());
+ modelType.setUpdatedBy("System");
+ modelType.setTags(nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + ","
+ + nodeType.getDerivedFrom());
+ modelTypeService.saveModel(modelType);
+ log.trace("Loaded Node Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ errorBuilder.appendln("Node type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private void loadDataType(Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Data Type: {}", file.getFilename());
+ String dataKey = file.getFilename().replace(".json", "");
+ String definitionContent = getResourceContent(file);
+ DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelType.setDerivedFrom(dataType.getDerivedFrom());
+ modelType.setDescription(dataType.getDescription());
+ modelType.setDefinition(definitionContent);
+ modelType.setModelName(dataKey);
+ modelType.setVersion(dataType.getVersion());
+ modelType.setUpdatedBy("System");
+ modelType.setTags(dataKey + "," + dataType.getDerivedFrom() + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelTypeService.saveModel(modelType);
+ log.trace(" Loaded Data Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ errorBuilder.appendln("Data type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private void loadArtifactType(Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Artifact Type: {}", file.getFilename());
+ String dataKey = file.getFilename().replace(".json", "");
+ String definitionContent = getResourceContent(file);
+ ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
+ modelType.setDerivedFrom(artifactType.getDerivedFrom());
+ modelType.setDescription(artifactType.getDescription());
+ modelType.setDefinition(definitionContent);
+ modelType.setModelName(dataKey);
+ modelType.setVersion(artifactType.getVersion());
+ modelType.setUpdatedBy("System");
+ modelType.setTags(dataKey + "," + artifactType.getDerivedFrom() + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
+ modelTypeService.saveModel(modelType);
+ log.trace("Loaded Artifact Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ errorBuilder.appendln("Artifact type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private Resource[] getPathResources(String path, String extension) throws IOException {
+ return resourceLoader.getResources("file:" + path + "/*" + extension);
+ }
+
+ private String getResourceContent(Resource resource) throws IOException {
+ return IOUtils.toString(resource.getInputStream(), Charset.defaultCharset());
+ }
+
+}
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
new file mode 100644
index 00000000..2bc2963b
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java
@@ -0,0 +1,178 @@
+/*
+ * 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;
+
+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
+ */
+ public ModelTypeService(ModelTypeRepository modelTypeRepository) {
+ this.modelTypeRepository = modelTypeRepository;
+ }
+
+
+ /**
+ * This is a getModelTypeByName service
+ *
+ * @param modelTypeName
+ * @return ModelType
+ * @throws BluePrintException
+ */
+ public ModelType getModelTypeByName(String modelTypeName) throws BluePrintException {
+ ModelType modelType = null;
+ if (StringUtils.isNotBlank(modelTypeName)) {
+ Optional<ModelType> modelTypeOption = modelTypeRepository.findByModelName(modelTypeName);
+ if (modelTypeOption.isPresent()) {
+ modelType = modelTypeOption.get();
+ }
+ } else {
+ throw new BluePrintException("Model Name Information is missing.");
+ }
+ return modelType;
+ }
+
+
+ /**
+ * This is a searchModelTypes service
+ *
+ * @param tags
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ public List<ModelType> searchModelTypes(String tags) throws BluePrintException {
+ if (tags != null) {
+ return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
+ } else {
+ throw new BluePrintException("No Search Information provide");
+ }
+ }
+
+ /**
+ * This is a saveModel service
+ *
+ * @param modelType
+ * @return ModelType
+ * @throws BluePrintException
+ */
+ public ModelType saveModel(ModelType modelType) throws BluePrintException {
+
+ 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
+ * @throws BluePrintException
+ */
+ public void deleteByModelName(String modelName) throws BluePrintException {
+ if (modelName != null) {
+ modelTypeRepository.deleteByModelName(modelName);
+ } else {
+ throw new BluePrintException("Model Name Information is missing.");
+ }
+ }
+
+ /**
+ * This is a getModelTypeByTags service
+ *
+ * @param tags
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ public List<ModelType> getModelTypeByTags(String tags) throws BluePrintException {
+ if (StringUtils.isNotBlank(tags)) {
+ return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
+ } else {
+ throw new BluePrintException("Model Tag Information is missing.");
+ }
+ }
+
+ /**
+ * This is a getModelTypeByDefinitionType service
+ *
+ * @param definitionType
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ public List<ModelType> getModelTypeByDefinitionType(String definitionType) throws BluePrintException {
+ if (StringUtils.isNotBlank(definitionType)) {
+ return modelTypeRepository.findByDefinitionType(definitionType);
+ } else {
+ throw new BluePrintException("Model definitionType Information is missing.");
+ }
+ }
+
+ /**
+ * This is a getModelTypeByDerivedFrom service
+ *
+ * @param derivedFrom
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ public List<ModelType> getModelTypeByDerivedFrom(String derivedFrom) throws BluePrintException {
+ if (StringUtils.isNotBlank(derivedFrom)) {
+ return modelTypeRepository.findByDerivedFrom(derivedFrom);
+ } else {
+ throw new BluePrintException("Model derivedFrom Information is missing.");
+ }
+ }
+
+
+}
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
new file mode 100644
index 00000000..b9567db1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
@@ -0,0 +1,169 @@
+/*
+ * 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;
+
+import org.apache.commons.lang3.StringUtils;
+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.data.DictionaryDefinition;
+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;
+
+ /**
+ * This is a DataDictionaryService, used to save and get the Resource Mapping stored in database
+ *
+ * @param dataDictionaryRepository
+ *
+ */
+ public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository) {
+ this.resourceDictionaryRepository = dataDictionaryRepository;
+ }
+
+ /**
+ * This is a getDataDictionaryByName service
+ *
+ * @param name
+ * @return DataDictionary
+ * @throws BluePrintException
+ */
+ public ResourceDictionary getResourceDictionaryByName(String name) throws BluePrintException {
+ if (StringUtils.isNotBlank(name)) {
+ return resourceDictionaryRepository.findByName(name).get();
+ } else {
+ throw new BluePrintException("Resource Mapping Name Information is missing.");
+ }
+ }
+
+ /**
+ * This is a searchResourceDictionaryByNames service
+ *
+ * @param names
+ * @return List<ResourceDictionary>
+ * @throws BluePrintException
+ */
+ public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names)
+ throws BluePrintException {
+ if (names != null && !names.isEmpty()) {
+ return resourceDictionaryRepository.findByNameIn(names);
+ } else {
+ throw new BluePrintException("No Search Information provide");
+ }
+ }
+
+ /**
+ * This is a searchResourceDictionaryByTags service
+ *
+ * @param tags
+ * @return List<ResourceDictionary>
+ * @throws BluePrintException
+ */
+ public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) throws BluePrintException {
+ if (StringUtils.isNotBlank(tags)) {
+ return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags);
+ } else {
+ throw new BluePrintException("No Search Information provide");
+ }
+ }
+
+ /**
+ * This is a saveDataDictionary service
+ *
+ * @param resourceDictionary
+ * @return DataDictionary
+ * @throws BluePrintException
+ */
+ public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary)
+ throws BluePrintException {
+ if (resourceDictionary != null) {
+ ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);
+
+ DictionaryDefinition dictionaryDefinition =
+ JacksonUtils.readValue(resourceDictionary.getDefinition(), DictionaryDefinition.class);
+
+ if (dictionaryDefinition == null) {
+ throw new BluePrintException(
+ "Resource dictionary definition is not valid content " + resourceDictionary.getDefinition());
+ }
+
+ dictionaryDefinition.setName(resourceDictionary.getName());
+ dictionaryDefinition.setResourcePath(resourceDictionary.getResourcePath());
+ dictionaryDefinition.setResourceType(resourceDictionary.getResourceType());
+ dictionaryDefinition.setDataType(resourceDictionary.getDataType());
+ dictionaryDefinition.setEntrySchema(resourceDictionary.getEntrySchema());
+ dictionaryDefinition.setTags(resourceDictionary.getTags());
+ dictionaryDefinition.setDescription(resourceDictionary.getDescription());
+ dictionaryDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());
+
+ String definitionContent = JacksonUtils.getJson(dictionaryDefinition, true);
+ resourceDictionary.setDefinition(definitionContent);
+
+ 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.setResourceType(resourceDictionary.getResourceType());
+ dbResourceDictionary.setResourcePath(resourceDictionary.getResourcePath());
+ dbResourceDictionary.setDataType(resourceDictionary.getDataType());
+ dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());
+ dbResourceDictionary.setTags(resourceDictionary.getTags());
+ dbResourceDictionary.setValidValues(resourceDictionary.getValidValues());
+ resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);
+ } else {
+ resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);
+ }
+ } else {
+ throw new BluePrintException("Resource Dictionary information is missing");
+ }
+ return resourceDictionary;
+ }
+
+ /**
+ * This is a deleteResourceDictionary service
+ *
+ * @param name
+ * @throws BluePrintException
+ */
+ public void deleteResourceDictionary(String name) throws BluePrintException {
+ if (name != null) {
+ resourceDictionaryRepository.deleteByName(name);
+ } else {
+ throw new BluePrintException("Resource Mapping Id Information is missing.");
+ }
+
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java
new file mode 100644
index 00000000..a75651f1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java
@@ -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;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.common.SwaggerGenerator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * SchemaGeneratorService.java Purpose: Provide Service to generate service template input schema definition and Sample
+ * Json generation.
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+public class SchemaGeneratorService {
+ private static Logger log = LoggerFactory.getLogger(SchemaGeneratorService.class);
+
+ private Map<String, DataType> dataTypes;
+
+ /**
+ * This is a SchemaGeneratorService constructor
+ */
+ public SchemaGeneratorService() {
+ dataTypes = new HashMap<>();
+ }
+
+ /**
+ * This is a generateSchema
+ *
+ * @param serviceTemplateContent service template content
+ * @return String
+ * @throws BluePrintException Blueprint Exception
+ */
+ public String generateSchema(String serviceTemplateContent) throws BluePrintException {
+ if (StringUtils.isNotBlank(serviceTemplateContent)) {
+ ServiceTemplate serviceTemplate = JacksonUtils.readValue(serviceTemplateContent,
+ ServiceTemplate.class);
+ return generateSchema(serviceTemplate);
+ } else {
+ throw new BluePrintException(
+ "Service Template Content is (" + serviceTemplateContent + ") not Defined.");
+ }
+ }
+
+ /**
+ * This is a generateSchema
+ *
+ * @param serviceTemplate service template content
+ * @return String
+ * @throws BluePrintException Blueprint Exception
+ */
+ public String generateSchema(ServiceTemplate serviceTemplate) throws BluePrintException {
+ String schemaContent = null;
+ Preconditions.checkNotNull(serviceTemplate, "Service Template is not defined.");
+ try {
+ if (serviceTemplate.getTopologyTemplate() != null
+ && serviceTemplate.getTopologyTemplate().getInputs() != null) {
+ SwaggerGenerator swaggerGenerator = new SwaggerGenerator(serviceTemplate);
+ schemaContent = swaggerGenerator.generateSwagger();
+ }
+ } catch (Exception e) {
+ throw new BluePrintException(e.getMessage(), e);
+ }
+
+ return schemaContent;
+ }
+
+ private void manageServiceTemplateActions(ServiceTemplate serviceTemplate, String actionName) {
+ if (serviceTemplate != null && serviceTemplate.getTopologyTemplate() != null
+ && StringUtils.isNotBlank(actionName)) {
+
+ if (MapUtils.isNotEmpty(serviceTemplate.getTopologyTemplate().getInputs())) {
+
+ serviceTemplate.getTopologyTemplate().getInputs().entrySet().removeIf(entity -> {
+ String keyName = entity.getKey();
+ String replacedAction = actionName.replace("-action", "-request");
+ log.debug("Key name : " + keyName + ", actionName "
+ + actionName + ", replacedAction :" + replacedAction);
+ if (keyName.endsWith("-request") && !keyName.equals(replacedAction)) {
+ log.info("deleting input property {} ", keyName);
+ return true;
+ }
+ return false;
+ });
+ }
+
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java
new file mode 100644
index 00000000..70b7917a
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java
@@ -0,0 +1,140 @@
+/*
+ * 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;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.validator.ResourceAssignmentValidator;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * ServiceTemplateService.java Purpose: Provide Service Template Create Service processing ServiceTemplateService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class ServiceTemplateService {
+
+ private ResourceDictionaryRepository dataDictionaryRepository;
+
+ private ConfigModelCreateService configModelCreateService;
+ private BluePrintEnhancerService bluePrintEnhancerService;
+
+ /**
+ * This is a SchemaGeneratorService constructor
+ *
+ * @param dataDictionaryRepository
+ * @param configModelCreateService
+ * @param bluePrintEnhancerService
+ */
+ public ServiceTemplateService(ResourceDictionaryRepository dataDictionaryRepository,
+ ConfigModelCreateService configModelCreateService,
+ BluePrintEnhancerService bluePrintEnhancerService) {
+ this.dataDictionaryRepository = dataDictionaryRepository;
+ this.configModelCreateService = configModelCreateService;
+ this.bluePrintEnhancerService = bluePrintEnhancerService;
+
+ }
+
+ /**
+ * This is a validateServiceTemplate method
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ return this.configModelCreateService.validateServiceTemplate(serviceTemplate);
+ }
+
+ /**
+ * This is a enrichServiceTemplate method
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ this.bluePrintEnhancerService.enhance(serviceTemplate);
+ return serviceTemplate;
+ }
+
+ /**
+ * This is a autoMap method to map the template keys
+ *
+ * @param resourceAssignments
+ * @return AutoMapResponse
+ * @throws BluePrintException
+ */
+ public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {
+ AutoResourceMappingService autoMappingService = new AutoResourceMappingService(dataDictionaryRepository);
+ AutoMapResponse autoMapResponse = autoMappingService.autoMap(resourceAssignments);
+ return autoMapResponse;
+ }
+
+ /**
+ * This is a validateResourceAssignments method
+ *
+ * @param resourceAssignments
+ * @return List<ResourceAssignment>
+ * @throws BluePrintException
+ */
+ public List<ResourceAssignment> validateResourceAssignments(List<ResourceAssignment> resourceAssignments)
+ throws BluePrintException {
+ try {
+ ResourceAssignmentValidator resourceAssignmentValidator =
+ new ResourceAssignmentValidator(resourceAssignments);
+ resourceAssignmentValidator.validateResourceAssignment();
+ } catch (BluePrintException e) {
+ throw new BluePrintException(e.getMessage(), e);
+ }
+ return resourceAssignments;
+ }
+
+ /**
+ * This is a generateResourceAssignments method
+ *
+ * @param templateContent
+ * @return List<ResourceAssignment>
+ */
+ public List<ResourceAssignment> generateResourceAssignments(ConfigModelContent templateContent) {
+ List<ResourceAssignment> resourceAssignments = new ArrayList<>();
+ if (templateContent != null && StringUtils.isNotBlank(templateContent.getContent())) {
+ Pattern p = Pattern.compile("(?<=\\$\\{)([^\\}]+)(?=\\})");
+ Matcher m = p.matcher(templateContent.getContent());
+ while (m.find()) {
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName(m.group());
+ resourceAssignments.add(resourceAssignment);
+ }
+ }
+ return resourceAssignments;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java
new file mode 100644
index 00000000..8dd74840
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java
@@ -0,0 +1,33 @@
+/*
+ * 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.common;
+
+/**
+ * ApplicationConstants.java Purpose: Provide ControllerBluprintsApplication Constant Information
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public final class ApplicationConstants {
+ private ApplicationConstants() {
+
+ }
+ public static final String ACTIVE_Y = "Y";
+ public static final String ACTIVE_N = "N";
+ public static final String ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL";
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java
new file mode 100644
index 00000000..f7a802e4
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java
@@ -0,0 +1,63 @@
+/*
+ * 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.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+import java.io.Serializable;
+
+@JsonInclude(Include.NON_NULL)
+public class ErrorMessage implements Serializable {
+ private Integer httpStatus;
+ private String message;
+ private Integer code;
+ private String developerMessage;
+
+ public Integer getHttpStatus() {
+ return httpStatus;
+ }
+
+ public void setHttpStatus(Integer httpStatus) {
+ this.httpStatus = httpStatus;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public String getDeveloperMessage() {
+ return developerMessage;
+ }
+
+ public void setDeveloperMessage(String developerMessage) {
+ this.developerMessage = developerMessage;
+ }
+
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java
new file mode 100644
index 00000000..f223dccb
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java
@@ -0,0 +1,42 @@
+/*
+ * 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.common;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+@Provider
+public class ServiceExceptionMapper implements ExceptionMapper<BluePrintException> {
+
+ @Override
+ public Response toResponse(BluePrintException ex) {
+ ErrorMessage errorMessage = new ErrorMessage();
+ errorMessage.setCode(ex.getCode());
+ errorMessage.setMessage(ex.getMessage());
+ StringWriter errorStackTrace = new StringWriter();
+ ex.printStackTrace(new PrintWriter(errorStackTrace));
+ errorMessage.setDeveloperMessage(ex.toString());
+ return Response.status(500).entity(errorMessage).type(MediaType.APPLICATION_JSON).build();
+ }
+
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java
new file mode 100644
index 00000000..e9080763
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java
@@ -0,0 +1,187 @@
+/*
+ * 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.common;
+
+import io.swagger.models.*;
+import io.swagger.models.parameters.BodyParameter;
+import io.swagger.models.parameters.Parameter;
+import io.swagger.models.properties.*;
+import io.swagger.util.Json;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+
+import java.util.*;
+
+/**
+ * SwaggerGenerator.java Purpose: Provide Service to generate service template input schema definition and Sample Json
+ * generation.
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Deprecated
+public class SwaggerGenerator {
+
+ private ServiceTemplate serviceTemplate;
+
+ /**
+ * This is a SwaggerGenerator constructor
+ */
+ public SwaggerGenerator(ServiceTemplate serviceTemplate) {
+ this.serviceTemplate = serviceTemplate;
+ }
+
+ /**
+ * This is a generateSwagger
+ *
+ * @return String
+ */
+ public String generateSwagger() {
+ String swaggerContent = null;
+
+ Swagger swagger = new Swagger().info(getInfo());
+
+ swagger.setPaths(getPaths());
+ swagger.setDefinitions(getDefinition());
+
+
+ swaggerContent = Json.pretty(swagger);
+ return swaggerContent;
+ }
+
+ private Info getInfo() {
+ Info info = new Info();
+ Contact contact = new Contact();
+ contact.setName(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR));
+ info.setContact(contact);
+ info.setTitle(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_NAME));
+ info.setDescription(serviceTemplate.getDescription());
+ info.setVersion(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_VERSION));
+ return info;
+ }
+
+ private Map<String, Path> getPaths() {
+ Map<String, Path> paths = new HashMap<>();
+ Path path = new Path();
+ Operation post = new Operation();
+ post.setOperationId("configure");
+ post.setConsumes(Arrays.asList("application/json", "application/xml"));
+ post.setProduces(Arrays.asList("application/json", "application/xml"));
+ List<Parameter> parameters = new ArrayList<>();
+ Parameter in = new BodyParameter().schema(new RefModel("#/definitions/inputs"));
+ in.setRequired(true);
+ in.setName("inputs");
+ parameters.add(in);
+ post.setParameters(parameters);
+
+ Map<String, Response> responses = new HashMap<>();
+ Response response = new Response().description("Success");
+ responses.put("200", response);
+
+ Response failureResponse = new Response().description("Failure");
+ responses.put("400", failureResponse);
+ post.setResponses(responses);
+
+ path.setPost(post);
+ paths.put("/operations/config-selfservice-api:configure", path);
+ return paths;
+ }
+
+ private Map<String, Model> getDefinition() {
+ Map<String, Model> models = new HashMap<>();
+
+ ModelImpl inputmodel = new ModelImpl();
+ inputmodel.setTitle("inputs");
+ serviceTemplate.getTopologyTemplate().getInputs().forEach((propertyName, property) -> {
+ Property defProperty = getPropery(propertyName, property);
+ inputmodel.property(propertyName, defProperty);
+ });
+ models.put("inputs", inputmodel);
+
+ if (MapUtils.isNotEmpty(serviceTemplate.getDataTypes())) {
+ serviceTemplate.getDataTypes().forEach((name, dataType) -> {
+ ModelImpl model = new ModelImpl();
+ model.setDescription(dataType.getDescription());
+ // model.setType("object");
+ if (dataType != null && MapUtils.isNotEmpty(dataType.getProperties())) {
+
+ dataType.getProperties().forEach((propertyName, property) -> {
+ Property defProperty = getPropery(propertyName, property);
+ model.addProperty(propertyName, defProperty);
+ });
+ }
+ models.put(name, model);
+ });
+ }
+ return models;
+
+ }
+
+ private Property getPropery(String name, PropertyDefinition propertyDefinition) {
+ Property defProperty = null;
+
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyDefinition.getType())) {
+ if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(propertyDefinition.getType())) {
+ defProperty = new BooleanProperty();
+ } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(propertyDefinition.getType())) {
+ StringProperty stringProperty = new StringProperty();
+ stringProperty.setType("integer");
+ defProperty = stringProperty;
+ } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(propertyDefinition.getType())) {
+ StringProperty stringProperty = new StringProperty();
+ stringProperty.setFormat("float");
+ defProperty = stringProperty;
+ } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(propertyDefinition.getType())) {
+ DateTimeProperty dateTimeProperty = new DateTimeProperty();
+ dateTimeProperty.setFormat("date-time");
+ defProperty = dateTimeProperty;
+ } else {
+ defProperty = new StringProperty();
+ }
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyDefinition.getType())) {
+ ArrayProperty arrayProperty = new ArrayProperty();
+ if (propertyDefinition.getEntrySchema() != null) {
+ String entrySchema = propertyDefinition.getEntrySchema().getType();
+ if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema)) {
+ Property innerType = new RefProperty("#/definitions/" + entrySchema);
+ arrayProperty.setItems(innerType);
+ } else {
+ Property innerType = new StringProperty();
+ arrayProperty.setItems(innerType);
+ }
+ defProperty = arrayProperty;
+ }
+
+ } else {
+ defProperty = new RefProperty("#/definitions/" + propertyDefinition.getType());
+ }
+ defProperty.setName(name);
+ if (propertyDefinition.getDefaultValue() != null) {
+ defProperty.setDefault(String.valueOf(propertyDefinition.getDefaultValue()));
+ }
+
+ defProperty.setRequired(BooleanUtils.isTrue(propertyDefinition.getRequired()));
+ defProperty.setDescription(propertyDefinition.getDescription());
+ return defProperty;
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
new file mode 100644
index 00000000..224960fa
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
@@ -0,0 +1,291 @@
+/*
+ * 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.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonManagedReference;
+import org.hibernate.annotations.Proxy;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ConfigModel.java Purpose: Provide Configuration Generator ConfigModel Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "CONFIG_MODEL")
+@Proxy(lazy=false)
+public class ConfigModel implements Serializable {
+ private static final long serialVersionUID = 1L;
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "config_model_id")
+ private Long id;
+
+ @Column(name = "service_uuid")
+ private String serviceUUID;
+
+ @Column(name = "distribution_id")
+ private String distributionId;
+
+ @Column(name = "service_name")
+ private String serviceName;
+
+ @Column(name = "service_description")
+ private String serviceDescription;
+
+ @Column(name = "resource_uuid")
+ private String resourceUUID;
+
+ @Column(name = "resource_instance_name")
+ private String resourceInstanceName;
+
+ @Column(name = "resource_name")
+ private String resourceName;
+
+ @Column(name = "resource_version")
+ private String resourceVersion;
+
+ @Column(name = "resource_type")
+ private String resourceType;
+
+ @Column(name = "artifact_uuid")
+ private String artifactUUId;
+
+ @Column(name = "artifact_type")
+ private String artifactType;
+
+ @NotNull
+ @Column(name = "artifact_version")
+ private String artifactVersion;
+
+ @Lob
+ @Column(name = "artifact_description")
+ private String artifactDescription;
+
+ @Column(name = "internal_version")
+ private Integer internalVersion;
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ private Date createdDate = new Date();
+
+ @NotNull
+ @Column(name = "artifact_name")
+ private String artifactName;
+
+ @NotNull
+ @Column(name = "published")
+ private String published;
+
+ @NotNull
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @NotNull
+ @Lob
+ @Column(name = "tags")
+ private String tags;
+
+
+ @OneToMany(mappedBy = "configModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
+ @Column(nullable = true)
+ @JsonManagedReference
+ private List<ConfigModelContent> configModelContents = new ArrayList<>();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getServiceUUID() {
+ return serviceUUID;
+ }
+
+ public void setServiceUUID(String serviceUUID) {
+ this.serviceUUID = serviceUUID;
+ }
+
+ public String getDistributionId() {
+ return distributionId;
+ }
+
+ public void setDistributionId(String distributionId) {
+ this.distributionId = distributionId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getServiceDescription() {
+ return serviceDescription;
+ }
+
+ public void setServiceDescription(String serviceDescription) {
+ this.serviceDescription = serviceDescription;
+ }
+
+ public String getResourceUUID() {
+ return resourceUUID;
+ }
+
+ public void setResourceUUID(String resourceUUID) {
+ this.resourceUUID = resourceUUID;
+ }
+
+ public String getResourceInstanceName() {
+ return resourceInstanceName;
+ }
+
+ public void setResourceInstanceName(String resourceInstanceName) {
+ this.resourceInstanceName = resourceInstanceName;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getArtifactUUId() {
+ return artifactUUId;
+ }
+
+ public void setArtifactUUId(String artifactUUId) {
+ this.artifactUUId = artifactUUId;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public Integer getInternalVersion() {
+ return internalVersion;
+ }
+
+ public void setInternalVersion(Integer internalVersion) {
+ this.internalVersion = internalVersion;
+ }
+
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getPublished() {
+ return published;
+ }
+
+ public void setPublished(String published) {
+ this.published = published;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public List<ConfigModelContent> getConfigModelContents() {
+ return configModelContents;
+ }
+
+ public void setConfigModelContents(List<ConfigModelContent> configModelContents) {
+ this.configModelContents = configModelContents;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java
new file mode 100644
index 00000000..f7bd554d
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java
@@ -0,0 +1,175 @@
+/*
+ * 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.domain;
+
+import com.fasterxml.jackson.annotation.JsonBackReference;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.Objects;
+
+/**
+ * DataDictionary.java Purpose: Provide Configuration Generator DataDictionary Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "CONFIG_MODEL_CONTENT")
+public class ConfigModelContent {
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "config_model_content_id")
+ private Long id;
+
+ @NotNull
+ @Column(name = "name")
+ private String name;
+
+ @NotNull
+ @Column(name = "content_type")
+ private String contentType;
+
+
+ @ManyToOne
+ @JoinColumn(name = "config_model_id")
+ @JsonBackReference
+ private ConfigModel configModel;
+
+ @Lob
+ @Column(name = "description")
+ private String description;
+
+ @NotNull
+ @Lob
+ @Column(name = "content")
+ private String content;
+
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "updated_date")
+ private Date creationDate;
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder("[");
+ builder.append("id = " + id);
+ builder.append(", name = " + name);
+ builder.append(", contentType = " + contentType);
+ builder.append("]");
+ return builder.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof ConfigModelContent)) {
+ return false;
+ }
+ ConfigModelContent configModelContent = (ConfigModelContent) o;
+ return Objects.equals(id, configModelContent.id) && Objects.equals(name, configModelContent.name)
+ && Objects.equals(contentType, configModelContent.contentType);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, name, contentType);
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public String getContentType() {
+ return contentType;
+ }
+
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+
+ public ConfigModel getConfigModel() {
+ return configModel;
+ }
+
+
+ public void setConfigModel(ConfigModel configModel) {
+ this.configModel = configModel;
+ }
+
+
+ public String getDescription() {
+ return description;
+ }
+
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+
+ public String getContent() {
+ return content;
+ }
+
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java
new file mode 100644
index 00000000..2e901883
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java
@@ -0,0 +1,171 @@
+/*
+ * 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.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.data.annotation.LastModifiedDate;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+@Entity
+@Table(name = "CONFIG_MODEL")
+public class ConfigModelSearch implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "config_model_id")
+ private Long id;
+
+ @Column(name = "artifact_uuid")
+ private String artifactUUId;
+
+ @Column(name = "artifact_type")
+ private String artifactType;
+
+ @NotNull
+ @Column(name = "artifact_version")
+ private String artifactVersion;
+
+ @Lob
+ @Column(name = "artifact_description")
+ private String artifactDescription;
+
+ @Column(name = "internal_version")
+ private Integer internalVersion;
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ private Date createdDate = new Date();
+
+ @NotNull
+ @Column(name = "artifact_name")
+ private String artifactName;
+
+ @NotNull
+ @Column(name = "published")
+ private String published;
+
+ @NotNull
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @NotNull
+ @Lob
+ @Column(name = "tags")
+ private String tags;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getArtifactUUId() {
+ return artifactUUId;
+ }
+
+ public void setArtifactUUId(String artifactUUId) {
+ this.artifactUUId = artifactUUId;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public Integer getInternalVersion() {
+ return internalVersion;
+ }
+
+ public void setInternalVersion(Integer internalVersion) {
+ this.internalVersion = internalVersion;
+ }
+
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getPublished() {
+ return published;
+ }
+
+ public void setPublished(String published) {
+ this.published = published;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+
+
+}
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
new file mode 100644
index 00000000..ed6340a6
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java
@@ -0,0 +1,170 @@
+/*
+ * 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.domain;
+
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * AsdcReference.java Purpose: Provide Configuration Generator AsdcReference Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "MODEL_TYPE")
+public class ModelType implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @NotNull
+ @Column(name = "model_name", nullable = false)
+ private String modelName;
+
+ @NotNull
+ @Column(name = "derived_from")
+ private String derivedFrom;
+
+ @NotNull
+ @Column(name = "definition_type")
+ private String definitionType;
+
+ @NotNull
+ @Lob
+ @Column(name = "definition")
+ private String definition;
+
+ @NotNull
+ @Lob
+ @Column(name = "description")
+ private String description;
+
+ @NotNull
+ @Column(name = "version")
+ private String version;
+
+ @NotNull
+ @Lob
+ @Column(name = "tags")
+ private String tags;
+
+ // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ private Date creationDate;
+
+ @NotNull
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder("[");
+ buffer.append(", modelName = " + modelName);
+ buffer.append(", derivedFrom = " + derivedFrom);
+ buffer.append(", definitionType = " + definitionType);
+ buffer.append(", description = " + description);
+ buffer.append(", creationDate = " + creationDate);
+ buffer.append(", version = " + version);
+ buffer.append(", updatedBy = " + updatedBy);
+ buffer.append(", tags = " + tags);
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getDerivedFrom() {
+ return derivedFrom;
+ }
+
+ public void setDerivedFrom(String derivedFrom) {
+ this.derivedFrom = derivedFrom;
+ }
+
+ public String getDefinitionType() {
+ return definitionType;
+ }
+
+ public void setDefinitionType(String definitionType) {
+ this.definitionType = definitionType;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(String definition) {
+ this.definition = definition;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java
new file mode 100644
index 00000000..adb01884
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java
@@ -0,0 +1,207 @@
+/*
+ * 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.domain;
+
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * DataDictionary.java Purpose: Provide Configuration Generator DataDictionary Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "RESOURCE_DICTIONARY")
+public class ResourceDictionary implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @NotNull
+ @Column(name = "name")
+ private String name;
+
+ @NotNull
+ @Column(name = "resource_path")
+ private String resourcePath;
+
+ @NotNull
+ @Column(name = "resource_type")
+ private String resourceType;
+
+ @NotNull
+ @Column(name = "data_type")
+ private String dataType;
+
+ @Column(name = "entry_schema")
+ private String entrySchema;
+
+ @Lob
+ @Column(name = "valid_values")
+ private String validValues;
+
+ @Lob
+ @Column(name = "sample_value")
+ private String sampleValue;
+
+ @NotNull
+ @Lob
+ @Column(name = "definition")
+ private String definition;
+
+ @NotNull
+ @Lob
+ @Column(name = "description")
+ private String description;
+
+ @NotNull
+ @Lob
+ @Column(name = "tags")
+ private String tags;
+
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ private Date creationDate;
+
+ @NotNull
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder("[");
+ buffer.append(", name = " + name);
+ buffer.append(", resourcePath = " + resourcePath);
+ buffer.append(", resourceType = " + resourceType);
+ buffer.append(", dataType = " + dataType);
+ buffer.append(", entrySchema = " + entrySchema);
+ buffer.append(", validValues = " + validValues);
+ buffer.append(", definition =" + definition);
+ buffer.append(", description = " + description);
+ buffer.append(", updatedBy = " + updatedBy);
+ buffer.append(", tags = " + tags);
+ buffer.append(", creationDate = " + creationDate);
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ public String getResourcePath() {
+ return resourcePath;
+ }
+
+ public void setResourcePath(String resourcePath) {
+ this.resourcePath = resourcePath;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getEntrySchema() {
+ return entrySchema;
+ }
+
+ public void setEntrySchema(String entrySchema) {
+ this.entrySchema = entrySchema;
+ }
+
+ public String getValidValues() {
+ return validValues;
+ }
+
+ public void setValidValues(String validValues) {
+ this.validValues = validValues;
+ }
+
+ public String getSampleValue() {
+ return sampleValue;
+ }
+
+ public void setSampleValue(String sampleValue) {
+ this.sampleValue = sampleValue;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(String definition) {
+ this.definition = definition;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java
new file mode 100644
index 00000000..2250828a
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java
@@ -0,0 +1,53 @@
+/*
+ * 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.model;
+
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+
+import java.util.List;
+
+/**
+ * ArtifactRequest.java Purpose: Provide Configuration Generator ArtifactRequest Model
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public class AutoMapResponse {
+
+ private List<ResourceAssignment> resourceAssignments;
+ private List<ResourceDictionary> dataDictionaries;
+
+ public List<ResourceAssignment> getResourceAssignments() {
+ return resourceAssignments;
+ }
+
+ public void setResourceAssignments(List<ResourceAssignment> resourceAssignments) {
+ this.resourceAssignments = resourceAssignments;
+ }
+
+ public List<ResourceDictionary> getDataDictionaries() {
+ return dataDictionaries;
+ }
+
+ public void setDataDictionaries(List<ResourceDictionary> dataDictionaries) {
+ this.dataDictionaries = dataDictionaries;
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java
new file mode 100644
index 00000000..ad2584a8
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java
@@ -0,0 +1,95 @@
+/*
+ * 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.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ConfigModelContentRepository.java Purpose: Provide ConfigModelContentRepository of Repository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ConfigModelContentRepository extends JpaRepository<ConfigModelContent, Long> {
+
+ /**
+ * This is a findById method
+ *
+ * @param id
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<ConfigModelContent> findById(Long id);
+
+ /**
+ * This is a findTopByConfigModelAndContentType method
+ *
+ * @param configModel
+ * @param contentType
+ * @return Optional<ConfigModelContent>
+ */
+ Optional<ConfigModelContent> findTopByConfigModelAndContentType(ConfigModel configModel, String contentType);
+
+ /**
+ * This is a findByConfigModelAndContentType method
+ *
+ * @param configModel
+ * @param contentType
+ * @return Optional<ConfigModelContent>
+ */
+ List<ConfigModelContent> findByConfigModelAndContentType(ConfigModel configModel, String contentType);
+
+ /**
+ * This is a findByConfigModel method
+ *
+ * @param configModel
+ * @return Optional<ConfigModelContent>
+ */
+ List<ConfigModelContent> findByConfigModel(ConfigModel configModel);
+
+ /**
+ * This is a findByConfigModelAndContentTypeAndName method
+ *
+ * @param configModel
+ * @param contentType
+ * @param name
+ * @return Optional<ConfigModelContent>
+ */
+ Optional<ConfigModelContent> findByConfigModelAndContentTypeAndName(ConfigModel configModel,
+ String contentType, String name);
+
+ /**
+ * This is a deleteByMdeleteByConfigModelodelName method
+ *
+ * @param configModel
+ */
+ void deleteByConfigModel(ConfigModel configModel);
+
+ /**
+ * This is a deleteById method
+ *
+ * @param id
+ */
+ void deleteById(Long id);
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java
new file mode 100644
index 00000000..4822ee97
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java
@@ -0,0 +1,90 @@
+/*
+ * 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.ConfigModel;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * AsdcArtifactsRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> {
+ /**
+ * This is a findById method
+ *
+ * @param id
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<ConfigModel> findById(Long id);
+
+ /**
+ * This is a findByArtifactNameAndArtifactVersion method
+ *
+ * @param artifactName
+ * @param artifactVersion
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<ConfigModel> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
+
+ /**
+ * This is a findTopByArtifactNameOrderByArtifactIdDesc method
+ *
+ * @param artifactName
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<ConfigModel> findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName);
+
+ /**
+ * This is a findTopByArtifactName method
+ *
+ * @param artifactName
+ * @return Optional<AsdcArtifacts>
+ */
+ List<ConfigModel> findTopByArtifactName(String artifactName);
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<ModelType>
+ */
+ List<ConfigModel> findByTagsContainingIgnoreCase(String tags);
+
+ /**
+ * This is a deleteByArtifactNameAndArtifactVersion method
+ *
+ * @param artifactName
+ * @param artifactVersion
+ */
+ void deleteByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
+
+ /**
+ * This is a deleteById method
+ *
+ * @param id
+ */
+ void deleteById(Long id);
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java
new file mode 100644
index 00000000..bafc3aa8
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java
@@ -0,0 +1,43 @@
+/*
+ * 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.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelSearch;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * ConfigModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ConfigModelSearchRepository extends JpaRepository<ConfigModelSearch, Long> {
+
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<ModelType>
+ */
+ List<ConfigModel> findByTagsContainingIgnoreCase(String tags);
+}
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/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
new file mode 100644
index 00000000..51ae752f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
@@ -0,0 +1,98 @@
+/*
+ * 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
+ * @return Optional<ModelType>
+ */
+ Optional<ModelType> findByModelName(String modelName);
+
+ /**
+ * This is a findByDerivedFrom method
+ *
+ * @param derivedFrom
+ * @return List<ModelType>
+ */
+ List<ModelType> findByDerivedFrom(String derivedFrom);
+
+
+ /**
+ * This is a findByDerivedFromIn method
+ *
+ * @param derivedFroms
+ * @return List<ModelType>
+ */
+ List<ModelType> findByDerivedFromIn(List<String> derivedFroms);
+
+ /**
+ * This is a findByDefinitionType method
+ *
+ * @param definitionType
+ * @return List<ModelType>
+ */
+ List<ModelType> findByDefinitionType(String definitionType);
+
+ /**
+ * This is a findByDefinitionTypeIn method
+ *
+ * @param definitionTypes
+ * @return List<ModelType>
+ */
+ List<ModelType> findByDefinitionTypeIn(List<String> definitionTypes);
+
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<ModelType>
+ */
+ List<ModelType> findByTagsContainingIgnoreCase(String tags);
+
+
+ /**
+ * This is a deleteByModelName method
+ *
+ * @param modelName
+ * @return Optional<ModelType>
+ */
+ void deleteByModelName(String modelName);
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java
new file mode 100644
index 00000000..279dcd1c
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java
@@ -0,0 +1,68 @@
+/*
+ * 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.ResourceDictionary;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ResourceMappingRepository.java Purpose: Provide Configuration Generator ResourceMappingRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ResourceDictionaryRepository extends JpaRepository<ResourceDictionary, String> {
+
+
+ /**
+ * This is a findByName method
+ *
+ * @param name
+ * @return Optional<ResourceMapping>
+ */
+ Optional<ResourceDictionary> findByName(String name);
+
+ /**
+ * This is a findByNameIn method
+ *
+ * @param names
+ * @return Optional<ResourceMapping>
+ */
+ List<ResourceDictionary> findByNameIn(List<String> names);
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<ModelType>
+ */
+ List<ResourceDictionary> findByTagsContainingIgnoreCase(String tags);
+
+ /**
+ * This is a deleteByName method
+ *
+ * @param name
+ */
+ void deleteByName(String name);
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java
new file mode 100644
index 00000000..86c89bf9
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java
@@ -0,0 +1,179 @@
+/*
+ * 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.rs;
+
+import io.swagger.annotations.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * ConfigModelRest.java Purpose: Rest service controller for ConfigModelRest Management
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Api
+@Path("/service")
+@Produces({MediaType.APPLICATION_JSON})
+public interface ConfigModelRest {
+
+ /**
+ * This is a getConfigModel rest service
+ *
+ * @param id
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodel/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ @RequestMapping(value = "/configmodel/{id}", method = RequestMethod.GET)
+ @ResponseBody ConfigModel getConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
+ throws BluePrintException;
+
+
+ /**
+ * This is a saveConfigModel rest service
+ *
+ * @param configModel
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/configmodel")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ServiceTemplate.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel saveConfigModel(@ApiParam(required = true) ConfigModel configModel)
+ throws BluePrintException;
+
+ /**
+ * This is a deleteConfigModel rest service
+ *
+ * @param id
+ * @throws BluePrintException
+ */
+ @DELETE
+ @Path("/configmodel/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to delete ConfigModel.")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ void deleteConfigModel(@ApiParam(required = true) @PathParam("id") Long id) throws BluePrintException;
+
+ /**
+ * This is a getInitialConfigModel rest service
+ *
+ * @param name
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelinitial/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel getInitialConfigModel(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a getCloneConfigModel rest service
+ *
+ * @param id
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelclone/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel getCloneConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
+ throws BluePrintException;
+
+ /**
+ * This is a publishConfigModel rest service
+ *
+ * @param id
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelpublish/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel publishConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
+ throws BluePrintException;
+
+ /**
+ * This is a getConfigModelByNameAndVersion rest service
+ *
+ * @param name
+ * @param version
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelbyname/{name}/version/{version}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel getConfigModelByNameAndVersion(@ApiParam(required = true) @PathParam("name") String name,
+ @ApiParam(required = true) @PathParam("version") String version) throws BluePrintException;
+
+ /**
+ * This is a searchServiceModels rest service
+ *
+ * @param tags
+ * @return List<ConfigModel>
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelsearch/{tags}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ConfigModel> searchConfigModels(@ApiParam(required = true) @PathParam("tags") String tags)
+ throws BluePrintException;
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java
new file mode 100644
index 00000000..a9abcd5f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java
@@ -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.rs;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@Service
+public class ConfigModelRestImpl implements ConfigModelRest {
+
+ private ConfigModelService configModelService;
+
+ /**
+ * This is a ConfigModelRestImpl constructor.
+ *
+ * @param configModelService Config Model Service
+ */
+ public ConfigModelRestImpl(ConfigModelService configModelService) {
+ this.configModelService = configModelService;
+
+ }
+
+ @Override
+ public ConfigModel getInitialConfigModel(String name) throws BluePrintException {
+ try {
+ return this.configModelService.getInitialConfigModel(name);
+ } catch (Exception e) {
+ throw new BluePrintException(2000, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
+ try {
+ return this.configModelService.saveConfigModel(configModel);
+ } catch (Exception e) {
+ throw new BluePrintException(2200, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteConfigModel(Long id) throws BluePrintException {
+ try {
+ this.configModelService.deleteConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(4000, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel publishConfigModel(Long id) throws BluePrintException {
+ try {
+ return this.configModelService.publishConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2500, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel getConfigModel(Long id) throws BluePrintException {
+ try {
+ return this.configModelService.getConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2001, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel getConfigModelByNameAndVersion(String name, String version) throws BluePrintException {
+ try {
+ return this.configModelService.getConfigModelByNameAndVersion(name, version);
+ } catch (Exception e) {
+ throw new BluePrintException(2002, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ConfigModel> searchConfigModels(String tags) throws BluePrintException {
+ try {
+ return this.configModelService.searchConfigModels(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(2003, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel getCloneConfigModel(Long id) throws BluePrintException {
+ try {
+ return this.configModelService.getCloneConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2004, e.getMessage(), e);
+ }
+ }
+
+}
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
new file mode 100644
index 00000000..59b73030
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.rs;
+
+import io.swagger.annotations.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * ModelTypeRest.java Purpose: Rest service controller for Artifact Handling
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Api
+@Path("/service")
+@Produces({MediaType.APPLICATION_JSON})
+public interface ModelTypeRest {
+
+ /**
+ * This is a getModelTypeByName rest service
+ *
+ * @param name
+ * @return ModelType
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/modeltype/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by id", response = ModelType.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ModelType getModelTypeByName(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a saveModelType rest service
+ *
+ * @param modelType
+ * @return ModelType
+ * @throws BluePrintException
+ */
+
+ @POST
+ @Path("/modeltype")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Save Model Type", response = ModelType.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ModelType saveModelType(@ApiParam(required = true) ModelType modelType) throws BluePrintException;
+
+ /**
+ * This is a deleteModelType rest service
+ *
+ * @param name
+ * @throws BluePrintException
+ */
+ @DELETE
+ @Path("/modeltype/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to delete Model Type")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ void deleteModelTypeByName(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a searchModelType rest service
+ *
+ * @param tags
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/modeltypesearch/{tags}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class,
+ responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ModelType> searchModelTypes(@ApiParam(required = true) @PathParam("tags") String tags)
+ throws BluePrintException;
+
+ /**
+ * This is a getModelTypeByDefinitionType rest service
+ *
+ * @param definitionType
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/modeltypebydefinition/{definitionType}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class,
+ responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ModelType> getModelTypeByDefinitionType(
+ @ApiParam(required = true) @PathParam("definitionType") String definitionType)
+ throws BluePrintException;
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java
new file mode 100644
index 00000000..6fbc6969
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java
@@ -0,0 +1,87 @@
+/*
+ * 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.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.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@Service
+public class ModelTypeRestImpl implements ModelTypeRest {
+
+ private ModelTypeService modelTypeService;
+
+ /**
+ * This is a ModelTypeResourceImpl, used to save and get the model types stored in database
+ *
+ * @param modelTypeService Model Type Service
+ */
+ public ModelTypeRestImpl(ModelTypeService modelTypeService) {
+ this.modelTypeService = modelTypeService;
+ }
+
+ @Override
+ public ModelType getModelTypeByName(String modelName) throws BluePrintException {
+ try {
+ return modelTypeService.getModelTypeByName(modelName);
+ } catch (Exception e) {
+ throw new BluePrintException(1000, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ModelType> searchModelTypes(String tags) throws BluePrintException {
+ try {
+ return modelTypeService.searchModelTypes(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(1001, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ModelType> getModelTypeByDefinitionType(String definitionType) throws BluePrintException {
+ try {
+ return modelTypeService.getModelTypeByDefinitionType(definitionType);
+ } catch (Exception e) {
+ throw new BluePrintException(1002, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ModelType saveModelType(ModelType modelType) throws BluePrintException {
+ try {
+ return modelTypeService.saveModel(modelType);
+ } catch (Exception e) {
+ throw new BluePrintException(1100, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteModelTypeByName(String name) throws BluePrintException {
+ try {
+ modelTypeService.deleteByModelName(name);
+ } catch (Exception e) {
+ throw new BluePrintException(1400, e.getMessage(), e);
+ }
+ }
+}
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
new file mode 100644
index 00000000..5bc98336
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.rs;
+
+import io.swagger.annotations.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * ResourceDictionaryRest.java Purpose: Rest service controller for Artifact Handling
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Api
+@Path("/service")
+@Produces({MediaType.APPLICATION_JSON})
+
+public interface ResourceDictionaryRest {
+
+ /**
+ * This is a getDataDictionaryByPath rest service
+ *
+ * @param name
+ * @return ResourceDictionary
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/dictionary/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Resource dictionary", response = ResourceDictionary.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ResourceDictionary getResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a saveDataDictionary rest service
+ *
+ * @param resourceMapping
+ * @return ResourceDictionary
+ * @throws BluePrintException
+ */
+
+ @POST
+ @Path("/dictionary")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Save Resource dictionary Type", response = ResourceDictionary.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ResourceDictionary saveResourceDictionary(@ApiParam(required = true) ResourceDictionary resourceMapping)
+ throws BluePrintException;
+
+ /**
+ * This is a deleteDataDictionaryByName rest service
+ *
+ * @param name
+ * @throws BluePrintException
+ */
+ @DELETE
+ @Path("/dictionary/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to delete ResourceDictionary Type")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ void deleteResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a searchResourceDictionaryByTags rest service
+ *
+ * @param tags
+ * @return ResourceDictionary
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/dictionarysearch/{tags}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to search Resource dictionary by tags",
+ response = ResourceDictionary.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ResourceDictionary> searchResourceDictionaryByTags(
+ @ApiParam(required = true) @PathParam("tags") String tags) throws BluePrintException;
+
+ /**
+ * This is a searchResourceDictionaryByNames rest service
+ *
+ * @param names
+ * @return List<ResourceDictionary>
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/dictionarybynames")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get ResourceDictionary Type by names",
+ response = ResourceDictionary.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ResourceDictionary> searchResourceDictionaryByNames(@ApiParam(required = true) List<String> names)
+ throws BluePrintException;
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java
new file mode 100644
index 00000000..e3448424
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java
@@ -0,0 +1,91 @@
+/*
+ * 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.rs;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@Service
+public class ResourceDictionaryRestImpl implements ResourceDictionaryRest {
+
+
+ private ResourceDictionaryService resourceDictionaryService;
+
+ /**
+ * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database
+ *
+ * @param dataDictionaryService Data Dictionary Service
+ */
+ public ResourceDictionaryRestImpl(ResourceDictionaryService dataDictionaryService) {
+ this.resourceDictionaryService = dataDictionaryService;
+ }
+
+ @Override
+ public ResourceDictionary saveResourceDictionary(ResourceDictionary dataDictionary)
+ throws BluePrintException {
+ try {
+ return resourceDictionaryService.saveResourceDictionary(dataDictionary);
+ } catch (Exception e) {
+ throw new BluePrintException(4100, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteResourceDictionaryByName(String name) throws BluePrintException {
+ try {
+ resourceDictionaryService.deleteResourceDictionary(name);
+ } catch (Exception e) {
+ throw new BluePrintException(4400, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ResourceDictionary getResourceDictionaryByName(String resourcePath) throws BluePrintException {
+ try {
+ return resourceDictionaryService.getResourceDictionaryByName(resourcePath);
+ } catch (Exception e) {
+ throw new BluePrintException(4001, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names)
+ throws BluePrintException {
+ try {
+ return resourceDictionaryService.searchResourceDictionaryByNames(names);
+ } catch (Exception e) {
+ throw new BluePrintException(4002, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) throws BluePrintException {
+ try {
+ return resourceDictionaryService.searchResourceDictionaryByTags(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(4003, e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java
new file mode 100644
index 00000000..fcb8f311
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.rs;
+
+import io.swagger.annotations.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+
+/**
+ * ServiceTemplateRest.java Purpose: ServiceTemplateRest interface
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Api
+@Path("/service")
+@Produces({MediaType.APPLICATION_JSON})
+public interface ServiceTemplateRest {
+
+ /**
+ * This is a enrichServiceTemplate rest service
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/servicetemplate/enrich")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to enrich service template", response = ServiceTemplate.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ServiceTemplate enrichServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate)
+ throws BluePrintException;
+
+ /**
+ * This is a validateServiceTemplate rest service
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/servicetemplate/validate")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to validate service template", response = ServiceTemplate.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ServiceTemplate validateServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate)
+ throws BluePrintException;
+
+ /**
+ * This is a generateResourceAssignments rest service
+ *
+ * @param templateContent
+ * @return List<ResourceAssignment>
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/resourceassignment/generate")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to auto map for the Resource Mapping",
+ response = ResourceAssignment.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ResourceAssignment> generateResourceAssignments(
+ @ApiParam(required = true) ConfigModelContent templateContent) throws BluePrintException;
+
+ /**
+ * This is a autoMap rest service
+ *
+ * @param resourceAssignments
+ * @return AutoMapResponse
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/resourceassignment/automap")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to auto map for the Resource assignments",
+ response = AutoMapResponse.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ AutoMapResponse autoMap(@ApiParam(required = true) List<ResourceAssignment> resourceAssignments)
+ throws BluePrintException;
+
+ /**
+ * This is a validateResourceAssignments rest service
+ *
+ * @param resourceAssignments
+ * @return List<ResourceAssignment>
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/resourceassignment/validate")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to validate Resource assignments", response = ResourceAssignment.class,
+ responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ResourceAssignment> validateResourceAssignments(
+ @ApiParam(required = true) List<ResourceAssignment> resourceAssignments) throws BluePrintException;
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java
new file mode 100644
index 00000000..6c49d5c6
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java
@@ -0,0 +1,94 @@
+/*
+ * 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.rs;
+
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@Service
+public class ServiceTemplateRestImpl implements ServiceTemplateRest {
+
+ private ServiceTemplateService serviceTemplateService;
+
+ /**
+ * This is a ServiceTemplateRestImpl constructor
+ *
+ * @param serviceTemplateService Service Template Service
+ */
+ public ServiceTemplateRestImpl(ServiceTemplateService serviceTemplateService) {
+ this.serviceTemplateService = serviceTemplateService;
+ }
+
+ @Override
+ public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ try {
+ return serviceTemplateService.enrichServiceTemplate(serviceTemplate);
+ } catch (Exception e) {
+ throw new BluePrintException(3500, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ try {
+ return serviceTemplateService.validateServiceTemplate(serviceTemplate);
+ } catch (Exception e) {
+ throw new BluePrintException(3501, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {
+ try {
+ return serviceTemplateService.autoMap(resourceAssignments);
+ } catch (Exception e) {
+ throw new BluePrintException(3502, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ResourceAssignment> validateResourceAssignments(List<ResourceAssignment> resourceAssignments)
+ throws BluePrintException {
+ try {
+ return serviceTemplateService.validateResourceAssignments(resourceAssignments);
+ } catch (Exception e) {
+ throw new BluePrintException(3503, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ResourceAssignment> generateResourceAssignments(ConfigModelContent templateContent)
+ throws BluePrintException {
+ try {
+ return serviceTemplateService.generateResourceAssignments(templateContent);
+ } catch (Exception e) {
+ throw new BluePrintException(3504, e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java
new file mode 100644
index 00000000..e31b04d1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java
@@ -0,0 +1,124 @@
+/*
+ * 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.utils;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class ConfigModelUtils {
+
+ private ConfigModelUtils(){
+
+ }
+ private static Logger log = LoggerFactory.getLogger(ConfigModelUtils.class);
+
+ public static ConfigModel getConfigModel(String blueprintPath) throws Exception {
+ Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "Blueprint Path is missing");
+ ToscaMetaData toscaMetaData = BluePrintMetadataUtils.toscaMetaData(blueprintPath);
+
+ Preconditions.checkNotNull(toscaMetaData, "failed to get Blueprint Metadata information");
+ Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getEntityDefinitions()), "failed to get Blueprint Definition file");
+ Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getCreatedBy()), "failed to get Blueprint created by");
+ Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getToscaMetaFileVersion()), "failed to get Blueprint package version");
+
+ String bluePrintName = FilenameUtils.getBaseName(toscaMetaData.getEntityDefinitions());
+ Preconditions.checkArgument(StringUtils.isNotBlank(bluePrintName), "failed to get Blueprint Definition Name");
+
+ // TODO - Update Rest of the Model
+ ConfigModel configModel = new ConfigModel();
+ configModel.setUpdatedBy(toscaMetaData.getCreatedBy());
+ configModel.setArtifactName(bluePrintName);
+ configModel.setArtifactVersion(toscaMetaData.getToscaMetaFileVersion());
+ configModel.setTags(toscaMetaData.getTemplateTags());
+ configModel.setArtifactType("SDNC_MODEL");
+
+ String blueprintContent =
+ getPathContent(blueprintPath + "/" + toscaMetaData.getEntityDefinitions());
+
+ Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "failed to get Blueprint content");
+
+ List<ConfigModelContent> configModelContents = new ArrayList<>();
+ ConfigModelContent stConfigModelContent = new ConfigModelContent();
+ stConfigModelContent.setName(configModel.getArtifactName());
+ stConfigModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
+ stConfigModelContent.setContent(blueprintContent);
+ configModelContents.add(stConfigModelContent);
+
+ String velocityDir = blueprintPath + "/Templates";
+ List<File> velocityTemplateFiles = getFileOfExtension(velocityDir, new String[]{"vtl"});
+
+ if (CollectionUtils.isNotEmpty(velocityTemplateFiles)) {
+ for (File velocityTemplateFile : velocityTemplateFiles) {
+ if (velocityTemplateFile != null) {
+ String contentName = velocityTemplateFile.getName().replace(".vtl", "");
+ ConfigModelContent velocityConfigModelContent = new ConfigModelContent();
+ String velocityConfigContent = getPathContent(velocityTemplateFile);
+ velocityConfigModelContent.setName(contentName);
+ velocityConfigModelContent
+ .setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
+ velocityConfigModelContent.setContent(velocityConfigContent);
+ configModelContents.add(velocityConfigModelContent);
+ log.info("Loaded blueprint template successfully: {}", velocityTemplateFile.getName());
+ }
+ }
+ }
+ configModel.setConfigModelContents(configModelContents);
+
+ return configModel;
+
+ }
+
+ public static String getPathContent(String path) throws IOException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(path), "Path is missing");
+ return FileUtils.readFileToString(new File(path), Charset.defaultCharset());
+ }
+
+ public static String getPathContent(File file) throws IOException {
+ Preconditions.checkNotNull(file, "File is missing");
+ return FileUtils.readFileToString(file, Charset.defaultCharset());
+ }
+
+ public static List<File> getFileOfExtension(String basePath, String[] extensions) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(basePath), "Path is missing");
+ Preconditions.checkNotNull(extensions, "Extensions is missing");
+ return (List<File>) FileUtils.listFiles(new File(basePath), extensions, true);
+ }
+
+ public static List<String> getBlueprintNames(String pathName) {
+ File blueprintDir = new File(pathName);
+ Preconditions.checkNotNull(blueprintDir, "failed to find the blueprint pathName file");
+ return Arrays.asList(blueprintDir.list(DirectoryFileFilter.INSTANCE));
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
new file mode 100644
index 00000000..85f256ea
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
@@ -0,0 +1,200 @@
+/*
+ * 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.validator;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.CapabilityDefinition;
+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.domain.ModelType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ModelTypeValidation.java Purpose: Provide Validation Service for Model Type ModelTypeValidation
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+public class ModelTypeValidator {
+
+ private ModelTypeValidator() {
+
+ }
+
+ private static List<String> getValidModelDefinitionType() {
+ List<String> validTypes = new ArrayList<>();
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE);
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE);
+ return validTypes;
+ }
+
+ @Deprecated
+ private static List<String> getValidModelDerivedFrom(String definitionType) {
+ List<String> validTypes = new ArrayList<>();
+ if (StringUtils.isNotBlank(definitionType)) {
+ if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_DG);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_VNF);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT);
+ } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_NETCONF);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SSH);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SFTP);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_CHEF);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_ANSIBLEF);
+ } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE.equalsIgnoreCase(definitionType)) {
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON);
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON);
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO);
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO);
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO);
+ }
+
+ }
+ return validTypes;
+ }
+
+ /**
+ * This is a validateNodeType
+ *
+ * @param definitionType
+ * @param derivedFrom
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public static boolean validateNodeType(String definitionType, String derivedFrom) throws BluePrintException {
+ boolean valid = true;
+ if (!BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)
+ && !BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {
+ List<String> validTypes = getValidModelDerivedFrom(definitionType);
+ if (!validTypes.contains(derivedFrom)) {
+ throw new BluePrintException(
+ "Not Valid Model Type (" + derivedFrom + "), It sould be " + validTypes);
+ }
+ }
+ return valid;
+ }
+
+ /**
+ * This is a validateModelTypeDefinition
+ *
+ * @param definitionType
+ * @param definitionContent
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public static boolean validateModelTypeDefinition(String definitionType, String definitionContent)
+ throws BluePrintException {
+ boolean valid = true;
+ if (StringUtils.isNotBlank(definitionContent)) {
+ if (BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)) {
+ DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
+ if (dataType == null) {
+ throw new BluePrintException(
+ "Model type definition is not DataType valid content " + definitionContent);
+ }
+ } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {
+ NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
+ if (nodeType == null) {
+ throw new BluePrintException(
+ "Model type definition is not NodeType valid content " + definitionContent);
+ }
+ } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {
+ ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
+ if (artifactType == null) {
+ throw new BluePrintException(
+ "Model type definition is not ArtifactType valid content " + definitionContent);
+ }
+ }else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {
+ CapabilityDefinition capabilityDefinition =
+ JacksonUtils.readValue(definitionContent, CapabilityDefinition.class);
+ if (capabilityDefinition == null) {
+ throw new BluePrintException(
+ "Model type definition is not CapabilityDefinition valid content " + definitionContent);
+ }
+ }
+
+ }
+ return valid;
+ }
+
+ /**
+ * This is a validateModelType method
+ *
+ * @param modelType
+ * @return boolean
+ */
+ public static boolean validateModelType(ModelType modelType) throws BluePrintException {
+ if (modelType != null) {
+
+ if (StringUtils.isBlank(modelType.getModelName())) {
+ throw new BluePrintException("Model Name Information is missing.");
+ }
+
+ if (StringUtils.isBlank(modelType.getDefinitionType())) {
+ throw new BluePrintException("Model Root Type Information is missing.");
+ }
+ if (StringUtils.isBlank(modelType.getDerivedFrom())) {
+ throw new BluePrintException("Model Type Information is missing.");
+ }
+
+ if (StringUtils.isBlank(modelType.getDefinition())) {
+ throw new BluePrintException("Model Definition Information is missing.");
+ }
+ if (StringUtils.isBlank(modelType.getDescription())) {
+ throw new BluePrintException("Model Description Information is missing.");
+ }
+
+ if (StringUtils.isBlank(modelType.getVersion())) {
+ throw new BluePrintException("Model Version Information is missing.");
+ }
+
+ if (StringUtils.isBlank(modelType.getUpdatedBy())) {
+ throw new BluePrintException("Model Updated By Information is missing.");
+ }
+
+ List<String> validRootTypes = getValidModelDefinitionType();
+ if (!validRootTypes.contains(modelType.getDefinitionType())) {
+ throw new BluePrintException("Not Valid Model Root Type(" + modelType.getDefinitionType()
+ + "), It sould be " + validRootTypes);
+ }
+
+ validateModelTypeDefinition(modelType.getDefinitionType(), modelType.getDefinition());
+
+ validateNodeType(modelType.getDefinitionType(), modelType.getDerivedFrom());
+
+ } else {
+ throw new BluePrintException("Model Type Information is missing.");
+ }
+
+ return true;
+
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java
new file mode 100644
index 00000000..eb2448e7
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java
@@ -0,0 +1,88 @@
+/*
+ * 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.validator;
+
+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.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+
+/**
+ * ResourceDictionaryValidator.java Purpose: Provide Validation Service for Model Type Resource
+ * Dictionary Validator
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public class ResourceDictionaryValidator {
+
+ private ResourceDictionaryValidator() {}
+
+ /**
+ * This is a validateResourceDictionaryDefinition
+ *
+ * @param definitionContent
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public static boolean validateResourceDictionaryDefinition(String definitionContent)
+ throws BluePrintException {
+ boolean valid = true;
+ if (StringUtils.isNotBlank(definitionContent)) {
+ DictionaryDefinition dictionaryDefinition =
+ JacksonUtils.readValue(definitionContent, DictionaryDefinition.class);
+ if (dictionaryDefinition == null) {
+ throw new BluePrintException(
+ "Resource dictionary definition is not valid content " + definitionContent);
+ }
+
+ }
+ return valid;
+ }
+
+ /**
+ * This is a validateResourceDictionary method
+ *
+ * @param resourceDictionary
+ * @return boolean
+ *
+ */
+ public static boolean validateResourceDictionary(ResourceDictionary resourceDictionary) {
+
+ Preconditions.checkNotNull(resourceDictionary,"ResourceDictionary Information is missing." );
+
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getName()),
+ "DataDictionary Alias Name Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getResourcePath()),
+ "DataDictionary Resource Name Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getResourceType()),
+ "DataDictionary Resource Type Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getDefinition()),
+ "DataDictionary Definition Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getDescription()),
+ "DataDictionary Description Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getTags()),
+ "DataDictionary Tags Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getUpdatedBy()),
+ "DataDictionary Updated By Information is missing.");
+ return true;
+
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
new file mode 100644
index 00000000..ea46f3ad
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
@@ -0,0 +1,123 @@
+/*
+ * 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.validator;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.validator.ResourceAssignmentValidator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * ServiceTemplateValidator.java Purpose: Provide Configuration Generator ServiceTemplateValidator
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+public class ServiceTemplateValidator extends BluePrintValidatorDefaultService {
+
+ StringBuilder message = new StringBuilder();
+ private Map<String, String> metaData = new HashMap();
+
+ /**
+ * This is a validateServiceTemplate
+ *
+ * @param serviceTemplateContent
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public boolean validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {
+ if (StringUtils.isNotBlank(serviceTemplateContent)) {
+ ServiceTemplate serviceTemplate =
+ JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+ return validateServiceTemplate(serviceTemplate);
+ } else {
+ throw new BluePrintException(
+ "Service Template Content is (" + serviceTemplateContent + ") not Defined.");
+ }
+ }
+
+ /**
+ * This is a validateServiceTemplate
+ *
+ * @param serviceTemplate
+ * @return boolean
+ * @throws BluePrintException
+ */
+ @SuppressWarnings("squid:S00112")
+ public boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ Map<String, Object> properties = new HashMap<>();
+ super.validateBlueprint(serviceTemplate, properties);
+ return true;
+ }
+
+ /**
+ * This is a getMetaData to get the key information during the
+ *
+ * @return Map<String ,
+ * String>
+ */
+ public Map<String, String> getMetaData() {
+ return metaData;
+ }
+
+ @Override
+ public void validateMetadata(@NotNull Map<String, String> metaDataMap) throws BluePrintException {
+
+ Preconditions.checkNotNull(serviceTemplate.getMetadata(), "Service Template Metadata Information is missing.");
+
+ this.metaData.putAll(serviceTemplate.getMetadata());
+
+ String author = serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR);
+ String serviceTemplateName =
+ serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_NAME);
+ String serviceTemplateVersion =
+ serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_VERSION);
+
+ Preconditions.checkArgument(StringUtils.isNotBlank(author), "Template Metadata (author) Information is missing.");
+ Preconditions.checkArgument(StringUtils.isNotBlank(serviceTemplateName), "Template Metadata (service-template-name) Information is missing.");
+ Preconditions.checkArgument(StringUtils.isNotBlank(serviceTemplateVersion), "Template Metadata (service-template-version) Information is missing.");
+ }
+
+
+ @Override
+ public void validateNodeTemplate(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)
+ throws BluePrintException {
+ super.validateNodeTemplate(nodeTemplateName, nodeTemplate);
+ validateNodeTemplateCustom(nodeTemplateName, nodeTemplate);
+
+ }
+
+ @Deprecated()
+ private void validateNodeTemplateCustom(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)
+ throws BluePrintException {
+ String derivedFrom = getBluePrintContext().nodeTemplateNodeType(nodeTemplateName).getDerivedFrom();
+ if ("tosca.nodes.Artifact".equals(derivedFrom)) {
+ ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(nodeTemplate);
+ resourceAssignmentValidator.validateResourceAssignment();
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/resources/service_template/default_netconf.json b/ms/controllerblueprints/modules/service/src/main/resources/service_template/default_netconf.json
new file mode 100644
index 00000000..95c829c4
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/resources/service_template/default_netconf.json
@@ -0,0 +1,890 @@
+{
+ "version": "1.0.0",
+ "metadata": {
+ "template_author": "xxxx@onap.com",
+ "template_name": "default_netconf",
+ "template_version": "1.0.0",
+ "service-type": "XXXXXXXXXXX",
+ "vnf-type": "XXXXXXXXX"
+ },
+ "topology_template": {
+ "inputs": {
+ "request-id": {
+ "required": true,
+ "type": "string"
+ },
+ "service-template-name": {
+ "required": true,
+ "type": "string"
+ },
+ "service-template-version": {
+ "required": true,
+ "type": "string"
+ },
+ "action-name": {
+ "required": true,
+ "type": "string"
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string"
+ },
+ "resource-type": {
+ "required": true,
+ "type": "string"
+ }
+ },
+ "node_templates": {
+ "base-config-template": {
+ "type": "artifact-config-template",
+ "properties": {
+ "action-names": [
+ "resource-assignment-action"
+ ]
+ },
+ "capabilities": {
+ "content": {
+ "properties": {
+ "content": ""
+ }
+ },
+ "mapping": {
+ "properties": {
+ "mapping": []
+ }
+ }
+ }
+ },
+ "licence-template": {
+ "type": "artifact-config-template",
+ "properties": {
+ "action-names": [
+ "activate-netconf-action"
+ ]
+ },
+ "capabilities": {
+ "content": {
+ "properties": {
+ "content": ""
+ }
+ },
+ "mapping": {
+ "properties": {
+ "mapping": []
+ }
+ }
+ }
+ },
+ "runningconfig-template": {
+ "type": "artifact-config-template",
+ "properties": {
+ "action-names": [
+ "activate-netconf-action"
+ ]
+ },
+ "capabilities": {
+ "content": {
+ "properties": {
+ "content": "<get-config><source><running/></source></get-config>"
+ }
+ },
+ "mapping": {
+ "properties": {
+ "mapping": []
+ }
+ }
+ }
+ },
+ "resource-assignment-action": {
+ "type": "dg-resource-assignment",
+ "interfaces": {
+ "CONFIG": {
+ "operations": {
+ "ResourceAssignment": {
+
+ }
+ }
+ }
+ },
+ "capabilities": {
+ "dg-node": {
+
+ }
+ },
+ "requirements": {
+ "component-dependency": {
+ "capability": "component-node",
+ "node": "get-resource-assignment",
+ "relationship": "tosca.relationships.DependsOn"
+ }
+ }
+ },
+ "activate-netconf-action": {
+ "type": "dg-activate-netconf",
+ "interfaces": {
+ "CONFIG": {
+ "operations": {
+ "ActivateNetconf": {
+
+ }
+ }
+ }
+ },
+ "capabilities": {
+ "dg-node": {
+
+ }
+ },
+ "requirements": {
+ "component-dependency": {
+ "capability": "component-node",
+ "node": "transaction-netconf-baseconfig",
+ "relationship": "tosca.relationships.DependsOn"
+ }
+ }
+ },
+ "resource-assignment": {
+ "type": "component-resource-assignment",
+ "interfaces": {
+ "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "resource-type": "vnf-type",
+ "template-names": [
+ "base-config-template",
+ "licence-template"
+ ],
+ "request-id": "{ \"get_attribute\" : \"request-id\" }",
+ "resource-id": "{ \"get_input\" : \"vnf-id\" }"
+ },
+ "outputs": {
+ "resource-assignment-params": "",
+ "status": ""
+ }
+ }
+ }
+ }
+ },
+ "capabilities": {
+ "component-node": {
+
+ }
+ }
+ },
+ "edit-netconf-config": {
+ "type": "component-netconf-edit",
+ "interfaces": {
+ "org-openecomp-sdnc-netconf-adaptor-service-SimpleNetconfEditConfigNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "rpc-message": false,
+ "wait": 0,
+ "unlock": false,
+ "config-target": "RUNNING",
+ "commit": true,
+ "edit-default-operation": "repalce",
+ "lock": false,
+ "post-restart-wait": false,
+ "pre-restart-wait": false
+ },
+ "outputs": {
+ "rpc-response-message": "",
+ "status": ""
+ }
+ }
+ }
+ }
+ },
+ "capabilities": {
+ "component-node": {
+
+ }
+ }
+ },
+ "transaction-netconf-baseconfig": {
+ "type": "component-transaction-netconf",
+ "interfaces": {
+ "org-openecomp-sdnc-netconf-adaptor-service-NetconfTransactionNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "rollback": false,
+ "transaction-templates": [
+ "runningconfig-template"
+ ],
+ "assignment-action-name": "resource-assignment-action",
+ "transaction-components": [
+ "get-netconf-config"
+ ],
+ "resource-type": "vnf-type",
+ "initialise-sftp": false,
+ "request-id": "{ \"get_input\" : \"request-id\" }",
+ "initialise-ssh": false,
+ "resource-id": "{ \"get_input\" : \"vnf-id\" }",
+ "action-name": "{ \"get_input\" : \"action-name\" }"
+ },
+ "outputs": {
+ "rpc-response-message": "",
+ "status": ""
+ }
+ }
+ }
+ }
+ },
+ "capabilities": {
+ "component-node": {
+
+ }
+ },
+ "requirements": {
+ "netconf-connection": {
+ "capability": "netconf",
+ "node": "vdbe-netconf-device",
+ "relationship": "tosca.relationships.ConnectsTo"
+ }
+ }
+ },
+ "get-netconf-config": {
+ "type": "component-netconf-get",
+ "interfaces": {
+ "org-openecomp-sdnc-netconf-adaptor-service-SimpleNetconfGetConfigNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "rpc-message": true,
+ "wait": 1,
+ "message-time-out": 10
+ },
+ "outputs": {
+ "rpc-response-message": "",
+ "status": ""
+ }
+ }
+ }
+ }
+ },
+ "capabilities": {
+ "component-node": {
+
+ }
+ }
+ }
+ }
+ },
+ "node_types": {
+ "vnf-netconf-device": {
+ "description": "This is VNF Device with Netconf and SSH Capability",
+ "version": "1.0.0",
+ "capabilities": {
+ "netconf": {
+ "type": "tosca.capability.Netconf",
+ "properties": {
+ "password": {
+ "required": false,
+ "type": "string"
+ },
+ "user-id": {
+ "required": true,
+ "type": "string"
+ },
+ "host-ip-address": {
+ "required": true,
+ "type": "string"
+ },
+ "port-number": {
+ "required": true,
+ "type": "integer",
+ "default": 830
+ },
+ "message-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 3000
+ },
+ "connection-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "ssh": {
+ "type": "tosca.capability.Ssh",
+ "properties": {
+ "password": {
+ "required": false,
+ "type": "string"
+ },
+ "user-id": {
+ "required": true,
+ "type": "string"
+ },
+ "host-ip-address": {
+ "required": true,
+ "type": "string"
+ },
+ "port-number": {
+ "required": true,
+ "type": "integer",
+ "default": 22
+ },
+ "message-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 180
+ },
+ "connection-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "sftp": {
+ "type": "tosca.capability.Sftp",
+ "properties": {
+ "password": {
+ "required": false,
+ "type": "string"
+ },
+ "user-id": {
+ "required": true,
+ "type": "string"
+ },
+ "host-ip-address": {
+ "required": true,
+ "type": "string"
+ },
+ "port-number": {
+ "required": true,
+ "type": "integer",
+ "default": 22
+ },
+ "message-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 180
+ },
+ "connection-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 30
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.Vnf"
+ },
+ "dg-resource-assignment": {
+ "description": "This is Resource Assignment Directed Graph",
+ "version": "1.0.0",
+ "properties": {
+ "mode": {
+ "required": false,
+ "type": "string",
+ "default": "sync"
+ },
+ "version": {
+ "required": false,
+ "type": "string",
+ "default": "LATEST"
+ },
+ "is-start-flow": {
+ "required": false,
+ "type": "boolean",
+ "default": "false"
+ }
+ },
+ "capabilities": {
+ "dg-node": {
+ "type": "tosca.capabilities.Node"
+ },
+ "content": {
+ "type": "tosca.capability.Content",
+ "properties": {
+ "type": {
+ "required": false,
+ "type": "string",
+ "default": "json"
+ },
+ "content": {
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ },
+ "requirements": {
+ "component-dependency": {
+ "capability": "component-node",
+ "node": "component-resource-assignment",
+ "relationship": "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces": {
+ "CONFIG": {
+ "operations": {
+ "ResourceAssignment": {
+ "inputs": {
+ "params": {
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "datatype-property"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.DG"
+ },
+ "dg-activate-netconf": {
+ "description": "This is Download Netconf Directed Graph",
+ "version": "1.0.0",
+ "properties": {
+ "mode": {
+ "required": false,
+ "type": "string",
+ "default": "sync"
+ },
+ "version": {
+ "required": false,
+ "type": "string",
+ "default": "LATEST"
+ },
+ "is-start-flow": {
+ "required": false,
+ "type": "boolean",
+ "default": "false"
+ }
+ },
+ "capabilities": {
+ "dg-node": {
+ "type": "tosca.capabilities.Node"
+ },
+ "content": {
+ "type": "tosca.capability.Content",
+ "properties": {
+ "type": {
+ "required": false,
+ "type": "string",
+ "default": "json"
+ },
+ "content": {
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ },
+ "requirements": {
+ "component-dependency": {
+ "capability": "component-node",
+ "node": "component-transaction-netconf",
+ "relationship": "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces": {
+ "CONFIG": {
+ "operations": {
+ "ActivateNetconf": {
+ "inputs": {
+ "params": {
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "datatype-property"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.DG"
+ },
+ "artifact-config-template": {
+ "description": "This is Configuration Velocity Template",
+ "version": "1.0.0",
+ "properties": {
+ "action-names": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "capabilities": {
+ "content": {
+ "type": "tosca.capability.Content",
+ "properties": {
+ "content": {
+ "required": true,
+ "type": "string"
+ }
+ }
+ },
+ "mapping": {
+ "type": "tosca.capability.Mapping",
+ "properties": {
+ "mapping": {
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "datatype-resource-assignment"
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.Artifact"
+ },
+ "component-resource-assignment": {
+ "description": "This is Resource Assignment Component API",
+ "version": "1.0.0",
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
+ "interfaces": {
+ "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "handler-name": {
+ "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",
+ "required": true,
+ "type": "string"
+ },
+ "resource-type": {
+ "required": false,
+ "type": "string"
+ },
+ "template-names": {
+ "description": "Name of the Artifact Node Templates, to get the template Content.",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "request-id": {
+ "description": "Request Id used to store the generated configuration, in the database along with the template-name",
+ "required": true,
+ "type": "string"
+ },
+ "resource-id": {
+ "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",
+ "required": true,
+ "type": "string"
+ },
+ "action-name": {
+ "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
+ "required": false,
+ "type": "string"
+ }
+ },
+ "outputs": {
+ "resource-assignment-params": {
+ "required": true,
+ "type": "string"
+ },
+ "status": {
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.Component"
+ },
+ "component-netconf-get": {
+ "description": "This is Netconf Get Running Configuration Component API",
+ "version": "1.0.0",
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
+ "interfaces": {
+ "org-openecomp-sdnc-netconf-adaptor-service-SimpleNetconfGetConfigNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "rpc-message": {
+ "description": "It should be true, If the message is Neconf RPC message, It should be false If it is plain Config message.",
+ "required": false,
+ "type": "boolean",
+ "default": false
+ },
+ "wait": {
+ "required": false,
+ "type": "integer",
+ "default": 0
+ },
+ "message-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 30
+ }
+ },
+ "outputs": {
+ "config-message": {
+ "type": "string"
+ },
+ "status": {
+ "description": "Status of the Component Execution ( success or failure )",
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.Component"
+ },
+ "component-netconf-edit": {
+ "description": "This is Netconf Edit Configuration Component API",
+ "version": "1.0.0",
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
+ "interfaces": {
+ "org-openecomp-sdnc-netconf-adaptor-service-SimpleNetconfEditConfigNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "rpc-message": {
+ "description": "If the message is Neconf RPC message,It should be true or false.",
+ "required": false,
+ "type": "boolean",
+ "default": false
+ },
+ "wait": {
+ "description": "Delay time in sec before performing edit-config action.",
+ "required": false,
+ "type": "integer",
+ "default": 0
+ },
+ "unlock": {
+ "description": "If unLock command has to send before Edit Configuration.",
+ "required": false,
+ "type": "boolean",
+ "default": false
+ },
+ "config-target": {
+ "required": false,
+ "type": "string"
+ },
+ "commit": {
+ "description": "Issue commit command to the device after performing edit-config action.",
+ "required": false,
+ "type": "boolean",
+ "default": false
+ },
+ "edit-default-operation": {
+ "required": false,
+ "type": "string"
+ },
+ "lock": {
+ "description": "Issue lock command to the device before performing edit-config action.",
+ "required": false,
+ "type": "boolean",
+ "default": false
+ },
+ "post-restart-wait": {
+ "description": "If Restart command should be issued before the Edit Operation, Provide the time to wait after restart. 0 meanno restart required or wait time in sec ex : 3000 for 5 ",
+ "required": false,
+ "type": "integer",
+ "default": 0
+ },
+ "pre-restart-wait": {
+ "description": "If Restart command should be issued after the Edit Operation, Provide the time to wait after restart. 0 meanno restart required or wait time in sec ex : 3000 for 5 ",
+ "required": false,
+ "type": "integer",
+ "default": 0
+ },
+ "message-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 30
+ }
+ },
+ "outputs": {
+ "rpc-response-message": {
+ "type": "string"
+ },
+ "status": {
+ "description": "Status of the Component Execution ( success or failure )",
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.Component"
+ },
+ "component-transaction-netconf": {
+ "description": "This is Netconf Transaction Configuration Component API",
+ "version": "1.0.0",
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
+ "requirements": {
+ "netconf-connection": {
+ "capability": "netconf",
+ "node": "vnf-netconf-device",
+ "relationship": "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces": {
+ "org-openecomp-sdnc-netconf-adaptor-service-NetconfTransactionNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "rollback": {
+ "required": false,
+ "type": "boolean"
+ },
+ "transaction-templates": {
+ "description": "Templates used by the Transaction Components during processing",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "assignment-action-name": {
+ "description": "Assignment Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
+ "required": true,
+ "type": "string"
+ },
+ "transaction-components": {
+ "description": "Components used to used for the atomic transaction, Default Handlers are org.openecomp.sdnc.netconf.adaptor.service.SimpleNetconfEditConfigNode and org.openecomp.sdnc.netconf.adaptor.service.SimpleNetconfGetConfigNode",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "resource-type": {
+ "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
+ "required": false,
+ "type": "string"
+ },
+ "initialise-sftp": {
+ "required": false,
+ "type": "boolean"
+ },
+ "request-id": {
+ "description": "Request Id used to store the generated configuration, in the database along with the template-name",
+ "required": true,
+ "type": "string"
+ },
+ "initialise-ssh": {
+ "required": false,
+ "type": "boolean"
+ },
+ "resource-id": {
+ "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
+ "required": false,
+ "type": "string"
+ },
+ "action-name": {
+ "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
+ "required": false,
+ "type": "string"
+ }
+ },
+ "outputs": {
+ "rpc-response-message": {
+ "type": "string"
+ },
+ "status": {
+ "description": "Status of the Component Execution ( success or failure )",
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.Component"
+ }
+ },
+ "data_types": {
+ "datatype-resource-assignment": {
+ "version": "1.0.0",
+ "description": "This is Resource Assignment Data Type",
+ "properties": {
+ "property": {
+ "required": true,
+ "type": "datatype-property"
+ },
+ "input-param": {
+ "required": true,
+ "type": "boolean"
+ },
+ "dictionary-name": {
+ "required": false,
+ "type": "string"
+ },
+ "dictionary-source": {
+ "required": false,
+ "type": "string"
+ },
+ "dependencies": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.datatypes.Root"
+ },
+ "datatype-property": {
+ "version": "1.0.0",
+ "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",
+ "properties": {
+ "type": {
+ "required": true,
+ "type": "string"
+ },
+ "description": {
+ "required": false,
+ "type": "string"
+ },
+ "required": {
+ "required": false,
+ "type": "boolean"
+ },
+ "default": {
+ "required": false,
+ "type": "string"
+ },
+ "entry_schema": {
+ "required": false,
+ "type": "string"
+ }
+ },
+ "derived_from": "tosca.datatypes.Root"
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/resources/sql/data.sql b/ms/controllerblueprints/modules/service/src/main/resources/sql/data.sql
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/resources/sql/data.sql
diff --git a/ms/controllerblueprints/modules/service/src/main/resources/sql/schema-local.sql b/ms/controllerblueprints/modules/service/src/main/resources/sql/schema-local.sql
new file mode 100644
index 00000000..1ba9c365
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/resources/sql/schema-local.sql
@@ -0,0 +1,87 @@
+-- drop table sdnctl.MODEL_TYPE;
+-- drop table sdnctl.RESOURCE_DICTIONARY;
+-- drop table sdnctl.CONFIG_MODEL_CONTENT;
+-- drop table sdnctl.CONFIG_MODEL;
+
+-- -----------------------------------------------------
+-- table CONFIG_MODEL
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL (
+ config_model_id INT(11) NOT NULL AUTO_INCREMENT,
+ service_uuid VARCHAR(50) NULL DEFAULT NULL,
+ distribution_id VARCHAR(50) NULL DEFAULT NULL,
+ service_name VARCHAR(255) NULL DEFAULT NULL,
+ service_description VARCHAR(255) NULL DEFAULT NULL,
+ resource_uuid VARCHAR(255) NULL DEFAULT NULL,
+ resource_instance_name VARCHAR(255) NULL DEFAULT NULL,
+ resource_name varchar(255) null default null,
+ resource_version varchar(50) null default null,
+ resource_type varchar(50) null default null,
+ artifact_uuid varchar(50) null default null,
+ artifact_type varchar(50) not null,
+ artifact_version varchar(25) not null,
+ artifact_description longtext null default null,
+ internal_version int(11) null default null,
+ creation_date datetime not null default current_timestamp,
+ artifact_name varchar(100) not null,
+ published varchar(1) not null,
+ updated_by varchar(100) not null,
+ tags longtext null default null,
+ primary key PK_CONFIG_MODEL (config_model_id),
+ UNIQUE KEY UK_CONFIG_MODEL (artifact_name , artifact_version)
+) ENGINE=InnoDB;
+
+
+-- -----------------------------------------------------
+-- table CONFIG_MODEL_CONTENT
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL_CONTENT (
+ config_model_content_id INT(11) NOT NULL AUTO_INCREMENT,
+ config_model_id INT NOT NULL,
+ name VARCHAR(100) NOT NULL,
+ content_type VARCHAR(50) NOT NULL,
+ description LONGTEXT NULL DEFAULT NULL,
+ updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ content LONGTEXT NULL DEFAULT NULL,
+ PRIMARY KEY PK_CONFIG_MODEL_CONTENT (config_model_content_id),
+ UNIQUE KEY UK_CONFIG_MODEL_CONTENT (config_model_id, name, content_type),
+ FOREIGN KEY FK_CONFIG_MODEL_CONTENT (config_model_id) REFERENCES sdnctl.CONFIG_MODEL(config_model_id) ON DELETE CASCADE
+) ENGINE=InnoDB;
+
+-- -----------------------------------------------------
+-- table MODEL_TYPE
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS sdnctl.MODEL_TYPE (
+ model_name VARCHAR(100) NOT NULL,
+ derived_from VARCHAR(100) NOT NULL,
+ definition_type VARCHAR(100) NOT NULL,
+ definition LONGTEXT NOT NULL,
+ version VARCHAR(10) NOT NULL,
+ description LONGTEXT NOT NULL,
+ tags LONGTEXT NULL DEFAULT NULL,
+ creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_by VARCHAR(100) NOT NULL,
+ PRIMARY KEY PK_MODEL_TYPE (model_name),
+ INDEX IX_MODEL_TYPE (model_name)
+) ENGINE=InnoDB;
+
+
+-- -----------------------------------------------------
+-- table RESOURCE_DICTIONARY
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS sdnctl.RESOURCE_DICTIONARY (
+ name VARCHAR(100) NOT NULL,
+ resource_path VARCHAR(500) NOT NULL,
+ resource_type VARCHAR(100) NOT NULL,
+ data_type VARCHAR(100) NOT NULL,
+ entry_schema VARCHAR(100) NULL DEFAULT NULL,
+ valid_values LONGTEXT NULL DEFAULT NULL,
+ sample_value LONGTEXT NULL DEFAULT NULL,
+ definition LONGTEXT NOT NULL,
+ description LONGTEXT NOT NULL,
+ tags LONGTEXT NOT NULL,
+ creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_by VARCHAR(100) NOT NULL,
+ primary key PK_RESOURCE_DICTIONARY (name),
+ INDEX IX_RESOURCE_DICTIONARY (name)
+) ENGINE=InnoDB; \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/resources/sql/schema.sql b/ms/controllerblueprints/modules/service/src/main/resources/sql/schema.sql
new file mode 100644
index 00000000..b884cf34
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/resources/sql/schema.sql
@@ -0,0 +1,82 @@
+-- -----------------------------------------------------
+-- table CONFIG_MODEL
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL (
+ config_model_id INT(11) NOT NULL AUTO_INCREMENT,
+ service_uuid VARCHAR(50) NULL DEFAULT NULL,
+ distribution_id VARCHAR(50) NULL DEFAULT NULL,
+ service_name VARCHAR(255) NULL DEFAULT NULL,
+ service_description VARCHAR(255) NULL DEFAULT NULL,
+ resource_uuid VARCHAR(255) NULL DEFAULT NULL,
+ resource_instance_name VARCHAR(255) NULL DEFAULT NULL,
+ resource_name varchar(255) null default null,
+ resource_version varchar(50) null default null,
+ resource_type varchar(50) null default null,
+ artifact_uuid varchar(50) null default null,
+ artifact_type varchar(50) not null,
+ artifact_version varchar(25) not null,
+ artifact_description longtext null default null,
+ internal_version int(11) null default null,
+ creation_date datetime not null default current_timestamp,
+ artifact_name varchar(100) not null,
+ published varchar(1) not null,
+ updated_by varchar(100) not null,
+ tags longtext null default null,
+ primary key PK_CONFIG_MODEL (config_model_id),
+ UNIQUE KEY UK_CONFIG_MODEL (artifact_name , artifact_version)
+) ENGINE=InnoDB;
+
+
+-- -----------------------------------------------------
+-- table CONFIG_MODEL_CONTENT
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL_CONTENT (
+ config_model_content_id INT(11) NOT NULL AUTO_INCREMENT,
+ config_model_id INT NOT NULL,
+ name VARCHAR(100) NOT NULL,
+ content_type VARCHAR(50) NOT NULL,
+ description LONGTEXT NULL DEFAULT NULL,
+ updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ content LONGTEXT NULL DEFAULT NULL,
+ PRIMARY KEY PK_CONFIG_MODEL_CONTENT (config_model_content_id),
+ UNIQUE KEY UK_CONFIG_MODEL_CONTENT (config_model_id, name, content_type),
+ FOREIGN KEY FK_CONFIG_MODEL_CONTENT (config_model_id) REFERENCES configurator.CONFIG_MODEL(config_model_id) ON DELETE CASCADE
+) ENGINE=InnoDB;
+
+-- -----------------------------------------------------
+-- table MODEL_TYPE
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS configurator.MODEL_TYPE (
+ model_name VARCHAR(100) NOT NULL,
+ derived_from VARCHAR(100) NOT NULL,
+ definition_type VARCHAR(100) NOT NULL,
+ definition LONGTEXT NOT NULL,
+ version VARCHAR(10) NOT NULL,
+ description LONGTEXT NOT NULL,
+ tags LONGTEXT NULL DEFAULT NULL,
+ creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_by VARCHAR(100) NOT NULL,
+ PRIMARY KEY PK_MODEL_TYPE (model_name),
+ INDEX IX_MODEL_TYPE (model_name)
+) ENGINE=InnoDB;
+
+
+-- -----------------------------------------------------
+-- table RESOURCE_DICTIONARY
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS configurator.RESOURCE_DICTIONARY (
+ name VARCHAR(100) NOT NULL,
+ resource_path VARCHAR(500) NOT NULL,
+ resource_type VARCHAR(100) NOT NULL,
+ data_type VARCHAR(100) NOT NULL,
+ entry_schema VARCHAR(100) NULL DEFAULT NULL,
+ valid_values LONGTEXT NULL DEFAULT NULL,
+ sample_value LONGTEXT NULL DEFAULT NULL,
+ definition LONGTEXT NOT NULL,
+ description LONGTEXT NOT NULL,
+ tags LONGTEXT NOT NULL,
+ creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_by VARCHAR(100) NOT NULL,
+ primary key PK_RESOURCE_DICTIONARY (name),
+ INDEX IX_RESOURCE_DICTIONARY (name)
+) ENGINE=InnoDB;
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java
new file mode 100644
index 00000000..db35fe66
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.sql.DataSource;
+
+/**
+ * DatabaseConfig.java Purpose: Provide Configuration Generator DatabaseConfig Information
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Configuration
+@EntityScan("org.onap.ccsdk.apps.controllerblueprints.service.domain")
+@EnableTransactionManagement
+@EnableJpaRepositories("org.onap.ccsdk.apps.controllerblueprints.service.repository")
+@EnableJpaAuditing
+public class DatabaseConfig {
+ /**
+ * This is a entityManagerFactory method
+ *
+ * @param dataSource
+ * @return LocalContainerEntityManagerFactoryBean
+ */
+
+ @Bean
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
+ HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
+ vendorAdapter.setGenerateDdl(true);
+ vendorAdapter.setShowSql(false);
+ LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
+ factory.setJpaVendorAdapter(vendorAdapter);
+ factory.setPackagesToScan("org.onap.ccsdk.apps.controllerblueprints.service.domain");
+ factory.setDataSource(dataSource);
+ return factory;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java
new file mode 100644
index 00000000..f5535eb1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java
@@ -0,0 +1,69 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import org.glassfish.jersey.logging.LoggingFeature;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletProperties;
+import org.onap.ccsdk.apps.controllerblueprints.service.common.ServiceExceptionMapper;
+import org.onap.ccsdk.apps.controllerblueprints.service.rs.ConfigModelRestImpl;
+import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestImpl;
+import org.onap.ccsdk.apps.controllerblueprints.service.rs.ResourceDictionaryRestImpl;
+import org.onap.ccsdk.apps.controllerblueprints.service.rs.ServiceTemplateRestImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import java.util.logging.Logger;
+
+
+@Component
+public class JerseyConfiguration extends ResourceConfig {
+ private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());
+
+ @Bean
+ @Primary
+ public ObjectMapper objectMapper() {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+ objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
+ objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+ objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
+ return objectMapper;
+ }
+
+ @Autowired
+ public JerseyConfiguration() {
+ register(ConfigModelRestImpl.class);
+ register(ModelTypeRestImpl.class);
+ register(ResourceDictionaryRestImpl.class);
+ register(ServiceTemplateRestImpl.class);
+ // Exception Mapping
+ register(ServiceExceptionMapper.class);
+ property(ServletProperties.FILTER_FORWARD_ON_404, true);
+ register(new LoggingFeature(log));
+ }
+
+
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestApplication.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestApplication.java
new file mode 100644
index 00000000..537429f0
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestApplication.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+
+@SpringBootApplication
+@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints"})
+@EnableAutoConfiguration
+public class TestApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TestApplication.class, args);
+ }
+
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java
new file mode 100644
index 00000000..ea259c9c
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import org.springframework.context.annotation.Bean;
+
+import java.util.ArrayList;
+
+//@Configuration
+public class TestConfiguration {
+
+ @Bean("jaxrsProviders")
+ public ArrayList<Object> provider() {
+ return new ArrayList<Object>();
+ }
+
+ @Bean("jaxrsServices")
+ public ArrayList<Object> service() {
+ return new ArrayList<Object>();
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SchemaGeneratorServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SchemaGeneratorServiceTest.java
new file mode 100644
index 00000000..50e94df9
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SchemaGeneratorServiceTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.common;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+import org.onap.ccsdk.apps.controllerblueprints.service.SchemaGeneratorService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.nio.charset.Charset;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class SchemaGeneratorServiceTest {
+
+ private static Logger log = LoggerFactory.getLogger(ServiceTemplateValidationTest.class);
+
+ @Test
+ public void test01GenerateSwaggerData() throws Exception {
+ log.info("******************* test01GenerateSwaggerData ******************************");
+
+ String file = "src/test/resources/enhance/enhanced-template.json";
+ String serviceTemplateContent = FileUtils.readFileToString(new File(file), Charset.defaultCharset());
+ SchemaGeneratorService schemaGeneratorService = new SchemaGeneratorService();
+ String schema = schemaGeneratorService.generateSchema(serviceTemplateContent);
+ log.trace("Generated Schema " + schema);
+ Assert.assertNotNull("failed to generate Sample Data", schema);
+
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceTemplateValidationTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceTemplateValidationTest.java
new file mode 100644
index 00000000..af309e21
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceTemplateValidationTest.java
@@ -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.common;
+
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ServiceTemplateValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.charset.Charset;
+import java.util.List;
+
+public class ServiceTemplateValidationTest {
+ private static Logger log = LoggerFactory.getLogger(ServiceTemplateValidationTest.class);
+
+ @Test
+ public void testBluePrintDirs(){
+ List<String> dirs = ConfigModelUtils.getBlueprintNames("load/blueprints");
+ Assert.assertNotNull("Failed to get blueprint directories", dirs );
+ Assert.assertEquals("Failed to get actual directories",2, dirs.size() );
+ }
+
+ // @Test
+ public void validateServiceTemplate() {
+ try {
+ String file = "load/service_template/vrr-201806-test/service-template.json";
+ String serviceTemplateContent =
+ IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader().getResourceAsStream(file),
+ Charset.defaultCharset());
+ ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator();
+ serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent);
+ log.info("Validated Service Template " + serviceTemplateValidator.getMetaData());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java
new file mode 100644
index 00000000..5b10a7e8
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.rs;
+
+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.TestConfiguration;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.List;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ConfigModelRestTest {
+
+ private static Logger log = LoggerFactory.getLogger(ConfigModelRestTest.class);
+
+ @Autowired
+ ConfigModelRest configModelRest;
+
+ ConfigModel configModel;
+
+ String name = "vrr-test";
+ String version = "1.0.0";
+
+ @Before
+ public void setUp() {
+
+ }
+
+
+ @After
+ public void tearDown() {
+ }
+
+
+ @Test
+ public void test01getInitialConfigModel() throws Exception {
+ log.info("** test01getInitialConfigModel *****************");
+
+ String name = "default_netconf";
+ ConfigModel configModel = configModelRest.getInitialConfigModel(name);
+ Assert.assertNotNull("Failed to get Initial Config Model , Return object is Null", configModel);
+ Assert.assertNotNull("Failed to get Service Template Content ", configModel.getConfigModelContents());
+
+ }
+
+
+ @Test
+ public void test02SaveServiceTemplate() throws Exception {
+ log.info("************************ test02SaveServiceTemplate ******************");
+
+
+ configModel = ConfigModelUtils.getConfigModel("load/blueprints/vrr-test");
+
+ configModel = configModelRest.saveConfigModel(configModel);
+ Assert.assertNotNull("Failed to ConfigModel, Return object is Null", configModel);
+ Assert.assertNotNull("Failed to ConfigModel Id , Return ID object is Null", configModel.getId());
+ Assert.assertNotNull("Failed to ConfigModel Content, Return object is Null",
+ configModel.getConfigModelContents());
+ Assert.assertEquals("Failed in validation of ConfigModel Content count,", 3,
+ configModel.getConfigModelContents().size());
+
+ ConfigModel dbconfigModel = configModelRest.getConfigModel(configModel.getId());
+
+ log.info("************************ test02SaveServiceTemplate-2 ******************");
+
+ dbconfigModel.getConfigModelContents().remove(2);
+ dbconfigModel = configModelRest.saveConfigModel(dbconfigModel);
+ log.info("Saved Config Model " + configModel.getId());
+ Assert.assertNotNull("Failed to ConfigModel, Return object is Null", dbconfigModel);
+ Assert.assertNotNull("Failed to ConfigModel Id ", dbconfigModel.getId());
+ Assert.assertNotNull("Failed to ConfigModel Content",
+ dbconfigModel.getConfigModelContents());
+ Assert.assertEquals("Failed to Remove the ConfigModel Content,", 2,
+ dbconfigModel.getConfigModelContents().size());
+
+
+ }
+
+
+ @Test
+ public void test03PublishServiceTemplate() throws Exception {
+ log.info("** test03PublishServiceTemplate *****************");
+
+ ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);
+ log.info("Publishing Config Model " + configModel.getId());
+ configModel = configModelRest.publishConfigModel(configModel.getId());
+ Assert.assertNotNull("Failed to ConfigModel, Return object is Null", configModel);
+ Assert.assertNotNull("Failed to ConfigModel Id ", configModel.getId());
+ Assert.assertNotNull("Failed to ConfigModel Content", configModel.getConfigModelContents());
+ Assert.assertEquals("Failed to update the publish indicator", "Y", configModel.getPublished());
+ }
+
+
+ @Test
+ public void test04GetConfigModel() throws Exception {
+ log.info("** test04GetConfigModel *****************");
+
+ ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);
+ Assert.assertNotNull("Failed to get ConfigModel for the Name (" + configModel.getArtifactName() + ") and ("
+ + configModel.getArtifactVersion() + ")", configModel);
+ Assert.assertNotNull("Failed to get ConfigModel Id", configModel.getId());
+
+ configModel = configModelRest.getConfigModel(configModel.getId());
+ Assert.assertNotNull("Failed to get ConfigModel for the Id (" + configModel.getId() + ") ", configModel);
+
+ }
+
+ @Test
+ public void test05GetCloneConfigModel() throws Exception {
+ log.info("** test05GetCloneConfigModel *****************");
+
+ ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);
+
+ Assert.assertNotNull("Failed to get ConfigModel for the Name (" + configModel.getArtifactName() + ") and ("
+ + configModel.getArtifactVersion() + ")", configModel);
+ Assert.assertNotNull("Failed to get ConfigModel Id", configModel.getId());
+
+ configModel = configModelRest.getCloneConfigModel(configModel.getId());
+ Assert.assertNotNull("Failed to get ConfigModel for the Id (" + configModel.getId() + ") ", configModel);
+ }
+
+
+ @Test
+ public void test07SearchConfigModels() throws Exception {
+ log.info("** test07SearchConfigModels *****************");
+
+ List<ConfigModel> configModels = configModelRest.searchConfigModels("vrr-test");
+ Assert.assertNotNull("Failed to search ConfigModel", configModels);
+ Assert.assertTrue("Failed to search ConfigModel with count", configModels.size() > 0);
+ // update the ServiceModelContent
+ }
+
+
+ @Test
+ public void test08DeleteConfigModels() throws Exception {
+ log.info("** test08DeleteConfigModels *****************");
+
+ ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);
+ configModelRest.deleteConfigModel(configModel.getId());
+
+ }
+
+
+}
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
new file mode 100644
index 00000000..d33349c5
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
@@ -0,0 +1,130 @@
+/*
+ * 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.rs;
+
+import org.apache.commons.io.FileUtils;
+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.TestConfiguration;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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.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)
+@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ModelTypeRestTest {
+ private static Logger log = LoggerFactory.getLogger(ModelTypeRestTest.class);
+ @Autowired
+ ModelTypeRest modelTypeRest;
+
+ String modelName = "test-datatype";
+
+ @Before
+ public void setUp() {
+
+ }
+
+
+ @After
+ public void tearDown() {}
+
+ @Test
+ public void test01SaveModelType() throws Exception {
+ log.info( "**************** test01SaveModelType ********************");
+
+ String content = FileUtils.readFileToString(new File("load/model_type/data_type/datatype-property.json"), Charset.defaultCharset());
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
+ modelType.setDescription("Definition for Sample Datatype ");
+ modelType.setDefinition(content);
+ modelType.setModelName(modelName);
+ modelType.setVersion("1.0.0");
+ modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelType.setUpdatedBy("xxxxxx@xxx.com");
+ modelType = modelTypeRest.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());
+ Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",
+ dbModelType);
+
+ // Model Update
+ modelType.setUpdatedBy("bs2796@xxx.com");
+ modelType = modelTypeRest.saveModelType(modelType);
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType);
+ Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());
+
+ }
+
+ @Test
+ public void test02SearchModelTypes() throws Exception {
+ log.info( "*********************** test02SearchModelTypes ***************************");
+
+ String tags = "test-datatype";
+
+ List<ModelType> dbModelTypes = modelTypeRest.searchModelTypes(tags);
+ Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);
+ Assert.assertEquals("Failed to search ResourceMapping by tags count", true, dbModelTypes.size() > 0);
+
+ }
+
+ @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);
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName());
+
+ List<ModelType> dbDatatypeModelTypes =
+ modelTypeRest.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes);
+ Assert.assertEquals("Failed to find getModelTypeByDefinitionType by count", true,
+ dbDatatypeModelTypes.size() > 0);
+ }
+
+ @Test
+ public void test04DeleteModelType() throws Exception {
+ log.info(
+ "************************ test03DeleteModelType ***********************");
+ ModelType dbResourceMapping = modelTypeRest.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());
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
new file mode 100644
index 00000000..71dff338
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.rs;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
+import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ResourceDictionaryRestTest {
+
+ private static Logger log = LoggerFactory.getLogger(ResourceDictionaryRestTest.class);
+
+ @Autowired
+ protected ResourceDictionaryRest resourceDictionaryRest;
+
+ @Before
+ public void setUp() {
+
+ }
+
+ @Test
+ public void test01SaveDataDictionary() throws Exception {
+ String definition = IOUtils.toString(
+ getClass().getClassLoader().getResourceAsStream("resourcedictionary/default_definition.json"),
+ Charset.defaultCharset());
+
+ ResourceDictionary dataDictionary = new ResourceDictionary();
+ dataDictionary.setResourcePath("test/vnf/ipaddress");
+ dataDictionary.setName("test-name");
+ dataDictionary.setDefinition(definition);
+ dataDictionary.setValidValues("127.0.0.1");
+ dataDictionary.setResourceType("ONAP");
+ dataDictionary.setDataType("string");
+ dataDictionary.setDescription("Sample Resource Mapping");
+ dataDictionary.setTags("test, ipaddress");
+ dataDictionary.setUpdatedBy("xxxxxx@xxx.com");
+
+ dataDictionary = resourceDictionaryRest.saveResourceDictionary(dataDictionary);
+
+ Assert.assertNotNull("Failed to get Saved Resource Dictionary", dataDictionary);
+ Assert.assertNotNull("Failed to get Saved Resource Dictionary, Id", dataDictionary.getName());
+
+ ResourceDictionary dbDataDictionary =
+ resourceDictionaryRest.getResourceDictionaryByName(dataDictionary.getName());
+ Assert.assertNotNull("Failed to query Resource Dictionary for ID (" + dataDictionary.getName() + ")",
+ dbDataDictionary);
+ Assert.assertNotNull("Failed to query Resource Dictionary definition for ID (" + dataDictionary.getName() + ")",
+ dbDataDictionary.getDefinition());
+
+ log.trace("Saved Dictionary " + dbDataDictionary.getDefinition());
+
+ }
+
+ @Test
+ public void test02GetDataDictionary() throws Exception {
+
+ ResourceDictionary dbResourceDictionary = resourceDictionaryRest.getResourceDictionaryByName("test-name");
+ Assert.assertNotNull("Failed to query Resource Dictionary by Name", dbResourceDictionary);
+
+ String tags = "ipaddress";
+
+ List<ResourceDictionary> dbResourceDictionaries = resourceDictionaryRest.searchResourceDictionaryByTags(tags);
+ Assert.assertNotNull("Failed to search ResourceDictionary by tags", dbResourceDictionaries);
+ Assert.assertTrue("Failed to search searchResourceDictionaryByTags by tags by count",
+ dbResourceDictionaries.size() > 0);
+
+ List<String> names = new ArrayList<>();
+ names.add("test-name");
+ dbResourceDictionaries = resourceDictionaryRest.searchResourceDictionaryByNames(names);
+ Assert.assertNotNull("Failed to search ResourceDictionary by Names", dbResourceDictionaries);
+ Assert.assertTrue("Failed to search searchResourceDictionaryByNames by tags by count",
+ dbResourceDictionaries.size() > 0);
+
+ }
+
+}
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
new file mode 100644
index 00000000..f81dd416
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.rs;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
+import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration;
+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.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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.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)
+@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ServiceTemplateRestTest {
+
+ private static Logger log = LoggerFactory.getLogger(ServiceTemplateRestTest.class);
+ @Autowired
+ ModelTypeRest modelTypeRest;
+
+ @Autowired
+ private ServiceTemplateRest serviceTemplateRest;
+
+ @Test
+ public void test02EnrichServiceTemplate() throws Exception {
+ log.info("*********** test02EnrichServiceTemplate ***********************");
+ String file = "src/test/resources/enhance/enhance-template.json";
+
+ String serviceTemplateContent = FileUtils.readFileToString(new File(file), Charset.defaultCharset());
+
+ ServiceTemplate serviceTemplate = JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+
+ serviceTemplate = serviceTemplateRest.enrichServiceTemplate(serviceTemplate);
+
+ String enhancedFile = "src/test/resources/enhance/enhanced-template.json";
+
+ FileUtils.write(new File(enhancedFile),
+ JacksonUtils.getJson(serviceTemplate, true), Charset.defaultCharset());
+
+ Assert.assertNotNull("Failed to get Enriched Blueprints, Return object is Null", serviceTemplate);
+ Assert.assertNotNull("Failed to get Enriched Blueprints Data Type, Return object is Null",
+ serviceTemplate.getDataTypes());
+ Assert.assertNotNull("Failed to get Enriched Blueprints Node Type, Return object is Null",
+ serviceTemplate.getNodeTypes());
+ log.trace("Enriched Service Template :\n" + JacksonUtils.getJson(serviceTemplate, true));
+ }
+
+ @Test
+ public void test03ValidateServiceTemplate() throws Exception {
+ log.info("*********** test03ValidateServiceTemplate *******************************************");
+ String enhancedFile = "src/test/resources/enhance/enhanced-template.json";
+ String serviceTemplateContent = FileUtils.readFileToString(new File(enhancedFile), Charset.defaultCharset());
+
+ ServiceTemplate serviceTemplate =
+ JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+
+ serviceTemplate = serviceTemplateRest.validateServiceTemplate(serviceTemplate);
+
+ Assert.assertNotNull("Failed to validate Service Template, Return object is Null", serviceTemplate);
+ Assert.assertNotNull("Failed to get Service Template Data Type, Return object is Null",
+ serviceTemplate.getDataTypes());
+ Assert.assertNotNull("Failed to get Service Template Node Type, Return object is Null",
+ serviceTemplate.getNodeTypes());
+
+ log.trace("Validated Service Template :\n" + JacksonUtils.getJson(serviceTemplate, true));
+
+ }
+
+
+ @Test
+ public void test04GenerateResourceAssignments() throws Exception {
+ log.info("*********** test04GenerateResourceAssignments *******************************************");
+ ConfigModelContent baseConfigConfigModelContent = new ConfigModelContent();
+ String baseConfigContent = FileUtils.readFileToString(new File("load/blueprints/vrr-test/Templates/base-config-template.vtl")
+ , Charset.defaultCharset());
+ baseConfigConfigModelContent.setName("base-config-template");
+ baseConfigConfigModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
+ baseConfigConfigModelContent.setContent(baseConfigContent);
+
+ List<ResourceAssignment> resourceAssignments =
+ serviceTemplateRest.generateResourceAssignments(baseConfigConfigModelContent);
+
+ Assert.assertNotNull("Failed to get ResourceAssignments, Return object is Null", resourceAssignments);
+ Assert.assertTrue("Failed to get ResourceAssignments count", resourceAssignments.size() > 0);
+
+ log.trace("Validated Service Template :\n" + JacksonUtils.getJson(resourceAssignments, true));
+
+
+ }
+
+ @Test
+ public void test05AutoMap() throws Exception {
+ log.info("*********** test05AutoMap *******************************************");
+
+ String resourceassignmentContent = FileUtils.readFileToString(
+ new File("src/test/resources/resourcedictionary/automap.json"), Charset.defaultCharset());
+ List<ResourceAssignment> batchResourceAssignment =
+ JacksonUtils.getListFromJson(resourceassignmentContent, ResourceAssignment.class);
+ AutoMapResponse autoMapResponse = serviceTemplateRest.autoMap(batchResourceAssignment);
+
+ Assert.assertNotNull("Failed to get ResourceAssignments, Return object is Null",
+ autoMapResponse.getResourceAssignments());
+ Assert.assertNotNull("Failed to get Data Dictionary from ResourceAssignments",
+ autoMapResponse.getDataDictionaries());
+ Assert.assertTrue("Failed to get ResourceAssignments count",
+ CollectionUtils.isNotEmpty(autoMapResponse.getDataDictionaries()));
+
+ List<ResourceAssignment> autoMappedResourceAssignment = autoMapResponse.getResourceAssignments();
+ autoMappedResourceAssignment.forEach(resourceAssignment -> {
+ if ("bundle-id".equals(resourceAssignment.getName())) {
+ Assert.assertEquals("Failed to assign default first source", "db",
+ resourceAssignment.getDictionarySource());
+ }
+ });
+
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtilsTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtilsTest.java
new file mode 100644
index 00000000..b38dd6de
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtilsTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.utils;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+
+public class ConfigModelUtilsTest {
+
+ @Test
+ public void testConfigModel() throws Exception {
+
+ ConfigModel configModel = ConfigModelUtils.getConfigModel("load/blueprints/vrr-test");
+ Assert.assertNotNull("Failed to prepare config model", configModel);
+ Assert.assertTrue("Failed to prepare config model contents", CollectionUtils.isNotEmpty(configModel.getConfigModelContents()));
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
new file mode 100644
index 00000000..a13e1684
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
@@ -0,0 +1,67 @@
+#
+# 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.
+#
+
+info.build.artifact=@project.artifactId@
+info.build.name=@project.name@
+info.build.description=@project.description@
+info.build.version=@project.version@
+info.build.groupId=@project.groupId@
+logging.level.root=info
+
+server.contextPath=/
+server.servlet-path=/
+spring.jersey.application-path=/api/controller-blueprints/v1
+server.routingPath=/api
+
+
+mots.application.acronym=MOTS_ID
+platform.identifier=AJSC7_JERSEY
+#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
+
+#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex
+
+
+#The max number of active threads in this pool
+server.tomcat.max-threads=200
+#The minimum number of threads always kept alive
+server.tomcat.min-Spare-Threads=25
+#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
+server.tomcat.max-idle-time=60000
+
+#for changing the tomcat port...
+#server.port=8081
+
+
+
+#Servlet context parameters
+server.context_parameters.p-name=value #context parameter with p-name as key and value as value.
+
+# make this true for AAF authentication and place cadi.properties into etc folder
+aaf.enabled=true
+
+# set to true to enable version proxy
+#ivp.enabled=false
+
+spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false
+
+
+logging.level.org.springframework.web=INFO
+logging.level.org.hibernate.SQL=warn
+logging.level.org.hibernate.type.descriptor.sql=debug
+
+
+blueprints.load.initial-data=true
+blueprints.load.path=load \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json
new file mode 100644
index 00000000..8b4fd9d3
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json
@@ -0,0 +1,345 @@
+{
+ "metadata": {
+ "template_author": "Brinda Santh",
+ "template_name": "enhance-template",
+ "template_version": "1.0.0",
+ "service-type": "Sample Service",
+ "release": "1806",
+ "vnf-type": "VPE"
+ },
+ "topology_template": {
+ "inputs": {
+ "request-id": {
+ "required": true,
+ "type": "string"
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string"
+ },
+ "scope-type": {
+ "required": true,
+ "type": "string"
+ },
+ "action-name": {
+ "required": true,
+ "type": "string"
+ },
+ "hostname": {
+ "required": true,
+ "type": "string"
+ }
+ },
+ "node_templates": {
+ "vpe-netconf-device": {
+ "capabilities": {
+ "netconf": {
+ "properties": {
+ "login-key": "sdnc",
+ "login-account": "sndc-local",
+ "source": "local",
+ "target-ip-address": "{\"get_attribute\":\"lo0-local-ipv4-address\"}",
+ "port-number": 22,
+ "connection-time-out": 30
+ }
+ }
+ },
+ "type": "vnf-netconf-device"
+ },
+ "activate-netconf-component": {
+ "capabilities": {
+ "component-node": {}
+ },
+ "requirements": {
+ "netconf-connection": {
+ "capability": "netconf",
+ "node": "vpe-netconf-device",
+ "relationship": "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces": {
+ "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "action-name": "{ \"get_input\" : \"action-name\" }",
+ "template_name": "{ \"get_attribute\" : \"template_name\" }",
+ "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }",
+ "resource-type": "vnf-type",
+ "request-id": "{ \"get_input\" : \"request-id\" }",
+ "resource-id": "{ \"get_input\" : \"hostname\" }",
+ "execution-script": "execution-script"
+ },
+ "outputs": {
+ "response-data": "{ \"get_attribute\" : \"netconf-executor-baseconfig.response-data\" }",
+ "status": "{ \"get_attribute\" : \"netconf-executor-baseconfig.status\" }"
+ },
+ "implementation" : {
+ "primary" : "file://netconf_adaptor/DefaultBaseLicenceConfig.py"
+ }
+ }
+ }
+ }
+ },
+ "type": "component-netconf-executor"
+ },
+ "resource-assignment-ra-component": {
+ "capabilities": {
+ "component-node": {}
+ },
+ "interfaces": {
+ "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "template-names": [
+ "base-config-template",
+ "licence-template"
+ ],
+ "action-name": "{ \"get_input\" : \"action-name\" }",
+ "service-template-name": "{ \"get_attribute\" : \"template_name\" }",
+ "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }",
+ "resource-type": "vnf-type",
+ "request-id": "{ \"get_input\" : \"request-id\" }",
+ "resource-id": "{ \"get_input\" : \"hostname\" }"
+ },
+ "outputs": {
+ "resource-assignment-params": "success",
+ "status": "status"
+ }
+ }
+ }
+ }
+ },
+ "type": "component-resource-assignment"
+ },
+ "resource-assignment-action": {
+ "properties": {
+ "mode": "sync",
+ "version": "LATEST",
+ "is-start-flow": "false"
+ },
+ "requirements": {
+ "component-dependency": {
+ "capability": "component-node",
+ "node": "resource-assignment-ra-component",
+ "relationship": "tosca.relationships.DependsOn"
+ }
+ },
+ "capabilities": {
+ "dg-node": {},
+ "content": {
+ "properties": {
+ "type": "json"
+ }
+ }
+ },
+ "interfaces": {
+ "CONFIG": {
+ "operations": {
+ "ResourceAssignment": {
+ "inputs": {
+ "params": []
+ }
+ }
+ }
+ }
+ },
+ "type": "dg-resource-assignment"
+ },
+ "activate-action": {
+ "properties": {
+ "mode": "sync",
+ "version": "LATEST",
+ "is-start-flow": "false"
+ },
+ "requirements": {
+ "component-dependency": {
+ "capability": "component-node",
+ "node": "activate-netconf-component",
+ "relationship": "tosca.relationships.DependsOn"
+ }
+ },
+ "capabilities": {
+ "dg-node": {},
+ "content": {
+ "properties": {
+ "type": "json"
+ }
+ }
+ },
+ "interfaces": {
+ "CONFIG": {
+ "operations": {
+ "ActivateNetconf": {
+ "inputs": {
+ "params": []
+ }
+ }
+ }
+ }
+ },
+ "type": "dg-activate-netconf"
+ },
+ "base-config-template": {
+ "capabilities": {
+ "content": {
+ "properties": {
+ "content": "db://base-config-template"
+ }
+ },
+ "mapping": {
+ "properties": {
+ "mapping": [
+ {
+ "name": "bundle-mac",
+ "property": {
+ "description": "",
+ "required": true,
+ "type": "string",
+ "status": "",
+ "constraints": [
+ {}
+ ],
+ "entry_schema": {
+ "type": ""
+ }
+ },
+ "input-param": false,
+ "dictionary-name": "bundle-mac",
+ "dictionary-source": "db",
+ "dependencies": [
+ "hostname"
+ ],
+ "version": 0
+ },
+ {
+ "name": "wan-aggregate-ipv4-addresses",
+ "property": {
+ "description": "",
+ "required": true,
+ "type": "list",
+ "status": "",
+ "constraints": [
+ {}
+ ],
+ "entry_schema": {
+ "type": "dt-v4-aggregate"
+ }
+ },
+ "input-param": false,
+ "dictionary-name": "wan-aggregate-ipv4-addresses",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "service-instance-id",
+ "oam-network-role",
+ "oam-v4-ip-type ",
+ "oam-vm-type"
+ ],
+ "version": 0
+ },
+ {
+ "name": "hostname",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "dictionary-name": "hostname",
+ "dictionary-source": "input",
+ "version": 0,
+ "input-param": false
+ },
+ {
+ "name": "service",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "dictionary-name": "service",
+ "dictionary-source": "input",
+ "version": 0,
+ "input-param": false
+ },
+ {
+ "name": "service-instance-id",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "version": 0,
+ "input-param": false
+ }
+ ]
+ }
+ }
+ },
+ "properties": {
+ "action-names": [
+ "resource-assignment-action"
+ ]
+ },
+ "type": "artifact-config-template"
+ },
+ "licence-template": {
+ "capabilities": {
+ "content": {
+ "properties": {
+ "content": "db://licence-template"
+ }
+ },
+ "mapping": {
+ "properties": {
+ "mapping": [
+ {
+ "name": "licenses",
+ "property": {
+ "description": "",
+ "required": true,
+ "type": "list",
+ "status": "",
+ "constraints": [
+ {}
+ ],
+ "entry_schema": {
+ "type": "dt-license-key"
+ }
+ },
+ "input-param": false,
+ "dictionary-name": "licenses",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "service-instance-id"
+ ],
+ "version": 0
+ },
+ {
+ "name": "service-instance-id",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "version": 0,
+ "input-param": false
+ }
+ ]
+ }
+ }
+ },
+ "properties": {
+ "action-names": [
+ "resource-assignment-action"
+ ]
+ },
+ "type": "artifact-config-template"
+ }
+ }
+ },
+ "node_types": {
+ },
+ "data_types": {
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json
new file mode 100644
index 00000000..18f49925
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json
@@ -0,0 +1,824 @@
+{
+ "metadata" : {
+ "template_author" : "Brinda Santh",
+ "template_name" : "enhance-template",
+ "template_version" : "1.0.0",
+ "service-type" : "Sample Service",
+ "release" : "1806",
+ "vnf-type" : "VPE"
+ },
+ "tosca_definitions_version" : "controller_blueprint_1_0_0",
+ "artifact_types" : { },
+ "data_types" : {
+ "dt-v4-aggregate" : {
+ "description" : "This is dt-v4-aggregate Data Type",
+ "version" : "1.0.0",
+ "properties" : {
+ "ipv4-address" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "ipv4-plen" : {
+ "required" : false,
+ "type" : "integer"
+ }
+ },
+ "derived_from" : "tosca.datatypes.Root"
+ },
+ "dt-license-key" : {
+ "description" : "This is dt-plicense-key Data Type",
+ "version" : "1.0.0",
+ "properties" : {
+ "license-key" : {
+ "required" : true,
+ "type" : "string"
+ }
+ },
+ "derived_from" : "tosca.datatypes.Root"
+ },
+ "datatype-resource-assignment" : {
+ "description" : "This is Resource Assignment Data Type",
+ "version" : "1.0.0",
+ "properties" : {
+ "property" : {
+ "required" : true,
+ "type" : "datatype-property"
+ },
+ "input-param" : {
+ "required" : true,
+ "type" : "boolean"
+ },
+ "dictionary-name" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "dictionary-source" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ },
+ "status" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "message" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "updated-date" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "updated-by" : {
+ "required" : false,
+ "type" : "string"
+ }
+ },
+ "derived_from" : "tosca.datatypes.Root"
+ },
+ "datatype-property" : {
+ "description" : "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",
+ "version" : "1.0.0",
+ "properties" : {
+ "type" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "description" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "required" : {
+ "required" : false,
+ "type" : "boolean"
+ },
+ "default" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "entry_schema" : {
+ "required" : false,
+ "type" : "string"
+ }
+ },
+ "derived_from" : "tosca.datatypes.Root"
+ },
+ "dt-resource-assignment-request" : {
+ "description" : "This is Dynamic Data type definition generated from resource mapping for the config template name base-config-template.",
+ "version" : "1.0.0",
+ "properties" : {
+ "bundle-mac" : {
+ "description" : "",
+ "required" : true,
+ "type" : "string",
+ "status" : "",
+ "constraints" : [ { } ],
+ "entry_schema" : {
+ "type" : ""
+ }
+ },
+ "hostname" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "licenses" : {
+ "description" : "",
+ "required" : true,
+ "type" : "list",
+ "status" : "",
+ "constraints" : [ { } ],
+ "entry_schema" : {
+ "type" : "dt-license-key"
+ }
+ },
+ "wan-aggregate-ipv4-addresses" : {
+ "description" : "",
+ "required" : true,
+ "type" : "list",
+ "status" : "",
+ "constraints" : [ { } ],
+ "entry_schema" : {
+ "type" : "dt-v4-aggregate"
+ }
+ },
+ "service" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "service-instance-id" : {
+ "required" : true,
+ "type" : "string"
+ }
+ },
+ "derived_from" : "tosca.datatypes.Dynamic"
+ }
+ },
+ "node_types" : {
+ "dg-resource-assignment" : {
+ "description" : "This is Resource Assignment Directed Graph",
+ "version" : "1.0.0",
+ "properties" : {
+ "mode" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "sync"
+ },
+ "version" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "LATEST"
+ },
+ "is-start-flow" : {
+ "required" : false,
+ "type" : "boolean",
+ "default" : "false"
+ }
+ },
+ "capabilities" : {
+ "dg-node" : {
+ "type" : "tosca.capabilities.Node"
+ },
+ "content" : {
+ "type" : "tosca.capability.Content",
+ "properties" : {
+ "type" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "json"
+ },
+ "content" : {
+ "required" : false,
+ "type" : "string"
+ }
+ }
+ }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "component-resource-assignment",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ResourceAssignment" : {
+ "inputs" : {
+ "params" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-property"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.DG"
+ },
+ "component-resource-assignment" : {
+ "description" : "This is Resource Assignment Component API",
+ "version" : "1.0.0",
+ "capabilities" : {
+ "component-node" : {
+ "type" : "tosca.capabilities.Node"
+ }
+ },
+ "interfaces" : {
+ "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode" : {
+ "operations" : {
+ "process" : {
+ "inputs" : {
+ "service-template-name" : {
+ "description" : "Service Template Name.",
+ "required" : true,
+ "type" : "string"
+ },
+ "service-template-version" : {
+ "description" : "Service Template Version.",
+ "required" : true,
+ "type" : "string"
+ },
+ "resource-type" : {
+ "description" : "Request type.",
+ "required" : true,
+ "type" : "string"
+ },
+ "template-names" : {
+ "description" : "Name of the artifact Node Templates, to get the template Content.",
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ },
+ "request-id" : {
+ "description" : "Request Id, Unique Id for the request.",
+ "required" : true,
+ "type" : "string"
+ },
+ "resource-id" : {
+ "description" : "Resource Id.",
+ "required" : true,
+ "type" : "string"
+ },
+ "action-name" : {
+ "description" : "Action Name of the process",
+ "required" : true,
+ "type" : "string"
+ }
+ },
+ "outputs" : {
+ "resource-assignment-params" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "status" : {
+ "required" : true,
+ "type" : "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Component"
+ },
+ "artifact-config-template" : {
+ "description" : "This is Configuration Velocity Template",
+ "version" : "1.0.0",
+ "properties" : {
+ "action-names" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "capabilities" : {
+ "content" : {
+ "type" : "tosca.capability.Content",
+ "properties" : {
+ "content" : {
+ "required" : true,
+ "type" : "string"
+ }
+ }
+ },
+ "mapping" : {
+ "type" : "tosca.capability.Mapping",
+ "properties" : {
+ "mapping" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-resource-assignment"
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Artifact"
+ },
+ "vnf-netconf-device" : {
+ "description" : "This is VNF Device with Netconf Capability",
+ "version" : "1.0.0",
+ "capabilities" : {
+ "netconf" : {
+ "type" : "tosca.capability.Netconf",
+ "properties" : {
+ "login-key" : {
+ "required" : true,
+ "type" : "string",
+ "default" : "sdnc"
+ },
+ "login-account" : {
+ "required" : true,
+ "type" : "string",
+ "default" : "sdnc-tacacs"
+ },
+ "source" : {
+ "required" : true,
+ "type" : "string",
+ "default" : "npm"
+ },
+ "target-ip-address" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "port-number" : {
+ "required" : true,
+ "type" : "integer",
+ "default" : 830
+ },
+ "connection-time-out" : {
+ "required" : false,
+ "type" : "integer",
+ "default" : 30
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Vnf"
+ },
+ "component-netconf-executor" : {
+ "description" : "This is Netconf Transaction Configuration Component API",
+ "version" : "1.0.0",
+ "capabilities" : {
+ "component-node" : {
+ "type" : "tosca.capabilities.Node"
+ }
+ },
+ "requirements" : {
+ "netconf-connection" : {
+ "capability" : "netconf",
+ "node" : "vnf-netconf-device",
+ "relationship" : "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces" : {
+ "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode" : {
+ "operations" : {
+ "process" : {
+ "inputs" : {
+ "request-id" : {
+ "description" : "Request Id used to store the generated configuration, in the database along with the template-name",
+ "required" : true,
+ "type" : "string"
+ },
+ "service-template-name" : {
+ "description" : "Service Template Name",
+ "required" : true,
+ "type" : "string"
+ },
+ "service-template-version" : {
+ "description" : "Service Template Version",
+ "required" : true,
+ "type" : "string"
+ },
+ "action-name" : {
+ "description" : "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
+ "required" : false,
+ "type" : "string"
+ },
+ "resource-type" : {
+ "description" : "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
+ "required" : false,
+ "type" : "string"
+ },
+ "resource-id" : {
+ "description" : "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
+ "required" : false,
+ "type" : "string"
+ },
+ "reservation-id" : {
+ "description" : "Reservation Id used to send to NPM",
+ "required" : false,
+ "type" : "string"
+ },
+ "execution-script" : {
+ "description" : "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.",
+ "required" : true,
+ "type" : "string"
+ }
+ },
+ "outputs" : {
+ "response-data" : {
+ "description" : "Execution Response Data in JSON format.",
+ "required" : false,
+ "type" : "string"
+ },
+ "status" : {
+ "description" : "Status of the Component Execution ( success or failure )",
+ "required" : true,
+ "type" : "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Component"
+ },
+ "dg-activate-netconf" : {
+ "description" : "This is Download Netconf Directed Graph",
+ "version" : "1.0.0",
+ "properties" : {
+ "mode" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "sync"
+ },
+ "version" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "LATEST"
+ },
+ "is-start-flow" : {
+ "required" : false,
+ "type" : "boolean",
+ "default" : "false"
+ }
+ },
+ "capabilities" : {
+ "dg-node" : {
+ "type" : "tosca.capabilities.Node"
+ },
+ "content" : {
+ "type" : "tosca.capability.Content",
+ "properties" : {
+ "type" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "json"
+ },
+ "content" : {
+ "required" : true,
+ "type" : "string"
+ }
+ }
+ }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "component-netconf-executor",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ActivateNetconf" : {
+ "inputs" : {
+ "params" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-property"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.DG"
+ }
+ },
+ "topology_template" : {
+ "inputs" : {
+ "request-id" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "service-instance-id" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "scope-type" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "action-name" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "hostname" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "resource-assignment-request" : {
+ "description" : "This is Dynamic Data type for the receipe resource-assignment-action.",
+ "required" : false,
+ "type" : "dt-resource-assignment-request"
+ }
+ },
+ "node_templates" : {
+ "vpe-netconf-device" : {
+ "type" : "vnf-netconf-device",
+ "capabilities" : {
+ "netconf" : {
+ "properties" : {
+ "login-key" : "sdnc",
+ "login-account" : "sndc-local",
+ "source" : "local",
+ "target-ip-address" : "{\"get_attribute\":\"lo0-local-ipv4-address\"}",
+ "port-number" : 22,
+ "connection-time-out" : 30
+ }
+ }
+ }
+ },
+ "activate-netconf-component" : {
+ "type" : "component-netconf-executor",
+ "capabilities" : {
+ "component-node" : { }
+ },
+ "requirements" : {
+ "netconf-connection" : {
+ "capability" : "netconf",
+ "node" : "vpe-netconf-device",
+ "relationship" : "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces" : {
+ "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode" : {
+ "operations" : {
+ "process" : {
+ "implementation" : {
+ "primary" : "file://netconf_adaptor/DefaultBaseLicenceConfig.py"
+ },
+ "inputs" : {
+ "action-name" : "{ \"get_input\" : \"action-name\" }",
+ "template_name" : "{ \"get_attribute\" : \"template_name\" }",
+ "service-template-version" : "{ \"get_attribute\" : \"service-template-version\" }",
+ "resource-type" : "vnf-type",
+ "request-id" : "{ \"get_input\" : \"request-id\" }",
+ "resource-id" : "{ \"get_input\" : \"hostname\" }",
+ "execution-script" : "execution-script"
+ },
+ "outputs" : {
+ "response-data" : "{ \"get_attribute\" : \"netconf-executor-baseconfig.response-data\" }",
+ "status" : "{ \"get_attribute\" : \"netconf-executor-baseconfig.status\" }"
+ }
+ }
+ }
+ }
+ }
+ },
+ "resource-assignment-ra-component" : {
+ "type" : "component-resource-assignment",
+ "capabilities" : {
+ "component-node" : { }
+ },
+ "interfaces" : {
+ "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode" : {
+ "operations" : {
+ "process" : {
+ "inputs" : {
+ "template-names" : [ "base-config-template", "licence-template" ],
+ "action-name" : "{ \"get_input\" : \"action-name\" }",
+ "service-template-name" : "{ \"get_attribute\" : \"template_name\" }",
+ "service-template-version" : "{ \"get_attribute\" : \"service-template-version\" }",
+ "resource-type" : "vnf-type",
+ "request-id" : "{ \"get_input\" : \"request-id\" }",
+ "resource-id" : "{ \"get_input\" : \"hostname\" }"
+ },
+ "outputs" : {
+ "resource-assignment-params" : "success",
+ "status" : "status"
+ }
+ }
+ }
+ }
+ }
+ },
+ "resource-assignment-action" : {
+ "type" : "dg-resource-assignment",
+ "properties" : {
+ "mode" : "sync",
+ "version" : "LATEST",
+ "is-start-flow" : "false"
+ },
+ "capabilities" : {
+ "dg-node" : { },
+ "content" : {
+ "properties" : {
+ "type" : "json"
+ }
+ }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "resource-assignment-ra-component",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ResourceAssignment" : {
+ "inputs" : {
+ "params" : [ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "activate-action" : {
+ "type" : "dg-activate-netconf",
+ "properties" : {
+ "mode" : "sync",
+ "version" : "LATEST",
+ "is-start-flow" : "false"
+ },
+ "capabilities" : {
+ "dg-node" : { },
+ "content" : {
+ "properties" : {
+ "type" : "json"
+ }
+ }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "activate-netconf-component",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ActivateNetconf" : {
+ "inputs" : {
+ "params" : [ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "base-config-template" : {
+ "type" : "artifact-config-template",
+ "properties" : {
+ "action-names" : [ "resource-assignment-action" ]
+ },
+ "capabilities" : {
+ "content" : {
+ "properties" : {
+ "content" : "db://base-config-template"
+ }
+ },
+ "mapping" : {
+ "properties" : {
+ "mapping" : [ {
+ "name" : "bundle-mac",
+ "property" : {
+ "description" : "",
+ "required" : true,
+ "type" : "string",
+ "status" : "",
+ "constraints" : [ { } ],
+ "entry_schema" : {
+ "type" : ""
+ }
+ },
+ "input-param" : false,
+ "dictionary-name" : "bundle-mac",
+ "dictionary-source" : "db",
+ "dependencies" : [ "hostname" ],
+ "version" : 0
+ }, {
+ "name" : "wan-aggregate-ipv4-addresses",
+ "property" : {
+ "description" : "",
+ "required" : true,
+ "type" : "list",
+ "status" : "",
+ "constraints" : [ { } ],
+ "entry_schema" : {
+ "type" : "dt-v4-aggregate"
+ }
+ },
+ "input-param" : false,
+ "dictionary-name" : "wan-aggregate-ipv4-addresses",
+ "dictionary-source" : "mdsal",
+ "dependencies" : [ "service-instance-id", "oam-network-role", "oam-v4-ip-type ", "oam-vm-type" ],
+ "version" : 0
+ }, {
+ "name" : "hostname",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dictionary-name" : "hostname",
+ "dictionary-source" : "input",
+ "version" : 0,
+ "input-param" : false
+ }, {
+ "name" : "service",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dictionary-name" : "service",
+ "dictionary-source" : "input",
+ "version" : 0,
+ "input-param" : false
+ }, {
+ "name" : "service-instance-id",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dictionary-name" : "service-instance-id",
+ "dictionary-source" : "input",
+ "version" : 0,
+ "input-param" : false
+ } ]
+ }
+ }
+ }
+ },
+ "licence-template" : {
+ "type" : "artifact-config-template",
+ "properties" : {
+ "action-names" : [ "resource-assignment-action" ]
+ },
+ "capabilities" : {
+ "content" : {
+ "properties" : {
+ "content" : "db://licence-template"
+ }
+ },
+ "mapping" : {
+ "properties" : {
+ "mapping" : [ {
+ "name" : "licenses",
+ "property" : {
+ "description" : "",
+ "required" : true,
+ "type" : "list",
+ "status" : "",
+ "constraints" : [ { } ],
+ "entry_schema" : {
+ "type" : "dt-license-key"
+ }
+ },
+ "input-param" : false,
+ "dictionary-name" : "licenses",
+ "dictionary-source" : "mdsal",
+ "dependencies" : [ "service-instance-id" ],
+ "version" : 0
+ }, {
+ "name" : "service-instance-id",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dictionary-name" : "service-instance-id",
+ "dictionary-source" : "input",
+ "version" : 0,
+ "input-param" : false
+ } ]
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json
new file mode 100644
index 00000000..a85e7155
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json
@@ -0,0 +1,11 @@
+[
+ {
+ "name": "action-name"
+ },
+ {
+ "name": "v4-ip-type"
+ },
+ {
+ "name": "bundle-id"
+ }
+] \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json
new file mode 100644
index 00000000..2b392054
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json
@@ -0,0 +1,19 @@
+{
+ "name": "v4-aggregat-list",
+ "description": "This collection v4-aggregate list",
+ "valid-values": null,
+ "sample-value": null,
+ "updated-by": "Brinda Santh (bs2796)",
+ "resource-type": "ONAP",
+ "resource-path": "/v4-aggregat-list",
+ "data-type": "list",
+ "entry-schema": "dt-v4-aggregate",
+ "tags": null,
+ "default": null,
+ "source": {
+ "input": {
+
+ }
+ },
+ "candidate-dependency": null
+} \ No newline at end of file