Skip to content
Snippets Groups Projects
Commit 77cf9226 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

allow to filter by element id

parent 8a1c3f22
No related branches found
No related tags found
1 merge request!171Resolve "data overlay should support element id"
......@@ -209,6 +209,11 @@ public class ColorModelCommand extends ModelCommand {
return false;
}
}
if (schema.getElementId() != null && !schema.getElementId().isEmpty()) {
if (!element.getElementId().equalsIgnoreCase(schema.getElementId())) {
return false;
}
}
if (schema.getTypes().size() > 0) {
boolean found = false;
for (Class<?> clazz : schema.getTypes()) {
......
......@@ -452,4 +452,46 @@ public class ColorModelCommandTest extends CommandTestFunctions {
}
}
public void testAliasColoringWithUnknownElementSourceId() throws Exception {
try {
Model model = getModelForFile("testFiles/sample.xml", false);
ColorSchema schema = new GenericColorSchema();
schema.setElementId("xxx");
Collection<ColorSchema> schemas = new ArrayList<>();
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
assertEquals(0, map.values().size());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testAliasColoringWithElementIdMatch() throws Exception {
try {
Model model = getModelForFile("testFiles/sample.xml", false);
ColorSchema schema = new GenericColorSchema();
schema.setElementId(model.getElements().iterator().next().getElementId());
Collection<ColorSchema> schemas = new ArrayList<>();
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
assertEquals(1, map.values().size());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
......@@ -42,6 +42,8 @@ public abstract class ColorSchema implements Serializable {
* Identifier of the reaction to change the color.
*/
private String reactionIdentifier = null;
private String elementId = null;
/**
* Should the direction of highlighted reaction be reversed.
......@@ -467,4 +469,12 @@ public abstract class ColorSchema implements Serializable {
this.modelName = modelName;
}
public String getElementId() {
return elementId;
}
public void setElementId(String elementId) {
this.elementId = elementId;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment