From 0c049f2c4f7dc4b8a10f270932179b6596e75de7 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 6 Feb 2018 13:41:55 +0100
Subject: [PATCH] reaction comparator use new collection set comaprator

---
 .../model/map/model/ModelComparator.java      | 44 +------------------
 1 file changed, 2 insertions(+), 42 deletions(-)

diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelComparator.java
index f19e1b2e6b..171fe14674 100644
--- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelComparator.java
+++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelComparator.java
@@ -120,7 +120,8 @@ public class ModelComparator extends Comparator<Model> {
       return status;
     }
 
-    status = compareReaction(arg0.getReactions(), arg1.getReactions());
+    SetComparator<Reaction> reactionSetComparator = new SetComparator<>(new ReactionComparator(epsilon));
+    status = reactionSetComparator.compare(arg0.getReactions(), arg1.getReactions());
     if (status != 0) {
       logger.debug("Set of reactions different");
       return status;
@@ -173,47 +174,6 @@ public class ModelComparator extends Comparator<Model> {
     return 0;
   }
 
-  /**
-   * Compares two set of reactions.
-   * 
-   * @param reactions
-   *          first set of reactions
-   * @param reactions2
-   *          second set of reactions
-   * @return if sets are equal then returns 0. If they are different then -1/1 is
-   *         returned.
-   */
-  private int compareReaction(Set<Reaction> reactions, Set<Reaction> reactions2) {
-    ReactionComparator comparator = new ReactionComparator(epsilon);
-
-    Map<String, Reaction> map = new HashMap<String, Reaction>();
-    Map<String, Reaction> map2 = new HashMap<String, Reaction>();
-
-    for (Reaction reaction : reactions) {
-      map.put(reaction.getIdReaction(), reaction);
-    }
-    for (Reaction reaction : reactions2) {
-      map2.put(reaction.getIdReaction(), reaction);
-    }
-
-    for (Reaction reaction : reactions) {
-      int status = comparator.compare(reaction, map2.get(reaction.getIdReaction()));
-      if (status != 0) {
-        logger.debug("Different reaction " + reaction.getIdReaction() + ": " + map2.get(reaction.getIdReaction()));
-        return status;
-      }
-    }
-
-    for (Reaction reaction : reactions2) {
-      int status = comparator.compare(reaction, map.get(reaction.getIdReaction()));
-      if (status != 0) {
-        logger.debug("Different reaction " + reaction.getIdReaction());
-        return status;
-      }
-    }
-    return 0;
-  }
-
   /**
    * Compares two sets of layers.
    * 
-- 
GitLab