From e4aca2f4201c9bf5eddfbc2344efc9a825b20fdf Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Wed, 11 Apr 2018 14:20:37 +0200 Subject: [PATCH] ReferenceGenomeView class removed --- .../genomics/ReferenceGenomeController.java | 28 +-- .../api/genomics/ReferenceGenomeRestImpl.java | 69 ++++++- .../ReferenceGenomeControllerTest.java | 3 +- .../services/impl/ReferenceGenomeService.java | 20 +- .../interfaces/IReferenceGenomeService.java | 12 +- .../view/ReferenceGenomeGeneMappingView.java | 125 ----------- ...ReferenceGenomeGeneMappingViewFactory.java | 59 ------ .../services/view/ReferenceGenomeView.java | 194 ------------------ .../view/ReferenceGenomeViewFactory.java | 68 ------ .../resources/applicationContext-service.xml | 3 - .../mapviewer/services/view/AllViewTests.java | 2 - ...renceGenomeGeneMappingViewFactoryTest.java | 55 ----- .../view/ReferenceGenomeViewFactoryTest.java | 55 ----- 13 files changed, 85 insertions(+), 608 deletions(-) delete mode 100644 service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingView.java delete mode 100644 service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingViewFactory.java delete mode 100644 service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeView.java delete mode 100644 service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeViewFactory.java delete mode 100644 service/src/test/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingViewFactoryTest.java delete mode 100644 service/src/test/java/lcsb/mapviewer/services/view/ReferenceGenomeViewFactoryTest.java diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeController.java b/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeController.java index 80caa2d0fd..67b4a370f0 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeController.java @@ -1,5 +1,7 @@ package lcsb.mapviewer.api.genomics; +import java.util.Map; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.CookieValue; @@ -8,26 +10,26 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javassist.tools.rmi.ObjectNotFoundException; import lcsb.mapviewer.api.BaseController; import lcsb.mapviewer.api.QueryException; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.services.SecurityException; -import lcsb.mapviewer.services.view.ReferenceGenomeView; @RestController public class ReferenceGenomeController extends BaseController { - @Autowired - private ReferenceGenomeRestImpl referenceGenomeController; + @Autowired + private ReferenceGenomeRestImpl referenceGenomeController; - @RequestMapping(value = "/genomics/taxonomies/{organismId}/genomeTypes/{type}/versions/{version}/", method = { RequestMethod.GET }, - produces = { MediaType.APPLICATION_JSON_VALUE }) - public ReferenceGenomeView getDrugsByQuery(// - @CookieValue(value = Configuration.AUTH_TOKEN) String token, // - @PathVariable(value = "organismId") String organism, // - @PathVariable(value = "type") String type, // - @PathVariable(value = "version") String version// - ) throws SecurityException, QueryException { - return referenceGenomeController.getReferenceGenome(token, organism, type, version); - } + @RequestMapping(value = "/genomics/taxonomies/{organismId}/genomeTypes/{type}/versions/{version}/", method = { + RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE }) + public Map<String, Object> getGenomesByQuery(// + @CookieValue(value = Configuration.AUTH_TOKEN) String token, // + @PathVariable(value = "organismId") String organism, // + @PathVariable(value = "type") String type, // + @PathVariable(value = "version") String version// + ) throws SecurityException, QueryException, ObjectNotFoundException { + return referenceGenomeController.getReferenceGenome(token, organism, type, version); + } } \ No newline at end of file diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeRestImpl.java index e517c1eaad..9c1f782af4 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeRestImpl.java @@ -1,19 +1,29 @@ package lcsb.mapviewer.api.genomics; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import lcsb.mapviewer.annotation.cache.BigFileCache; +import lcsb.mapviewer.api.BaseRestImpl; +import lcsb.mapviewer.api.ObjectNotFoundException; import lcsb.mapviewer.api.QueryException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.layout.ReferenceGenome; +import lcsb.mapviewer.model.map.layout.ReferenceGenomeGeneMapping; import lcsb.mapviewer.model.map.layout.ReferenceGenomeType; import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.interfaces.IReferenceGenomeService; -import lcsb.mapviewer.services.view.ReferenceGenomeView; @Transactional(value = "txManager") -public class ReferenceGenomeRestImpl { +public class ReferenceGenomeRestImpl extends BaseRestImpl { /** * Default class logger. @@ -27,25 +37,68 @@ public class ReferenceGenomeRestImpl { @Autowired private IReferenceGenomeService referenceGenomeService; - public ReferenceGenomeView getReferenceGenome(String token, String organismId, String type, String version) - throws SecurityException, QueryException { + @Autowired + private BigFileCache bigFileCache; + + public Map<String, Object> getReferenceGenome(String token, String organismId, String type, String version) + throws SecurityException, QueryException, ObjectNotFoundException { MiriamData organism = null; if (organismId != null && !organismId.isEmpty()) { organism = new MiriamData(MiriamType.TAXONOMY, organismId); } else { throw new QueryException("Unknown taxonomy organism: " + organismId); } - ReferenceGenomeView result = null; try { ReferenceGenomeType genomeType = ReferenceGenomeType.valueOf(type); version = version.replaceAll("\\*", ""); - result = referenceGenomeService.getReferenceGenomeViewByParams(organism, genomeType, version, token); - if (result == null) { - throw new QueryException("Cannot find requested reference genome"); + ReferenceGenome genome = referenceGenomeService.getReferenceGenomeViewByParams(organism, genomeType, version, + token); + if (genome == null) { + throw new ObjectNotFoundException("Cannot find requested reference genome"); } + return genomeToMap(genome); } catch (IllegalArgumentException e) { throw new QueryException("Cannot find type: " + type); } + } + + private Map<String, Object> genomeToMap(ReferenceGenome genome) { + Map<String, Object> result = new TreeMap<>(); + result.put("organism", super.createAnnotation(genome.getOrganism())); + result.put("version", genome.getVersion()); + result.put("downloadProgress", genome.getDownloadProgress()); + result.put("sourceUrl", genome.getSourceUrl()); + result.put("localUrl", getLocalUrl(genome.getSourceUrl())); + result.put("geneMapping", geneMappingToMaps(genome.getGeneMapping())); + + return null; + } + + private String getLocalUrl(String sourceUrl) { + String url = null; + try { + url = "../" + bigFileCache.getLocalPathForFile(sourceUrl); + } catch (FileNotFoundException e) { + logger.warn("Cannot find local file", e); + } + return url; + } + + private List<Map<String, Object>> geneMappingToMaps(List<ReferenceGenomeGeneMapping> geneMapping) { + List<Map<String, Object>> result = new ArrayList<>(); + for (ReferenceGenomeGeneMapping referenceGenomeGeneMapping : geneMapping) { + result.add(geneMappingToMap(referenceGenomeGeneMapping)); + } + + return result; + } + + private Map<String, Object> geneMappingToMap(ReferenceGenomeGeneMapping mapping) { + Map<String, Object> result = new TreeMap<>(); + result.put("downloadProgress", mapping.getDownloadProgress()); + result.put("localUrl", getLocalUrl(mapping.getSourceUrl())); + result.put("sourceUrl", mapping.getSourceUrl()); + result.put("name", mapping.getName()); return result; } diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/genomics/ReferenceGenomeControllerTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/genomics/ReferenceGenomeControllerTest.java index cc820e0780..4d9929a940 100644 --- a/rest-api/src/test/java/lcsb/mapviewer/api/genomics/ReferenceGenomeControllerTest.java +++ b/rest-api/src/test/java/lcsb/mapviewer/api/genomics/ReferenceGenomeControllerTest.java @@ -10,6 +10,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import lcsb.mapviewer.api.ObjectNotFoundException; import lcsb.mapviewer.api.QueryException; import lcsb.mapviewer.api.RestTestFunctions; @@ -49,7 +50,7 @@ public class ReferenceGenomeControllerTest extends RestTestFunctions { try { referenceGenomeRestImpl.getReferenceGenome(token, "960000", "UCSC", "ver"); fail("Exception expected"); - } catch (QueryException e2) { + } catch (ObjectNotFoundException e2) { assertTrue(e2.getMessage().contains("Cannot find requested reference genome")); } catch (Exception e) { e.printStackTrace(); diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ReferenceGenomeService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ReferenceGenomeService.java index 07fc7be059..b3bc006549 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ReferenceGenomeService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ReferenceGenomeService.java @@ -21,8 +21,6 @@ import lcsb.mapviewer.model.map.layout.ReferenceGenomeType; import lcsb.mapviewer.persist.dao.map.layout.ReferenceGenomeDao; import lcsb.mapviewer.services.interfaces.IReferenceGenomeService; import lcsb.mapviewer.services.utils.ReferenceGenomeExistsException; -import lcsb.mapviewer.services.view.ReferenceGenomeView; -import lcsb.mapviewer.services.view.ReferenceGenomeViewFactory; /** * Service managing reference genomes. @@ -52,12 +50,6 @@ public class ReferenceGenomeService implements IReferenceGenomeService { @Autowired private ReferenceGenomeDao referenceGenomeDao; - /** - * Factory that creates {@link ReferenceGenomeView}. - */ - @Autowired - private ReferenceGenomeViewFactory factory; - @Override public void addReferenceGenome(ReferenceGenomeType type, MiriamData organism, String version, String customUrl) throws IOException, URISyntaxException, ReferenceGenomeConnectorException { @@ -140,21 +132,15 @@ public class ReferenceGenomeService implements IReferenceGenomeService { } @Override - public ReferenceGenomeView getReferenceGenomeViewByParams(MiriamData miriamData, ReferenceGenomeType genomeType, - String version) { + public ReferenceGenome getReferenceGenomeViewByParams(MiriamData miriamData, ReferenceGenomeType genomeType, + String version, String authenticationToken) { List<ReferenceGenome> list = referenceGenomeDao.getByType(genomeType); for (ReferenceGenome referenceGenome : list) { if (referenceGenome.getOrganism().equals(miriamData) && referenceGenome.getVersion().equals(version)) { - return factory.create(referenceGenome); + return referenceGenome; } } return null; } - @Override - public ReferenceGenomeView getReferenceGenomeViewByParams(MiriamData organism, ReferenceGenomeType genomeType, - String version, String authenticationToken) { - return this.getReferenceGenomeViewByParams(organism, genomeType, version); - } - } diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/IReferenceGenomeService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/IReferenceGenomeService.java index 1857baf300..419116d1d7 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/IReferenceGenomeService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/IReferenceGenomeService.java @@ -9,7 +9,6 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.layout.ReferenceGenome; import lcsb.mapviewer.model.map.layout.ReferenceGenomeGeneMapping; import lcsb.mapviewer.model.map.layout.ReferenceGenomeType; -import lcsb.mapviewer.services.view.ReferenceGenomeView; /** * Service used to maintain referemce genome data. @@ -131,7 +130,7 @@ public interface IReferenceGenomeService { void removeReferenceGenomeGeneMapping(ReferenceGenomeGeneMapping mapping) throws IOException; /** - * Returns {@link ReferenceGenomeView} for specific reference genome. + * Returns {@link ReferenceGenome} for specific reference genome. * * @param organism * organism of reference genome @@ -139,11 +138,8 @@ public interface IReferenceGenomeService { * reference genome type * @param version * version of the reference genome - * @return {@link ReferenceGenomeView} for specific reference genome + * @return {@link ReferenceGenome} for specific reference genome */ - ReferenceGenomeView getReferenceGenomeViewByParams(MiriamData organism, ReferenceGenomeType genomeType, - String version); - - ReferenceGenomeView getReferenceGenomeViewByParams(MiriamData organism, ReferenceGenomeType genomeType, - String version, String authenticationToken); + ReferenceGenome getReferenceGenomeViewByParams(MiriamData organism, ReferenceGenomeType genomeType, String version, + String authenticationToken); } diff --git a/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingView.java b/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingView.java deleted file mode 100644 index f7c5284cb1..0000000000 --- a/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingView.java +++ /dev/null @@ -1,125 +0,0 @@ -package lcsb.mapviewer.services.view; - -import java.io.Serializable; - -import lcsb.mapviewer.model.map.layout.ReferenceGenome; -import lcsb.mapviewer.model.map.layout.ReferenceGenomeGeneMapping; - -/** - * View representation of the {@link ReferenceGenome}. - * - * @author Piotr Gawron - * - */ -public class ReferenceGenomeGeneMappingView extends AbstractView<ReferenceGenomeGeneMapping> implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * {@link ReferenceGenomeGeneMapping#name}. - */ - private String name; - - /** - * Url from which reference genome was downloaded. - */ - private String sourceUrl; - - /** - * Local url where reference genome file can be accessed. - */ - private String localUrl; - - /** - * Progess of downloading process (100 means file is downloaded). - */ - private double downloadProgress; - - /** - * Default constructor. - * - * @param object - * {@link ReferenceGenome} which this view should visualize - */ - protected ReferenceGenomeGeneMappingView(ReferenceGenomeGeneMapping object) { - super(object); - } - - /** - * Default constructor. Should be used only for deserialization. - */ - protected ReferenceGenomeGeneMappingView() { - } - - /** - * @return the name - * @see #name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - * @see #name - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the sourceUrl - * @see #sourceUrl - */ - public String getSourceUrl() { - return sourceUrl; - } - - /** - * @param sourceUrl - * the sourceUrl to set - * @see #sourceUrl - */ - public void setSourceUrl(String sourceUrl) { - this.sourceUrl = sourceUrl; - } - - /** - * @return the localUrl - * @see #localUrl - */ - public String getLocalUrl() { - return localUrl; - } - - /** - * @param localUrl - * the localUrl to set - * @see #localUrl - */ - public void setLocalUrl(String localUrl) { - this.localUrl = localUrl; - } - - /** - * @return the downloadProgress - * @see #downloadProgress - */ - public double getDownloadProgress() { - return downloadProgress; - } - - /** - * @param downloadProgress - * the downloadProgress to set - * @see #downloadProgress - */ - public void setDownloadProgress(double downloadProgress) { - this.downloadProgress = downloadProgress; - } - -} diff --git a/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingViewFactory.java deleted file mode 100644 index 9eabc77f2f..0000000000 --- a/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingViewFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -package lcsb.mapviewer.services.view; - -import java.io.FileNotFoundException; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.gson.Gson; - -import lcsb.mapviewer.annotation.cache.BigFileCache; -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.ReferenceGenomeGeneMapping; - -/** - * Factory class for {@link AnnotationView} class. - * - * @author Piotr Gawron - * - */ -public class ReferenceGenomeGeneMappingViewFactory extends AbstractViewFactory<ReferenceGenomeGeneMapping, ReferenceGenomeGeneMappingView> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ReferenceGenomeGeneMappingViewFactory.class); - - /** - * Service that allows to access big files (reference genome is stored as a - * big file on the server). - */ - @Autowired - private BigFileCache bigFileCache; - - @Override - public ReferenceGenomeGeneMappingView create(ReferenceGenomeGeneMapping object) { - ReferenceGenomeGeneMappingView result = new ReferenceGenomeGeneMappingView(); - result.setDownloadProgress(object.getDownloadProgress()); - try { - result.setLocalUrl("../" + bigFileCache.getLocalPathForFile(object.getSourceUrl())); - } catch (FileNotFoundException e) { - result.setLocalUrl(null); - } - result.setSourceUrl(object.getSourceUrl()); - result.setName(object.getName()); - return result; - } - - @Override - public String createGson(ReferenceGenomeGeneMappingView object) { - return new Gson().toJson(object); - } - - @Override - public ReferenceGenomeGeneMapping viewToObject(ReferenceGenomeGeneMappingView view) { - throw new NotImplementedException(); - } - -} diff --git a/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeView.java b/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeView.java deleted file mode 100644 index 9ab0d68a2a..0000000000 --- a/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeView.java +++ /dev/null @@ -1,194 +0,0 @@ -package lcsb.mapviewer.services.view; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.ReferenceGenome; -import lcsb.mapviewer.model.map.layout.ReferenceGenomeType; - -/** - * View representation of the {@link ReferenceGenome}. - * - * @author Piotr Gawron - * - */ -public class ReferenceGenomeView extends AbstractView<ReferenceGenome> implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * {@link ReferenceGenome#organism}. - */ - private MiriamData organism; - - /** - * {@link ReferenceGenome#type}. - */ - private ReferenceGenomeType type; - - /** - * {@link ReferenceGenome#version}. - */ - private String version; - - /** - * Progress of download process (100 means that file is complete). - */ - private double downloadProgress; - - /** - * Url from which reference genome file was downloaded. - */ - private String sourceUrl; - - /** - * Url to local copy of reference genome file. - */ - private String localUrl; - - /** - * List of gene mappings for reference genome. - */ - private List<ReferenceGenomeGeneMappingView> geneMapping = new ArrayList<>(); - - /** - * Default constructor. - * - * @param object - * {@link ReferenceGenome} which this view should visualize - */ - protected ReferenceGenomeView(ReferenceGenome object) { - super(object); - } - - /** - * Default constructor. Should be used only for deserialization. - */ - protected ReferenceGenomeView() { - } - - /** - * @return the organism - * @see #organism - */ - public MiriamData getOrganism() { - return organism; - } - - /** - * @param organism - * the organism to set - * @see #organism - */ - public void setOrganism(MiriamData organism) { - this.organism = organism; - } - - /** - * @return the type - * @see #type - */ - public ReferenceGenomeType getType() { - return type; - } - - /** - * @param type - * the type to set - * @see #type - */ - public void setType(ReferenceGenomeType type) { - this.type = type; - } - - /** - * @return the version - * @see #version - */ - public String getVersion() { - return version; - } - - /** - * @param version - * the version to set - * @see #version - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * @return the downloadProgress - * @see #downloadProgress - */ - public double getDownloadProgress() { - return downloadProgress; - } - - /** - * @param downloadProgress - * the downloadProgress to set - * @see #downloadProgress - */ - public void setDownloadProgress(double downloadProgress) { - this.downloadProgress = downloadProgress; - } - - /** - * @return the sourceUrl - * @see #sourceUrl - */ - public String getSourceUrl() { - return sourceUrl; - } - - /** - * @param sourceUrl - * the sourceUrl to set - * @see #sourceUrl - */ - public void setSourceUrl(String sourceUrl) { - this.sourceUrl = sourceUrl; - } - - /** - * @return the localUrl - * @see #localUrl - */ - public String getLocalUrl() { - return localUrl; - } - - /** - * @param localUrl - * the localUrl to set - * @see #localUrl - */ - public void setLocalUrl(String localUrl) { - this.localUrl = localUrl; - } - - /** - * @return the geneMapping - * @see #geneMapping - */ - public List<ReferenceGenomeGeneMappingView> getGeneMapping() { - return geneMapping; - } - - /** - * @param geneMapping - * the geneMapping to set - * @see #geneMapping - */ - public void setGeneMapping(List<ReferenceGenomeGeneMappingView> geneMapping) { - this.geneMapping = geneMapping; - } - -} diff --git a/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeViewFactory.java deleted file mode 100644 index c85ad828df..0000000000 --- a/service/src/main/java/lcsb/mapviewer/services/view/ReferenceGenomeViewFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -package lcsb.mapviewer.services.view; - -import java.io.FileNotFoundException; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.gson.Gson; - -import lcsb.mapviewer.annotation.cache.BigFileCache; -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.ReferenceGenome; - -/** - * Factory class for {@link AnnotationView} class. - * - * @author Piotr Gawron - * - */ -public class ReferenceGenomeViewFactory extends AbstractViewFactory<ReferenceGenome, ReferenceGenomeView> { - - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(ReferenceGenomeViewFactory.class); - - /** - * Access point for big files. - */ - @Autowired - private BigFileCache bigFileCache; - - /** - * Factory that creates readable gene mappings. - */ - @Autowired - private ReferenceGenomeGeneMappingViewFactory referenceGenomeGeneMappingViewFactory; - - @Override - public ReferenceGenomeView create(ReferenceGenome object) { - ReferenceGenomeView result = new ReferenceGenomeView(); - result.setDownloadProgress(object.getDownloadProgress()); - result.setGeneMapping(referenceGenomeGeneMappingViewFactory.createList(object.getGeneMapping())); - try { - result.setLocalUrl("../" + bigFileCache.getLocalPathForFile(object.getSourceUrl())); - } catch (FileNotFoundException e) { - logger.warn("Cannot find local file", e); - result.setLocalUrl(null); - } - result.setOrganism(object.getOrganism()); - result.setSourceUrl(object.getSourceUrl()); - result.setType(object.getType()); - result.setVersion(object.getVersion()); - return result; - } - - @Override - public String createGson(ReferenceGenomeView object) { - return new Gson().toJson(object); - } - - @Override - public ReferenceGenome viewToObject(ReferenceGenomeView view) { - throw new NotImplementedException(); - } - -} diff --git a/service/src/main/resources/applicationContext-service.xml b/service/src/main/resources/applicationContext-service.xml index e259fea970..ab4eb9ada7 100644 --- a/service/src/main/resources/applicationContext-service.xml +++ b/service/src/main/resources/applicationContext-service.xml @@ -45,9 +45,6 @@ <bean id="PasswordEncoder" class="lcsb.mapviewer.services.impl.Md5PasswordEncoder"/> <!-- View factories --> - <bean id="ReferenceGenomeViewFactory" class="lcsb.mapviewer.services.view.ReferenceGenomeViewFactory"/> - <bean id="ReferenceGenomeGeneMappingViewFactory" class="lcsb.mapviewer.services.view.ReferenceGenomeGeneMappingViewFactory"/> - <bean id="FullAliasViewFactory" class="lcsb.mapviewer.services.search.data.FullAliasViewFactory"/> <bean id="FullReactionViewFactory" class="lcsb.mapviewer.services.search.data.FullReactionViewFactory"/> <bean id="LightAliasViewFactory" class="lcsb.mapviewer.services.search.data.LightAliasViewFactory"/> diff --git a/service/src/test/java/lcsb/mapviewer/services/view/AllViewTests.java b/service/src/test/java/lcsb/mapviewer/services/view/AllViewTests.java index 3497bf17ae..ce60a5e13e 100644 --- a/service/src/test/java/lcsb/mapviewer/services/view/AllViewTests.java +++ b/service/src/test/java/lcsb/mapviewer/services/view/AllViewTests.java @@ -6,8 +6,6 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({ FrameworkVersionViewTest.class, // - ReferenceGenomeViewFactoryTest.class, // - ReferenceGenomeGeneMappingViewFactoryTest.class, // }) public class AllViewTests { diff --git a/service/src/test/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingViewFactoryTest.java deleted file mode 100644 index 6ad7e4e64b..0000000000 --- a/service/src/test/java/lcsb/mapviewer/services/view/ReferenceGenomeGeneMappingViewFactoryTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package lcsb.mapviewer.services.view; - -import static org.junit.Assert.assertNotNull; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import lcsb.mapviewer.model.map.layout.ReferenceGenomeGeneMapping; -import lcsb.mapviewer.services.ServiceTestFunctions; - -public class ReferenceGenomeGeneMappingViewFactoryTest extends ServiceTestFunctions { - - @Autowired - ReferenceGenomeGeneMappingViewFactory factory; - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testCreateEmpty() throws Exception { - try { - ReferenceGenomeGeneMapping referenceGenome = new ReferenceGenomeGeneMapping(); - Object object = factory.create(referenceGenome); - assertNotNull(object); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testCreateGson() throws Exception { - try { - ReferenceGenomeGeneMapping mapping = new ReferenceGenomeGeneMapping(); - ReferenceGenomeGeneMappingView object = factory.create(mapping); - assertNotNull(factory.createGson(object)); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - -} diff --git a/service/src/test/java/lcsb/mapviewer/services/view/ReferenceGenomeViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/view/ReferenceGenomeViewFactoryTest.java deleted file mode 100644 index 9a2eb39ee5..0000000000 --- a/service/src/test/java/lcsb/mapviewer/services/view/ReferenceGenomeViewFactoryTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package lcsb.mapviewer.services.view; - -import static org.junit.Assert.assertNotNull; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import lcsb.mapviewer.model.map.layout.ReferenceGenome; -import lcsb.mapviewer.services.ServiceTestFunctions; - -public class ReferenceGenomeViewFactoryTest extends ServiceTestFunctions { - - @Autowired - ReferenceGenomeViewFactory factory; - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testCreateEmpty() throws Exception { - try { - ReferenceGenome referenceGenome = new ReferenceGenome(); - Object object = factory.create(referenceGenome); - assertNotNull(object); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testCreateGson() throws Exception { - try { - ReferenceGenome referenceGenome = new ReferenceGenome(); - ReferenceGenomeView object = factory.create(referenceGenome); - assertNotNull(factory.createGson(object)); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - -} -- GitLab