From d97c72d7d951dc3d79f57355e6196944cdaab91c Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 19 Nov 2018 11:06:09 +0100
Subject: [PATCH] debug logs improved

---
 .../model/sbgnml/SbgnmlXmlExporter.java          | 16 ++++++++--------
 .../mapviewer/modelutils/map/ElementUtils.java   |  5 +++++
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java
index 39b313a258..0015b30511 100644
--- a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java
+++ b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java
@@ -46,6 +46,7 @@ import lcsb.mapviewer.model.map.reaction.OrOperator;
 import lcsb.mapviewer.model.map.reaction.Product;
 import lcsb.mapviewer.model.map.reaction.Reactant;
 import lcsb.mapviewer.model.map.reaction.Reaction;
+import lcsb.mapviewer.model.map.reaction.ReactionNode;
 import lcsb.mapviewer.model.map.reaction.SplitOperator;
 import lcsb.mapviewer.model.map.reaction.type.DissociationReaction;
 import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction;
@@ -177,9 +178,8 @@ public class SbgnmlXmlExporter {
         try {
           map.getArc().add(getArcFromReducedReaction(reaction));
         } catch (InvalidArgumentException e) {
-          logger.warn("Invalid arc type."
-              + " Reduced notation reaction found of type that is not compliant with SBGN-ML format." + " Reaction: "
-              + reaction.getIdReaction());
+          logger.warn(eu.getElementTag(reaction) + "Invalid arc type."
+              + " Reduced notation reaction found of type that is not compliant with SBGN-ML format.");
         }
         continue;
       }
@@ -707,7 +707,8 @@ public class SbgnmlXmlExporter {
     }
 
     if (reaction.getProducts().get(0).getElement() instanceof Phenotype) {
-      logger.warn("Found Phenotype being a reactant in process. That is discouraged");
+      logger.warn(eu.getElementTag(reaction.getProducts().get(0).getElement())
+          + "Found Phenotype being a reactant in process. That is discouraged");
     }
 
     arc.setSource(sourceTargetMap.get(reaction.getReactants().get(0).getElement().getElementId()));
@@ -801,13 +802,12 @@ public class SbgnmlXmlExporter {
     List<Arc> arcList = new ArrayList<>();
 
     // Parse all nodes except NodeOperators
-    for (AbstractNode node : reaction.getNodes().stream().filter(n -> !(n instanceof NodeOperator))
-        .collect(Collectors.toList())) {
+    for (ReactionNode node : reaction.getReactionNodes()) {
       try {
         arcList.add(getArcFromNode(node, glyphList));
       } catch (InvalidArgumentException ex) {
-        logger.warn("Node skipped in export process, since it is not compliant with SBGN-ML format: "
-            + node.getClass().getName());
+        logger.warn(
+            eu.getElementTag(node) + "Node skipped in export process, since it is not compliant with SBGN-ML format.");
         continue;
       }
     }
diff --git a/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java b/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java
index 91048a0216..8632b77cf0 100644
--- a/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java
+++ b/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java
@@ -14,6 +14,7 @@ import org.reflections.Reflections;
 import lcsb.mapviewer.common.exception.NotImplementedException;
 import lcsb.mapviewer.model.map.BioEntity;
 import lcsb.mapviewer.model.map.reaction.Reaction;
+import lcsb.mapviewer.model.map.reaction.ReactionNode;
 import lcsb.mapviewer.model.map.species.Element;
 
 /**
@@ -257,4 +258,8 @@ public final class ElementUtils {
     ElementUtils.reactionClasses = reactionClasses;
   }
 
+  public String getElementTag(ReactionNode node) {
+    return "[" + node.getClass().getSimpleName() + "]" + getElementTag(node.getElement());
+  }
+
 }
-- 
GitLab