diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-03-25 13:04:18 -0400 |
---|---|---|
committer | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-03-25 13:41:44 -0400 |
commit | c90edac236dffb7c495e266dd04991de7e8f04b7 (patch) | |
tree | 103bb4d0870101ff61442f6b0fe291d1ad53b950 /ms/controllerblueprints/modules/service/src/main/java | |
parent | ffb6bdfd6de2afa23d95d0884c9db4059982deed (diff) |
Migrate ccsdk/apps to ccsdk/cds
Issue-ID: CCSDK-1177
Issue-ID: CCSDK-1178
Change-Id: I0c02702fbec52211ca367abbba72aebecee8cbaa
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/main/java')
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/ApplicationRegistrationService.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java) | 112 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java) | 420 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/SchemaGeneratorService.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java) | 232 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/common/ErrorMessage.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java) | 148 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SwaggerGenerator.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java) | 370 | ||||
-rwxr-xr-x | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModel.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModel.java) | 569 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModelContent.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelContent.java) | 340 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModelSearch.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelSearch.java) | 332 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/JpaJsonNodeConverter.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java) | 78 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java) | 78 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/ModelType.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java) | 342 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/ResourceDictionary.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java) | 316 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/model/AutoMapResponse.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java) | 106 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java) | 4 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java) | 138 |
15 files changed, 1793 insertions, 1792 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/ApplicationRegistrationService.java index fc7410f96..1e7109262 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/ApplicationRegistrationService.java @@ -1,56 +1,56 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.apache.commons.collections.CollectionUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import java.util.List;
-
-@Component
-@SuppressWarnings("unused")
-public class ApplicationRegistrationService {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationRegistrationService.class);
-
- @Value("#{'${resourceSourceMappings}'.split(',')}")
- private List<String> resourceSourceMappings;
-
- @PostConstruct
- public void register() {
- registerDictionarySources();
- }
-
- public void registerDictionarySources() {
- log.info("Registering Dictionary Sources : {}", resourceSourceMappings);
- if (CollectionUtils.isNotEmpty(resourceSourceMappings)) {
- resourceSourceMappings.forEach(resourceSourceMapping -> {
- String[] mappingKeyValue = resourceSourceMapping.split("=");
- if (mappingKeyValue != null && mappingKeyValue.length == 2) {
- ResourceSourceMappingFactory.INSTANCE.registerSourceMapping(mappingKeyValue[0].trim(), mappingKeyValue[1].trim());
- } else {
- log.warn("failed to get resource source mapping {}", resourceSourceMapping);
- }
- });
- }
- }
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.controllerblueprints.service; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.apache.commons.collections.CollectionUtils; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.List; + +@Component +@SuppressWarnings("unused") +public class ApplicationRegistrationService { + private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationRegistrationService.class); + + @Value("#{'${resourceSourceMappings}'.split(',')}") + private List<String> resourceSourceMappings; + + @PostConstruct + public void register() { + registerDictionarySources(); + } + + public void registerDictionarySources() { + log.info("Registering Dictionary Sources : {}", resourceSourceMappings); + if (CollectionUtils.isNotEmpty(resourceSourceMappings)) { + resourceSourceMappings.forEach(resourceSourceMapping -> { + String[] mappingKeyValue = resourceSourceMapping.split("="); + if (mappingKeyValue != null && mappingKeyValue.length == 2) { + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping(mappingKeyValue[0].trim(), mappingKeyValue[1].trim()); + } else { + log.warn("failed to get resource source mapping {}", resourceSourceMapping); + } + }); + } + } +} 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/cds/controllerblueprints/service/AutoResourceMappingService.java index 1965ac901..c04c0dcf4 100644 --- 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/cds/controllerblueprints/service/AutoResourceMappingService.java @@ -1,210 +1,210 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.base.Preconditions;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
-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.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
-@SuppressWarnings("unused")
-public class AutoResourceMappingService {
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(AutoResourceMappingService.class);
-
- private ResourceDictionaryRepository dataDictionaryRepository;
-
- /**
- * This is a AutoResourceMappingService constructor
- *
- * @param dataDictionaryRepository dataDictionaryRepository
- */
- public AutoResourceMappingService(ResourceDictionaryRepository dataDictionaryRepository) {
- this.dataDictionaryRepository = dataDictionaryRepository;
- }
-
- /**
- * This is a autoMap service to map the template keys automatically to Dictionary fields.
- *
- * @param resourceAssignments 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);
-
- }
- }
- }
- 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 && dbDataDictionary.getDefinition() != null) {
-
- ResourceDefinition dictionaryDefinition = dbDataDictionary.getDefinition();
-
- 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<>();
- 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(resourceAssignments, dependencieName)) {
- names.add(dependencieName);
- }
- }
- }
- }
- }
-
- if (!names.isEmpty()) {
- dictionaries = dataDictionaryRepository.findByNameIn(names);
- }
- if (dictionaries != null) {
- for (ResourceDictionary resourcedictionary : dictionaries) {
- ResourceDefinition dictionaryDefinition = resourcedictionary.getDefinition();
- Preconditions.checkNotNull(dictionaryDefinition, "failed to get Resource Definition from dictionary definition");
- 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);
- resourceAssignments.add(resourceAssignment);
- }
- }
- return resourceAssignments;
-
- }
-
-
- private boolean checkAssignmentsExists(List<ResourceAssignment> resourceAssignmentsWithDepencies, String resourceName) {
- return resourceAssignmentsWithDepencies.stream().anyMatch(names -> names.getName().equalsIgnoreCase(resourceName));
- }
-
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.controllerblueprints.service; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.base.Preconditions; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils; +import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary; +import org.onap.ccsdk.cds.controllerblueprints.service.model.AutoMapResponse; +import org.onap.ccsdk.cds.controllerblueprints.service.repository.ResourceDictionaryRepository; +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 +@SuppressWarnings("unused") +public class AutoResourceMappingService { + + private static EELFLogger log = EELFManager.getInstance().getLogger(AutoResourceMappingService.class); + + private ResourceDictionaryRepository dataDictionaryRepository; + + /** + * This is a AutoResourceMappingService constructor + * + * @param dataDictionaryRepository dataDictionaryRepository + */ + public AutoResourceMappingService(ResourceDictionaryRepository dataDictionaryRepository) { + this.dataDictionaryRepository = dataDictionaryRepository; + } + + /** + * This is a autoMap service to map the template keys automatically to Dictionary fields. + * + * @param resourceAssignments 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); + + } + } + } + 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 && dbDataDictionary.getDefinition() != null) { + + ResourceDefinition dictionaryDefinition = dbDataDictionary.getDefinition(); + + 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<>(); + 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(resourceAssignments, dependencieName)) { + names.add(dependencieName); + } + } + } + } + } + + if (!names.isEmpty()) { + dictionaries = dataDictionaryRepository.findByNameIn(names); + } + if (dictionaries != null) { + for (ResourceDictionary resourcedictionary : dictionaries) { + ResourceDefinition dictionaryDefinition = resourcedictionary.getDefinition(); + Preconditions.checkNotNull(dictionaryDefinition, "failed to get Resource Definition from dictionary definition"); + 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); + resourceAssignments.add(resourceAssignment); + } + } + return resourceAssignments; + + } + + + private 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/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/SchemaGeneratorService.java index 3a1535ac0..6c09ef8cd 100644 --- 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/cds/controllerblueprints/service/SchemaGeneratorService.java @@ -1,116 +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.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-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 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
- */
-@Deprecated
-public class SchemaGeneratorService {
- private static EELFLogger log = EELFManager.getInstance().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.Companion.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;
- });
- }
-
- }
- }
-
-}
+/* + * 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.cds.controllerblueprints.service; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.base.Preconditions; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType; +import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate; +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.cds.controllerblueprints.service.common.SwaggerGenerator; + +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 + */ +@Deprecated +public class SchemaGeneratorService { + private static EELFLogger log = EELFManager.getInstance().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.Companion.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/common/ErrorMessage.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/common/ErrorMessage.java index 5486262f6..155a162b6 100644 --- 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/cds/controllerblueprints/service/common/ErrorMessage.java @@ -1,75 +1,75 @@ -/*
- * 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.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.annotation.JsonTypeName;
-
-import java.io.Serializable;
-import java.util.Date;
-
-@JsonInclude(Include.NON_NULL)
-@JsonTypeName("errorMessage")
-@JsonTypeInfo(include= JsonTypeInfo.As.WRAPPER_OBJECT, use=JsonTypeInfo.Id.NAME)
-public class ErrorMessage implements Serializable {
- private String message;
- private Integer code;
- private String debugMessage;
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- private Date timestamp = new Date();
-
- public ErrorMessage(String message, Integer code, String debugMessage){
- this.message = message;
- this.code = code;
- this.debugMessage = debugMessage;
- }
-
- 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 getDebugMessage() {
- return debugMessage;
- }
-
- public void setDebugMessage(String developerMessage) {
- this.debugMessage = developerMessage;
- }
-
- public Date getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(Date timestamp) {
- this.timestamp = timestamp;
- }
+/* + * 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.cds.controllerblueprints.service.common; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.io.Serializable; +import java.util.Date; + +@JsonInclude(Include.NON_NULL) +@JsonTypeName("errorMessage") +@JsonTypeInfo(include= JsonTypeInfo.As.WRAPPER_OBJECT, use=JsonTypeInfo.Id.NAME) +public class ErrorMessage implements Serializable { + private String message; + private Integer code; + private String debugMessage; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + private Date timestamp = new Date(); + + public ErrorMessage(String message, Integer code, String debugMessage){ + this.message = message; + this.code = code; + this.debugMessage = debugMessage; + } + + 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 getDebugMessage() { + return debugMessage; + } + + public void setDebugMessage(String developerMessage) { + this.debugMessage = developerMessage; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } }
\ 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/cds/controllerblueprints/service/common/SwaggerGenerator.java index 77de8e7cf..abf774981 100644 --- 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/cds/controllerblueprints/service/common/SwaggerGenerator.java @@ -1,185 +1,185 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.common;
-
-import io.swagger.models.*;
-import io.swagger.models.parameters.BodyParameter;
-import io.swagger.models.parameters.Parameter;
-import io.swagger.models.properties.*;
-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;
- public static final String INPUTS="inputs";
-
- /**
- * This is a SwaggerGenerator constructor
- */
- public SwaggerGenerator(ServiceTemplate serviceTemplate) {
- this.serviceTemplate = serviceTemplate;
- }
-
- /**
- * This is a generateSwagger
- *
- * @return String
- */
- public String generateSwagger() {
-
- Swagger swagger = new Swagger().info(getInfo());
-
- swagger.setPaths(getPaths());
- swagger.setDefinitions(getDefinition());
-
-
- return swagger.toString();
- }
-
- 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());
- 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;
- }
-
-
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.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 org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.BooleanUtils; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes; +import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition; +import org.onap.ccsdk.cds.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; + public static final String INPUTS="inputs"; + + /** + * This is a SwaggerGenerator constructor + */ + public SwaggerGenerator(ServiceTemplate serviceTemplate) { + this.serviceTemplate = serviceTemplate; + } + + /** + * This is a generateSwagger + * + * @return String + */ + public String generateSwagger() { + + Swagger swagger = new Swagger().info(getInfo()); + + swagger.setPaths(getPaths()); + swagger.setDefinitions(getDefinition()); + + + return swagger.toString(); + } + + 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()); + 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/BlueprintModel.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModel.java index 245e4a80a..916e94b4e 100755 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModel.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModel.java @@ -1,284 +1,285 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 Bell Canada.
- *
- * 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 io.swagger.annotations.ApiModelProperty;
-import org.hibernate.annotations.Proxy;
-import org.springframework.data.annotation.LastModifiedDate;
-import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-
-import javax.persistence.*;
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * BlueprintModel.java Purpose: Provide Configuration Generator BlueprintModel Entity
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-@EntityListeners({AuditingEntityListener.class})
-@Entity
-@Table(name = "CONFIG_MODEL", uniqueConstraints=@UniqueConstraint(columnNames={"artifact_name","artifact_version"}))
-@Proxy(lazy=false)
-public class BlueprintModel implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @Column(name = "config_model_id")
- private String 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;
-
- @Column(name = "artifact_version", nullable = false)
- @ApiModelProperty(required=true)
- private String artifactVersion;
-
- @Lob
- @Column(name = "artifact_description")
- private String artifactDescription;
-
- @Column(name = "internal_version")
- private Integer internalVersion;
-
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- @LastModifiedDate
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "creation_date")
- private Date createdDate = new Date();
-
- @Column(name = "artifact_name", nullable = false)
- @ApiModelProperty(required=true)
- private String artifactName;
-
- @Column(name = "published", nullable = false)
- @ApiModelProperty(required=true)
- private String published;
-
- @Column(name = "updated_by", nullable = false)
- @ApiModelProperty(required=true)
- private String updatedBy;
-
- @Lob
- @Column(name = "tags", nullable = false)
- @ApiModelProperty(required=true)
- private String tags;
-
- @OneToOne(mappedBy = "blueprintModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
- private BlueprintModelContent blueprintModelContent;
-
- public String getId() {
- return id;
- }
-
- public void setId(String 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 BlueprintModelContent getBlueprintModelContent() {
- return blueprintModelContent;
- }
-
- public void setBlueprintModelContent(BlueprintModelContent blueprintModelContent) {
- this.blueprintModelContent = blueprintModelContent;
- }
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 Bell Canada. + * + * 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.cds.controllerblueprints.service.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.Proxy; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +/** + * BlueprintModel.java Purpose: Provide Configuration Generator BlueprintModel Entity + * + * @author Brinda Santh + * @version 1.0 + */ + +@EntityListeners({AuditingEntityListener.class}) +@Entity +@Table(name = "CONFIG_MODEL", uniqueConstraints=@UniqueConstraint(columnNames={"artifact_name","artifact_version"})) +@Proxy(lazy=false) +public class BlueprintModel implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Column(name = "config_model_id") + private String 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; + + @Column(name = "artifact_version", nullable = false) + @ApiModelProperty(required=true) + private String artifactVersion; + + @Lob + @Column(name = "artifact_description") + private String artifactDescription; + + @Column(name = "internal_version") + private Integer internalVersion; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "creation_date") + private Date createdDate = new Date(); + + @Column(name = "artifact_name", nullable = false) + @ApiModelProperty(required=true) + private String artifactName; + + @Column(name = "published", nullable = false) + @ApiModelProperty(required=true) + private String published; + + @Column(name = "updated_by", nullable = false) + @ApiModelProperty(required=true) + private String updatedBy; + + @Lob + @Column(name = "tags", nullable = false) + @ApiModelProperty(required=true) + private String tags; + + @OneToOne(mappedBy = "blueprintModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL) + private org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelContent blueprintModelContent; + + public String getId() { + return id; + } + + public void setId(String 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 org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelContent getBlueprintModelContent() { + return blueprintModelContent; + } + + public void setBlueprintModelContent( + org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelContent blueprintModelContent) { + this.blueprintModelContent = blueprintModelContent; + } +} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModelContent.java index 0bfa0f124..20a1fdcdf 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelContent.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModelContent.java @@ -1,170 +1,170 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 Bell Canada.
- *
- * 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 io.swagger.annotations.ApiModelProperty;
-import org.springframework.data.annotation.LastModifiedDate;
-import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-
-import javax.persistence.*;
-import java.io.Serializable;
-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 BlueprintModelContent implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Id
- @Column(name = "config_model_content_id")
- private String id;
-
- @Column(name = "name", nullable = false)
- @ApiModelProperty(required=true)
- private String name;
-
- @Column(name = "content_type", nullable = false)
- @ApiModelProperty(required=true)
- private String contentType;
-
- @OneToOne
- @JoinColumn(name = "config_model_id")
- private BlueprintModel blueprintModel;
-
- @Lob
- @Column(name = "description")
- private String description;
-
- @Lob
- @Column(name = "content", nullable = false)
- @ApiModelProperty(required=true)
- private byte[] content;
-
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- @LastModifiedDate
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "updated_date")
- private Date creationDate = new Date();
-
- @Override
- public String toString() {
- return "[" + "id = " + id +
- ", name = " + name +
- ", contentType = " + contentType +
- "]";
- }
-
- @Override
- public boolean equals(Object o) {
-
- if (o == this) {
- return true;
- }
- if (!(o instanceof BlueprintModelContent)) {
- return false;
- }
- BlueprintModelContent blueprintModelContent = (BlueprintModelContent) o;
- return Objects.equals(id, blueprintModelContent.id) && Objects.equals(name, blueprintModelContent.name)
- && Objects.equals(contentType, blueprintModelContent.contentType);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, name, contentType);
- }
-
- public String getId() {
- return id;
- }
-
-
- public void setId(String 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 BlueprintModel getBlueprintModel() {
- return blueprintModel;
- }
-
-
- public void setBlueprintModel(BlueprintModel blueprintModel) {
- this.blueprintModel = blueprintModel;
- }
-
-
- public String getDescription() {
- return description;
- }
-
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-
- public byte[] getContent() {
- return content;
- }
-
-
- public void setContent(byte[] content) {
- this.content = content;
- }
-
-
- public Date getCreationDate() {
- return creationDate;
- }
-
-
- public void setCreationDate(Date creationDate) {
- this.creationDate = creationDate;
- }
-
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 Bell Canada. + * + * 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.cds.controllerblueprints.service.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.*; +import java.io.Serializable; +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 BlueprintModelContent implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "config_model_content_id") + private String id; + + @Column(name = "name", nullable = false) + @ApiModelProperty(required=true) + private String name; + + @Column(name = "content_type", nullable = false) + @ApiModelProperty(required=true) + private String contentType; + + @OneToOne + @JoinColumn(name = "config_model_id") + private BlueprintModel blueprintModel; + + @Lob + @Column(name = "description") + private String description; + + @Lob + @Column(name = "content", nullable = false) + @ApiModelProperty(required=true) + private byte[] content; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "updated_date") + private Date creationDate = new Date(); + + @Override + public String toString() { + return "[" + "id = " + id + + ", name = " + name + + ", contentType = " + contentType + + "]"; + } + + @Override + public boolean equals(Object o) { + + if (o == this) { + return true; + } + if (!(o instanceof BlueprintModelContent)) { + return false; + } + BlueprintModelContent blueprintModelContent = (BlueprintModelContent) o; + return Objects.equals(id, blueprintModelContent.id) && Objects.equals(name, blueprintModelContent.name) + && Objects.equals(contentType, blueprintModelContent.contentType); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, contentType); + } + + public String getId() { + return id; + } + + + public void setId(String 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 BlueprintModel getBlueprintModel() { + return blueprintModel; + } + + + public void setBlueprintModel(BlueprintModel blueprintModel) { + this.blueprintModel = blueprintModel; + } + + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public byte[] getContent() { + return content; + } + + + public void setContent(byte[] 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/BlueprintModelSearch.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModelSearch.java index 33753b2f2..5c351bc63 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelSearch.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/BlueprintModelSearch.java @@ -1,166 +1,166 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 Bell Canada.
- *
- * 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.JsonTypeInfo;
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.springframework.data.annotation.LastModifiedDate;
-
-import javax.persistence.*;
-import java.io.Serializable;
-import java.util.Date;
-
-@Entity
-@Table(name = "CONFIG_MODEL")
-@JsonTypeName("blueprintModel")
-@JsonTypeInfo(include= JsonTypeInfo.As.WRAPPER_OBJECT, use=JsonTypeInfo.Id.NAME)
-public class BlueprintModelSearch implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @Column(name = "config_model_id")
- private String id;
-
- @Column(name = "artifact_uuid")
- private String artifactUUId;
-
- @Column(name = "artifact_type")
- private String artifactType;
-
- @Column(name = "artifact_version", nullable = false)
- private String artifactVersion;
-
- @Lob
- @Column(name = "artifact_description")
- private String artifactDescription;
-
- @Column(name = "internal_version")
- private Integer internalVersion;
-
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- @LastModifiedDate
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "creation_date")
- private Date createdDate = new Date();
-
- @Column(name = "artifact_name", nullable = false)
- private String artifactName;
-
- @Column(name = "published", nullable = false)
- private String published;
-
- @Column(name = "updated_by", nullable = false)
- private String updatedBy;
-
- @Lob
- @Column(name = "tags", nullable = false)
- private String tags;
-
- public String getId() {
- return id;
- }
-
- public void setId(String 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;
- }
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 Bell Canada. + * + * 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.cds.controllerblueprints.service.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.springframework.data.annotation.LastModifiedDate; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +@Entity +@Table(name = "CONFIG_MODEL") +@JsonTypeName("blueprintModel") +@JsonTypeInfo(include= JsonTypeInfo.As.WRAPPER_OBJECT, use=JsonTypeInfo.Id.NAME) +public class BlueprintModelSearch implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "config_model_id") + private String id; + + @Column(name = "artifact_uuid") + private String artifactUUId; + + @Column(name = "artifact_type") + private String artifactType; + + @Column(name = "artifact_version", nullable = false) + private String artifactVersion; + + @Lob + @Column(name = "artifact_description") + private String artifactDescription; + + @Column(name = "internal_version") + private Integer internalVersion; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "creation_date") + private Date createdDate = new Date(); + + @Column(name = "artifact_name", nullable = false) + private String artifactName; + + @Column(name = "published", nullable = false) + private String published; + + @Column(name = "updated_by", nullable = false) + private String updatedBy; + + @Lob + @Column(name = "tags", nullable = false) + private String tags; + + public String getId() { + return id; + } + + public void setId(String 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/JpaJsonNodeConverter.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/JpaJsonNodeConverter.java index 074483a7c..f45c30fc6 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/JpaJsonNodeConverter.java @@ -1,40 +1,40 @@ -/*
- * 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.databind.JsonNode;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-
-import javax.persistence.AttributeConverter;
-import javax.persistence.Converter;
-/**
- * @author Brinda Santh
- */
-@Converter
-public class JpaJsonNodeConverter implements
- AttributeConverter<JsonNode, String> {
-
- @Override
- public String convertToDatabaseColumn(JsonNode node) {
- return JacksonUtils.Companion.getJson(node, true);
- }
-
- @Override
- public JsonNode convertToEntityAttribute(String dbData) {
- return JacksonUtils.Companion.jsonNode(dbData);
- }
+/* + * 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.cds.controllerblueprints.service.domain; + +import com.fasterxml.jackson.databind.JsonNode; +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; + +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; +/** + * @author Brinda Santh + */ +@Converter +public class JpaJsonNodeConverter implements + AttributeConverter<JsonNode, String> { + + @Override + public String convertToDatabaseColumn(JsonNode node) { + return JacksonUtils.Companion.getJson(node, true); + } + + @Override + public JsonNode convertToEntityAttribute(String dbData) { + return JacksonUtils.Companion.jsonNode(dbData); + } }
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java index e28cdcd5b..60c069428 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java @@ -1,39 +1,39 @@ -/*
- * 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.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
-
-import javax.persistence.AttributeConverter;
-import javax.persistence.Converter;
-/**
- * @author Brinda Santh
- */
-@Converter
-public class JpaResourceDefinitionConverter implements
- AttributeConverter<ResourceDefinition, String> {
- @Override
- public String convertToDatabaseColumn(ResourceDefinition resourceDefinition) {
- return JacksonUtils.Companion.getJson(resourceDefinition);
- }
-
- @Override
- public ResourceDefinition convertToEntityAttribute(String content) {
- return JacksonUtils.Companion.readValue(content, ResourceDefinition.class);
- }
-}
+/* + * 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.cds.controllerblueprints.service.domain; + +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition; + +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; +/** + * @author Brinda Santh + */ +@Converter +public class JpaResourceDefinitionConverter implements + AttributeConverter<ResourceDefinition, String> { + @Override + public String convertToDatabaseColumn(ResourceDefinition resourceDefinition) { + return JacksonUtils.Companion.getJson(resourceDefinition); + } + + @Override + public ResourceDefinition convertToEntityAttribute(String content) { + return JacksonUtils.Companion.readValue(content, ResourceDefinition.class); + } +} 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/cds/controllerblueprints/service/domain/ModelType.java index 65a135c19..31b792407 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/domain/ModelType.java @@ -1,171 +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 com.fasterxml.jackson.databind.JsonNode;
-import io.swagger.annotations.ApiModelProperty;
-import org.springframework.data.annotation.LastModifiedDate;
-import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-
-import javax.persistence.*;
-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
- @Column(name = "model_name", nullable = false)
- @ApiModelProperty(required=true)
- private String modelName;
-
- @Column(name = "derived_from", nullable = false)
- @ApiModelProperty(required=true)
- private String derivedFrom;
-
- @Column(name = "definition_type", nullable = false)
- @ApiModelProperty(required=true)
- private String definitionType;
-
- @Lob
- @Convert(converter = JpaJsonNodeConverter.class)
- @Column(name = "definition", nullable = false)
- @ApiModelProperty(required=true)
- private JsonNode definition;
-
- @Lob
- @Column(name = "description", nullable = false)
- @ApiModelProperty(required=true)
- private String description;
-
- @Column(name = "version", nullable = false)
- @ApiModelProperty(required=true)
- private String version;
-
- @Lob
- @Column(name = "tags", nullable = false)
- @ApiModelProperty(required=true)
- private String tags;
-
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- @LastModifiedDate
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "creation_date")
- private Date creationDate;
-
- @Column(name = "updated_by", nullable = false)
- @ApiModelProperty(required=true)
- private String updatedBy;
-
- @Override
- public String toString() {
- return "[" + "modelName = " + modelName +
- ", derivedFrom = " + derivedFrom +
- ", definitionType = " + definitionType +
- ", description = " + description +
- ", creationDate = " + creationDate +
- ", version = " + version +
- ", updatedBy = " + updatedBy +
- ", tags = " + tags +
- "]";
- }
-
- 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 JsonNode getDefinition() {
- return definition;
- }
-
- public void setDefinition(JsonNode 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;
- }
-
-
-}
+/* + * 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.cds.controllerblueprints.service.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.JsonNode; +import io.swagger.annotations.ApiModelProperty; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.*; +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 + @Column(name = "model_name", nullable = false) + @ApiModelProperty(required=true) + private String modelName; + + @Column(name = "derived_from", nullable = false) + @ApiModelProperty(required=true) + private String derivedFrom; + + @Column(name = "definition_type", nullable = false) + @ApiModelProperty(required=true) + private String definitionType; + + @Lob + @Convert(converter = JpaJsonNodeConverter.class) + @Column(name = "definition", nullable = false) + @ApiModelProperty(required=true) + private JsonNode definition; + + @Lob + @Column(name = "description", nullable = false) + @ApiModelProperty(required=true) + private String description; + + @Column(name = "version", nullable = false) + @ApiModelProperty(required=true) + private String version; + + @Lob + @Column(name = "tags", nullable = false) + @ApiModelProperty(required=true) + private String tags; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "creation_date") + private Date creationDate; + + @Column(name = "updated_by", nullable = false) + @ApiModelProperty(required=true) + private String updatedBy; + + @Override + public String toString() { + return "[" + "modelName = " + modelName + + ", derivedFrom = " + derivedFrom + + ", definitionType = " + definitionType + + ", description = " + description + + ", creationDate = " + creationDate + + ", version = " + version + + ", updatedBy = " + updatedBy + + ", tags = " + tags + + "]"; + } + + 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 JsonNode getDefinition() { + return definition; + } + + public void setDefinition(JsonNode 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/cds/controllerblueprints/service/domain/ResourceDictionary.java index 5352d9c96..2a6ab459b 100644 --- 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/cds/controllerblueprints/service/domain/ResourceDictionary.java @@ -1,158 +1,158 @@ -/*
- * 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 io.swagger.annotations.ApiModelProperty;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
-import org.springframework.data.annotation.LastModifiedDate;
-import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-
-import javax.persistence.*;
-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
- @Column(name = "name", nullable = false)
- @ApiModelProperty(required=true)
- private String name;
-
- @Column(name = "data_type", nullable = false)
- @ApiModelProperty(required=true)
- private String dataType;
-
- @Column(name = "entry_schema")
- private String entrySchema;
-
- @Lob
- @Convert(converter = JpaResourceDefinitionConverter.class)
- @Column(name = "definition", nullable = false)
- @ApiModelProperty(required=true)
- private ResourceDefinition definition;
-
- @Lob
- @Column(name = "description", nullable = false)
- @ApiModelProperty(required=true)
- private String description;
-
- @Lob
- @Column(name = "tags", nullable = false)
- @ApiModelProperty(required=true)
- private String tags;
-
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- @LastModifiedDate
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "creation_date")
- private Date creationDate;
-
- @Column(name = "updated_by", nullable = false)
- @ApiModelProperty(required=true)
- private String updatedBy;
-
- @Override
- public String toString() {
- return "[" + ", name = " + name +
- ", dataType = " + dataType +
- ", entrySchema = " + entrySchema +
- ", definition =" + definition +
- ", description = " + description +
- ", updatedBy = " + updatedBy +
- ", tags = " + tags +
- ", creationDate = " + creationDate +
- "]";
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- 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 ResourceDefinition getDefinition() {
- return definition;
- }
-
- public void setDefinition(ResourceDefinition 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;
- }
-
-
-
-}
+/* + * 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.cds.controllerblueprints.service.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.*; +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 + @Column(name = "name", nullable = false) + @ApiModelProperty(required=true) + private String name; + + @Column(name = "data_type", nullable = false) + @ApiModelProperty(required=true) + private String dataType; + + @Column(name = "entry_schema") + private String entrySchema; + + @Lob + @Convert(converter = JpaResourceDefinitionConverter.class) + @Column(name = "definition", nullable = false) + @ApiModelProperty(required=true) + private ResourceDefinition definition; + + @Lob + @Column(name = "description", nullable = false) + @ApiModelProperty(required=true) + private String description; + + @Lob + @Column(name = "tags", nullable = false) + @ApiModelProperty(required=true) + private String tags; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "creation_date") + private Date creationDate; + + @Column(name = "updated_by", nullable = false) + @ApiModelProperty(required=true) + private String updatedBy; + + @Override + public String toString() { + return "[" + ", name = " + name + + ", dataType = " + dataType + + ", entrySchema = " + entrySchema + + ", definition =" + definition + + ", description = " + description + + ", updatedBy = " + updatedBy + + ", tags = " + tags + + ", creationDate = " + creationDate + + "]"; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + 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 ResourceDefinition getDefinition() { + return definition; + } + + public void setDefinition(ResourceDefinition 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/cds/controllerblueprints/service/model/AutoMapResponse.java index 2250828ac..0fa337762 100644 --- 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/cds/controllerblueprints/service/model/AutoMapResponse.java @@ -1,53 +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;
- }
-
-
-
-}
+/* + * 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.cds.controllerblueprints.service.model; + +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.cds.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/ControllerBlueprintModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java index 343f8c67b..9aeee1771 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.onap.ccsdk.apps.controllerblueprints.service.repository; +package org.onap.ccsdk.cds.controllerblueprints.service.repository; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch; +import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; 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/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.java index c53040e2b..314ac6a4e 100644 --- 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/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.java @@ -1,69 +1,69 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.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 name
- * @return Optional<ResourceMapping>
- */
- Optional<ResourceDictionary> findByName(String name);
-
- /**
- * This is a findByNameIn method
- *
- * @param names names
- * @return Optional<ResourceMapping>
- */
- List<ResourceDictionary> findByNameIn(List<String> names);
-
- /**
- * This is a findByTagsContainingIgnoreCase method
- *
- * @param tags tags
- * @return Optional<ModelType>
- */
- List<ResourceDictionary> findByTagsContainingIgnoreCase(String tags);
-
- /**
- * This is a deleteByName method
- *
- * @param name name
- */
- void deleteByName(String name);
-
-
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.controllerblueprints.service.repository; + +import org.onap.ccsdk.cds.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 name + * @return Optional<ResourceMapping> + */ + Optional<ResourceDictionary> findByName(String name); + + /** + * This is a findByNameIn method + * + * @param names names + * @return Optional<ResourceMapping> + */ + List<ResourceDictionary> findByNameIn(List<String> names); + + /** + * This is a findByTagsContainingIgnoreCase method + * + * @param tags tags + * @return Optional<ModelType> + */ + List<ResourceDictionary> findByTagsContainingIgnoreCase(String tags); + + /** + * This is a deleteByName method + * + * @param name name + */ + void deleteByName(String name); + + +} |