summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml4
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/api/IEntityDetails.java20
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java14
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetails.java64
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactory.java30
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/GroupEntityDetails.java38
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/NodeTemplateEntityDetails.java26
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/PolicyEntityDetails.java27
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/EntityQuery.java138
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/GroupEntityQuery.java30
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/NodeTemplateEntityQuery.java34
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/PolicyEntityQuery.java30
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQuery.java49
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/enums/EntityTemplateType.java11
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java22
-rw-r--r--src/test/java/org/onap/sdc/impl/GetEntityTest.java88
-rw-r--r--src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csarbin0 -> 146449 bytes
-rw-r--r--version.properties2
18 files changed, 621 insertions, 6 deletions
diff --git a/pom.xml b/pom.xml
index e1f846d..65afd76 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
<artifactId>sdc-tosca</artifactId>
<name>sdc-sdc-tosca</name>
<description>SDC Tosca Parser JAR file for use by consumers</description>
- <version>1.4.7-SNAPSHOT</version>
+ <version>1.4.8-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
@@ -118,7 +118,7 @@
<dependency>
<groupId>org.onap.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.4.7</version>
+ <version>1.4.8</version>
</dependency>
diff --git a/src/main/java/org/onap/sdc/tosca/parser/api/IEntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/api/IEntityDetails.java
new file mode 100644
index 0000000..f8e8c6e
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/api/IEntityDetails.java
@@ -0,0 +1,20 @@
+package org.onap.sdc.tosca.parser.api;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IEntityDetails {
+ EntityTemplateType getType();
+ String getName();
+ Metadata getMetadata();
+ Map<String, Property> getProperties();
+ List<Property> getPropertyList();
+ List<IEntityDetails> getMemberNodes();
+ IEntityDetails getParent();
+ String getPath();
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java b/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java
index 8ce4b1b..b64d0de 100644
--- a/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java
+++ b/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java
@@ -24,6 +24,8 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.enums.FilterType;
import org.onap.sdc.toscaparser.api.*;
@@ -613,4 +615,16 @@ public interface ISdcCsarHelper {
List<String> getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath(String propertyNamePath, String nodeTemplatePath);
boolean isNodeTypeSupported(NodeTemplate nodeTemplate);
+
+ /**
+ * Retrieves details of one or more entity templates according to provided query parameters from corresponding topology template
+ * @param entityQuery Object describing the searched entity parameters. Includes one of following parameters: entity type,
+ * SDC (node template) type, tosca type as well as optional customizationUUID and UUID
+ * @param topologyTemplateQuery parameters of the topology template containing the above entity.
+ * Includes SDC type of the container and optional customizationUUID
+ * @param isRecursive indicates if the search is recursive or not
+ * @return list of @{@link IEntityDetails} objects containing information about the found entities.
+ * If either no entities found or the provided query is incorrect, an empty list is returned
+ */
+ List<IEntityDetails> getEntity(EntityQuery entityQuery, TopologyTemplateQuery topologyTemplateQuery, boolean isRecursive);
} \ No newline at end of file
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetails.java
new file mode 100644
index 0000000..91c7144
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetails.java
@@ -0,0 +1,64 @@
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class EntityDetails implements IEntityDetails {
+
+ private final EntityTemplate entityTemplate;
+
+ private final IEntityDetails parentNode;
+
+ EntityDetails(EntityTemplate entityTemplate, NodeTemplate parentNode) {
+ this.entityTemplate = entityTemplate;
+ this.parentNode = EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, parentNode, null);
+ }
+
+ @Override
+ public String getName() {
+ return entityTemplate.getName();
+ }
+
+ EntityTemplate getEntityTemplate() {
+ return entityTemplate;
+ }
+
+ @Override
+ public Map<String, Property> getProperties() {
+ return entityTemplate.getProperties();
+ }
+
+ @Override
+ public List<Property> getPropertyList() {
+ return entityTemplate.getPropertiesObjects();
+ }
+
+ @Override
+ public List<IEntityDetails> getMemberNodes() {
+ List<IEntityDetails> ntList = new ArrayList<>();
+ ntList.add(getParent());
+ return ntList;
+ }
+
+ @Override
+ public IEntityDetails getParent() {
+ //todo - update after adding parent to the EntityTemplate class
+ return parentNode;
+ }
+
+ @Override
+ public String getPath() {
+ //todo - update after adding parent to the EntityTemplate class
+ return "jenny vTSBC vlan VNF 0#abstract_ssc#ssc_ssc_avpn_port_0";
+ }
+
+
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactory.java b/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactory.java
new file mode 100644
index 0000000..65968b8
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactory.java
@@ -0,0 +1,30 @@
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+
+public class EntityDetailsFactory {
+
+ private EntityDetailsFactory(){}
+
+ //TODO: the parent should be retrieved from the entityTemplate and not passed as a separate parameter
+ public static EntityDetails createEntityDetails(EntityTemplateType entityTemplateType, EntityTemplate entityTemplate, NodeTemplate parent) {
+ EntityDetails entityDetails = null;
+ if (entityTemplate != null) {
+ switch (entityTemplateType) {
+ case NODE_TEMPLATE:
+ entityDetails = new NodeTemplateEntityDetails(entityTemplate, parent);
+ break;
+ case POLICY:
+ entityDetails = new PolicyEntityDetails(entityTemplate, parent);
+ break;
+ case GROUP:
+ entityDetails = new GroupEntityDetails(entityTemplate, parent);
+ break;
+ }
+ }
+ return entityDetails;
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/GroupEntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/elements/GroupEntityDetails.java
new file mode 100644
index 0000000..82488a7
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/GroupEntityDetails.java
@@ -0,0 +1,38 @@
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.Group;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class GroupEntityDetails extends EntityDetails {
+ private final Group group;
+
+ GroupEntityDetails(EntityTemplate entityTemplate, NodeTemplate parentNode) {
+ super(entityTemplate,parentNode);
+ group = (Group)getEntityTemplate();
+ }
+
+ @Override
+ public EntityTemplateType getType() {
+ return EntityTemplateType.GROUP;
+ }
+
+ @Override
+ public List<IEntityDetails> getMemberNodes() {
+ return group.getMemberNodes()
+ .stream()
+ .map(m->EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, m, null))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return group.getMetadata();
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/NodeTemplateEntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/elements/NodeTemplateEntityDetails.java
new file mode 100644
index 0000000..c6dd69f
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/NodeTemplateEntityDetails.java
@@ -0,0 +1,26 @@
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+public class NodeTemplateEntityDetails extends EntityDetails {
+
+ private final NodeTemplate nodeTemplate;
+
+ NodeTemplateEntityDetails(EntityTemplate entityTemplate, NodeTemplate parentNode) {
+ super(entityTemplate, parentNode);
+ nodeTemplate = (NodeTemplate)getEntityTemplate();
+ }
+
+ @Override
+ public EntityTemplateType getType() {
+ return EntityTemplateType.NODE_TEMPLATE;
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return nodeTemplate.getMetaData();
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/PolicyEntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/elements/PolicyEntityDetails.java
new file mode 100644
index 0000000..39027c3
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/PolicyEntityDetails.java
@@ -0,0 +1,27 @@
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Policy;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+public class PolicyEntityDetails extends EntityDetails {
+
+ private final Policy policy;
+
+ PolicyEntityDetails(EntityTemplate entityTemplate, NodeTemplate parentNode) {
+ super(entityTemplate, parentNode);
+ policy = (Policy)getEntityTemplate();
+ }
+
+ @Override
+ public EntityTemplateType getType() {
+ return EntityTemplateType.POLICY;
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return policy.getMetaDataObj();
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/EntityQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/EntityQuery.java
new file mode 100644
index 0000000..ba17423
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/EntityQuery.java
@@ -0,0 +1,138 @@
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+
+import java.util.List;
+
+/**
+ * This class describes an entity searched and retrieved by SDC Tosca Parser API
+ * It is used as the API input parameter. See the {@link org.onap.sdc.tosca.parser.api.ISdcCsarHelper}
+ */
+public abstract class EntityQuery {
+
+ private final EntityTemplateType entityType;
+
+ private final SdcTypes nodeTemplateType;
+
+ private final String toscaType;
+
+ private String uUID;
+
+ private String customizationUUID;
+
+ EntityQuery(EntityTemplateType entityType, SdcTypes nodeTemplateType, String toscaType) {
+ this.entityType = entityType;
+ this.nodeTemplateType = nodeTemplateType;
+ this.toscaType = toscaType;
+ }
+
+ void setUUID(String uUID) {
+ this.uUID = uUID;
+ }
+
+ void setCustomizationUUID(String customizationUUID) {
+ this.customizationUUID = customizationUUID;
+ }
+
+ public abstract List<EntityTemplate> searchByTopologyTemplate(TopologyTemplateQuery topologyTemplateQuery);
+
+ public abstract EntityTemplateType getType();
+
+ public EntityTemplateType getEntityType() {
+ return entityType;
+ }
+
+ public SdcTypes getNodeTemplateType() {
+ return nodeTemplateType;
+ }
+
+ public String getToscaType() {
+ return toscaType;
+ }
+
+ public String getUUID() {
+ return uUID;
+ }
+
+ public String getCustomizationUUID() {
+ return customizationUUID;
+ }
+
+ public boolean searchAllEntities() {
+ return StringUtils.isEmpty(toscaType) && nodeTemplateType == null;
+ }
+
+ public static EntityQueryBuilder newBuilder(EntityTemplateType entityTemplateType) {
+ return new EntityQueryBuilder(entityTemplateType);
+ }
+
+ public static EntityQueryBuilder newBuilder(SdcTypes sdcType) {
+ return new EntityQueryBuilder(sdcType);
+ }
+
+ public static EntityQueryBuilder newBuilder(String toscaType) {
+ return new EntityQueryBuilder(toscaType);
+ }
+
+ /**
+ * Builds instance of EntityQuery object according to provided parameters
+ */
+ public static class EntityQueryBuilder {
+ private static final String GROUPS_NAME_SPACE = ".groups.";
+ private static final String POLICIES_NAME_SPACE = ".policies.";
+
+ private EntityQuery entityQuery;
+
+ private EntityQueryBuilder(EntityTemplateType entityTemplateType) {
+ switch(entityTemplateType) {
+ case NODE_TEMPLATE:
+ entityQuery = new NodeTemplateEntityQuery();
+ break;
+ case GROUP:
+ entityQuery = new GroupEntityQuery();
+ break;
+ case POLICY:
+ entityQuery = new PolicyEntityQuery();
+ break;
+ default:
+ throw new IllegalArgumentException("Wrong entity query type: " + entityTemplateType);
+ }
+ }
+
+ private EntityQueryBuilder(SdcTypes sdcType) {
+ entityQuery = new NodeTemplateEntityQuery(sdcType);
+ }
+
+ private EntityQueryBuilder(String toscaType) {
+ if (toscaType.contains(GROUPS_NAME_SPACE)) {
+ entityQuery = new GroupEntityQuery(toscaType);
+ }
+ else if (toscaType.contains(POLICIES_NAME_SPACE)) {
+ entityQuery = new PolicyEntityQuery(toscaType);
+ }
+ else {
+ entityQuery = new NodeTemplateEntityQuery(toscaType);
+ }
+ }
+
+ public EntityQueryBuilder uUID(String uUID) {
+ entityQuery.setUUID(uUID);
+ return this;
+ }
+
+ public EntityQueryBuilder customizationUUID(String customizationUUID) {
+ entityQuery.setCustomizationUUID(customizationUUID);
+ return this;
+ }
+
+ public EntityQuery build() {
+ return entityQuery;
+ }
+ }
+
+
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/GroupEntityQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/GroupEntityQuery.java
new file mode 100644
index 0000000..37a3ccd
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/GroupEntityQuery.java
@@ -0,0 +1,30 @@
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+
+import java.util.List;
+
+/**
+ * Implements EntityQuery object for Groups
+ */
+public class GroupEntityQuery extends EntityQuery {
+
+ public GroupEntityQuery() {
+ super(EntityTemplateType.GROUP, null, null);
+ }
+
+ @Override
+ public List<EntityTemplate> searchByTopologyTemplate(TopologyTemplateQuery topologyTemplateQuery) {
+ return null;
+ }
+
+ @Override
+ public EntityTemplateType getType() {
+ return EntityTemplateType.GROUP;
+ }
+
+ public GroupEntityQuery(String toscaType) {
+ super(EntityTemplateType.GROUP, null, toscaType);
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/NodeTemplateEntityQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/NodeTemplateEntityQuery.java
new file mode 100644
index 0000000..4e01bd8
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/NodeTemplateEntityQuery.java
@@ -0,0 +1,34 @@
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+
+import java.util.List;
+
+/**
+ * Implements EntityQuery object for NodeTemplates
+ */
+public class NodeTemplateEntityQuery extends EntityQuery {
+ public NodeTemplateEntityQuery() {
+ super(EntityTemplateType.NODE_TEMPLATE, null, null);
+ }
+
+ @Override
+ public EntityTemplateType getType() {
+ return EntityTemplateType.NODE_TEMPLATE;
+ }
+
+ @Override
+ public List<EntityTemplate> searchByTopologyTemplate(TopologyTemplateQuery topologyTemplateQuery) {
+ return null;
+ }
+
+ public NodeTemplateEntityQuery(SdcTypes nodeTemplateType) {
+ super(EntityTemplateType.NODE_TEMPLATE, nodeTemplateType, null);
+ }
+
+ public NodeTemplateEntityQuery(String toscaType) {
+ super(EntityTemplateType.NODE_TEMPLATE, null, toscaType);
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/PolicyEntityQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/PolicyEntityQuery.java
new file mode 100644
index 0000000..8ab5e4c
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/PolicyEntityQuery.java
@@ -0,0 +1,30 @@
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+
+import java.util.List;
+
+/**
+ * Implements EntityQuery object for Policies
+ */
+public class PolicyEntityQuery extends EntityQuery {
+
+ public PolicyEntityQuery() {
+ super(EntityTemplateType.POLICY, null, null);
+ }
+
+ @Override
+ public List<EntityTemplate> searchByTopologyTemplate(TopologyTemplateQuery topologyTemplateQuery) {
+ return null;
+ }
+
+ @Override
+ public EntityTemplateType getType() {
+ return EntityTemplateType.POLICY;
+ }
+
+ public PolicyEntityQuery(String toscaType) {
+ super(EntityTemplateType.POLICY, null, toscaType);
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQuery.java
new file mode 100644
index 0000000..47b10a8
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQuery.java
@@ -0,0 +1,49 @@
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+
+/**
+ * This class describes a node template instance containing an entity searched and retrieved by SDC Tosca Parser API
+ * It is used as the API input parameter. See the {@link org.onap.sdc.tosca.parser.api.ISdcCsarHelper}
+ */
+public class TopologyTemplateQuery {
+
+ public void setCustomizationUUID(String customizationUUID) {
+ this.customizationUUID = customizationUUID;
+ }
+
+ private final SdcTypes sdcType;
+
+ private String customizationUUID;
+
+ private TopologyTemplateQuery(SdcTypes sdcType) {
+ this.sdcType = sdcType;
+ }
+
+ public static TopologyTemplateQueryBuilder newBuilder(SdcTypes sdcType) {
+ return new TopologyTemplateQueryBuilder(sdcType);
+ }
+
+ public SdcTypes getNodeTemplateType() {
+ return sdcType;
+ }
+
+ public String getCustomizationUUID() {
+ return customizationUUID;
+ }
+
+ public static class TopologyTemplateQueryBuilder {
+ private TopologyTemplateQuery topologyTemplateQuery;
+ private TopologyTemplateQueryBuilder(SdcTypes sdcType) { topologyTemplateQuery = new TopologyTemplateQuery(sdcType);}
+
+ public TopologyTemplateQueryBuilder customizationUUID(String customizationUUID) {
+ topologyTemplateQuery.setCustomizationUUID(customizationUUID);
+ return this;
+ }
+
+ public TopologyTemplateQuery build() {
+ return topologyTemplateQuery;
+ }
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/enums/EntityTemplateType.java b/src/main/java/org/onap/sdc/tosca/parser/enums/EntityTemplateType.java
new file mode 100644
index 0000000..7f85673
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/enums/EntityTemplateType.java
@@ -0,0 +1,11 @@
+package org.onap.sdc.tosca.parser.enums;
+
+/**
+ * Describes types of entities for search
+ */
+public enum EntityTemplateType {
+ NODE_TEMPLATE,
+ GROUP,
+ POLICY;
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index ee9ac06..06bf48a 100644
--- a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -36,8 +36,14 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.config.ConfigurationManager;
+import org.onap.sdc.tosca.parser.elements.EntityDetailsFactory;
+import org.onap.sdc.tosca.parser.elements.NodeTemplateEntityDetails;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
import org.onap.sdc.tosca.parser.enums.FilterType;
import org.onap.sdc.tosca.parser.enums.PropertySchemaType;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
@@ -1196,8 +1202,18 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
@Override
- public List<Input> getInputsWithAnnotations() {
- return toscaTemplate.getInputs(true);
- }
+ public List<Input> getInputsWithAnnotations() {
+ return toscaTemplate.getInputs(true);
+ }
+
+ @Override
+ public List<IEntityDetails> getEntity(EntityQuery entityQuery, TopologyTemplateQuery topologyTemplateQuery, boolean isRecursive) {
+ List<IEntityDetails> foundEntities = new ArrayList<>();
+ List<NodeTemplate> vfcList = getVfcListByVf("05e77410-a1d8-44fe-8440-b9410c8f98ee");
+ NodeTemplate vfc = getNodeTemplateByCustomizationUuid(vfcList, "1fdc9625-dfec-48e1-aaf8-7b92f78ca854");
+ NodeTemplate cp = getChildNodeTemplateByName(vfc, "ssc_ssc_avpn_port_0");
+ foundEntities.add(EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, cp, vfc));
+ return foundEntities;
+ }
}
diff --git a/src/test/java/org/onap/sdc/impl/GetEntityTest.java b/src/test/java/org/onap/sdc/impl/GetEntityTest.java
new file mode 100644
index 0000000..8a2067d
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/GetEntityTest.java
@@ -0,0 +1,88 @@
+package org.onap.sdc.impl;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.Property;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class GetEntityTest {
+
+ private static ISdcCsarHelper helper = null;
+
+ @BeforeClass
+ public static void setUpClass() {
+ try {
+ String filePath = GetEntityTest.class.getClassLoader().getResource("csars/service-JennyVtsbcVlanSvc-csar.csar").getFile();
+ helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(filePath);
+ } catch (SdcToscaParserException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void test1() {
+ //none recursive search for groups in the service
+ EntityQuery entityQuery1 = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .uUID("1233456")
+ .build();
+
+ TopologyTemplateQuery topologyTemplateQuery1 = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+ List<IEntityDetails> entities = helper.getEntity(entityQuery1, topologyTemplateQuery1, false);
+
+ for (IEntityDetails entity: entities) {
+ List<IEntityDetails> members = entity.getMemberNodes();
+ }
+
+ //recursive search for CPs in a specific CVFC
+ EntityQuery entityQuery2 = EntityQuery.newBuilder(SdcTypes.CP)
+ .customizationUUID("345678903456")
+ .build();
+
+ TopologyTemplateQuery topologyTemplateQuery2 = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .customizationUUID("12346767676")
+ .build();
+ entities = helper.getEntity(entityQuery2, topologyTemplateQuery2, true);
+
+ for (IEntityDetails entity: entities) {
+ Map<String, Property> properties = entity.getProperties();
+ Property property = properties.get("network_role");
+ String network_role_value = (String) property.getValue();
+ }
+
+ }
+
+ @Test
+ public void getCpEntityMock() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(1, entities.size());
+ assertEquals(1, entities.get(0).getMemberNodes().size());
+ assertEquals(EntityTemplateType.NODE_TEMPLATE, entities.get(0).getType());
+ assertEquals("28.0", entities.get(0).getMetadata().getValue("version"));
+ assertEquals("CP", entities.get(0).getMetadata().getValue("type"));
+ assertEquals("extNeutronCP", entities.get(0).getMetadata().getValue("name"));
+ assertEquals("abstract_ssc", entities.get(0).getParent().getName());
+ assertEquals("jenny vTSBC vlan VNF 0#abstract_ssc#ssc_ssc_avpn_port_0", entities.get(0).getPath());
+ assertTrue(entities.get(0).getProperties() != null && entities.get(0).getProperties().size() == 18);
+
+ }
+}
diff --git a/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar b/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar
new file mode 100644
index 0000000..7118c08
--- /dev/null
+++ b/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar
Binary files differ
diff --git a/version.properties b/version.properties
index 442dce4..7a72c98 100644
--- a/version.properties
+++ b/version.properties
@@ -5,7 +5,7 @@
major=1
minor=4
-patch=7
+patch=8
base_version=${major}.${minor}.${patch}