From 69779180f8f4e020606634f9bd8cac728daed2a2 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Tue, 15 Dec 2020 16:12:59 +0000 Subject: Support for category specific metadata Signed-off-by: MichaelMorris Issue-ID: SDC-3412 Change-Id: I87392cc21dc25253b558bdc1d453d99659d049fa --- .../org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java | 14 ++++++++++++++ .../sdc/be/dao/neo4j/GraphPropertiesDictionary.java | 3 ++- .../sdc/be/resources/data/category/CategoryData.java | 7 +++++++ .../sdc/be/resources/data/category/SubCategoryData.java | 7 +++++++ 4 files changed, 30 insertions(+), 1 deletion(-) (limited to 'catalog-dao') diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java index 11dcdceaaf..f3e64b11c6 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java @@ -167,6 +167,20 @@ public class GraphVertex { } return null; } + + public void setJsonMetadataField(String field, Object value) { + if (metadataJson == null) { + metadataJson = new HashMap<>(); + } + metadataJson.put(field, value); + } + + public Object getJsonMetadataField(String field) { + if (metadataJson != null) { + return metadataJson.get(field); + } + return null; + } /** * Updates metadata json with current metadataProperties. Note that already existing property containing in metadata json can be overrided by new value if metadataProperties contains the same property (by key). Note that metadata json can contain diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java index da6e5d5d44..8581895681 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java @@ -126,7 +126,8 @@ public enum GraphPropertiesDictionary { CONSTANT_UUID ("constantUuidNew", String.class, false, true), CONTACTS ("contacts", String.class, false, false), //categorys - ICONS ("icons", String.class, false, false), + ICONS ("icons", String.class, false, false), + METADATA_KEYS ("metadataKeys", String.class, false, false), USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES ("useServiceSubstitutionForNestedServices", Boolean.class, false, false), //relation CAPABILITY_OWNER_ID ("capOwnerId", String.class, false, false), diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java index 8db7b53017..613f91d841 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java @@ -24,6 +24,7 @@ import com.google.gson.reflect.TypeToken; import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.datatypes.category.CategoryDataDefinition; +import org.openecomp.sdc.be.datatypes.category.MetadataKeyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import java.lang.reflect.Type; @@ -60,6 +61,11 @@ public class CategoryData extends GraphNode { List iconsfromJson = getGson() .fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType); categoryDataDefinition.setIcons(iconsfromJson); + + final Type metadataKeylistType = new TypeToken>() {}.getType(); + final List metadataKeysfromJson = getGson() + .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA_KEYS.getProperty()), metadataKeylistType); + categoryDataDefinition.setMetadataKeys(metadataKeysfromJson); } @Override @@ -82,6 +88,7 @@ public class CategoryData extends GraphNode { // addIfExists(map, GraphPropertiesDictionary.ICONS, icons); addIfExists(map, GraphPropertiesDictionary.ICONS, categoryDataDefinition.getIcons()); addIfExists(map, GraphPropertiesDictionary.USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES, categoryDataDefinition.isUseServiceSubstitutionForNestedServices()); + addIfExists(map, GraphPropertiesDictionary.METADATA_KEYS, categoryDataDefinition.getMetadataKeys()); return map; } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java index cbae4561e1..13976035b6 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java @@ -23,6 +23,7 @@ package org.openecomp.sdc.be.resources.data.category; import com.google.gson.reflect.TypeToken; import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; +import org.openecomp.sdc.be.datatypes.category.MetadataKeyDataDefinition; import org.openecomp.sdc.be.datatypes.category.SubCategoryDataDefinition; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; @@ -59,6 +60,11 @@ public class SubCategoryData extends GraphNode { List iconsfromJson = getGson() .fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType); subCategoryDataDefinition.setIcons(iconsfromJson); + + final Type metadataKeylistType = new TypeToken>() {}.getType(); + final List metadataKeysfromJson = getGson() + .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA_KEYS.getProperty()), metadataKeylistType); + subCategoryDataDefinition.setMetadataKeys(metadataKeysfromJson); } public SubCategoryDataDefinition getSubCategoryDataDefinition() { @@ -80,6 +86,7 @@ public class SubCategoryData extends GraphNode { // String icons=getGson().toJson(subCategoryDataDefinition.getIcons()); // addIfExists(map, GraphPropertiesDictionary.ICONS, icons); addIfExists(map, GraphPropertiesDictionary.ICONS, subCategoryDataDefinition.getIcons()); + addIfExists(map, GraphPropertiesDictionary.METADATA_KEYS, subCategoryDataDefinition.getMetadataKeys()); return map; } } -- cgit 1.2.3-korg