Commit 6c89a8f1 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

concurency issue

parent 35b3d86e
Pipeline #50754 failed with stage
in 60 minutes and 4 seconds
......@@ -6,6 +6,9 @@ minerva (16.0.5) stable; urgency=medium
* Bug fix (performance): showing data overlay on big map was time consuming
* Bug fix: invalid SBML file could crash map upload/format conversion (#1611)
* Bug fix: some old maps could not be removed (#1607)
* Bug fix: concurency issue when exporting to CellDesigner - minerva could
crash when there were two exports running in parallel (#1598)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 13 Dec 2021 15:00:00 +0200
......
......@@ -4,13 +4,20 @@ import java.awt.Color;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.io.ByteArrayInputStream;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.xml.parsers.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Node;
import org.xml.sax.*;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.InvalidStateException;
......@@ -42,23 +49,24 @@ public class CommonXmlParser {
}
@Override
public void setSize(double width, double height) {
public void setSize(final double width, final double height) {
this.width = width;
this.height = height;
}
}
public static Set<MiriamRelationType> RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER;
{
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER = new HashSet<>();
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.addAll(Arrays.asList(MiriamRelationType.values()));
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_MODEL_IS_DERIVED_FROM);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_BIOL_HAS_PROPERTY);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_BIOL_IS_PROPERTY_OF);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_MODEL_IS_INSTANCE_OF);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_MODEL_HAS_INSTANCE);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_BIOL_HAS_TAXON);
public static final Set<MiriamRelationType> RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER;
static {
Set<MiriamRelationType> types = new HashSet<>();
types.addAll(Arrays.asList(MiriamRelationType.values()));
types.remove(MiriamRelationType.BQ_MODEL_IS_DERIVED_FROM);
types.remove(MiriamRelationType.BQ_BIOL_HAS_PROPERTY);
types.remove(MiriamRelationType.BQ_BIOL_IS_PROPERTY_OF);
types.remove(MiriamRelationType.BQ_MODEL_IS_INSTANCE_OF);
types.remove(MiriamRelationType.BQ_MODEL_HAS_INSTANCE);
types.remove(MiriamRelationType.BQ_BIOL_HAS_TAXON);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER = Collections.unmodifiableSet(types);
}
private DocumentBuilderFactory dbFactory;
......@@ -70,17 +78,17 @@ public class CommonXmlParser {
dBuilder = dbFactory.newDocumentBuilder();
dBuilder.setErrorHandler(new ErrorHandler() {
@Override
public void warning(SAXParseException e) throws SAXException {
public void warning(final SAXParseException e) throws SAXException {
;
}
@Override
public void fatalError(SAXParseException e) throws SAXException {
public void fatalError(final SAXParseException e) throws SAXException {
throw e;
}
@Override
public void error(SAXParseException e) throws SAXException {
public void error(final SAXParseException e) throws SAXException {
throw e;
}
});
......@@ -97,7 +105,7 @@ public class CommonXmlParser {
* xml node to parse
* @return Point2D object
*/
public Point2D getPosition(Node node) {
public Point2D getPosition(final Node node) {
double x = Double.parseDouble(XmlParser.getNodeAttr("x", node));
double y = Double.parseDouble(XmlParser.getNodeAttr("y", node));
return new Point2D.Double(x, y);
......@@ -111,7 +119,7 @@ public class CommonXmlParser {
* xml node to parse
* @return dimension (with width and height fields)
*/
public Dimension2D getDimension(Node node) {
public Dimension2D getDimension(final Node node) {
double width = Double.parseDouble(XmlParser.getNodeAttr("width", node));
double height = Double.parseDouble(XmlParser.getNodeAttr("height", node));
DimensionDouble result = new DimensionDouble();
......@@ -126,7 +134,7 @@ public class CommonXmlParser {
* xml node to parse
* @return single line object (with width field)
*/
public SingleLine getSingleLine(Node node) {
public SingleLine getSingleLine(final Node node) {
SingleLine result = new SingleLine();
result.setWidth(Double.parseDouble(XmlParser.getNodeAttr("width", node)));
return result;
......@@ -139,9 +147,10 @@ public class CommonXmlParser {
* xml node to parse
* @return Color value stored in xml
*/
public Color getColor(Node node) {
public Color getColor(final Node node) {
String color = XmlParser.getNodeAttr("color", node);
// cellDesigner has a bug that removes info about alpha when alpha is 0 (#1103)
// cellDesigner has a bug that removes info about alpha when alpha is 0
// (#1103)
color = StringUtils.leftPad(color, 8, "0");
return XmlParser.stringToColor(color);
......@@ -155,7 +164,7 @@ public class CommonXmlParser {
* @return view parsed from xml
* @see View
*/
public View getView(Node node) {
public View getView(final Node node) {
View result = new View();
Node tmpNode = XmlParser.getNode("celldesigner:innerPosition", node.getChildNodes());
if (tmpNode != null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment