diff --git a/commons/src/main/java/lcsb/mapviewer/common/XmlParser.java b/commons/src/main/java/lcsb/mapviewer/common/XmlParser.java index 9a163309bc817137ec53514ea5f437929828e8fa..ce34cdefa4ae5db57b0e402fbd76106f1aae2de5 100644 --- a/commons/src/main/java/lcsb/mapviewer/common/XmlParser.java +++ b/commons/src/main/java/lcsb/mapviewer/common/XmlParser.java @@ -222,7 +222,7 @@ final public class XmlParser { * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - private static Document getXmlDocumentFromString(final String text, boolean validate) throws InvalidXmlSchemaException { + public static Document getXmlDocumentFromString(final String text, boolean validate) throws InvalidXmlSchemaException { InputSource is = new InputSource(); is.setCharacterStream(new StringReader(text)); try { diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java index e7b443111d26d84cfb33fb20e40d476970389258..59ea4f1820799347dd9fab0565d0a2296538f442 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java @@ -31,14 +31,11 @@ import lcsb.mapviewer.annotation.services.MiriamConnector; import lcsb.mapviewer.annotation.services.PubmedParser; import lcsb.mapviewer.annotation.services.PubmedSearchException; import lcsb.mapviewer.annotation.services.annotators.ElementAnnotator; -import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; -import lcsb.mapviewer.converter.IConverter; -import lcsb.mapviewer.converter.graphics.AbstractImageGenerator; -import lcsb.mapviewer.converter.graphics.ImageGenerators; +import lcsb.mapviewer.converter.Converter; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; import lcsb.mapviewer.converter.model.sbgnml.SbgnmlXmlConverter; import lcsb.mapviewer.converter.model.sbml.SbmlParser; @@ -322,8 +319,8 @@ public abstract class BaseRestImpl { this.projectService = projectService; } - protected IConverter getModelParser(String handlerClass) throws QueryException { - for (IConverter converter : getModelConverters()) { + protected Converter getModelParser(String handlerClass) throws QueryException { + for (Converter converter : getModelConverters()) { if (converter.getClass().getCanonicalName().equals(handlerClass)) { return converter; } @@ -331,8 +328,8 @@ public abstract class BaseRestImpl { throw new QueryException("Unknown handlerClass: " + handlerClass); } - protected List<IConverter> getModelConverters() { - List<IConverter> result = new ArrayList<>(); + protected List<Converter> getModelConverters() { + List<Converter> result = new ArrayList<>(); result.add(new CellDesignerXmlParser()); result.add(new SbgnmlXmlConverter()); result.add(new SbmlParser()); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java index 3030964b4d50e8140eca19c6e05c048f02fd54f0..171eb6ceeca592d3ae93114cd0ce07cb3296c9d2 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java @@ -20,7 +20,7 @@ import lcsb.mapviewer.api.BaseRestImpl; import lcsb.mapviewer.api.QueryException; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.converter.IConverter; +import lcsb.mapviewer.converter.Converter; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator; import lcsb.mapviewer.converter.graphics.ImageGenerators; import lcsb.mapviewer.model.graphics.MapCanvasType; @@ -117,11 +117,11 @@ public class ConfigurationRestImpl extends BaseRestImpl { public List<Map<String, Object>> getModelFormats(String token) throws SecurityException { verifyToken(token); - List<IConverter> converters = getModelConverters(); + List<Converter> converters = getModelConverters(); List<Map<String, Object>> result = new ArrayList<>(); - for (IConverter converter : converters) { + for (Converter converter : converters) { Map<String, Object> row = new TreeMap<>(); row.put("name", converter.getCommonName()); row.put("handler", converter.getClass().getCanonicalName()); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/convert/ConvertRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/convert/ConvertRestImpl.java index 9d8a7d1152cc6f4a7ea5f7ede507a37ec212684d..c68685a48b43bf748772b971a11223a15fd3f542 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/convert/ConvertRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/convert/ConvertRestImpl.java @@ -24,7 +24,7 @@ import lcsb.mapviewer.api.QueryException; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.converter.ConverterException; import lcsb.mapviewer.converter.ConverterParams; -import lcsb.mapviewer.converter.IConverter; +import lcsb.mapviewer.converter.Converter; import lcsb.mapviewer.converter.InvalidInputDataExecption; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator; import lcsb.mapviewer.converter.graphics.DrawingException; @@ -49,8 +49,8 @@ public class ConvertRestImpl extends BaseRestImpl { ConverterParams params = createConvertParams(input); Model model = getModelParserByNameOrClass(fromFormat).createModel(params); - IConverter exporter = getModelParserByNameOrClass(toFormat); - return IOUtils.toString(exporter.exportModelToInputStream(model)); + Converter exporter = getModelParserByNameOrClass(toFormat); + return IOUtils.toString(exporter.model2InputStream(model)); } public ByteArrayOutputStream converToImage(String token, String fromFormat, String toFormat, String input, @@ -82,7 +82,7 @@ public class ConvertRestImpl extends BaseRestImpl { List<Object> converters = new ArrayList<>(); - for (IConverter converter: getModelConverters()) { + for (Converter converter: getModelConverters()) { List<String> names = new ArrayList<>(); names.add(removeWhiteSpaces(converter.getCommonName())); @@ -119,7 +119,7 @@ public class ConvertRestImpl extends BaseRestImpl { return info; } - private IConverter getModelParserByNameOrClass(String id) throws QueryException { + private Converter getModelParserByNameOrClass(String id) throws QueryException { try { return getModelParserByName(id); } catch (QueryException e) { @@ -131,8 +131,8 @@ public class ConvertRestImpl extends BaseRestImpl { return str.replace(' ', '_'); } - private IConverter getModelParserByName(String name) throws QueryException { - for (IConverter converter : getModelConverters()) { + private Converter getModelParserByName(String name) throws QueryException { + for (Converter converter : getModelConverters()) { if (removeWhiteSpaces(converter.getCommonName()).equals(name)) { return converter; } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java index 1da0a9b5261fd32b6957c8992c5fcf932362311b..2f334b9debe88a5ac7053d4fb574d6282b359227 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java @@ -1,7 +1,6 @@ package lcsb.mapviewer.api.projects; import java.awt.geom.Point2D; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.Serializable; import java.security.MessageDigest; @@ -16,7 +15,6 @@ import java.util.Set; import java.util.TreeMap; import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.MultiValueMap; @@ -31,7 +29,7 @@ import lcsb.mapviewer.api.QueryException; import lcsb.mapviewer.api.projects.models.publications.PublicationsRestImpl; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.IConverter; +import lcsb.mapviewer.converter.Converter; import lcsb.mapviewer.converter.zip.ImageZipEntryFile; import lcsb.mapviewer.converter.zip.LayoutZipEntryFile; import lcsb.mapviewer.converter.zip.ModelZipEntryFile; @@ -379,7 +377,7 @@ public class ProjectRestImpl extends BaseRestImpl { if (parserClass == null) { throw new QueryException("parser is obligatory"); } - IConverter parser = getModelParser(parserClass); + Converter parser = getModelParser(parserClass); List<ZipEntryFile> zipEntries = extractZipEntries(data); params.complex(zipEntries.size() > 0); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java index 2632a23fbd040a92db7fe41f7e3301c1efb5b4f5..2c21e157e274a5002e16003acaf464092577df20 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java @@ -244,7 +244,7 @@ public class ModelRestImpl extends BaseRestImpl { } Converter parser = getModelParser(handlerClass); - InputStream is = parser.exportModelToInputStream(part); + InputStream is = parser.model2InputStream(part); String fileExtension = parser.getFileExtension();