Filtered the relationship which target node is same to the source node.
authorYuanHu <yuan.hu1@zte.com.cn>
Mon, 21 Nov 2016 01:49:20 +0000 (09:49 +0800)
committerYuanHu <yuan.hu1@zte.com.cn>
Mon, 21 Nov 2016 01:49:20 +0000 (09:49 +0800)
Change-Id: I5e8a8148f7d449be1e7094dea4568d68d7fcff35
Issue-id: TOSCA-183
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java

index 5145d64..71372c2 100644 (file)
@@ -186,7 +186,8 @@ public class AriaModelParser extends AbstractModelParser {
    * @return
    * @throws CatalogResourceException 
    */
-  private List<RelationShip> parseNodeTemplateRelationShip(Relationship[] relationships, Node sourceNode, Node[] nodes) throws CatalogResourceException {
+  private List<RelationShip> parseNodeTemplateRelationShip(Relationship[] relationships,
+      Node sourceNode, Node[] nodes) throws CatalogResourceException {
     List<RelationShip> retList = new ArrayList<>();
 
     if (relationships == null || relationships.length == 0) {
@@ -194,6 +195,10 @@ public class AriaModelParser extends AbstractModelParser {
     }
 
     for (Relationship relationship : relationships) {
+      if (relationship.getTarget_node_id().equals(sourceNode.getId())) {
+        continue;  // target == source, ignore.
+      }
+      
       RelationShip ret = new RelationShip();
       ret.setSourceNodeId(sourceNode.getTemplate_name());
       ret.setSourceNodeName(sourceNode.getTemplate_name());