diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java index 07d2e6faedbcfa9ac354d6881ea491c91b5f24a2..bda5fc3e6191d9ff22e3140cced9ad3e2439d081 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java @@ -4,8 +4,10 @@ import java.awt.Color; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.log4j.Logger; @@ -289,9 +291,10 @@ public class ColorModelCommand extends ModelCommand { List<Model> models = new ArrayList<>(); models.add(getModel()); models.addAll(getModel().getSubmodels()); + for (Model model : models) { - for (ColorSchema schema : schemas) { - for (BioEntity element : model.getBioEntities()) { + for (BioEntity element : model.getBioEntities()) { + for (ColorSchema schema : schemas) { if (match(element, schema)) { if (result.get(element) != null && !colorExtractor.getNormalizedColor(result.get(element)).equals(Color.WHITE)) { diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java index 59fe3d09bfaf927e088277d3a9b7b33a238c8f3a..4f6be19fe04c2a0c97e866f15a4a5b9adca02104 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java @@ -2,6 +2,7 @@ package lcsb.mapviewer.commands; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.awt.Color; @@ -537,4 +538,32 @@ public class ColorModelCommandTest extends CommandTestFunctions { } } + @Test + public void testGetModifiedElements() throws Exception { + try { + Reaction reaction = new Reaction(); + reaction.addMiriamData(new MiriamData(MiriamType.PUBMED, "1234")); + + Model model = new ModelFullIndexed(null); + model.addReaction(reaction); + + GenericColorSchema colorSchema = new GenericColorSchema(); + colorSchema.addMiriamData(new MiriamData(MiriamType.PUBMED,"1234")); + + List<ColorSchema> schemas = new ArrayList<>(); + schemas.add(colorSchema); + + ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor); + + assertNotNull(factory.getModifiedElements().get(reaction)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + + }