summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-01-29 17:25:21 +0000
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-04-19 16:35:32 +0000
commitcd6f933375c412c2f79a12e909821322d58a8499 (patch)
tree758ff2e742b514169bbc84a8433d68fe221ef5c9 /catalog-model/src/main/java/org
parentdc56692a4a307f378c827f017d2efbf754c223e0 (diff)
Configure a new Artifact Type
Centralizes artifact configuration in one yaml entry. Allow the configuration of a new artifact type without the need of code changes. The configuration file now is used as a source of artifacts types instead the artifact type enum. The enum will be used as a source of base artifact types and also in hard coded business rules. Change-Id: Id0383d9fca9bce0519a4d52a4ecb3a68c8713f0f Issue-ID: SDC-2754 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java22
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java21
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java50
5 files changed, 39 insertions, 58 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
index 38f2f36ae2..7d4dfa72f4 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
@@ -321,7 +321,7 @@ public abstract class Component implements PropertiesOwner {
return safeGetComponentInstanceDeploymentArtifacts(componentInstanceId)
.values()
.stream()
- .filter(artifact -> ArtifactTypeEnum.HEAT_ENV.name().equals(artifact.getArtifactType()))
+ .filter(artifact -> ArtifactTypeEnum.HEAT_ENV.getType().equals(artifact.getArtifactType()))
.collect(Collectors.toList());
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java
index caebf4a275..ca154f3076 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java
@@ -116,7 +116,7 @@ public class GroupInstance extends GroupInstanceDataDefinition {
String label = artifactId.substring(artifactId.lastIndexOf('.') + 1);
ArtifactDefinition artifact = deploymentArtifacts.get(label);
log.debug("current artifact id: {}, current artifact definition: {}", artifactId, artifact);
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType());
+ ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(artifact.getArtifactType());
if (artifactType != ArtifactTypeEnum.HEAT_ENV){
addArtifactsIdToCollection(artifactUuids, artifact);
}else{
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
index 50c165f535..3c8e0ee5cf 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
@@ -312,7 +312,11 @@ public class ArtifactsOperations extends BaseOperation {
String currentChecksum = updateArtifactData.getArtifactChecksum();
if (isUpdate) {
- ArtifactTypeEnum type = ArtifactTypeEnum.findType(updateArtifactData.getArtifactType());
+ final ArtifactTypeEnum type = ArtifactTypeEnum.parse(updateArtifactData.getArtifactType());
+ if(type == null) {
+ generateUUIDForNonHeatArtifactType(updateArtifactData, oldChecksum, oldVesrion, currentChecksum);
+ return;
+ }
switch (type) {
case HEAT_ENV:
if (edgeLabel == EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS) {
@@ -384,17 +388,11 @@ public class ArtifactsOperations extends BaseOperation {
return addArtifactToComponent(artifactHeatEnv, component, parentType, failIfExist, instanceId);
}
- public Either<ArtifactDefinition, StorageOperationStatus> getHeatArtifactByHeatEnvId(String parentId, ArtifactDefinition heatEnv, NodeTypeEnum parentType, String containerId, ComponentTypeEnum componentType) {
- String id = heatEnv.getGeneratedFromId();
- ComponentTypeEnum compType;
- switch (parentType) {
- case ResourceInstance:
- compType = ComponentTypeEnum.RESOURCE_INSTANCE;
- break;
- default:
- compType = componentType;
- }
- return getArtifactById(parentId, id, compType, containerId);
+ public Either<ArtifactDefinition, StorageOperationStatus> getHeatArtifactByHeatEnvId(final String parentId,
+ final ArtifactDefinition heatEnv,
+ final String containerId,
+ final ComponentTypeEnum componentType) {
+ return getArtifactById(parentId, heatEnv.getGeneratedFromId(), componentType, containerId);
}
public Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvArtifact(Component component, ArtifactDefinition artifactEnvInfo, String artifactId, String newArtifactId, NodeTypeEnum type, String instanceId) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java
index 6ecfc1048b..33877add47 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java
@@ -21,6 +21,8 @@
package org.openecomp.sdc.be.model.operations.api;
import fj.data.Either;
+import java.util.List;
+import java.util.Map;
import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
@@ -33,9 +35,6 @@ import org.openecomp.sdc.be.model.category.GroupingDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.resources.data.CategoryData;
-import java.util.List;
-import java.util.Map;
-
public interface IElementOperation {
Either<List<CategoryDefinition>, ActionStatus> getAllResourceCategories();
@@ -44,21 +43,19 @@ public interface IElementOperation {
Either<List<CategoryDefinition>, ActionStatus> getAllProductCategories();
- public Either<List<Tag>, ActionStatus> getAllTags();
-
- public Either<List<PropertyScope>, ActionStatus> getAllPropertyScopes();
+ Either<List<Tag>, ActionStatus> getAllTags();
- public Either<List<ArtifactType>, ActionStatus> getAllArtifactTypes();
+ Either<List<PropertyScope>, ActionStatus> getAllPropertyScopes();
- public Either<Map<String, Object>, ActionStatus> getAllDeploymentArtifactTypes();
+ List<ArtifactType> getAllArtifactTypes();
- public Either<Configuration.HeatDeploymentArtifactTimeout, ActionStatus> getDefaultHeatTimeout();
+ Either<Configuration.HeatDeploymentArtifactTimeout, ActionStatus> getDefaultHeatTimeout();
- public <T extends GraphNode> Either<CategoryData, StorageOperationStatus> getCategoryData(String name, NodeTypeEnum type, Class<T> clazz);
+ <T extends GraphNode> Either<CategoryData, StorageOperationStatus> getCategoryData(String name, NodeTypeEnum type, Class<T> clazz);
- public <T extends GraphNode> Either<org.openecomp.sdc.be.resources.data.category.CategoryData, StorageOperationStatus> getNewCategoryData(String name, NodeTypeEnum type, Class<T> clazz);
+ <T extends GraphNode> Either<org.openecomp.sdc.be.resources.data.category.CategoryData, StorageOperationStatus> getNewCategoryData(String name, NodeTypeEnum type, Class<T> clazz);
- public Either<Map<String, String>, ActionStatus> getResourceTypesMap();
+ Either<Map<String, String>, ActionStatus> getResourceTypesMap();
Either<CategoryDefinition, ActionStatus> createCategory(CategoryDefinition category, NodeTypeEnum nodeType);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java
index 402129b8ba..9d0c7b1075 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java
@@ -20,22 +20,29 @@
package org.openecomp.sdc.be.model.operations.impl;
-import org.janusgraph.core.JanusGraph;
-import org.janusgraph.core.JanusGraphVertex;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphVertex;
+import org.openecomp.sdc.be.config.ArtifactConfigManager;
+import org.openecomp.sdc.be.config.ArtifactConfiguration;
import org.openecomp.sdc.be.config.Configuration;
-import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
import org.openecomp.sdc.be.datatypes.category.CategoryDataDefinition;
import org.openecomp.sdc.be.datatypes.category.GroupingDataDefinition;
import org.openecomp.sdc.be.datatypes.category.SubCategoryDataDefinition;
@@ -58,8 +65,6 @@ import org.openecomp.sdc.common.util.ValidationUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
-import java.util.*;
-
@Component("element-operation")
public class ElementOperation implements IElementOperation {
@@ -781,32 +786,13 @@ public class ElementOperation implements IElementOperation {
}
@Override
- public Either<List<ArtifactType>, ActionStatus> getAllArtifactTypes() {
- List<ArtifactType> artifactTypes = new ArrayList<>();
-
- List<String> artifactTypesList = ConfigurationManager.getConfigurationManager().getConfiguration().getArtifactTypes();
- for (String artifactType : artifactTypesList) {
- ArtifactType artifactT = new ArtifactType();
- artifactT.setName(artifactType);
- artifactTypes.add(artifactT);
- }
- return Either.left(artifactTypes);
- }
-
- @Override
- public Either<Map<String, Object>, ActionStatus> getAllDeploymentArtifactTypes() {
-
- Map<String, Object> artifactTypes = new HashMap<>();
- Map<String, ArtifactTypeConfig> artifactResourceTypes = ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts();
- Map<String, ArtifactTypeConfig> artifactServiceTypes = ConfigurationManager.getConfigurationManager().getConfiguration().getServiceDeploymentArtifacts();
- Map<String, ArtifactTypeConfig> artifactResourceInstanceTypes = ConfigurationManager.getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts();
-
- artifactTypes.put("resourceDeploymentArtifacts", artifactResourceTypes);
- artifactTypes.put("serviceDeploymentArtifacts", artifactServiceTypes);
- artifactTypes.put("resourceInstanceDeploymentArtifacts", artifactResourceInstanceTypes);
-
- return Either.left(artifactTypes);
-
+ public List<ArtifactType> getAllArtifactTypes() {
+ final List<ArtifactConfiguration> artifactTypesList = ArtifactConfigManager.getInstance().getConfiguration();
+ return artifactTypesList.stream().map(artifactConfiguration -> {
+ final ArtifactType artifactType = new ArtifactType();
+ artifactType.setName(artifactConfiguration.getType());
+ return artifactType;
+ }).collect(Collectors.toList());
}
@Override