Commit c4a9b6db authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch 'master' into multithread-test-issue

parents 6a0c4f10 e03ef028
Pipeline #6762 passed with stage
in 9 minutes and 37 seconds
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<parent> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>lcsb.mapviewer</groupId> <modelVersion>4.0.0</modelVersion>
<artifactId>parent</artifactId> <parent>
<version>1.0</version> <groupId>lcsb.mapviewer</groupId>
</parent> <artifactId>parent</artifactId>
<artifactId>CellDesigner-plugin</artifactId> <version>1.0</version>
<!-- dependency from the MapViewer model --> </parent>
<artifactId>CellDesigner-plugin</artifactId>
<repositories> <!-- dependency from the MapViewer model -->
<repository>
<id>central</id> <repositories>
<url>http://repo.maven.apache.org/maven2/</url> <repository>
</repository> <id>central</id>
<url>http://repo.maven.apache.org/maven2/</url>
<repository> </repository>
<id>repo</id>
<releases> <repository>
<enabled>true</enabled> <id>repo</id>
<checksumPolicy>ignore</checksumPolicy> <releases>
</releases> <enabled>true</enabled>
<snapshots> <checksumPolicy>ignore</checksumPolicy>
<enabled>false</enabled> </releases>
</snapshots> <snapshots>
<url>file://${project.basedir}/repo</url> <enabled>false</enabled>
</repository> </snapshots>
<url>file://${project.basedir}/repo</url>
</repositories> </repository>
<build> </repositories>
<plugins>
<plugin> <build>
<artifactId>maven-assembly-plugin</artifactId> <plugins>
<executions> <plugin>
<execution> <artifactId>maven-assembly-plugin</artifactId>
<id>make-assembly</id> <!-- this is used for inheritance merges --> <executions>
<phase>package</phase> <!-- bind to the packaging phase --> <execution>
<goals> <id>make-assembly</id> <!-- this is used for inheritance merges -->
<goal>single</goal> <phase>package</phase> <!-- bind to the packaging phase -->
</goals> <goals>
<configuration> <goal>single</goal>
<descriptor>install.xml</descriptor> </goals>
</configuration> <configuration>
</execution> <descriptor>install.xml</descriptor>
</executions> </configuration>
</plugin> </execution>
</plugins> </executions>
</build> </plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>lcsb.mapviewer</groupId> <dependencies>
<artifactId>model</artifactId> <dependency>
<version>1.0</version> <groupId>lcsb.mapviewer</groupId>
</dependency> <artifactId>model</artifactId>
<version>1.0</version>
<dependency> </dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>commons</artifactId> <dependency>
<version>1.0</version> <groupId>lcsb.mapviewer</groupId>
</dependency> <artifactId>commons</artifactId>
<version>1.0</version>
<dependency> </dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter-CellDesigner</artifactId> <dependency>
<version>1.0</version> <groupId>lcsb.mapviewer</groupId>
</dependency> <artifactId>converter-CellDesigner</artifactId>
<version>1.0</version>
<dependency> </dependency>
<groupId>jp.sbi</groupId>
<artifactId>celldesigner</artifactId> <dependency>
<version>${celldesigner.version}</version> <groupId>jp.sbi</groupId>
</dependency> <artifactId>celldesigner</artifactId>
<version>${celldesigner.version}</version>
<dependency> </dependency>
<groupId>org.sbml</groupId>
<artifactId>libsbml</artifactId> <dependency>
<version>${libsbml.version}</version> <groupId>org.sbml</groupId>
</dependency> <artifactId>libsbml</artifactId>
<version>${libsbml.version}</version>
</dependencies> </dependency>
</dependencies>
</project> </project>
\ No newline at end of file
...@@ -160,7 +160,11 @@ public class RestAnnotationParser extends XmlParser { ...@@ -160,7 +160,11 @@ public class RestAnnotationParser extends XmlParser {
return ""; return "";
} }
} else if (value instanceof String) { } else if (value instanceof String) {
return type.getCommonName() + ": " + value + "\n"; if (!((String) value).trim().isEmpty() || forceFullInfo) {
return type.getCommonName() + ": " + value + "\n";
} else {
return "";
}
} else if (value instanceof Integer) { } else if (value instanceof Integer) {
return type.getCommonName() + ": " + value + "\n"; return type.getCommonName() + ": " + value + "\n";
} else if (value instanceof Collection) { } else if (value instanceof Collection) {
...@@ -350,7 +354,7 @@ public class RestAnnotationParser extends XmlParser { ...@@ -350,7 +354,7 @@ public class RestAnnotationParser extends XmlParser {
logger.debug("Y"); logger.debug("Y");
notes = notes.substring(notes.indexOf("</head>") + "</head>".length()); notes = notes.substring(notes.indexOf("</head>") + "</head>".length());
} }
notes = notes.replace("xmlns=\"http://www.w3.org/1999/xhtml\"",""); notes = notes.replace("xmlns=\"http://www.w3.org/1999/xhtml\"", "");
return notes.replaceAll("&amp;", "&"); return notes.replaceAll("&amp;", "&");
} }
......
...@@ -76,9 +76,9 @@ ...@@ -76,9 +76,9 @@
<dependency> <dependency>
<groupId>org.sbml.jsbml</groupId> <groupId>org.sbml.jsbml</groupId>
<artifactId>jsbml</artifactId> <artifactId>jsbml</artifactId>
<version>1.3.1</version> <version>${jsbml.version}</version>
<!-- for now we use lower version of log4j and this one introduce some <!-- for now we use lower version of log4j and this one introduce some
problem with tomcat loggin --> problem with tomcat logging -->
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
...@@ -97,24 +97,67 @@ ...@@ -97,24 +97,67 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>commons-logging</groupId> <groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId> <artifactId>commons-logging</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.woodstox</groupId> <groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId> <artifactId>stax2-api</artifactId>
</exclusion>
<!-- https://github.com/sbmlteam/jsbml/issues/156 -->
<exclusion>
<groupId>org.sbml.jsbml</groupId>
<artifactId>jsbml-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.sbml.jsbml</groupId>
<artifactId>jsbml-core</artifactId>
<version>${jsbml.version}</version>
<!-- for now we use lower version of log4j and this one introduce some
problem with tomcat logging -->
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.woodstox</groupId> <groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId> <artifactId>stax2-api</artifactId>
<version>${stax2-api.version}</version> <version>${stax2-api.version}</version>
</dependency> </dependency>
<dependency> <dependency>
......
package lcsb.mapviewer.converter.model.sbml; package lcsb.mapviewer.converter.model.sbml;
import java.awt.Color;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -11,6 +12,13 @@ import org.apache.log4j.Logger; ...@@ -11,6 +12,13 @@ import org.apache.log4j.Logger;
import org.sbml.jsbml.Model; import org.sbml.jsbml.Model;
import org.sbml.jsbml.ext.layout.AbstractReferenceGlyph; import org.sbml.jsbml.ext.layout.AbstractReferenceGlyph;
import org.sbml.jsbml.ext.layout.Layout; import org.sbml.jsbml.ext.layout.Layout;
import org.sbml.jsbml.ext.render.ColorDefinition;
import org.sbml.jsbml.ext.render.LocalRenderInformation;
import org.sbml.jsbml.ext.render.LocalStyle;
import org.sbml.jsbml.ext.render.RenderConstants;
import org.sbml.jsbml.ext.render.RenderGraphicalObjectPlugin;
import org.sbml.jsbml.ext.render.RenderGroup;
import org.sbml.jsbml.ext.render.RenderLayoutPlugin;
import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.InvalidStateException;
...@@ -116,6 +124,13 @@ public abstract class SbmlBioEntityExporter<T extends BioEntity, S extends org.s ...@@ -116,6 +124,13 @@ public abstract class SbmlBioEntityExporter<T extends BioEntity, S extends org.s
this.layout = layout; this.layout = layout;
} }
protected RenderLayoutPlugin getRenderPlugin() {
if (layout.getExtensionCount() > 0) {
return (RenderLayoutPlugin) layout.getExtension("render");
}
return null;
}
protected lcsb.mapviewer.model.map.model.Model getMinervaModel() { protected lcsb.mapviewer.model.map.model.Model getMinervaModel() {
return minervaModel; return minervaModel;
} }
...@@ -132,4 +147,47 @@ public abstract class SbmlBioEntityExporter<T extends BioEntity, S extends org.s ...@@ -132,4 +147,47 @@ public abstract class SbmlBioEntityExporter<T extends BioEntity, S extends org.s
return sbmlGlyphByElementId.get(elementId); return sbmlGlyphByElementId.get(elementId);
} }
protected ColorDefinition getColorDefinition(Color color) {
RenderLayoutPlugin renderPlugin = getRenderPlugin();
LocalRenderInformation renderInformation = null;
for (LocalRenderInformation lri : renderPlugin.getListOfLocalRenderInformation()) {
if (lri.getId().equals("minerva_definitions")) {
renderInformation = lri;
}
}
if (renderInformation == null) {
renderInformation = new LocalRenderInformation("minerva_definitions");
renderPlugin.addLocalRenderInformation(renderInformation);
}
for (ColorDefinition cd : renderInformation.getListOfColorDefinitions()) {
if (cd.getValue().equals(color)) {
return cd;
}
}
ColorDefinition colorDefinition = new ColorDefinition("color_" + colorToString(color), color);
renderInformation.addColorDefinition(colorDefinition);
return colorDefinition;
}
protected void assignStyleToGlyph(AbstractReferenceGlyph speciesGlyph, LocalStyle style) {
RenderGraphicalObjectPlugin rgop = new RenderGraphicalObjectPlugin(speciesGlyph);
rgop.setObjectRole(style.getRoleList().get(0));
speciesGlyph.addExtension(RenderConstants.shortLabel, rgop);
}
protected LocalStyle createStyle(T element) {
LocalRenderInformation renderInformation = new LocalRenderInformation();
LocalStyle style = new LocalStyle();
style.getRoleList().add("style_" + element.getElementId());
style.setGroup(new RenderGroup());
renderInformation.addLocalStyle(style);
getRenderPlugin().addLocalRenderInformation(renderInformation);
return style;
}
} }
package lcsb.mapviewer.converter.model.sbml; package lcsb.mapviewer.converter.model.sbml;
import java.awt.Color;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
...@@ -9,6 +12,9 @@ import org.apache.log4j.Logger; ...@@ -9,6 +12,9 @@ import org.apache.log4j.Logger;
import org.sbml.jsbml.AbstractNamedSBase; import org.sbml.jsbml.AbstractNamedSBase;
import org.sbml.jsbml.Annotation; import org.sbml.jsbml.Annotation;
import org.sbml.jsbml.ext.layout.Layout; import org.sbml.jsbml.ext.layout.Layout;
import org.sbml.jsbml.ext.render.LocalRenderInformation;
import org.sbml.jsbml.ext.render.LocalStyle;
import org.sbml.jsbml.ext.render.RenderLayoutPlugin;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.XmlParser;
...@@ -89,4 +95,67 @@ public class SbmlBioEntityParser extends XmlParser { ...@@ -89,4 +95,67 @@ public class SbmlBioEntityParser extends XmlParser {
return (idCounter++) + ""; return (idCounter++) + "";
} }
/**
* Returns {@link LocalStyle} from the layout data identified by objectRole.
*
* @param objectRole
* object role identifier
* @return {@link LocalStyle} from the layout data
*/
protected LocalStyle getStyleForRole(String objectRole) {
RenderLayoutPlugin renderPlugin = (RenderLayoutPlugin) layout.getExtension("render");
for (LocalRenderInformation lri : renderPlugin.getListOfLocalRenderInformation()) {
for (LocalStyle style : lri.getListOfLocalStyles()) {
if (style.getRoleList().contains(objectRole)) {
return style;
}
}
}
return null;
}
protected Color getColorByColorDefinition(String fill) {
RenderLayoutPlugin renderPlugin = (RenderLayoutPlugin) layout.getExtension("render");
for (LocalRenderInformation lri : renderPlugin.getListOfLocalRenderInformation()) {
if (lri.getColorDefinition(fill) != null) {
return lri.getColorDefinition(fill).getValue();
}
}
return null;
}
protected LocalStyle getStyleForElement(BioEntity element) {
LocalStyle result = getStyleByRole("style_" + element.getElementId());
if (result == null && element.getElementId().contains("__")) {
result = getStyleByRole("style_" + element.getElementId().split("__")[1]);
}
if (result == null) {
result = getStyleByRole("default_" + element.getClass().getSimpleName());
}
return result;
}
private Map<String, LocalStyle> styleById = null;
LocalStyle getStyleByRole(String string) {
if (styleById == null) {
styleById = new HashMap<>();
if (layout != null) {
RenderLayoutPlugin renderPlugin = (RenderLayoutPlugin) layout.getExtension("render");
if (renderPlugin != null) {
for (LocalRenderInformation lri : renderPlugin.getListOfLocalRenderInformation()) {
if (lri.getId().equals("minerva_definitions")) {
for (LocalStyle style : lri.getListOfLocalStyles()) {
for (String role : style.getRoleList()) {
styleById.put(role, style);
}
}
}
}
}
}
}
return styleById.get(string);
}
} }
\ No newline at end of file
...@@ -6,6 +6,8 @@ import org.sbml.jsbml.ext.layout.BoundingBox; ...@@ -6,6 +6,8 @@ import org.sbml.jsbml.ext.layout.BoundingBox;
import org.sbml.jsbml.ext.layout.Dimensions; import org.sbml.jsbml.ext.layout.Dimensions;
import org.sbml.jsbml.ext.layout.Layout; import org.sbml.jsbml.ext.layout.Layout;
import org.sbml.jsbml.ext.layout.Point; import org.sbml.jsbml.ext.layout.Point;
import org.sbml.jsbml.ext.render.ColorDefinition;
import org.sbml.jsbml.ext.render.LocalStyle;
import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Element;
...@@ -25,8 +27,14 @@ public abstract class SbmlElementExporter<T extends Element, S extends org.sbml. ...@@ -25,8 +27,14 @@ public abstract class SbmlElementExporter<T extends Element, S extends org.sbml.
dimensions.setWidth(element.getWidth()); dimensions.setWidth(element.getWidth());
dimensions.setHeight(element.getHeight()); dimensions.setHeight(element.getHeight());
boundingBox.setDimensions(dimensions); boundingBox.setDimensions(dimensions);
speciesGlyph.setBoundingBox(boundingBox); speciesGlyph.setBoundingBox(boundingBox);
LocalStyle style = createStyle(element);
ColorDefinition color = getColorDefinition(element.getColor());
style.getGroup().setFill(color.getId());
assignStyleToGlyph(speciesGlyph, style);
} }
} }
package lcsb.mapviewer.converter.model.sbml; package lcsb.mapviewer.converter.model.sbml;
import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
...@@ -12,6 +13,9 @@ import org.sbml.jsbml.ListOf; ...@@ -12,6 +13,9 @@ import org.sbml.jsbml.ListOf;
import org.sbml.jsbml.Model; import org.sbml.jsbml.Model;
import org.sbml.jsbml.ext.layout.AbstractReferenceGlyph; import org.sbml.jsbml.ext.layout.AbstractReferenceGlyph;
import org.sbml.jsbml.ext.layout.Layout; import org.sbml.jsbml.ext.layout.Layout;
import org.sbml.jsbml.ext.render.LocalStyle;
import org.sbml.jsbml.ext.render.RenderConstants;
import org.sbml.jsbml.ext.render.RenderGraphicalObjectPlugin;
import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.converter.InvalidInputDataExecption; import lcsb.mapviewer.converter.InvalidInputDataExecption;
...@@ -57,6 +61,13 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends ...@@ -57,6 +61,13 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends
elementBySbmlId.put(species.getElementId(), species); elementBySbmlId.put(species.getElementId(), species);
} }
for (Element element : elements) {
LocalStyle style = getStyleForElement(element);
if (style != null) {
applyStyleToElement(element, style);
}
}
for (Pair<String, AbstractReferenceGlyph> idGlyphPair : getGlyphs(sbmlLayout)) { for (Pair<String, AbstractReferenceGlyph> idGlyphPair : getGlyphs(sbmlLayout)) {
String id = idGlyphPair.getLeft(); String id = idGlyphPair.getLeft();
Element source = elementBySbmlId.get(id); Element source = elementBySbmlId.get(id);
...@@ -68,12 +79,7 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends ...@@ -68,12 +79,7 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends
if (glyph.getId() == null || glyph.getId().equals("")) { if (glyph.getId() == null || glyph.getId().equals("")) {
throw new InvalidInputDataExecption("Glyph for Species " + idGlyphPair.getLeft() + " doesn't have id"); throw new InvalidInputDataExecption("Glyph for Species " + idGlyphPair.getLeft() + " doesn't have id");
} }
Element elementWithLayout = source.copy(); Element elementWithLayout = createElementWithLayout(source, glyph);
elementWithLayout.setElementId(glyph.getId());
elementWithLayout.setX(glyph.getBoundingBox().getPosition().getX());
elementWithLayout.setY(glyph.getBoundingBox().getPosition().getY());
elementWithLayout.setWidth(glyph.getBoundingBox().getDimensions().getWidth());
elementWithLayout.setHeight(glyph.getBoundingBox().getDimensions().getHeight());
minervaModel.addElement(elementWithLayout); minervaModel.addElement(elementWithLayout);
result.add(elementWithLayout); result.add(elementWithLayout);
elementBySbmlId.put(id, elementWithLayout); elementBySbmlId.put(id, elementWithLayout);
...@@ -91,6 +97,33 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends ...@@ -91,6 +97,33 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends
return result; return result;