summaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2020-12-15 16:12:59 +0000
committerMichael Morris <michael.morris@est.tech>2021-01-12 16:35:48 +0000
commit69779180f8f4e020606634f9bd8cac728daed2a2 (patch)
tree87167832f478509436365d07bd2e46a9c8970365 /catalog-dao/src/main
parent1f4756dab7b29843a89fb42943ae3dc0ee8b1ae9 (diff)
Support for category specific metadata
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3412 Change-Id: I87392cc21dc25253b558bdc1d453d99659d049fa
Diffstat (limited to 'catalog-dao/src/main')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java14
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java3
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java7
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java7
4 files changed, 30 insertions, 1 deletions
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<String> iconsfromJson = getGson()
.fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType);
categoryDataDefinition.setIcons(iconsfromJson);
+
+ final Type metadataKeylistType = new TypeToken<List<MetadataKeyDataDefinition>>() {}.getType();
+ final List<MetadataKeyDataDefinition> 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<String> iconsfromJson = getGson()
.fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType);
subCategoryDataDefinition.setIcons(iconsfromJson);
+
+ final Type metadataKeylistType = new TypeToken<List<MetadataKeyDataDefinition>>() {}.getType();
+ final List<MetadataKeyDataDefinition> 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;
}
}