From b3d55d3dd8508919ae48d5f60425aa13e5731ac2 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Tue, 18 May 2021 16:31:28 +0100 Subject: Add Support for creating model type Add new vertex type called "model" was added to represent models Add new edge type called MODEL_ELEMENT was added to connect a tosca type to a model Add new edge type called MODEL was added to connect a resource/service to the model it is based on Issue-ID: SDC-3596 Signed-off-by: MichaelMorris Signed-off-by: aribeiro Change-Id: I310e14d0cf5a9ca0eb0bda592efe8a3baf73749c --- .../org/openecomp/sdc/be/dao/api/ActionStatus.java | 2 + .../sdc/be/dao/graph/GraphElementFactory.java | 5 ++ .../sdc/be/dao/jsongraph/types/EdgeLabelEnum.java | 3 +- .../sdc/be/dao/jsongraph/types/VertexTypeEnum.java | 3 +- .../openecomp/sdc/be/resources/data/ModelData.java | 54 ++++++++++++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ModelData.java (limited to 'catalog-dao/src/main') diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java index 619f88263c..1ebaeab54f 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java @@ -51,6 +51,8 @@ public enum ActionStatus { VENDOR_NAME_EXCEEDS_LIMIT, VENDOR_RELEASE_EXCEEDS_LIMIT, INVALID_VENDOR_NAME, INVALID_VENDOR_RELEASE, MISSING_VENDOR_NAME, MISSING_VENDOR_RELEASE, RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, INVALID_RESOURCE_VENDOR_MODEL_NUMBER, // Category related COMPONENT_MISSING_CATEGORY, COMPONENT_INVALID_CATEGORY, COMPONENT_ELEMENT_INVALID_NAME_FORMAT, COMPONENT_ELEMENT_INVALID_NAME_LENGTH, COMPONENT_CATEGORY_ALREADY_EXISTS, COMPONENT_CATEGORY_NOT_FOUND, COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY, COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY, COMPONENT_GROUPING_EXISTS_FOR_SUB_CATEGORY, + // Model related + MODEL_ALREADY_EXISTS, // Service API URL INVALID_SERVICE_API_URL, // Property related diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java index c3c5e9f704..1c500e722d 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java @@ -46,6 +46,7 @@ import org.openecomp.sdc.be.resources.data.HeatParameterValueData; import org.openecomp.sdc.be.resources.data.InputValueData; import org.openecomp.sdc.be.resources.data.InputsData; import org.openecomp.sdc.be.resources.data.InterfaceData; +import org.openecomp.sdc.be.resources.data.ModelData; import org.openecomp.sdc.be.resources.data.OperationData; import org.openecomp.sdc.be.resources.data.PolicyTypeData; import org.openecomp.sdc.be.resources.data.ProductMetadataData; @@ -255,6 +256,10 @@ public class GraphElementFactory { break; case AnnotationType: element = clazz.cast(new AnnotationTypeData(properties)); + break; + case Model: + element = clazz.cast(new ModelData(properties)); + break; default: break; } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java index 33a4391c9f..7fc954e0a8 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java @@ -69,7 +69,8 @@ public enum EdgeLabelEnum { INST_INTERFACES, NODE_FILTER_TEMPLATE, SUBSTITUTION_FILTER_TEMPLATE, - DATA_TYPES; + DATA_TYPES, + MODEL_ELEMENT; // @formatter:on /** diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java index cc8c8bcd87..e9648a3579 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java @@ -92,7 +92,8 @@ public enum VertexTypeEnum { NODE_FILTER_TEMPLATE ("NodeTemplateFilter", CINodeFilterDataDefinition.class), SUBSTITUTION_FILTER_TEMPLATE ("substitution_mapping", SubstitutionFilterDataDefinition.class), INST_INTERFACES ("InstInterfaces", MapInterfaceDataDefinition.class), - DATA_TYPES ("data_types", DataTypeDataDefinition.class); + DATA_TYPES ("data_types", DataTypeDataDefinition.class), + MODEL ("model", null); // @formatter:on private final String name; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ModelData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ModelData.java new file mode 100644 index 0000000000..026b1d7998 --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ModelData.java @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdc.be.resources.data; + +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; +import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; +import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; +import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; + +@Getter +public class ModelData extends GraphNode { + + private final String name; + private final String uniqueId; + + public ModelData(final String name, final String uniqueId) { + super(NodeTypeEnum.Model); + this.name = name; + this.uniqueId = uniqueId; + } + + public ModelData(final Map properties) { + super(NodeTypeEnum.Model); + name = (String) properties.get(GraphPropertiesDictionary.NAME.getProperty()); + uniqueId = (String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()); + } + + @Override + public Map toGraphMap() { + final Map map = new HashMap<>(); + addIfExists(map, GraphPropertiesDictionary.NAME, name); + addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId); + return map; + } + +} \ No newline at end of file -- cgit 1.2.3-korg