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

list of converters is resolved based on spring components

parent 525fc054
......@@ -67,6 +67,13 @@
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframework.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.xerces.parsers.DOMParser;
import org.springframework.stereotype.Component;
import org.w3c.dom.*;
import lcsb.mapviewer.common.*;
......@@ -55,6 +56,7 @@ import lcsb.mapviewer.model.map.species.Element;
* @author Piotr Gawron
*
*/
@Component
public class CellDesignerXmlParser extends Converter {
/**
......
......@@ -9,12 +9,14 @@ import org.apache.commons.text.StringEscapeUtils;
import org.apache.logging.log4j.core.LogEvent;
import org.sbgn.SbgnUtil;
import org.sbgn.bindings.Sbgn;
import org.springframework.stereotype.Component;
import lcsb.mapviewer.common.MimeType;
import lcsb.mapviewer.common.MinervaLoggerAppender;
import lcsb.mapviewer.converter.*;
import lcsb.mapviewer.model.map.model.Model;
@Component
public class SbgnmlXmlConverter extends Converter {
@Override
......
......@@ -13,6 +13,7 @@ import org.sbml.jsbml.ext.SBasePlugin;
import org.sbml.jsbml.ext.layout.Layout;
import org.sbml.jsbml.ext.layout.LayoutModelPlugin;
import org.sbml.jsbml.ext.multi.MultiModelPlugin;
import org.springframework.stereotype.Component;
import lcsb.mapviewer.commands.CommandExecutionException;
import lcsb.mapviewer.commands.layout.ApplySimpleLayoutModelCommand;
......@@ -33,6 +34,7 @@ import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
import lcsb.mapviewer.model.map.species.field.SpeciesWithModificationResidue;
@Component
public class SbmlParser extends Converter {
/**
......
......@@ -5,6 +5,7 @@ import java.io.IOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;
import lcsb.mapviewer.common.MimeType;
import lcsb.mapviewer.converter.*;
......@@ -13,6 +14,7 @@ import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.wikipathway.XML.GPMLToModel;
import lcsb.mapviewer.wikipathway.XML.ModelToGPML;
@Component
public class GpmlParser extends Converter {
Logger logger = LogManager.getLogger();
......
......@@ -23,9 +23,6 @@ import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.comparator.StringComparator;
import lcsb.mapviewer.common.exception.*;
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;
import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.reaction.Reaction;
......@@ -33,7 +30,6 @@ import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.user.annotator.*;
import lcsb.mapviewer.services.interfaces.*;
import lcsb.mapviewer.services.search.ElementMatcher;
import lcsb.mapviewer.wikipathway.GpmlParser;
@Transactional
public abstract class BaseRestImpl {
......@@ -61,6 +57,9 @@ public abstract class BaseRestImpl {
@Autowired
private PubmedParser pubmedParser;
@Autowired
private List<Converter> modelConverters;
private ElementMatcher elementMatcher = new ElementMatcher();
private Transformer mathMlTransformer;
......@@ -162,7 +161,7 @@ public abstract class BaseRestImpl {
* @param modelId
* list of model identifiers separated by "," or '*' when all models
* should be returned
* @throws QueryException
* @throws QueryException
*/
protected List<Model> getModels(String projectId, String modelId) throws QueryException {
Model model = modelService.getLastModelByProjectId(projectId);
......@@ -319,12 +318,7 @@ public abstract class BaseRestImpl {
}
protected List<Converter> getModelConverters() {
List<Converter> result = new ArrayList<>();
result.add(new CellDesignerXmlParser());
result.add(new SbgnmlXmlConverter());
result.add(new SbmlParser());
result.add(new GpmlParser());
return result;
return modelConverters;
}
protected String getFirstValue(List<Object> list) {
......
......@@ -8,7 +8,7 @@ import lcsb.mapviewer.services.SpringServiceConfig;
@Configuration
@EnableWebMvc
@Import({ SpringServiceConfig.class })
@ComponentScan(basePackages = { "lcsb.mapviewer.api" })
@ComponentScan(basePackages = { "lcsb.mapviewer" })
public class SpringRestApiConfig {
}
......@@ -15,16 +15,21 @@ import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.annotation.services.MiriamConnector;
import lcsb.mapviewer.annotation.services.PubmedParser;
import lcsb.mapviewer.annotation.services.annotators.ElementAnnotator;
import lcsb.mapviewer.api.projects.ProjectRestImpl;
import lcsb.mapviewer.converter.Converter;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.user.annotator.AnnotatorData;
public class BaseRestImplTest extends RestTestFunctions {
Logger logger = LogManager.getLogger(BaseRestImplTest.class);
Logger logger = LogManager.getLogger();
@Autowired
MiriamConnector mc;
@Autowired
ProjectRestImpl restImpl;
@Autowired
PubmedParser pubmedParser;
......@@ -107,4 +112,11 @@ public class BaseRestImplTest extends RestTestFunctions {
Integer x = controller.parseInteger(null);
assertNull(x);
}
@Test
public void testGetConverters() throws Exception {
List<Converter> list = restImpl.getModelConverters();
assertTrue(list.size() > 0);
}
}
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