diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4c8e77f73dc9ab17d7d6cec19defa40c7f5d9f30..41eb854438ae39659a21c3c8e2072271d5dbb5a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,48 @@ image: node before_script: - - cd frontend-js - - npm install - - cd .. + - apt-get update + + +stages: + - build + - test test_frontend: + stage: test script: - cd frontend-js + - npm install - npm test - \ No newline at end of file + +build_war: + image: debian + stage: build + only: + - tags + artifacts: + paths: + - minerva.war + script: + - apt-get install -y curl sudo gnupg git openjdk-8-jdk ant maven + - curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - + - sudo apt-get install -y nodejs + - ant maven-build + - cp web/target/web-1.0.war minerva.war + +build_debian_package: + image: debian + stage: build + only: + - tags + artifacts: + paths: + - "debian/*.deb" + script: + - apt-get install -y curl sudo gnupg git openjdk-8-jdk ant maven dh-make build-essential lintian devscripts xsltproc fakeroot xsltproc docbook-xsl + - curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - + - sudo apt-get install -y nodejs + - export DEBFULLNAME="Piotr Gawron" + - export DEBEMAIL="piotr.gawron@uni.lu" + - ant debian-pkg + diff --git a/CHANGELOG b/CHANGELOG index 1f1020106ed7fc6f93ef5829c8218d36723e85c5..58f8734fe19016b816bff246dcf1330e6a4dbec9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,18 @@ +minerva (12.0.0) stable; urgency=medium + * STUB CHANGLELOG ENTRY + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 14 Dec 2017 16:00:00 +0200 + +minerva (11.0.7) stable; urgency=medium + * Bug fix: redirection added when anonymous tries to access secured map + * Bug fix: loading time of custom overlays is reduced + * Bug fix: there should be no problem with symlink when upgrading debian + package + * Bug fix: number of services changed API address to https: pmceurope + (pubmed), uniprot, ensembl, hgnc, recon, ctd database + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 18 Jan 2018 16:00:00 +0200 + minerva (11.0.6) stable; urgency=medium * Bug fix: fix a bug when entering invalid mirna id diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/PermanentDatabaseLevelCache.java b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/PermanentDatabaseLevelCache.java index 08c0fabbfe8fa51f82996ee01cbe73c63facd78b..f01300330495637f235777329ddac6edc8b15930 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/PermanentDatabaseLevelCache.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/PermanentDatabaseLevelCache.java @@ -45,29 +45,29 @@ public class PermanentDatabaseLevelCache extends XmlParser /** * This class represents new thread task for quering database. - * + * * @author Piotr Gawron - * + * */ private final class QueryTask implements Callable<CacheQuery> { /** * Identifier of cached entry. - * + * * @see CacheQuery#query */ private String query; /** * Type of cached entry. - * + * * @see CacheQuery#type */ private CacheType type; /** * Default constructor. - * + * * @param query * {@link #query} * @param type @@ -79,45 +79,47 @@ public class PermanentDatabaseLevelCache extends XmlParser this.type = type; } - @Override - public CacheQuery call() throws Exception { - logger.debug("Query task call"); - dbUtils.createSessionForCurrentThread(); - logger.debug("Query task session started"); - CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type); - logger.debug("Query task data retrieved"); - dbUtils.closeSessionForCurrentThread(); - logger.debug("Query task return"); - return entry; - } + @Override + public CacheQuery call() throws Exception { + logger.debug("Query task call"); + try { + dbUtils.createSessionForCurrentThread(); + logger.debug("Query task session started"); + CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type); + logger.debug("Query task data retrieved"); + return entry; + } finally { + dbUtils.closeSessionForCurrentThread(); + } + } } /** * This class represents new thread task for refreshing element in db. - * + * * @author Piotr Gawron - * + * */ private final class RefreshTask implements Callable<CacheQuery> { /** * Identifier of cached entry. - * + * * @see CacheQuery#query */ private String query; /** * Type of cached entry. - * + * * @see CacheQuery#type */ private CacheType type; /** * Default constructor. - * + * * @param query * {@link #query} * @param type @@ -183,42 +185,42 @@ public class PermanentDatabaseLevelCache extends XmlParser /** * This class represents new thread task for adding entry to database. - * + * * @author Piotr Gawron - * + * */ private final class AddTask implements Callable<CacheQuery> { /** * Identifier of cached entry. - * + * * @see CacheQuery#query */ private String query; /** * Type of cached entry. - * + * * @see CacheQuery#type */ private CacheType type; /** * Value to cache. - * + * * @see CacheQuery#value */ private String value; /** * How long should the entry be valid in days. - * + * */ private int validDays; /** * Default constructor. - * + * * @param query * {@link #query} * @param type @@ -234,57 +236,60 @@ public class PermanentDatabaseLevelCache extends XmlParser this.validDays = validDays; } - @Override - public CacheQuery call() throws Exception { - logger.debug("Add task call"); - dbUtils.createSessionForCurrentThread(); - CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type); - - if (entry == null) { - entry = new CacheQuery(); - entry.setQuery((String) query); - entry.setAccessed(Calendar.getInstance()); - } else { - entry.setAccessed(Calendar.getInstance()); - } - entry.setValue(value); - entry.setType(type); - Calendar expires = Calendar.getInstance(); - expires.add(Calendar.DAY_OF_MONTH, validDays); - entry.setExpires(expires); - - getCacheQueryDao().add(entry); - dbUtils.closeSessionForCurrentThread(); - return entry; - } + @Override + public CacheQuery call() throws Exception { + logger.debug("Add task call"); + try { + dbUtils.createSessionForCurrentThread(); + CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type); + + if (entry == null) { + entry = new CacheQuery(); + entry.setQuery((String) query); + entry.setAccessed(Calendar.getInstance()); + } else { + entry.setAccessed(Calendar.getInstance()); + } + entry.setValue(value); + entry.setType(type); + Calendar expires = Calendar.getInstance(); + expires.add(Calendar.DAY_OF_MONTH, validDays); + entry.setExpires(expires); + + getCacheQueryDao().add(entry); + return entry; + } finally { + dbUtils.closeSessionForCurrentThread(); + } + } } /** * This class represents new thread task for removing entry from database. - * + * * @author Piotr Gawron - * + * */ private final class RemoveTask implements Callable<CacheQuery> { /** * Identifier of cached entry. - * + * * @see CacheQuery#query */ private String query; /** * Type of cached entry. - * + * * @see CacheQuery#type */ private CacheType type; /** * Default constructor. - * + * * @param query * {@link #query} * @param type @@ -296,25 +301,28 @@ public class PermanentDatabaseLevelCache extends XmlParser this.type = type; } - @Override - public CacheQuery call() throws Exception { - logger.debug("Remove task call"); - dbUtils.createSessionForCurrentThread(); - CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type); - if (entry != null) { - getCacheQueryDao().delete(entry); - } - dbUtils.closeSessionForCurrentThread(); - return entry; - } + @Override + public CacheQuery call() throws Exception { + logger.debug("Remove task call"); + try { + dbUtils.createSessionForCurrentThread(); + CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type); + if (entry != null) { + getCacheQueryDao().delete(entry); + } + return entry; + } finally { + dbUtils.closeSessionForCurrentThread(); + } + } } /** * This class represents new thread task for invalidating entry in database. - * + * * @author Piotr Gawron - * + * */ private final class InvalidateTask implements Callable<CacheQuery> { @@ -330,7 +338,7 @@ public class PermanentDatabaseLevelCache extends XmlParser /** * Default constructor. - * + * * @param query * {@link #query} * @param type @@ -529,7 +537,7 @@ public class PermanentDatabaseLevelCache extends XmlParser /** * Executes and returns result of the task provided in the parameter. This * method is blocking (it's waiting for the results). - * + * * @param task * task to be executed * @return value returned by the task diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/WebPageDownloader.java b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/WebPageDownloader.java index c03944fd8fb1507836139a32d05ffcde9b3864d3..5f468f1ad11eb4a49bf8d5599622191751bfe16a 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/WebPageDownloader.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/WebPageDownloader.java @@ -20,8 +20,8 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.annotation.services.WrongResponseCodeIOException; /** - * This class helps to download webpages. The pages are downloaded in separate - * thred, due to the fact that sometimes java socket can hang (related JVM bug: + * This class helps to download web pages. The pages are downloaded in separate + * thread, due to the fact that sometimes java socket can hang (related JVM bug: * https://bugs.openjdk.java.net/browse/JDK-8075484 ). * * @author Piotr Gawron @@ -40,13 +40,13 @@ public class WebPageDownloader { /** * Hard timeout (threads are terminated) of http connection that access data - * across internet. + * across Internet. */ private static final int HTTP_CONNECTION_TIMEOUT_SEC = 120; /** * How much time should the thread sleep before another try to access the - * webpage that thrown INTERNAL SERVER ERROR http response. + * web page that thrown INTERNAL SERVER ERROR http response. */ private static final int HTTP_INTERNAL_ERROR_RECONNECT_SLEEP_TIME = 2000; @@ -55,15 +55,15 @@ public class WebPageDownloader { * receiving INTERNAL SERVER ERROR http response. */ private static final int HTTP_INTERNAL_ERROR_RECONNECT_TIMES = 2; - - - + + + /** - * Returns content of the webpage identified by url using GET. + * Returns content of the web page identified by url. * * @param accessUrl - * url of a webpage - * @return content of the webpage identified by url + * url of a web page + * @return content of the web page identified by url * @throws IOException * thrown when there is any problem with accessing webpage */ @@ -71,18 +71,18 @@ public class WebPageDownloader { return getFromNetwork(accessUrl, "GET", null); } - + /** - * Returns content of the webpage identified by url. The HTTP query is done + * Returns content of the webpage identified by url. The HTTP query is done * using the provided POST if postData is not null. - * - * + * + * * @param accessUrl * url of a webpage * @param httpRequestMethod * type of HTTP request (GET, POST, PUT, PATCH, DELETE, ...) * @param data - * string to be sent in the body of the + * string to be sent in the body of the * @return content of the webpage identified by url * @throws IOException * thrown when there is any problem with accessing webpage @@ -90,7 +90,7 @@ public class WebPageDownloader { public String getFromNetwork(String accessUrl, String httpRequestMethod, String data) throws IOException { /** - * Tasks that retrieves content from webpage + * Tasks that retrieves content from web page * * @author Piotr Gawron * @@ -107,17 +107,17 @@ public class WebPageDownloader { // connect to the server, if HTTP_INTERNAL_ERROR occurred then try to // reconnect HTTP_INTERNAL_ERROR_RECONNECT_TIMES times while (code == HttpURLConnection.HTTP_INTERNAL_ERROR || code == HttpURLConnection.HTTP_NOT_FOUND) { - urlConn = openConnection(accessUrl); + urlConn = openConnection(accessUrl); urlConn.addRequestProperty("User-Agent", "minerva-framework"); - + urlConn.setRequestMethod(httpRequestMethod); - if (data != null) { - urlConn.setDoOutput(true); + if (data != null) { + urlConn.setDoOutput(true); DataOutputStream wr = new DataOutputStream(urlConn.getOutputStream()); wr.writeBytes(data); - wr.close(); + wr.close(); } - + try { urlConn.connect(); code = urlConn.getResponseCode(); @@ -174,7 +174,7 @@ public class WebPageDownloader { * argument. * * @param accessUrl - * url to the webpagae + * url to the web page * @return {@link HttpURLConnection connection} to the url given in the * argument * @throws MalformedURLException diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChemicalParser.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChemicalParser.java index 20351481b2d36412f64f2277bafa28ca1d9a6bdc..886b9f1a894bf2195bb37507fed14282c403c704 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChemicalParser.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChemicalParser.java @@ -69,18 +69,18 @@ public class ChemicalParser extends CachableInterface implements IExternalServic /** * Home page of ctd database. */ - static final String URL = "http://ctdbase.org/"; + static final String URL = "https://ctdbase.org/"; /** * URL to get a list of chemicals by disease id. */ - public static final String DISEASE_URL = "http://ctdbase.org/detail.go?6578706f7274=1&d-1332398-e=5&view=chem&" + public static final String DISEASE_URL = "https://ctdbase.org/detail.go?6578706f7274=1&d-1332398-e=5&view=chem&" + "type=disease&acc=MESH%3A"; /** * URL to get a list of chemicals by gene id. */ - public static final String DISEASE_GENE_URL = "http://ctdbase.org/detail.go?slimTerm=all&6578706f7274=1&qid=3464576&" + public static final String DISEASE_GENE_URL = "https://ctdbase.org/detail.go?slimTerm=all&6578706f7274=1&qid=3464576&" + "d-1332398-e=5&view=disease&type=gene&assnType=curated&acc="; /** @@ -173,7 +173,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic private MeSHParser meshParser; /** - * + * */ public ChemicalParser() { super(ChemicalParser.class); @@ -252,7 +252,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic /** * Serializes list of chemicalId-chemicalName pairs. - * + * * @param chemicals * list of objects to serialize * @return serialized string @@ -267,7 +267,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic /** * Deserializes list of chemicalId-chemicalName pairs. - * + * * @param chemicalNode * string to deserialize * @return list of chemicalId-chemicalName pairs @@ -420,7 +420,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic /** * Method that creates chemical from a tab separated row from ctd database. Data * looks like (line wrapping added for clarity): - * + * * <pre> 1. Disease Name Disease ID Direct Evidence Inference Network Inference Score Reference Count 2. Drug-Induced Liver Injury MESH:D056486 1-(2-trifluoromethoxyphenyl)-2-nitroethanone|1,4-bis(2-(3,5-dichloropyridyloxy))benzene| @@ -433,7 +433,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic pirinixic acid|Polyphenols|Polysaccharides|potassium chromate(VI)|propiconazole|Quercetin|resveratrol|rosiglitazone|Rotenone| Streptozocin|Tetrachlorodibenzodioxin|titanium dioxide|Tretinoin|usnic acid|Valproic Acid|Vincristine|Zinc|zinc chloride 190.67 634 * </pre> - * + * * @param lineValues * line split by tab separator * @param chemID @@ -480,7 +480,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic if (entrez == null) { invalidHgnc.add(md); } else { - String query = "http://ctdbase.org/detail.go?type=gene&view=ixn&chemAcc=" + chemID.getResource() + "&acc=" + String query = "https://ctdbase.org/detail.go?type=gene&view=ixn&chemAcc=" + chemID.getResource() + "&acc=" + entrez.getResource(); String referencesPage = getWebPageContent(query); Matcher matcher = pattern.matcher(referencesPage); @@ -488,7 +488,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic idx.add(matcher.group(1)); } for (String string : idx) { - String query2 = "http://ctdbase.org/detail.go?6578706f7274=1&d-1340579-e=5&type=relationship&ixnId=" + String query2 = "https://ctdbase.org/detail.go?6578706f7274=1&d-1340579-e=5&type=relationship&ixnId=" + string; String referencesPage2 = getWebPageContent(query2); String[] lines = referencesPage2.split("\n"); @@ -535,7 +535,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic /** * Returns list of chemicals for given set of target genes related to the * disease. - * + * * @param targets * set of target genes * @param diseaseMiriam @@ -592,7 +592,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic /** * Return list of chemical names that interact with a target. - * + * * @param diseaseMiriam * we want to get chemicals in context of the disease * @param target @@ -631,7 +631,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic /** * Returns list of chemicals that interact with a target. - * + * * @param target * target for which we are looking for chemicals * @param disease @@ -674,6 +674,9 @@ public class ChemicalParser extends CachableInterface implements IExternalServic } public List<String> getSuggestedQueryList(Project project, MiriamData diseaseMiriam) throws ChemicalSearchException { + if (diseaseMiriam == null) { + return new ArrayList<>(); + } String cacheQuery = PROJECT_SUGGESTED_QUERY_PREFIX + "\n" + project.getId() + "\n" + diseaseMiriam.getResource(); String cachedData = getCacheValue(cacheQuery); List<String> result; diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugAnnotation.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugAnnotation.java index 48bebd6690f38480135bc34e2cee30751cad88ce..6376921856b067878e2ab05f1f6d401acf7d38a2 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugAnnotation.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugAnnotation.java @@ -257,6 +257,9 @@ public abstract class DrugAnnotation extends CachableInterface { } public List<String> getSuggestedQueryList(Project project, MiriamData organism) throws DrugSearchException { + if (organism == null) { + return new ArrayList<>(); + } String cacheQuery = PROJECT_SUGGESTED_QUERY_PREFIX + "\n" + project.getId() + "\n" + organism.getResource(); String cachedData = getCacheValue(cacheQuery); List<String> result; diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/PubmedParser.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/PubmedParser.java index 851847b75d185a38b232e0edeefcd26a044e60e5..0fbcd7a00e507a8d95cb43a2491c02a565fc1610 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/PubmedParser.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/PubmedParser.java @@ -29,7 +29,7 @@ import lcsb.mapviewer.model.map.MiriamType; /** * This class is a backend to publically available pubmed API in - * <a href="http://europepmc.org/RestfulWebService">Europe PubMed Central </a>. + * <a href="https://europepmc.org/RestfulWebService">Europe PubMed Central </a>. * * @author Piotr Gawron * @@ -55,7 +55,9 @@ public class PubmedParser extends CachableInterface implements IExternalService /** * Version of the remote API thnat is supported by this connecting class. */ - static final String SUPPORTED_VERSION = "5.2.1"; + static final String SUPPORTED_VERSION = "5.2.2"; + + static final String API_URL = "https://www.ebi.ac.uk/europepmc/webservices/rest/"; /** * Connector used for accessing data from miriam registry. @@ -131,7 +133,7 @@ public class PubmedParser extends CachableInterface implements IExternalService result = new Article(); try { - String url = "http://www.ebi.ac.uk/europepmc/webservices/rest/search/resulttype=core&query=" + String url = API_URL+"search/resulttype=core&query=" + java.net.URLEncoder.encode("src:med ext_id:" + id, "UTF-8"); String content = getWebPageContent(url); @@ -261,7 +263,7 @@ public class PubmedParser extends CachableInterface implements IExternalService @Override public ExternalServiceStatus getServiceStatus() { - ExternalServiceStatus status = new ExternalServiceStatus("Europe PubMed Central", "http://europepmc.org/RestfulWebService"); + ExternalServiceStatus status = new ExternalServiceStatus("Europe PubMed Central", "https://europepmc.org/RestfulWebService"); GeneralCacheInterface cacheCopy = getCache(); this.setCache(null); @@ -292,7 +294,7 @@ public class PubmedParser extends CachableInterface implements IExternalService */ public String getApiVersion() throws PubmedSearchException { try { - String url = "http://www.ebi.ac.uk/europepmc/webservices/rest/search/resulttype=core&query=src%3Amed+ext_id%3A23644949"; + String url = API_URL+"search/resulttype=core&query=src%3Amed+ext_id%3A23644949"; String content = getWebPageContent(url); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java index ae7b3fab53198f99a246bcbbe7b109b03de65074..65d3eebe51a610124534dab35c5ffe84887ee70e 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java @@ -29,7 +29,7 @@ import lcsb.mapviewer.modelutils.map.ElementUtils; /** * This class is responsible for connecting to - * <a href="http://rest.ensembl.org">Ensembl API</a> and annotate elements with + * <a href="https://rest.ensembl.org">Ensembl API</a> and annotate elements with * information taken from this service. * * @@ -41,12 +41,12 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi /** * Version of the rest API that is supported by this annotator. */ - static final String SUPPORTED_VERSION = "6.1"; + static final String SUPPORTED_VERSION = "6.2"; /** - * Url address of ensembl restfull service. + * Url address of ensembl restful service. */ - private static final String REST_SERVICE_URL = "http://rest.ensembl.org/xrefs/id/"; + private static final String REST_SERVICE_URL = "https://rest.ensembl.org/xrefs/id/"; /** * Suffix that is needed for getting proper result using @@ -57,7 +57,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi /** * Url used for retrieving version of the restful API. */ - private static final String REST_SERVICE_VERSION_URL = "http://rest.ensembl.org/info/rest?content-type=text/xml"; + private static final String REST_SERVICE_VERSION_URL = "https://rest.ensembl.org/info/rest?content-type=text/xml"; /** * Default constructor. diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java index 9a8d06d49126ea7a3d2ba4b0b3301a4619b7b37e..b7cd593c8d99a78aeea7d1b947a28397df869160 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java @@ -16,6 +16,7 @@ import lcsb.mapviewer.annotation.services.ExternalServiceStatus; import lcsb.mapviewer.annotation.services.ExternalServiceStatusType; import lcsb.mapviewer.annotation.services.IExternalService; import lcsb.mapviewer.annotation.services.MiriamConnector; +import lcsb.mapviewer.annotation.services.WrongResponseCodeIOException; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.model.map.BioEntity; @@ -31,7 +32,7 @@ import lcsb.mapviewer.modelutils.map.ElementUtils; /** * This class is responsible for connecting to - * <a href="http://rest.genenames.org/">HGNC restfull API</a> and annotate + * <a href="https://rest.genenames.org/">HGNC restfull API</a> and annotate * elements with information taken from this service. * * @@ -43,7 +44,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService /** * Address of HGNC API that should be used for retrieving data. */ - private static final String REST_API_URL = "http://rest.genenames.org/fetch/"; + private static final String REST_API_URL = "https://rest.genenames.org/fetch/"; @Autowired private MiriamConnector miriamConnector; @@ -99,7 +100,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService try { GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias - .addMiriamData(createMiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.HGNC_SYMBOL, "SNCA")); + .addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.HGNC_SYMBOL, "SNCA")); annotateElement(proteinAlias); if (proteinAlias.getFullName() == null || proteinAlias.getFullName().equals("")) { @@ -181,16 +182,16 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService // add hgnc id only when there was no hgnc_id in the element String id = getNodeValue(node); id = id.replaceAll("HGNC:", ""); - element.addMiriamData(createMiriamData(MiriamType.HGNC, id)); + element.addMiriamData(new MiriamData(MiriamType.HGNC, id)); } else if (type.equals("ensembl_gene_id")) { - element.addMiriamData(createMiriamData(MiriamType.ENSEMBL, getNodeValue(node))); + element.addMiriamData(new MiriamData(MiriamType.ENSEMBL, getNodeValue(node))); } else if (type.equals("entrez_id")) { - element.addMiriamData(createMiriamData(MiriamType.ENTREZ, getNodeValue(node))); + element.addMiriamData(new MiriamData(MiriamType.ENTREZ, getNodeValue(node))); } else if (type.equals("symbol")) { if (symbols.size() == 0) { // add hgnc symbol annnotation only when there was no // hgnc_symbol in the element - element.addMiriamData(createMiriamData(MiriamType.HGNC_SYMBOL, getNodeValue(node))); + element.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, getNodeValue(node))); } setSymbol(element, getNodeValue(node), prefix); } else if (type.equals("name")) { @@ -203,7 +204,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService for (int j = 0; j < sublist.getLength(); j++) { Node subnode = sublist.item(j); if (subnode.getNodeType() == Node.ELEMENT_NODE) { - element.addMiriamData(createMiriamData(MiriamType.REFSEQ, getNodeValue(subnode))); + element.addMiriamData(new MiriamData(MiriamType.REFSEQ, getNodeValue(subnode))); } } } else if (type.equals("prev_symbol")) { @@ -231,24 +232,26 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService for (int j = 0; j < sublist.getLength(); j++) { Node subnode = sublist.item(j); if (subnode.getNodeType() == Node.ELEMENT_NODE) { - element.addMiriamData(createMiriamData(MiriamType.UNIPROT, getNodeValue(subnode))); + element.addMiriamData(new MiriamData(MiriamType.UNIPROT, getNodeValue(subnode))); } } } - } - } - } - } - } catch (Exception e) { - throw new AnnotatorException(e); - } - } - } + } + } + } + } + } catch (WrongResponseCodeIOException e) { + logger.warn(prefix + "Cannot find information for element."); + } catch (Exception e) { + throw new AnnotatorException(e); + } + } + } /** * Creates query url for given {@link MiriamType#HGNC} identifier. - * + * * @param id * {@link MiriamType#HGNC} identifier * @return url to restful api webpage for given identifier @@ -259,7 +262,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService /** * Creates query url for given {@link MiriamType#HGNC_SYMBOL}. - * + * * @param name * {@link MiriamType#HGNC_SYMBOL} * @return url to restful api webpage for given hgnc symbol @@ -271,7 +274,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService /** * Converts {@link MiriamType#HGNC}/{@link MiriamType#HGNC_SYMBOL} identifier * into list of {@link MiriamType#UNIPROT} identifiers. - * + * * @param miriamData * {@link MiriamData} with {@link MiriamType#HGNC} identifier * @return list of {@link MiriamData} with {@link MiriamType#UNIPROT} @@ -301,38 +304,41 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService } else { Node entry = getNode("doc", resultNode.getChildNodes()); - NodeList list = entry.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node node = list.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - if (node.getNodeName().equals("arr")) { - String type = getNodeAttr("name", node); - if (type.equals("uniprot_ids")) { - NodeList uniprotList = node.getChildNodes(); - for (int j = 0; j < uniprotList.getLength(); j++) { - Node uniprotNode = uniprotList.item(j); - if (uniprotNode.getNodeType() == Node.ELEMENT_NODE) { - if (uniprotNode.getNodeName().equals("str")) { - result.add(createMiriamData(MiriamType.UNIPROT, uniprotNode.getTextContent())); - } - } - } - } - } - } - } - } - return result; - } catch (Exception e) { - throw new AnnotatorException(e); - } + NodeList list = entry.getChildNodes(); + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + if (node.getNodeName().equals("arr")) { + String type = getNodeAttr("name", node); + if (type.equals("uniprot_ids")) { + NodeList uniprotList = node.getChildNodes(); + for (int j = 0; j < uniprotList.getLength(); j++) { + Node uniprotNode = uniprotList.item(j); + if (uniprotNode.getNodeType() == Node.ELEMENT_NODE) { + if (uniprotNode.getNodeName().equals("str")) { + result.add(new MiriamData(MiriamType.UNIPROT, uniprotNode.getTextContent())); + } + } + } + } + } + } + } + } + return result; + } catch (WrongResponseCodeIOException e) { + logger.warn("No HGNC data found for id: "+miriamData); + return new ArrayList<>(); + } catch (Exception e) { + throw new AnnotatorException(e); + } } /** * Converts {@link MiriamType#HGNC} identifier into * {@link MiriamType#HGNC_SYMBOL}. - * + * * @param miriamData * {@link MiriamData} with {@link MiriamType#HGNC} identifier * @return {@link MiriamData} with {@link MiriamType#HGNC_SYMBOL} @@ -366,7 +372,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService if (node.getNodeName().equals("str")) { String type = getNodeAttr("name", node); if (type.equals("symbol")) { - return createMiriamData(MiriamType.HGNC_SYMBOL, node.getTextContent()); + return new MiriamData(MiriamType.HGNC_SYMBOL, node.getTextContent()); } } } @@ -381,7 +387,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService /** * Returns <code>true</code> if the {@link MiriamData} given in the parameter is * a valid {@link MiriamType#HGNC} or {@link MiriamType#HGNC_SYMBOL}. - * + * * @param md * {@link MiriamData} to validate * @return <code>true</code> if the {@link MiriamData} given in the parameter is @@ -403,7 +409,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService /** * Transforms HGNC symbol into {@link MiriamType#ENTREZ} identifier. - * + * * @param md * hgnc symbol * @return {@link MiriamType#ENTREZ} identifier for a given hgnc symbol @@ -438,7 +444,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService String type = getNodeAttr("name", node); if (type.equals("entrez_id")) { String id = getNodeValue(node); - return createMiriamData(MiriamType.ENTREZ, id); + return new MiriamData(MiriamType.ENTREZ, id); } } } diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java index 3e26f3006a7d190ec35450ba5f9c388cc2d4e8af..c006d49ed4106d58c1323c1bf5dcd930001bcf36 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java @@ -43,7 +43,7 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService /** * Address of annotation rest service for reactions. */ - private static final String REACTION_ANNOTATION_URL_PREFIX = "http://vmh.uni.lu/_api/reactions/?page_size=10000&format=json&search="; + private static final String REACTION_ANNOTATION_URL_PREFIX = "https://vmh.uni.lu/_api/reactions/?page_size=10000&format=json&search="; /** * Class used for some simple operations on {@link BioEntity} elements. diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java index 59a344ff620ef1ed027b71a0b6ac054e5f7a027e..8f940055079b6a4b74e7aed4c8ba53cc376e192b 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java @@ -141,7 +141,7 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi * @return url to uniprot restfull API about uniprot entry */ private String getUniprotUrl(String uniprotId) { - return "http://www.uniprot.org/uniprot/" + uniprotId + ".txt"; + return "https://www.uniprot.org/uniprot/" + uniprotId + ".txt"; } /** diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChemicalParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChemicalParserTest.java index 36e85c27dbde7245cabfc955df81540b5f293fa1..bc17b72cdf808cc2d9c8bb156e8412d81ec77160 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChemicalParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChemicalParserTest.java @@ -193,7 +193,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions { } } - + @Test public void testGetChemicalBySynonym() throws Exception { try { @@ -209,7 +209,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions { } } - + @Test public void testFindByInvalidIdFromChemicalList() throws Exception { @@ -584,7 +584,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions { // remove info about single publication from cache (so we will have to download // it) chemicalParser.getCache().removeByQuery( - "http://ctdbase.org/detail.go?6578706f7274=1&d-1340579-e=5&type=relationship&ixnId=4802115", + "https://ctdbase.org/detail.go?6578706f7274=1&d-1340579-e=5&type=relationship&ixnId=4802115", chemicalParser.getCacheType()); // disallow to use cache for first query (it will be directly about drug), @@ -646,4 +646,22 @@ public class ChemicalParserTest extends AnnotationTestFunctions { } + @Test + public void testGetSuggestedQueryListForUnknownDiseas() throws Exception { + try { + Project project = new Project(); + Model model = getModelForFile("testFiles/target_chemical/target.xml", false); + project.addModel(model); + + List<String> result = chemicalParser.getSuggestedQueryList(project, null); + + assertEquals(0, result.size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + } diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java index 4a21747861d8dcf6bc80ce4f69a5e2071ba29e4a..3a2da6838af0ac27e23615aec275c61c0917fc04 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java @@ -811,4 +811,22 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { } + @Test + public void testGetSuggestedQueryListForUnknownOrganism() throws Exception { + try { + Project project = new Project(); + Model model = getModelForFile("testFiles/target_chemical/target.xml", false); + project.addModel(model); + + List<String> result = drugBankHTMLParser.getSuggestedQueryList(project, null); + + assertEquals(0, result.size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + } diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java index 85d4105e01be05a67a1a7dc2fb85f3f9498856ac..b9cdf4c350cef2be50835c5a575c212a2a123644 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java @@ -208,6 +208,21 @@ public class MiriamConnectorTest extends AnnotationTestFunctions { } } + @Test + public void testGetUrlForDoi() throws Exception { + try { + // exclude first cached value + MiriamData md = new MiriamData(MiriamType.DOI, "10.1038/npjsba.2016.20"); + + String url = miriamConnector.getUrlString(md); + assertNotNull(url); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testMiriamDataToUri() throws Exception { try { diff --git a/annotation/src/test/resources/log4j.properties b/annotation/src/test/resources/log4j.properties index 473855faa6b70690575e254c92710b3c8e06fe32..e23927cb8932324e1cb8b40fe1be2b99fb755c69 100644 --- a/annotation/src/test/resources/log4j.properties +++ b/annotation/src/test/resources/log4j.properties @@ -14,6 +14,8 @@ log4j.appender.R.File=${catalina.home}/logs/MapViewer.log log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n +#Silence miriam debug logs +log4j.logger.uk.ac.ebi.miriam.lib=warn log4j.logger.org.springframework=warn log4j.logger.org.hibernate=warn diff --git a/converter-CellDesigner/.classpath b/converter-CellDesigner/.classpath index d46faf10ed6b222a00963f1db7c75123572c051c..8edbacf9fa49b0886f975776cf413b07ef093d2d 100644 --- a/converter-CellDesigner/.classpath +++ b/converter-CellDesigner/.classpath @@ -23,6 +23,12 @@ </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + <attribute name="org.eclipse.jst.component.nondependency" value=""/> + </attributes> + </classpathentry> + <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> diff --git a/debian/template/postinst b/debian/template/postinst index 44228b77f9db6a5d9d50ee43d4917a886fe73f9e..2f2c3863a88d87c25e0f49a67687296261a2a16e 100644 --- a/debian/template/postinst +++ b/debian/template/postinst @@ -64,7 +64,7 @@ case "$1" in #availble when new war is deployed from debian package, so tomcat will catch SQL exception and stop deployment invoke-rc.d $TOMCAT_PACKAGE stop || true rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva - ln -s /usr/share/minerva/minerva.war /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war + ln -sf /usr/share/minerva/minerva.war /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war invoke-rc.d $TOMCAT_PACKAGE start ;; *) diff --git a/frontend-js/src/main/js/GuiConnector.js b/frontend-js/src/main/js/GuiConnector.js index 34f05f2b6725a81a42e0403dad51c5a388a024ec..c3b40206069b7aa812bba3f7df4999fd97bbcd54 100644 --- a/frontend-js/src/main/js/GuiConnector.js +++ b/frontend-js/src/main/js/GuiConnector.js @@ -175,6 +175,33 @@ GuiConnector.prototype.hideProcessing = function () { $(self._processingDialog).dialog("close"); }; +GuiConnector.prototype.alert = function (error, redirectIfSecurityError) { + if (redirectIfSecurityError === undefined) { + redirectIfSecurityError = false; + } + if (redirectIfSecurityError && error instanceof SecurityError && ServerConnector.getSessionData().getLogin() === "anonymous") { + window.location.href = ServerConnector.getServerBaseUrl() + "login.xhtml?from=" + encodeURI(window.location.href); + } else { + var self = returnThisOrSingleton(this); + logger.error(error); + if (self._errorDialog === undefined) { + self._errorDialog = document.createElement("div"); + self._errorDialogContent = document.createElement("div"); + self._errorDialog.appendChild(self._errorDialogContent); + document.body.appendChild(self._errorDialog); + $(self._errorDialog).dialog({ + classes: { + "ui-dialog": "ui-state-error" + }, + modal: true, + title: "ERROR" + }).siblings('.ui-dialog-titlebar').css("background", "red"); + } + self._errorDialogContent.innerHTML = self.getErrorMessageForError(error); + $(self._errorDialog).dialog("open"); + } +}; + GuiConnector.prototype.getErrorMessageForError = function (error) { var message = error; if (message instanceof SecurityError) { @@ -200,27 +227,6 @@ GuiConnector.prototype.getErrorMessageForError = function (error) { return message; }; -GuiConnector.prototype.alert = function (error) { - var self = returnThisOrSingleton(this); - logger.error(error); - if (self._errorDialog === undefined) { - self._errorDialog = document.createElement("div"); - self._errorDialogContent = document.createElement("div"); - self._errorDialog.appendChild(self._errorDialogContent); - document.body.appendChild(self._errorDialog); - $(self._errorDialog).dialog({ - classes: { - "ui-dialog": "ui-state-error" - }, - modal: true, - title: "ERROR" - }).siblings('.ui-dialog-titlebar').css("background", "red"); - } - self._errorDialogContent.innerHTML = self.getErrorMessageForError(error); - $(self._errorDialog).dialog("open"); - -}; - GuiConnector.prototype.info = function (message) { var self = returnThisOrSingleton(this); if (self._infoDialog === undefined) { diff --git a/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js b/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js index 0bfead2f5f23cf5c213d2a3ff4b8f075a39fc632..a73bc3a727fbb7ca63399fa1b5b5fde5cbd684ab 100644 --- a/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js @@ -32,7 +32,11 @@ AbstractPanel.prototype._createEventHandlers = function () { var searchInput = self.getControlElement(PanelControlElementType.SEARCH_INPUT); var searchByQuery = function () { - return self.searchByQuery(); + var busyImage = $("[name=busyImage]", self.getElement()); + busyImage.show(); + return self.searchByQuery().finally(function () { + busyImage.hide(); + }); }; searchButton.onclick = searchByQuery; @@ -75,6 +79,14 @@ AbstractPanel.prototype._initializeGui = function (placeholder) { this.getElement().appendChild(searchQueryDiv); this.setControlElement(PanelControlElementType.SEARCH_DIV, searchQueryDiv); + var busyImage = Functions.createElement({ + type: "img", + name: "busyImage", + style: "display:block;position: absolute;margin-left: 80px;z-index: 10;display:none", + src: "resources/images/icons/ajax-loader.gif" + }); + searchQueryDiv.appendChild(busyImage); + var searchLabel = Functions.createElement({ type: "div", name: "searchLabel", diff --git a/frontend-js/src/main/js/gui/leftPanel/GenericSearchPanel.js b/frontend-js/src/main/js/gui/leftPanel/GenericSearchPanel.js index 611816bb2fa2d6f1f5a2bfdba7dd0a481a92edda..30faa341b633ce1991ada5dc038ed710a36f6b43 100644 --- a/frontend-js/src/main/js/gui/leftPanel/GenericSearchPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/GenericSearchPanel.js @@ -6,6 +6,7 @@ var Promise = require("bluebird"); var AbstractDbPanel = require('./AbstractDbPanel'); var Alias = require('../../map/data/Alias'); +var InvalidArgumentError = require('../../InvalidArgumentError'); var PanelControlElementType = require('../PanelControlElementType'); var Reaction = require('../../map/data/Reaction'); @@ -122,7 +123,13 @@ GenericSearchPanel.prototype.refreshSearchAutocomplete = function () { GenericSearchPanel.prototype.init = function () { var query = ServerConnector.getSessionData().getSearchQuery(); if (query !== undefined) { - return this.getOverlayDb().searchByEncodedQuery(query, false); + return this.getOverlayDb().searchByEncodedQuery(query, false).catch(function(error){ + if (error instanceof InvalidArgumentError) { + logger.warn(error.message); + } else { + throw error; + } + }); } else { return Promise.resolve(); } diff --git a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js index 38fbe4ab32b1cb5084dfe5154c6b60f07598be8e..ac49e55221864d8b3b9ccef9e418a30f96763033 100644 --- a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js +++ b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js @@ -119,7 +119,8 @@ GuiUtils.prototype.createAnnotationLink = function (annotation, showType) { type = "PUBMED"; name = article.getId(); } else { - name = annotation.getResource(); + //replace encoded parts of uri (like %2F - > "/") + name = decodeURIComponent(annotation.getResource()); var miriamType = self.getConfiguration().getMiriamTypeByName(annotation.getType()); if (miriamType === null) { logger.warn("Unknown miriam type: " + annotation.getType()); diff --git a/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js b/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js index bf80688294254502ae9563f89b4b858dce14a763..66b39646bee816b5d4607487d11ced0a596f6369 100644 --- a/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js @@ -50,7 +50,7 @@ SubmapPanel.prototype.createRow = function (model) { var link = document.createElement("a"); link.href = "#"; link.onclick = function () { - self.getMap().openSubmap(model.getId()); + return self.getMap().openSubmap(model.getId()); }; link.appendChild(img); openTd.appendChild(link); @@ -99,7 +99,11 @@ SubmapPanel.prototype.init = function () { } for (i = 0; i < types.length; i++) { var type = types[i]; - div.appendChild(self.createTable(modelsByType[type], type + " submaps")); + var tableName = type + " submaps"; + if (type === "UNKNOWN") { + tableName = "" + } + div.appendChild(self.createTable(modelsByType[type], tableName)); } if (models.length === 0) { self.getParent().hideTab(self); diff --git a/frontend-js/src/main/js/map/marker/MarkerSurfaceCollection.js b/frontend-js/src/main/js/map/marker/MarkerSurfaceCollection.js index 7a36d523bb8e1286629219c8cb6e68eb96123fa1..e92e4744a2fcfd27512a4eec7cdc9bc77ebe2761 100644 --- a/frontend-js/src/main/js/map/marker/MarkerSurfaceCollection.js +++ b/frontend-js/src/main/js/map/marker/MarkerSurfaceCollection.js @@ -1,6 +1,5 @@ "use strict"; -var AbstractMarker = require('./AbstractMarker'); var AliasMarker = require('./AliasMarker'); var IdentifiedElement = require('../data/IdentifiedElement'); var PointMarker = require('./PointMarker'); @@ -83,9 +82,9 @@ MarkerSurfaceCollection.prototype.addMarker = function (params) { element: element, map: self.getMap(), onClick: [function () { - return self.getMap()._openInfoWindowForIdentifiedElement(element, result.getGoogleMarker()); + return self.getMap().getTopMap()._openInfoWindowForIdentifiedElement(element, result.getGoogleMarker()); }, function () { - return self.getMap().callListeners("onBioEntityClick", element); + return self.getMap().getTopMap().callListeners("onBioEntityClick", element); }] }); result.setIcons(icons); @@ -238,7 +237,6 @@ MarkerSurfaceCollection.prototype.removeUnmodifiedSurfaces = function (modifiedM var surfaceOverlaysPerType = this._overlaySurfaces[dbOverlay.getName()]; for (var key in surfaceOverlaysPerType) { if (surfaceOverlaysPerType.hasOwnProperty(key)) { - var mapOverlay = surfaceOverlaysPerType[key]; if (!modifiedSurfaces[key]) { surfaceOverlaysPerType[key].setMap(null); delete surfaceOverlaysPerType[key]; diff --git a/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js b/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js index 6aca213bd7a5f8010fcdcc9ba4d2a8213e018402..c42c4907d327b425532a27f1f776797e99eac8c9 100644 --- a/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js +++ b/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js @@ -55,13 +55,13 @@ AbstractDbOverlay.prototype.encodeQuery = function (type, arg0, arg1, arg2) { type: type, modelId: modelId, coordinates: coordinates, - zoom: zoom, + zoom: zoom }); } else if (type === AbstractDbOverlay.QueryType.SEARCH_BY_TARGET) { var target = arg0; return JSON.stringify({ type: type, - target: target, + target: target }); } else if (type === AbstractDbOverlay.QueryType.SEARCH_BY_QUERY) { var query = arg0; @@ -69,7 +69,7 @@ AbstractDbOverlay.prototype.encodeQuery = function (type, arg0, arg1, arg2) { return JSON.stringify({ type: type, query: query, - perfect: perfect, + perfect: perfect }); } else { throw new Error("Unknown query type: " + type); diff --git a/frontend-js/src/main/js/map/overlay/SearchDbOverlay.js b/frontend-js/src/main/js/map/overlay/SearchDbOverlay.js index 28d47e4eb8a3b8eb88033e9a39b1c2ed2d789a75..03001a285e37b1fae8f102c333a8c630e410dd73 100644 --- a/frontend-js/src/main/js/map/overlay/SearchDbOverlay.js +++ b/frontend-js/src/main/js/map/overlay/SearchDbOverlay.js @@ -9,6 +9,7 @@ var Promise = require("bluebird"); var AbstractDbOverlay = require('./AbstractDbOverlay'); var Alias = require('../data/Alias'); var IdentifiedElement = require('../data/IdentifiedElement'); +var InvalidArgumentException = require('../../InvalidArgumentError'); var Reaction = require('../data/Reaction'); var ServerConnector = require('../../ServerConnector'); @@ -24,7 +25,7 @@ function SearchDbOverlay(params) { SearchDbOverlay.prototype = Object.create(AbstractDbOverlay.prototype); SearchDbOverlay.prototype.constructor = SearchDbOverlay; -SearchDbOverlay.prototype.getElementsByQuery = function(query) { +SearchDbOverlay.prototype.getElementsByQuery = function (query) { var self = this; var i; var queryId = null; @@ -43,7 +44,7 @@ SearchDbOverlay.prototype.getElementsByQuery = function(query) { var model = self.getMap().getSubmapById(elements[0].getModelId()).getModel(); promises.push(model.getByIdentifiedElement(elements[i], true)); } - return Promise.all(promises).then(function(fullElements) { + return Promise.all(promises).then(function (fullElements) { var result = []; var iconCounter = 1; for (var i = 0; i < fullElements.length; i++) { @@ -55,21 +56,21 @@ SearchDbOverlay.prototype.getElementsByQuery = function(query) { throw new Error("Unknown element type: " + element.getType()); } result.push({ - element : element, - icon : icon + element: element, + icon: icon }); } return result; }); }; -SearchDbOverlay.prototype._getFirstVisibleParentOrObject = function(identifiedElement, zoomLevel, coordinates) { +SearchDbOverlay.prototype._getFirstVisibleParentOrObject = function (identifiedElement, zoomLevel, coordinates) { if (identifiedElement === undefined) { return Promise.resolve(); } var self = this; var model = self.getMap().getSubmapById(identifiedElement.getModelId()).getModel(); - return model.getByIdentifiedElement(identifiedElement, true).then(function(fullElement) { + return model.getByIdentifiedElement(identifiedElement, true).then(function (fullElement) { if (fullElement.getHierarchyVisibilityLevel() <= zoomLevel) { return identifiedElement; } else { @@ -83,9 +84,9 @@ SearchDbOverlay.prototype._getFirstVisibleParentOrObject = function(identifiedEl } if (parentId !== undefined) { var parent = new IdentifiedElement({ - id : parentId, - type : "ALIAS", - modelId : identifiedElement.getModelId(), + id: parentId, + type: "ALIAS", + modelId: identifiedElement.getModelId(), }); return self._getFirstVisibleParentOrObject(parent, zoomLevel, coordinates); } else { @@ -96,7 +97,7 @@ SearchDbOverlay.prototype._getFirstVisibleParentOrObject = function(identifiedEl } }); }; -SearchDbOverlay.prototype.searchByCoordinates = function(params) { +SearchDbOverlay.prototype.searchByCoordinates = function (params) { var modelId = params.modelId; var coordinates = params.coordinates; var zoom = params.zoom; @@ -107,20 +108,23 @@ SearchDbOverlay.prototype.searchByCoordinates = function(params) { ServerConnector.getSessionData().setSearchQuery(query); if (self._elementsByQuery[query] !== undefined) { - self.setQueries([ query ]); + self.setQueries([query]); return self.callListeners('onSearch', { - fitBounds : false, - identifiedElements : [ self._elementsByQuery[query] ], - type : AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES, - }).then(function() { + fitBounds: false, + identifiedElements: [self._elementsByQuery[query]], + type: AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES + }).then(function () { return Promise.resolve(self._elementsByQuery[query]); }); } else { var searchResult = null; var maxDistance; - - var model = self.getMap().getSubmapById(modelId).getModel(); - return ServerConnector.getMaxSearchDistance().then(function(distance) { + var map = self.getMap().getSubmapById(modelId); + if (map === null) { + return Promise.reject(new InvalidArgumentException("model doesn't exist for modelId: " + modelId)); + } + var model = map.getModel(); + return ServerConnector.getMaxSearchDistance().then(function (distance) { var maxZoom = model.getMaxZoom(); var zoomDiff = maxZoom - zoom; for (var i = 0; i < zoomDiff; i++) { @@ -128,11 +132,11 @@ SearchDbOverlay.prototype.searchByCoordinates = function(params) { } maxDistance = distance; return ServerConnector.getClosestElementsByCoordinates({ - modelId : modelId, - coordinates : coordinates, - count : 1 + modelId: modelId, + coordinates: coordinates, + count: 1 }); - }).then(function(elements) { + }).then(function (elements) { var nestedOverlay = "Pathways and compartments"; if (elements.length === 0) { return undefined; @@ -143,11 +147,11 @@ SearchDbOverlay.prototype.searchByCoordinates = function(params) { return elements[0]; } } - }).then(function(visibleObject) { + }).then(function (visibleObject) { if (visibleObject !== undefined) { - searchResult = [ visibleObject ]; + searchResult = [visibleObject]; if (searchResult[0].getType() === "REACTION") { - return model.getReactionById(searchResult[0].getId(), true).then(function(reaction) { + return model.getReactionById(searchResult[0].getId(), true).then(function (reaction) { var i = 0; var reactionElements = reaction.getElements(); for (i = 0; i < reactionElements.length; i++) { @@ -158,60 +162,60 @@ SearchDbOverlay.prototype.searchByCoordinates = function(params) { } else { searchResult = []; } - }).then(function() { + }).then(function () { if (searchResult.length > 0) { return self.getMap().getDistance({ - modelId : modelId, - coordinates : coordinates, - element : searchResult[0], + modelId: modelId, + coordinates: coordinates, + element: searchResult[0], }); } else { return Number.POSITIVE_INFINITY; } - }).then(function(distance) { + }).then(function (distance) { if (distance <= maxDistance) { self._elementsByQuery[query] = searchResult; } else { self._elementsByQuery[query] = []; } - self.setQueries([ query ]); + self.setQueries([query]); return self.callListeners('onSearch', { - fitBounds : params.fitBounds, - identifiedElements : [ self._elementsByQuery[query] ], - type : AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES, + fitBounds: params.fitBounds, + identifiedElements: [self._elementsByQuery[query]], + type: AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES, }); - }).then(function() { + }).then(function () { return self._elementsByQuery[query]; }); } }; -SearchDbOverlay.prototype.searchBySingleQuery = function(originalQuery, perfect) { +SearchDbOverlay.prototype.searchBySingleQuery = function (originalQuery, perfect) { var self = this; var query = self.encodeQuery(AbstractDbOverlay.QueryType.SEARCH_BY_QUERY, originalQuery, perfect); if (self._elementsByQuery[query] !== undefined) { return Promise.resolve(self._elementsByQuery[query]); } else { return ServerConnector.getElementsByQuery({ - query : originalQuery, - perfectMatch : perfect - }).then(function(elements) { + query: originalQuery, + perfectMatch: perfect + }).then(function (elements) { var result = []; for (var i = 0; i < elements.length; i++) { result.push(new IdentifiedElement(elements[i])); } self._elementsByQuery[query] = result; return self.getMap().fetchIdentifiedElements(result, true); - }).then(function() { + }).then(function () { return self._elementsByQuery[query]; }); } }; -SearchDbOverlay.prototype.getIdentifiedElements = function() { +SearchDbOverlay.prototype.getIdentifiedElements = function () { var self = this; - return new Promise(function(resolve) { + return new Promise(function (resolve) { var queries = self.getQueries(); var result = []; for (var i = 0; i < queries.length; i++) { @@ -234,7 +238,7 @@ SearchDbOverlay.prototype.getIdentifiedElements = function() { }); }; -SearchDbOverlay.prototype.getDetailDataByIdentifiedElement = function(element) { +SearchDbOverlay.prototype.getDetailDataByIdentifiedElement = function (element) { if (element.getType() === "POINT") { return Promise.resolve(null); } diff --git a/frontend-js/src/test/js/gui/leftPanel/GenericSearchPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/GenericSearchPanel-test.js index fa757f58a7b69479a0c8ef5c9acda6a10c56bf19..89bb1965b537d0d66689913c4091551cd3315dad 100644 --- a/frontend-js/src/test/js/gui/leftPanel/GenericSearchPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/GenericSearchPanel-test.js @@ -4,14 +4,16 @@ require('../../mocha-config.js'); var Alias = require('../../../../main/js/map/data/Alias'); var GenericSearchPanel = require('../../../../main/js/gui/leftPanel/GenericSearchPanel'); +var AbstractDbOverlay = require('../../../../main/js/map/overlay/AbstractDbOverlay'); var PanelControlElementType = require('../../../../main/js/gui/PanelControlElementType'); +var ServerConnector = require('../../ServerConnector-mock'); var chai = require('chai'); var assert = chai.assert; var logger = require('../../logger'); describe('GenericSearchPanel', function () { - var createPanel = function() { + var createPanel = function () { var map = helper.createCustomMap(); map.getModel().setId(15781); helper.createSearchDbOverlay(map); @@ -231,4 +233,25 @@ describe('GenericSearchPanel', function () { }); + describe('init', function () { + it('default', function () { + var panel = createPanel(); + return panel.init().then(function () { + panel.destroy(); + }); + }); + it('map invalid session search query', function () { + var panel = new createPanel(); + var unknownModelId = -1; + var coordinates = new google.maps.Point(0, 0); + var zoom = 2; + var encodedQuery = panel.getOverlayDb().encodeQuery(AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES, unknownModelId, coordinates, zoom); + ServerConnector.getSessionData().setSearchQuery(encodedQuery); + return panel.init().then(function () { + assert.ok(logger.getWarnings().length > 0); + panel.destroy(); + }); + }); + }); + }); diff --git a/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js b/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js index 0b8d3520736d54720a2643a36ed2324a1ec71d13..5d3aa3a65bb5bb07828a255af7625f7770079c10 100644 --- a/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js @@ -3,6 +3,7 @@ require('../../mocha-config.js'); var Alias = require('../../../../main/js/map/data/Alias'); +var Annotation = require('../../../../main/js/map/data/Annotation'); var GuiUtils = require('../../../../main/js/gui/leftPanel/GuiUtils'); var chai = require('chai'); @@ -11,7 +12,7 @@ var logger = require('../../logger'); describe('GuiUtils', function () { - it('constructor', function() { + it('constructor', function () { var map = helper.createCustomMap(); helper.createSearchDbOverlay(map); @@ -21,19 +22,19 @@ describe('GuiUtils', function () { it('default', function () { var aliasObj = { - symbol : "S1_SYMBOL", - formerSymbols : [], - modelId : 15781, - synonyms : [ "syn44" ], - description : "DESCRIPTION", - type : "Simple molecule", - abbreviation : "ABBREVIATION", - name : "s1", - bounds : { - x : 170.0, - y : 171.5, - width : 70.0, - height : 25.0 + symbol: "S1_SYMBOL", + formerSymbols: [], + modelId: 15781, + synonyms: ["syn44"], + description: "DESCRIPTION", + type: "Simple molecule", + abbreviation: "ABBREVIATION", + name: "s1", + bounds: { + x: 170.0, + y: 171.5, + width: 70.0, + height: 25.0 }, formula: "FORMULA", id: 380217, @@ -152,5 +153,21 @@ describe('GuiUtils', function () { assert.ok(logger.getWarnings().length > 0); }); }); + describe('createAnnotationLink', function () { + it('with encoded part in resource', function () { + // noinspection SpellCheckingInspection + var annotation = new Annotation({ + resource: "10.1038%2Fnpjsba.2016.20", + link: "http://doi.org/10.1038%2Fnpjsba.2016.20", + id: 1116748, + type: "DOI" + }); + var guiUtils = new GuiUtils(helper.getConfiguration()); + var link = guiUtils.createAnnotationLink(annotation); + assert.ok(link); + assert.equal(0, logger.getWarnings().length); + assert.ok(link.innerHTML.indexOf("%2F") < 0, "url contains encoded %2F part of id"); + }); + }); }); diff --git a/frontend-js/src/test/js/gui/leftPanel/SubmapPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/SubmapPanel-test.js index c2f34d7c1147f49e08deada88192c9eaffd76a1d..8264a0fed24d046cd0c1e77c8588c34b83bea866 100644 --- a/frontend-js/src/test/js/gui/leftPanel/SubmapPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/SubmapPanel-test.js @@ -3,23 +3,24 @@ require('../../mocha-config.js'); var SubmapPanel = require('../../../../main/js/gui/leftPanel/SubmapPanel'); +var ServerConnector = require('../../ServerConnector-mock'); var chai = require('chai'); var assert = chai.assert; var logger = require('../../logger'); -describe('SubmapPanel', function() { +describe('SubmapPanel', function () { - it('constructor', function() { + it('constructor', function () { var div = document.createElement("div"); var map = helper.createCustomMap(); new SubmapPanel({ - element : div, - customMap : map, - parent : { - getMap : function() { + element: div, + customMap: map, + parent: { + getMap: function () { return map; } } @@ -29,4 +30,56 @@ describe('SubmapPanel', function() { assert.equal(buttons.length, 1); }); + describe('init', function () { + it('simple', function () { + var div = document.createElement("div"); + + var map = helper.createCustomMap(); + + var panel = new SubmapPanel({ + element: div, + customMap: map, + parent: { + getMap: function () { + return map; + }, + hideTab: function () { + } + } + }); + return panel.init().then(function () { + assert.equal(logger.getWarnings().length, 0); + var buttons = div.getElementsByTagName("button"); + assert.equal(buttons.length, 1); + }).finally(function () { + return panel.destroy(); + }) + }); + it('with submaps', function () { + var div = document.createElement("div"); + var panel; + return ServerConnector.getProject("complex_model_with_submaps").then(function (project) { + var map = helper.createCustomMap(project); + + panel = new SubmapPanel({ + element: div, + customMap: map, + parent: { + getMap: function () { + return map; + }, + hideTab: function () { + } + } + }); + return panel.init(); + }).then(function () { + assert.equal(logger.getWarnings().length, 0); + assert.equal(panel.getElement().innerHTML.indexOf("UNKNOWN submaps"), -1, "UNKNOWN submaps table should have no title"); + }).finally(function () { + return panel.destroy(); + }) + }); + }); + }); diff --git a/frontend-js/src/test/js/map/marker/MarkerSurfaceCollection-test.js b/frontend-js/src/test/js/map/marker/MarkerSurfaceCollection-test.js index c091f31dac8140d2572b97356a6f8537dce33cd4..2440feaa97a348a76682c8a49b5945dcfad7d97f 100644 --- a/frontend-js/src/test/js/map/marker/MarkerSurfaceCollection-test.js +++ b/frontend-js/src/test/js/map/marker/MarkerSurfaceCollection-test.js @@ -71,6 +71,24 @@ describe('MarkerSurfaceCollection', function () { }); }); + it("click on marker on submap", function () { + helper.setUrl("http://test/?id=complex_model_with_submaps"); + var submap, marker, collection; + var element = new IdentifiedElement({ + id: 345325, + modelId: 16729, + type: "ALIAS" + }); + return ServerConnector.getProject().then(function (project) { + submap = helper.createCustomMap(project).getSubmapById(16729); + collection = submap.getMarkerSurfaceCollection(); + return collection.addMarker({element: element, icons: ["empty.png"]}); + }).then(function (result) { + marker = result; + return marker.onClickHandler(); + }); + }); + }); describe("createSurfaceForDbOverlay", function () { diff --git a/frontend-js/src/test/js/minerva-test.js b/frontend-js/src/test/js/minerva-test.js index 9c743127841a5697b4725329b25ad589302997dc..fd53d158f8fde5b329803cefb433c6bb179b17bf 100644 --- a/frontend-js/src/test/js/minerva-test.js +++ b/frontend-js/src/test/js/minerva-test.js @@ -1,268 +1,293 @@ -"use strict"; - -require("./mocha-config"); - -var minerva = require('../../main/js/minerva'); -var ServerConnectorMock = require('./ServerConnector-mock'); -var ProxyAccessPlugin = require('./plugin/ProxyAccessPlugin'); - -var chai = require('chai'); -var assert = chai.assert; -var logger = require('./logger'); - -describe('minerva global', function () { - beforeEach(function () { - global.ServerConnector = undefined; - }); - - afterEach(function () { - global.ServerConnector = ServerConnectorMock; - }); - - describe('create', function () { - it('default', function () { - var options = null; - return ServerConnectorMock.getProject().then(function (project) { - options = helper.createCustomMapOptions(project); - - return minerva.create(options); - }).then(function (result) { - assert.ok(result); - assert.equal(logger.getWarnings().length, 0); - return result.destroy(); - }); - }); - it('invalid projectId', function () { - var options = { - projectId: "unknownId", - element: testDiv - }; - return minerva.create(options).then(function () { - assert.ok(false); - }, function (error) { - assert.ok(error.message.indexOf("Project with given id doesn't exist") >= 0); - }); - }); - it('with overview', function () { - helper.setUrl("http://test/?id=complex_model_with_images"); - var customMap; - return ServerConnectorMock.getProject().then(function (project) { - var options = helper.createOptions(project); - - return minerva.create(options); - }).then(function (result) { - customMap = result; - assert.ok(result); - assert.equal(logger.getWarnings().length, 0); - var showOverviewButton = document.getElementsByName("showOverviewButton")[0]; - return showOverviewButton.onclick(); - }).then(function () { - return customMap.destroy(); - }); - }); - }); - - - it("showComments", function () { - var options = null; - var map ; - return ServerConnectorMock.getProject().then(function (project) { - options = helper.createCustomMapOptions(project); - return minerva.create(options); - }).then(function (result) { - map = result; - var commentCheckbox = document.getElementsByName("commentCheckbox")[0]; - commentCheckbox.checked = true; - return commentCheckbox.onclick(); - }).then(function () { - assert.ok(ServerConnectorMock.getSessionData(options.getProject()).getShowComments()); - return map.destroy(); - }); - }); - - describe("constructor", function () { - - it("with GET zoom param", function () { - helper.setUrl("http://test/?zoom=5"); - var options; - return ServerConnectorMock.getProject().then(function (project) { - options = helper.createCustomMapOptions(project); - return minerva.create(options); - }).then(function (result) { - var sessionData = ServerConnectorMock.getSessionData(options.getProject()); - assert.equal(sessionData.getZoomLevel(options.getProject().getModel()), 5); - return result.destroy(); - }); - }); - - it("with GET coordinates param", function () { - helper.setUrl("http://test/?x=5&y=6"); - var options; - return ServerConnectorMock.getProject().then(function (project) { - options = helper.createCustomMapOptions(project); - return minerva.create(options); - }).then(function (result) { - var center = ServerConnectorMock.getSessionData(options.getProject()).getCenter(options.getProject().getModel()); - assert.ok(center instanceof google.maps.Point); - assert.equal(center.x, 5); - assert.equal(center.y, 6); - return result.destroy(); - }); - }); - - it("simple", function () { - var options = { - projectId: "sample", - element: testDiv - }; - return minerva.create(options).then(function (result) { - assert.ok(result); - result.destroy(); - }); - }); - }); - - it('create with layout', function () { - var layout, project, plugin, map; - return ServerConnectorMock.getProject().then(function (result) { - project = result; - var options = helper.createCustomMapOptions(project); - - plugin = new ProxyAccessPlugin({}); - options.getPlugins().push(plugin); - - layout = project.getModel().getLayouts()[1]; - - helper.setUrl("http://test/?layout=" + layout.getName()); - - return minerva.create(options); - }).then(function (result) { - map = result; - assert.ok(result); - // input file is not available so it's the background - return plugin.getMinervaPluginProxy().project.map.getVisibleDataOverlays(); - }).then(function (visibleDataOverlays) { - // input file is available so it's not the background file but overlay - assert.equal(visibleDataOverlays.length, 0); - assert.equal(ServerConnectorMock.getSessionData(project).getSelectedBackgroundOverlay(), layout.getId()); - assert.equal(logger.getWarnings().length, 0); - return map.destroy(); - }); - }); - - it('create with layout from session data', function () { - var layout; - return ServerConnectorMock.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - - layout = project.getModel().getLayouts()[1]; - - ServerConnectorMock.getSessionData(project).setSelectedBackgroundOverlay(layout.getId()); - - return minerva.create(options); - }).then(function (result) { - assert.equal(ServerConnectorMock.getSessionData().getSelectedBackgroundOverlay(), layout.getId()); - return result.destroy(); - }); - }); - - it('create with layout 2', function () { - helper.setUrl("http://test/?layout=xxx"); - var globalObject, plugin; - return ServerConnectorMock.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - plugin = new ProxyAccessPlugin(); - options.getPlugins().push(plugin); - return minerva.create(options); - }).then(function (result) { - globalObject = result; - assert.ok(result); - return plugin.getMinervaPluginProxy().project.map.getVisibleDataOverlays(); - }).then(function (visibleDataOverlays) { - // input file is available so it's not the background file but overlay - assert.equal(visibleDataOverlays.length, 1); - assert.equal(logger.getWarnings().length, 0); - return globalObject.destroy(); - }); - }); - - it('create with search overlay and GET search param', function () { - helper.setUrl("http://test/?search=s1"); - - var globalObject, plugin; - return ServerConnectorMock.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - plugin = new ProxyAccessPlugin(); - options.getPlugins().push(plugin); - return minerva.create(options); - }).then(function (result) { - globalObject = result; - return plugin.getMinervaPluginProxy().project.map.getHighlightedBioEntities("search"); - }).then(function (elements) { - assert.ok(elements.length > 0); - return globalObject.destroy(); - }); - }); - - it('create with show submodel GET param', function () { - helper.setUrl("http://test/?submap=15781"); - - var project = helper.createProject(); - project.getModel().setId(15781); - - return ServerConnectorMock.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - - return minerva.create(options); - }).then(function (result) { - return result.destroy(); - }); - }); - - it("constructor with touch enabled", function () { - return ServerConnectorMock.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - options.setCustomTouchInterface(true); - return minerva.create(options).then(function (result) { - assert.ok(result); - return result.destroy(); - }); - }); - }); - - - it('create Export', function () { - var options = null; - return ServerConnectorMock.getProject().then(function (project) { - options = helper.createCustomMapOptions(project); - - return minerva.createExport(options); - }).then(function (result) { - assert.ok(result); - assert.equal(logger.getWarnings().length, 0); - }); - }); - - it('create Admin', function () { - var options = null; - return ServerConnectorMock.getProject().then(function (project) { - options = helper.createCustomMapOptions(project); - - return minerva.createAdmin(options); - }).then(function (result) { - assert.ok(result); - assert.equal(logger.getWarnings().length, 0); - result.destroy(); - }); - }); - it('getProject', function () { - return ServerConnectorMock.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - return minerva.create(options); - }).then(function (result) { - assert.equal(result.getProject().getProjectId(), "sample"); - return result.destroy(); - }); - }); - -}); +"use strict"; + +require("./mocha-config"); + +var Alias = require('../../main/js/map/data/Alias'); +var minerva = require('../../main/js/minerva'); +var Project = require('../../main/js/map/data/Project'); +var GuiConnectorMock = require('./GuiConnector-mock'); +var SecurityError = require('../../main/js/SecurityError'); +var ServerConnectorMock = require('./ServerConnector-mock'); +var ProxyAccessPlugin = require('./plugin/ProxyAccessPlugin'); + +var chai = require('chai'); +var assert = chai.assert; +var logger = require('./logger'); + +describe('minerva global', function () { + beforeEach(function () { + global.ServerConnector = undefined; + }); + + afterEach(function () { + global.ServerConnector = ServerConnectorMock; + }); + + describe('create', function() { + it('default', function() { + var options = null; + return ServerConnectorMock.getProject().then(function(project) { + options = helper.createCustomMapOptions(project); + + return minerva.create(options); + }).then(function(result) { + assert.ok(result); + assert.equal(logger.getWarnings().length, 0); + return result.destroy(); + }); + }); + it('invalid projectId', function() { + var options = { + projectId: "unknownId", + element: testDiv + }; + return minerva.create(options).then(function () { + assert.ok(false); + }, function (error) { + assert.ok(error.message.indexOf("Project with given id doesn't exist") >= 0); + }); + }); + it('with overview', function () { + helper.setUrl("http://test/?id=complex_model_with_images"); + var customMap; + return ServerConnectorMock.getProject().then(function (project) { + var options = helper.createOptions(project); + + return minerva.create(options); + }).then(function (result) { + customMap = result; + assert.ok(result); + assert.equal(logger.getWarnings().length, 0); + var showOverviewButton = document.getElementsByName("showOverviewButton")[0]; + return showOverviewButton.onclick(); + }).then(function () { + return customMap.destroy(); + }); + }); + }); + + + it("showComments", function() { + var options = null; + var map ; + return ServerConnectorMock.getProject().then(function (project) { + options = helper.createCustomMapOptions(project); + return minerva.create(options); + }).then(function (result) { + map = result; + var commentCheckbox = document.getElementsByName("commentCheckbox")[0]; + commentCheckbox.checked = true; + return commentCheckbox.onclick(); + }).then(function() { + assert.ok(ServerConnectorMock.getSessionData(options.getProject()).getShowComments()); + return map.destroy(); + }); + }); + + describe("constructor", function () { + + it("with GET zoom param", function () { + helper.setUrl("http://test/?zoom=5"); + var options; + return ServerConnectorMock.getProject().then(function (project) { + options = helper.createCustomMapOptions(project); + return minerva.create(options); + }).then(function (result) { + var sessionData = ServerConnectorMock.getSessionData(options.getProject()); + assert.equal(sessionData.getZoomLevel(options.getProject().getModel()), 5); + return result.destroy(); + }); + }); + + it("with GET coordinates param", function () { + helper.setUrl("http://test/?x=5&y=6"); + var options; + return ServerConnectorMock.getProject().then(function (project) { + options = helper.createCustomMapOptions(project); + return minerva.create(options); + }).then(function (result) { + var center = ServerConnectorMock.getSessionData(options.getProject()).getCenter(options.getProject().getModel()); + assert.ok(center instanceof google.maps.Point); + assert.equal(center.x, 5); + assert.equal(center.y, 6); + return result.destroy(); + }); + }); + + it("simple", function () { + var options = { + projectId: "sample", + element: testDiv + }; + return minerva.create(options).then(function (result) { + assert.ok(result); + result.destroy(); + }); + }); + }); + + it('create with layout', function () { + var layout, project, plugin, map; + return ServerConnectorMock.getProject().then(function (result) { + project = result; + var options = helper.createCustomMapOptions(project); + + plugin = new ProxyAccessPlugin({}); + options.getPlugins().push(plugin); + + layout = project.getModel().getLayouts()[1]; + + helper.setUrl("http://test/?layout=" + layout.getName()); + + return minerva.create(options); + }).then(function (result) { + map = result; + assert.ok(result); + // input file is not available so it's the background + return plugin.getMinervaPluginProxy().project.map.getVisibleDataOverlays(); + }).then(function (visibleDataOverlays) { + // input file is available so it's not the background file but overlay + assert.equal(visibleDataOverlays.length, 0); + assert.equal(ServerConnectorMock.getSessionData(project).getSelectedBackgroundOverlay(), layout.getId()); + assert.equal(logger.getWarnings().length, 0); + return map.destroy(); + }); + }); + + it('create restricted map', function () { + var originalFunction = ServerConnectorMock.getProject; + ServerConnectorMock.getProject=function(){ + return Promise.reject(new SecurityError("Access denied.")); + }; + helper.setUrl("http://test/?id=restricted_sample"); + var options = { + element: testDiv, + mapDiv: testDiv, + configuration: helper.getConfiguration() + }; + + return minerva.create(options).then(function (map) { + assert.equal(null, map); + }).catch(function (e) { + assert.ok(e.message.indexOf("Access denied") >= 0); + }).finally(function(){ + ServerConnectorMock.getProject = originalFunction; + }); + }); + + it('create with layout from session data', function() { + var layout; + return ServerConnectorMock.getProject().then(function(project) { + var options = helper.createCustomMapOptions(project); + + layout = project.getModel().getLayouts()[1]; + + ServerConnectorMock.getSessionData(project).setSelectedBackgroundOverlay(layout.getId()); + + return minerva.create(options); + }).then(function (result) { + assert.equal(ServerConnectorMock.getSessionData().getSelectedBackgroundOverlay(), layout.getId()); + return result.destroy(); + }); + }); + + it('create with layout 2', function () { + helper.setUrl("http://test/?layout=xxx"); + var globalObject, plugin; + return ServerConnectorMock.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + plugin = new ProxyAccessPlugin(); + options.getPlugins().push(plugin); + return minerva.create(options); + }).then(function (result) { + globalObject = result; + assert.ok(result); + return plugin.getMinervaPluginProxy().project.map.getVisibleDataOverlays(); + }).then(function (visibleDataOverlays) { + // input file is available so it's not the background file but overlay + assert.equal(visibleDataOverlays.length, 1); + assert.equal(logger.getWarnings().length, 0); + return globalObject.destroy(); + }); + }); + + it('create with search overlay and GET search param', function () { + helper.setUrl("http://test/?search=s1"); + + var globalObject, plugin; + return ServerConnectorMock.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + plugin = new ProxyAccessPlugin(); + options.getPlugins().push(plugin); + return minerva.create(options); + }).then(function (result) { + globalObject = result; + return plugin.getMinervaPluginProxy().project.map.getHighlightedBioEntities("search"); + }).then(function (elements) { + assert.ok(elements.length > 0); + return globalObject.destroy(); + }); + }); + + it('create with show submodel GET param', function () { + helper.setUrl("http://test/?submap=15781"); + + var project = helper.createProject(); + project.getModel().setId(15781); + + return ServerConnectorMock.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + + return minerva.create(options); + }).then(function (result) { + return result.destroy(); + }); + }); + + it("constructor with touch enabled", function () { + return ServerConnectorMock.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + options.setCustomTouchInterface(true); + return minerva.create(options).then(function(result) { + assert.ok(result); + return result.destroy(); + }); + }); + }); + + + it('create Export', function () { + var options = null; + return ServerConnectorMock.getProject().then(function (project) { + options = helper.createCustomMapOptions(project); + + return minerva.createExport(options); + }).then(function (result) { + assert.ok(result); + assert.equal(logger.getWarnings().length, 0); + }); + }); + + it('create Admin', function () { + var options = null; + return ServerConnectorMock.getProject().then(function (project) { + options = helper.createCustomMapOptions(project); + + return minerva.createAdmin(options); + }).then(function (result) { + assert.ok(result); + assert.equal(logger.getWarnings().length, 0); + result.destroy(); + }); + }); + it('getProject', function () { + return ServerConnectorMock.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + return minerva.create(options); + }).then(function (result) { + assert.equal(result.getProject().getProjectId(), "sample"); + return result.destroy(); + }); + }); + +}); diff --git a/frontend-js/testFiles/apiCalls/configuration/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/configuration/token=MOCK_TOKEN_ID& index 0511d724faaed26c89ddcc24ff4dca4fb5f4eaa8..363a62838acc6969b9b792ed50978f9c493c102e 100644 --- a/frontend-js/testFiles/apiCalls/configuration/token=MOCK_TOKEN_ID& +++ b/frontend-js/testFiles/apiCalls/configuration/token=MOCK_TOKEN_ID& @@ -1 +1 @@ -{"modelFormats":[{"handler":"lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser","extension":"xml","name":"CellDesigner SBML"},{"handler":"lcsb.mapviewer.converter.model.sbgnml.SbgnmlXmlConverter","extension":"sbgn","name":"SBGN-ML"}],"elementTypes":[{"name":"Degraded","className":"lcsb.mapviewer.model.map.species.Degraded","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.LeftSquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.IonChannelProtein","parentClass":"lcsb.mapviewer.model.map.species.Protein"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.TopSquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Ion","className":"lcsb.mapviewer.model.map.species.Ion","parentClass":"lcsb.mapviewer.model.map.species.Chemical"},{"name":"Species","className":"lcsb.mapviewer.model.map.species.Species","parentClass":"lcsb.mapviewer.model.map.species.Element"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.RightSquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Drug","className":"lcsb.mapviewer.model.map.species.Drug","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.Protein","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.TruncatedProtein","parentClass":"lcsb.mapviewer.model.map.species.Protein"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.PathwayCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.BottomSquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"RNA","className":"lcsb.mapviewer.model.map.species.Rna","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Chemical","className":"lcsb.mapviewer.model.map.species.Chemical","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.Compartment","parentClass":"lcsb.mapviewer.model.map.species.Element"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.OvalCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.SquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Unknown","className":"lcsb.mapviewer.model.map.species.Unknown","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Element","className":"lcsb.mapviewer.model.map.species.Element","parentClass":"lcsb.mapviewer.model.map.BioEntity"},{"name":"Phenotype","className":"lcsb.mapviewer.model.map.species.Phenotype","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Complex","className":"lcsb.mapviewer.model.map.species.Complex","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Antisense RNA","className":"lcsb.mapviewer.model.map.species.AntisenseRna","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.ReceptorProtein","parentClass":"lcsb.mapviewer.model.map.species.Protein"},{"name":"Simple molecule","className":"lcsb.mapviewer.model.map.species.SimpleMolecule","parentClass":"lcsb.mapviewer.model.map.species.Chemical"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.GenericProtein","parentClass":"lcsb.mapviewer.model.map.species.Protein"},{"name":"Gene","className":"lcsb.mapviewer.model.map.species.Gene","parentClass":"lcsb.mapviewer.model.map.species.Species"}],"modificationStateTypes":{"PHOSPHORYLATED":{"commonName":"phosphorylated","abbreviation":"P"},"METHYLATED":{"commonName":"methylated","abbreviation":"Me"},"PALMYTOYLATED":{"commonName":"palmytoylated","abbreviation":"Pa"},"ACETYLATED":{"commonName":"acetylated","abbreviation":"Ac"},"SULFATED":{"commonName":"sulfated","abbreviation":"S"},"GLYCOSYLATED":{"commonName":"glycosylated","abbreviation":"G"},"PRENYLATED":{"commonName":"prenylated","abbreviation":"Pr"},"UBIQUITINATED":{"commonName":"ubiquitinated","abbreviation":"Ub"},"PROTONATED":{"commonName":"protonated","abbreviation":"H"},"HYDROXYLATED":{"commonName":"hydroxylated","abbreviation":"OH"},"MYRISTOYLATED":{"commonName":"myristoylated","abbreviation":"My"},"UNKNOWN":{"commonName":"unknown","abbreviation":"?"},"EMPTY":{"commonName":"empty","abbreviation":""},"DONT_CARE":{"commonName":"don't care","abbreviation":"*"}},"imageFormats":[{"handler":"lcsb.mapviewer.converter.graphics.PngImageGenerator","extension":"png","name":"PNG image"},{"handler":"lcsb.mapviewer.converter.graphics.PdfImageGenerator","extension":"pdf","name":"PDF"},{"handler":"lcsb.mapviewer.converter.graphics.SvgImageGenerator","extension":"svg","name":"SVG image"}],"plugins":[{"load-on-start":false,"url":"resources/js/plugins/empty.js"}],"annotators":[{"name":"Biocompendium","className":"lcsb.mapviewer.annotation.services.annotators.BiocompendiumAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Gene","lcsb.mapviewer.model.map.species.Rna"],"url":"http://biocompendium.embl.de/"},{"name":"Chebi","className":"lcsb.mapviewer.annotation.services.annotators.ChebiAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Chemical"],"url":"http://www.ebi.ac.uk/chebi/"},{"name":"Uniprot","className":"lcsb.mapviewer.annotation.services.annotators.UniprotAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Gene","lcsb.mapviewer.model.map.species.Rna"],"url":"http://www.uniprot.org/"},{"name":"Gene Ontology","className":"lcsb.mapviewer.annotation.services.annotators.GoAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Phenotype","lcsb.mapviewer.model.map.compartment.Compartment","lcsb.mapviewer.model.map.species.Complex"],"url":"http://amigo.geneontology.org/amigo"},{"name":"HGNC","className":"lcsb.mapviewer.annotation.services.annotators.HgncAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Rna","lcsb.mapviewer.model.map.species.Gene"],"url":"http://www.genenames.org"},{"name":"Protein Data Bank","className":"lcsb.mapviewer.annotation.services.annotators.PdbAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Rna","lcsb.mapviewer.model.map.species.Gene"],"url":"http://www.pdbe.org/"},{"name":"Recon annotator","className":"lcsb.mapviewer.annotation.services.annotators.ReconAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Chemical","lcsb.mapviewer.model.map.reaction.Reaction"],"url":"http://humanmetabolism.org/"},{"name":"Entrez Gene","className":"lcsb.mapviewer.annotation.services.annotators.EntrezAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Rna","lcsb.mapviewer.model.map.species.Gene"],"url":"http://www.ncbi.nlm.nih.gov/gene"},{"name":"Ensembl","className":"lcsb.mapviewer.annotation.services.annotators.EnsemblAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Rna","lcsb.mapviewer.model.map.species.Gene"],"url":"www.ensembl.org"}],"buildDate":" 15/11/2017 14:13","reactionTypes":[{"name":"Unknown positive influence","className":"lcsb.mapviewer.model.map.reaction.type.UnknownPositiveInfluenceReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Generic Reaction","className":"lcsb.mapviewer.model.map.reaction.Reaction","parentClass":"lcsb.mapviewer.model.map.BioEntity"},{"name":"Reduced physical stimulation","className":"lcsb.mapviewer.model.map.reaction.type.ReducedPhysicalStimulationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Negative influence","className":"lcsb.mapviewer.model.map.reaction.type.NegativeInfluenceReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Known transition omitted","className":"lcsb.mapviewer.model.map.reaction.type.KnownTransitionOmittedReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Reduced modulation","className":"lcsb.mapviewer.model.map.reaction.type.ReducedModulationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Translation","className":"lcsb.mapviewer.model.map.reaction.type.TranslationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Heterodimer association","className":"lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Transcription","className":"lcsb.mapviewer.model.map.reaction.type.TranscriptionReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown reduced trigger","className":"lcsb.mapviewer.model.map.reaction.type.UnknownReducedTriggerReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown negative influence","className":"lcsb.mapviewer.model.map.reaction.type.UnknownNegativeInfluenceReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Truncation","className":"lcsb.mapviewer.model.map.reaction.type.TruncationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Transport","className":"lcsb.mapviewer.model.map.reaction.type.TransportReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Reduced trigger","className":"lcsb.mapviewer.model.map.reaction.type.ReducedTriggerReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"State transition","className":"lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Positive influence","className":"lcsb.mapviewer.model.map.reaction.type.PositiveInfluenceReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown reduced physical stimulation","className":"lcsb.mapviewer.model.map.reaction.type.UnknownReducedPhysicalStimulationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Boolean logic gate","className":"lcsb.mapviewer.model.map.reaction.type.BooleanLogicGateReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown reduced modulation","className":"lcsb.mapviewer.model.map.reaction.type.UnknownReducedModulationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown transition","className":"lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Dissociation","className":"lcsb.mapviewer.model.map.reaction.type.DissociationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"}],"version":"11.0.4","mapTypes":[{"name":"Downstream targets","id":"DOWNSTREAM_TARGETS"},{"name":"Pathway","id":"PATHWAY"},{"name":"Unknown","id":"UNKNOWN"}],"miriamTypes":{"CHEMBL_TARGET":{"commonName":"ChEMBL target","uris":["urn:miriam:chembl.target"],"homepage":"https://www.ebi.ac.uk/chembldb/","registryIdentifier":"MIR:00000085"},"UNIPROT":{"commonName":"Uniprot","uris":["urn:miriam:uniprot"],"homepage":"http://www.uniprot.org/","registryIdentifier":"MIR:00000005"},"MI_R_BASE_MATURE_SEQUENCE":{"commonName":"miRBase Mature Sequence Database","uris":["urn:miriam:mirbase.mature"],"homepage":"http://www.mirbase.org/","registryIdentifier":"MIR:00000235"},"PFAM":{"commonName":"Protein Family Database","uris":["urn:miriam:pfam"],"homepage":"http://pfam.xfam.org//","registryIdentifier":"MIR:00000028"},"ENSEMBL_PLANTS":{"commonName":"Ensembl Plants","uris":["urn:miriam:ensembl.plant"],"homepage":"http://plants.ensembl.org/","registryIdentifier":"MIR:00000205"},"WIKIPEDIA":{"commonName":"Wikipedia (English)","uris":["urn:miriam:wikipedia.en"],"homepage":"http://en.wikipedia.org/wiki/Main_Page","registryIdentifier":"MIR:00000384"},"CHEBI":{"commonName":"Chebi","uris":["urn:miriam:obo.chebi","urn:miriam:chebi"],"homepage":"http://www.ebi.ac.uk/chebi/","registryIdentifier":"MIR:00000002"},"WIKIDATA":{"commonName":"Wikidata","uris":["urn:miriam:wikidata"],"homepage":"https://www.wikidata.org/","registryIdentifier":"MIR:00000549"},"REACTOME":{"commonName":"Reactome","uris":["urn:miriam:reactome"],"homepage":"http://www.reactome.org/","registryIdentifier":"MIR:00000018"},"EC":{"commonName":"Enzyme Nomenclature","uris":["urn:miriam:ec-code"],"homepage":"http://www.enzyme-database.org/","registryIdentifier":"MIR:00000004"},"UNIPROT_ISOFORM":{"commonName":"UniProt Isoform","uris":["urn:miriam:uniprot.isoform"],"homepage":"http://www.uniprot.org/","registryIdentifier":"MIR:00000388"},"OMIM":{"commonName":"Online Mendelian Inheritance in Man","uris":["urn:miriam:omim"],"homepage":"http://omim.org/","registryIdentifier":"MIR:00000016"},"DRUGBANK_TARGET_V4":{"commonName":"DrugBank Target v4","uris":["urn:miriam:drugbankv4.target"],"homepage":"http://www.drugbank.ca/targets","registryIdentifier":"MIR:00000528"},"MIR_TAR_BASE_MATURE_SEQUENCE":{"commonName":"miRTarBase Mature Sequence Database","uris":["urn:miriam:mirtarbase"],"homepage":"http://mirtarbase.mbc.nctu.edu.tw/","registryIdentifier":"MIR:00100739"},"CHEMBL_COMPOUND":{"commonName":"ChEMBL","uris":["urn:miriam:chembl.compound"],"homepage":"https://www.ebi.ac.uk/chembldb/","registryIdentifier":"MIR:00000084"},"KEGG_PATHWAY":{"commonName":"Kegg Pathway","uris":["urn:miriam:kegg.pathway"],"homepage":"http://www.genome.jp/kegg/pathway.html","registryIdentifier":"MIR:00000012"},"CAS":{"commonName":"Chemical Abstracts Service","uris":["urn:miriam:cas"],"homepage":"http://commonchemistry.org","registryIdentifier":"MIR:00000237"},"REFSEQ":{"commonName":"RefSeq","uris":["urn:miriam:refseq"],"homepage":"http://www.ncbi.nlm.nih.gov/projects/RefSeq/","registryIdentifier":"MIR:00000039"},"WORM_BASE":{"commonName":"WormBase","uris":["urn:miriam:wormbase"],"homepage":"http://wormbase.bio2rdf.org/fct","registryIdentifier":"MIR:00000027"},"MI_R_BASE_SEQUENCE":{"commonName":"miRBase Sequence Database","uris":["urn:miriam:mirbase"],"homepage":"http://www.mirbase.org/","registryIdentifier":"MIR:00000078"},"TAIR_LOCUS":{"commonName":"TAIR Locus","uris":["urn:miriam:tair.locus"],"homepage":"http://arabidopsis.org/index.jsp","registryIdentifier":"MIR:00000050"},"PHARM":{"commonName":"PharmGKB Pathways","uris":["urn:miriam:pharmgkb.pathways"],"homepage":"http://www.pharmgkb.org/","registryIdentifier":"MIR:00000089"},"PDB":{"commonName":"Protein Data Bank","uris":["urn:miriam:pdb"],"homepage":"http://www.pdbe.org/","registryIdentifier":"MIR:00000020"},"PANTHER":{"commonName":"PANTHER Family","uris":["urn:miriam:panther.family","urn:miriam:panther"],"homepage":"http://www.pantherdb.org/","registryIdentifier":"MIR:00000060"},"TAXONOMY":{"commonName":"Taxonomy","uris":["urn:miriam:taxonomy"],"homepage":"http://www.ncbi.nlm.nih.gov/taxonomy/","registryIdentifier":"MIR:00000006"},"UNIGENE":{"commonName":"UniGene","uris":["urn:miriam:unigene"],"homepage":"http://www.ncbi.nlm.nih.gov/unigene","registryIdentifier":"MIR:00000346"},"HGNC":{"commonName":"HGNC","uris":["urn:miriam:hgnc"],"homepage":"http://www.genenames.org","registryIdentifier":"MIR:00000080"},"HGNC_SYMBOL":{"commonName":"HGNC Symbol","uris":["urn:miriam:hgnc.symbol"],"homepage":"http://www.genenames.org","registryIdentifier":"MIR:00000362"},"COG":{"commonName":"Clusters of Orthologous Groups","uris":["urn:miriam:cogs"],"homepage":"https://www.ncbi.nlm.nih.gov/COG/","registryIdentifier":"MIR:00000296"},"WIKIPATHWAYS":{"commonName":"WikiPathways","uris":["urn:miriam:wikipathways"],"homepage":"http://www.wikipathways.org/","registryIdentifier":"MIR:00000076"},"HMDB":{"commonName":"HMDB","uris":["urn:miriam:hmdb"],"homepage":"http://www.hmdb.ca/","registryIdentifier":"MIR:00000051"},"CHEMSPIDER":{"commonName":"ChemSpider","uris":["urn:miriam:chemspider"],"homepage":"http://www.chemspider.com//","registryIdentifier":"MIR:00000138"},"ENSEMBL":{"commonName":"Ensembl","uris":["urn:miriam:ensembl"],"homepage":"www.ensembl.org","registryIdentifier":"MIR:00000003"},"GO":{"commonName":"Gene Ontology","uris":["urn:miriam:obo.go","urn:miriam:go"],"homepage":"http://amigo.geneontology.org/amigo","registryIdentifier":"MIR:00000022"},"KEGG_REACTION":{"commonName":"Kegg Reaction","uris":["urn:miriam:kegg.reaction"],"homepage":"http://www.genome.jp/kegg/reaction/","registryIdentifier":"MIR:00000014"},"KEGG_ORTHOLOGY":{"commonName":"KEGG Orthology","uris":["urn:miriam:kegg.orthology"],"homepage":"http://www.genome.jp/kegg/ko.html","registryIdentifier":"MIR:00000116"},"PUBCHEM":{"commonName":"PubChem-compound","uris":["urn:miriam:pubchem.compound"],"homepage":"http://pubchem.ncbi.nlm.nih.gov/","registryIdentifier":"MIR:00000034"},"MESH_2012":{"commonName":"MeSH 2012","uris":["urn:miriam:mesh.2012","urn:miriam:mesh"],"homepage":"http://www.nlm.nih.gov/mesh/","registryIdentifier":"MIR:00000270"},"MGD":{"commonName":"Mouse Genome Database","uris":["urn:miriam:mgd"],"homepage":"http://www.informatics.jax.org/","registryIdentifier":"MIR:00000037"},"ENTREZ":{"commonName":"Entrez Gene","uris":["urn:miriam:ncbigene","urn:miriam:entrez.gene"],"homepage":"http://www.ncbi.nlm.nih.gov/gene","registryIdentifier":"MIR:00000069"},"PUBCHEM_SUBSTANCE":{"commonName":"PubChem-substance","uris":["urn:miriam:pubchem.substance"],"homepage":"http://pubchem.ncbi.nlm.nih.gov/","registryIdentifier":"MIR:00000033"},"CCDS":{"commonName":"Consensus CDS","uris":["urn:miriam:ccds"],"homepage":"http://www.ncbi.nlm.nih.gov/CCDS/","registryIdentifier":"MIR:00000375"},"KEGG_GENES":{"commonName":"Kegg Genes","uris":["urn:miriam:kegg.genes","urn:miriam:kegg.genes:hsa"],"homepage":"http://www.genome.jp/kegg/genes.html","registryIdentifier":"MIR:00000070"},"TOXICOGENOMIC_CHEMICAL":{"commonName":"Toxicogenomic Chemical","uris":["urn:miriam:ctd.chemical"],"homepage":"http://ctdbase.org/","registryIdentifier":"MIR:00000098"},"SGD":{"commonName":"Saccharomyces Genome Database","uris":["urn:miriam:sgd"],"homepage":"http://www.yeastgenome.org/","registryIdentifier":"MIR:00000023"},"KEGG_COMPOUND":{"commonName":"Kegg Compound","uris":["urn:miriam:kegg.compound"],"homepage":"http://www.genome.jp/kegg/ligand.html","registryIdentifier":"MIR:00000013"},"INTERPRO":{"commonName":"InterPro","uris":["urn:miriam:interpro"],"homepage":"http://www.ebi.ac.uk/interpro/","registryIdentifier":"MIR:00000011"},"UNKNOWN":{"commonName":"Unknown","uris":[],"homepage":null,"registryIdentifier":null},"DRUGBANK":{"commonName":"DrugBank","uris":["urn:miriam:drugbank"],"homepage":"http://www.drugbank.ca/","registryIdentifier":"MIR:00000102"},"PUBMED":{"commonName":"PubMed","uris":["urn:miriam:pubmed"],"homepage":"http://www.ncbi.nlm.nih.gov/PubMed/","registryIdentifier":"MIR:00000015"}},"options":[{"idObject":9,"type":"EMAIL_ADDRESS","value":"your.account@domain.com","valueType":"EMAIL","commonName":"E-mail address"},{"idObject":10,"type":"EMAIL_LOGIN","value":"your@l","valueType":"STRING","commonName":"E-mail server login"},{"idObject":11,"type":"EMAIL_PASSWORD","value":"email.secret.password","valueType":"PASSWORD","commonName":"E-mail server password"},{"idObject":13,"type":"EMAIL_IMAP_SERVER","value":"your.imap.domain.com","valueType":"STRING","commonName":"IMAP server"},{"idObject":12,"type":"EMAIL_SMTP_SERVER","value":"your.smtp.domain.com","valueType":"STRING","commonName":"SMTP server"},{"idObject":14,"type":"EMAIL_SMTP_PORT","value":"25","valueType":"INTEGER","commonName":"SMTP port"},{"idObject":6,"type":"DEFAULT_MAP","value":"sample","valueType":"STRING","commonName":"Default Project Id"},{"idObject":4,"type":"LOGO_IMG","value":"udl.png","valueType":"URL","commonName":"Logo icon"},{"idObject":3,"type":"LOGO_LINK","value":"http://wwwen.uni.lu/","valueType":"URL","commonName":"Logo link (after click)"},{"idObject":7,"type":"SEARCH_DISTANCE","value":"10","valueType":"DOUBLE","commonName":"Max distance for clicking on element (px)"},{"idObject":1,"type":"REQUEST_ACCOUNT_EMAIL","value":"your.email@domain.com","valueType":"EMAIL","commonName":"Email used for requesting an account"},{"idObject":8,"type":"SEARCH_RESULT_NUMBER","value":"100","valueType":"INTEGER","commonName":"Max number of results in search box. "},{"idObject":2,"type":"GOOGLE_ANALYTICS_IDENTIFIER","value":"","valueType":"STRING","commonName":"Google Analytics tracking ID used for statistics"},{"idObject":5,"type":"LOGO_TEXT","value":"University of Luxembourg","valueType":"STRING","commonName":"Logo description"},{"idObject":56,"type":"X_FRAME_DOMAIN","value":"http://localhost:8080/","valueType":"URL","commonName":"Domain allowed to connect via x-frame technology"},{"idObject":131,"type":"BIG_FILE_STORAGE_DIR","value":"minerva-big/","valueType":"STRING","commonName":"Path to store big files"},{"idObject":138,"type":"LEGEND_FILE_1","value":"resources/images/legend_a.png","valueType":"URL","commonName":"Legend 1 image file"},{"idObject":139,"type":"LEGEND_FILE_2","value":"resources/images/legend_b.png","valueType":"URL","commonName":"Legend 2 image file"},{"idObject":140,"type":"LEGEND_FILE_3","value":"resources/images/legend_c.png","valueType":"URL","commonName":"Legend 3 image file"},{"idObject":141,"type":"LEGEND_FILE_4","value":"resources/images/legend_d.png","valueType":"URL","commonName":"Legend 4 image file"},{"idObject":142,"type":"USER_MANUAL_FILE","value":"resources/other/user_guide.pdf","valueType":"URL","commonName":"User manual file"},{"idObject":205,"type":"MIN_COLOR_VAL","value":"FF0000","valueType":"COLOR","commonName":"Overlay color for negative values"},{"idObject":206,"type":"MAX_COLOR_VAL","value":"fbff00","valueType":"COLOR","commonName":"Overlay color for postive values"},{"idObject":218,"type":"SIMPLE_COLOR_VAL","value":"00ff40","valueType":"COLOR","commonName":"Overlay color when no values are defined"},{"idObject":239,"type":"NEUTRAL_COLOR_VAL","value":"0400ff","valueType":"COLOR","commonName":"Overlay color for value=0"}],"privilegeTypes":{"VIEW_PROJECT":{"commonName":"View project","valueType":"boolean","objectType":"Project"},"LAYOUT_MANAGEMENT":{"commonName":"Manage layouts","valueType":"boolean","objectType":"Project"},"PROJECT_MANAGEMENT":{"commonName":"Map management","valueType":"boolean","objectType":null},"CUSTOM_LAYOUTS":{"commonName":"Custom layouts","valueType":"int","objectType":null},"ADD_MAP":{"commonName":"Add project","valueType":"boolean","objectType":null},"LAYOUT_VIEW":{"commonName":"View layout","valueType":"boolean","objectType":"Layout"},"MANAGE_GENOMES":{"commonName":"Manage genomes","valueType":"boolean","objectType":null},"EDIT_COMMENTS_PROJECT":{"commonName":"Manage comments","valueType":"boolean","objectType":"Project"},"CONFIGURATION_MANAGE":{"commonName":"Manage configuration","valueType":"boolean","objectType":null},"USER_MANAGEMENT":{"commonName":"User management","valueType":"boolean","objectType":null}},"overlayTypes":[{"name":"GENERIC"},{"name":"GENETIC_VARIANT"}]} \ No newline at end of file +{"modelFormats":[{"handler":"lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser","extension":"xml","name":"CellDesigner SBML"},{"handler":"lcsb.mapviewer.converter.model.sbgnml.SbgnmlXmlConverter","extension":"sbgn","name":"SBGN-ML"}],"elementTypes":[{"name":"Degraded","className":"lcsb.mapviewer.model.map.species.Degraded","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.LeftSquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.IonChannelProtein","parentClass":"lcsb.mapviewer.model.map.species.Protein"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.TopSquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Ion","className":"lcsb.mapviewer.model.map.species.Ion","parentClass":"lcsb.mapviewer.model.map.species.Chemical"},{"name":"Species","className":"lcsb.mapviewer.model.map.species.Species","parentClass":"lcsb.mapviewer.model.map.species.Element"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.RightSquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Drug","className":"lcsb.mapviewer.model.map.species.Drug","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.Protein","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.TruncatedProtein","parentClass":"lcsb.mapviewer.model.map.species.Protein"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.PathwayCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.BottomSquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"RNA","className":"lcsb.mapviewer.model.map.species.Rna","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Chemical","className":"lcsb.mapviewer.model.map.species.Chemical","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.Compartment","parentClass":"lcsb.mapviewer.model.map.species.Element"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.OvalCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Compartment","className":"lcsb.mapviewer.model.map.compartment.SquareCompartment","parentClass":"lcsb.mapviewer.model.map.compartment.Compartment"},{"name":"Unknown","className":"lcsb.mapviewer.model.map.species.Unknown","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Element","className":"lcsb.mapviewer.model.map.species.Element","parentClass":"lcsb.mapviewer.model.map.BioEntity"},{"name":"Phenotype","className":"lcsb.mapviewer.model.map.species.Phenotype","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Complex","className":"lcsb.mapviewer.model.map.species.Complex","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Antisense RNA","className":"lcsb.mapviewer.model.map.species.AntisenseRna","parentClass":"lcsb.mapviewer.model.map.species.Species"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.ReceptorProtein","parentClass":"lcsb.mapviewer.model.map.species.Protein"},{"name":"Simple molecule","className":"lcsb.mapviewer.model.map.species.SimpleMolecule","parentClass":"lcsb.mapviewer.model.map.species.Chemical"},{"name":"Protein","className":"lcsb.mapviewer.model.map.species.GenericProtein","parentClass":"lcsb.mapviewer.model.map.species.Protein"},{"name":"Gene","className":"lcsb.mapviewer.model.map.species.Gene","parentClass":"lcsb.mapviewer.model.map.species.Species"}],"modificationStateTypes":{"PHOSPHORYLATED":{"commonName":"phosphorylated","abbreviation":"P"},"METHYLATED":{"commonName":"methylated","abbreviation":"Me"},"PALMYTOYLATED":{"commonName":"palmytoylated","abbreviation":"Pa"},"ACETYLATED":{"commonName":"acetylated","abbreviation":"Ac"},"SULFATED":{"commonName":"sulfated","abbreviation":"S"},"GLYCOSYLATED":{"commonName":"glycosylated","abbreviation":"G"},"PRENYLATED":{"commonName":"prenylated","abbreviation":"Pr"},"UBIQUITINATED":{"commonName":"ubiquitinated","abbreviation":"Ub"},"PROTONATED":{"commonName":"protonated","abbreviation":"H"},"HYDROXYLATED":{"commonName":"hydroxylated","abbreviation":"OH"},"MYRISTOYLATED":{"commonName":"myristoylated","abbreviation":"My"},"UNKNOWN":{"commonName":"unknown","abbreviation":"?"},"EMPTY":{"commonName":"empty","abbreviation":""},"DONT_CARE":{"commonName":"don't care","abbreviation":"*"}},"imageFormats":[{"handler":"lcsb.mapviewer.converter.graphics.PngImageGenerator","extension":"png","name":"PNG image"},{"handler":"lcsb.mapviewer.converter.graphics.PdfImageGenerator","extension":"pdf","name":"PDF"},{"handler":"lcsb.mapviewer.converter.graphics.SvgImageGenerator","extension":"svg","name":"SVG image"}],"plugins":[],"annotators":[{"name":"Biocompendium","className":"lcsb.mapviewer.annotation.services.annotators.BiocompendiumAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Gene","lcsb.mapviewer.model.map.species.Rna"],"url":"http://biocompendium.embl.de/"},{"name":"Chebi","className":"lcsb.mapviewer.annotation.services.annotators.ChebiAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Chemical"],"url":"http://www.ebi.ac.uk/chebi/"},{"name":"Uniprot","className":"lcsb.mapviewer.annotation.services.annotators.UniprotAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Gene","lcsb.mapviewer.model.map.species.Rna"],"url":"http://www.uniprot.org/"},{"name":"Gene Ontology","className":"lcsb.mapviewer.annotation.services.annotators.GoAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Phenotype","lcsb.mapviewer.model.map.compartment.Compartment","lcsb.mapviewer.model.map.species.Complex"],"url":"http://amigo.geneontology.org/amigo"},{"name":"HGNC","className":"lcsb.mapviewer.annotation.services.annotators.HgncAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Rna","lcsb.mapviewer.model.map.species.Gene"],"url":"http://www.genenames.org"},{"name":"Protein Data Bank","className":"lcsb.mapviewer.annotation.services.annotators.PdbAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Rna","lcsb.mapviewer.model.map.species.Gene"],"url":"http://www.pdbe.org/"},{"name":"Recon annotator","className":"lcsb.mapviewer.annotation.services.annotators.ReconAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Chemical","lcsb.mapviewer.model.map.reaction.Reaction"],"url":"http://humanmetabolism.org/"},{"name":"Entrez Gene","className":"lcsb.mapviewer.annotation.services.annotators.EntrezAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Rna","lcsb.mapviewer.model.map.species.Gene"],"url":"http://www.ncbi.nlm.nih.gov/gene"},{"name":"Ensembl","className":"lcsb.mapviewer.annotation.services.annotators.EnsemblAnnotator","elementClassNames":["lcsb.mapviewer.model.map.species.Protein","lcsb.mapviewer.model.map.species.Rna","lcsb.mapviewer.model.map.species.Gene"],"url":"www.ensembl.org"}],"buildDate":" 24/01/2018 12:08","reactionTypes":[{"name":"Unknown positive influence","className":"lcsb.mapviewer.model.map.reaction.type.UnknownPositiveInfluenceReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Generic Reaction","className":"lcsb.mapviewer.model.map.reaction.Reaction","parentClass":"lcsb.mapviewer.model.map.BioEntity"},{"name":"Reduced physical stimulation","className":"lcsb.mapviewer.model.map.reaction.type.ReducedPhysicalStimulationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Negative influence","className":"lcsb.mapviewer.model.map.reaction.type.NegativeInfluenceReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Known transition omitted","className":"lcsb.mapviewer.model.map.reaction.type.KnownTransitionOmittedReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Reduced modulation","className":"lcsb.mapviewer.model.map.reaction.type.ReducedModulationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Translation","className":"lcsb.mapviewer.model.map.reaction.type.TranslationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Heterodimer association","className":"lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Transcription","className":"lcsb.mapviewer.model.map.reaction.type.TranscriptionReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown reduced trigger","className":"lcsb.mapviewer.model.map.reaction.type.UnknownReducedTriggerReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown negative influence","className":"lcsb.mapviewer.model.map.reaction.type.UnknownNegativeInfluenceReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Truncation","className":"lcsb.mapviewer.model.map.reaction.type.TruncationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Transport","className":"lcsb.mapviewer.model.map.reaction.type.TransportReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Reduced trigger","className":"lcsb.mapviewer.model.map.reaction.type.ReducedTriggerReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"State transition","className":"lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Positive influence","className":"lcsb.mapviewer.model.map.reaction.type.PositiveInfluenceReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown reduced physical stimulation","className":"lcsb.mapviewer.model.map.reaction.type.UnknownReducedPhysicalStimulationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Boolean logic gate","className":"lcsb.mapviewer.model.map.reaction.type.BooleanLogicGateReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown reduced modulation","className":"lcsb.mapviewer.model.map.reaction.type.UnknownReducedModulationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Unknown transition","className":"lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"},{"name":"Dissociation","className":"lcsb.mapviewer.model.map.reaction.type.DissociationReaction","parentClass":"lcsb.mapviewer.model.map.reaction.Reaction"}],"version":"12.0.0","mapTypes":[{"name":"Downstream targets","id":"DOWNSTREAM_TARGETS"},{"name":"Pathway","id":"PATHWAY"},{"name":"Unknown","id":"UNKNOWN"}],"miriamTypes":{"CHEMBL_TARGET":{"commonName":"ChEMBL target","uris":["urn:miriam:chembl.target"],"homepage":"https://www.ebi.ac.uk/chembldb/","registryIdentifier":"MIR:00000085"},"UNIPROT":{"commonName":"Uniprot","uris":["urn:miriam:uniprot"],"homepage":"http://www.uniprot.org/","registryIdentifier":"MIR:00000005"},"MI_R_BASE_MATURE_SEQUENCE":{"commonName":"miRBase Mature Sequence Database","uris":["urn:miriam:mirbase.mature"],"homepage":"http://www.mirbase.org/","registryIdentifier":"MIR:00000235"},"PFAM":{"commonName":"Protein Family Database","uris":["urn:miriam:pfam"],"homepage":"http://pfam.xfam.org//","registryIdentifier":"MIR:00000028"},"ENSEMBL_PLANTS":{"commonName":"Ensembl Plants","uris":["urn:miriam:ensembl.plant"],"homepage":"http://plants.ensembl.org/","registryIdentifier":"MIR:00000205"},"WIKIPEDIA":{"commonName":"Wikipedia (English)","uris":["urn:miriam:wikipedia.en"],"homepage":"http://en.wikipedia.org/wiki/Main_Page","registryIdentifier":"MIR:00000384"},"CHEBI":{"commonName":"Chebi","uris":["urn:miriam:obo.chebi","urn:miriam:chebi"],"homepage":"http://www.ebi.ac.uk/chebi/","registryIdentifier":"MIR:00000002"},"WIKIDATA":{"commonName":"Wikidata","uris":["urn:miriam:wikidata"],"homepage":"https://www.wikidata.org/","registryIdentifier":"MIR:00000549"},"REACTOME":{"commonName":"Reactome","uris":["urn:miriam:reactome"],"homepage":"http://www.reactome.org/","registryIdentifier":"MIR:00000018"},"EC":{"commonName":"Enzyme Nomenclature","uris":["urn:miriam:ec-code"],"homepage":"http://www.enzyme-database.org/","registryIdentifier":"MIR:00000004"},"DOI":{"commonName":"Digital Object Identifier","uris":["urn:miriam:doi"],"homepage":"http://www.doi.org/","registryIdentifier":"MIR:00000019"},"UNIPROT_ISOFORM":{"commonName":"UniProt Isoform","uris":["urn:miriam:uniprot.isoform"],"homepage":"http://www.uniprot.org/","registryIdentifier":"MIR:00000388"},"OMIM":{"commonName":"Online Mendelian Inheritance in Man","uris":["urn:miriam:omim"],"homepage":"http://omim.org/","registryIdentifier":"MIR:00000016"},"DRUGBANK_TARGET_V4":{"commonName":"DrugBank Target v4","uris":["urn:miriam:drugbankv4.target"],"homepage":"http://www.drugbank.ca/targets","registryIdentifier":"MIR:00000528"},"MIR_TAR_BASE_MATURE_SEQUENCE":{"commonName":"miRTarBase Mature Sequence Database","uris":["urn:miriam:mirtarbase"],"homepage":"http://mirtarbase.mbc.nctu.edu.tw/","registryIdentifier":"MIR:00100739"},"CHEMBL_COMPOUND":{"commonName":"ChEMBL","uris":["urn:miriam:chembl.compound"],"homepage":"https://www.ebi.ac.uk/chembldb/","registryIdentifier":"MIR:00000084"},"KEGG_PATHWAY":{"commonName":"Kegg Pathway","uris":["urn:miriam:kegg.pathway"],"homepage":"http://www.genome.jp/kegg/pathway.html","registryIdentifier":"MIR:00000012"},"CAS":{"commonName":"Chemical Abstracts Service","uris":["urn:miriam:cas"],"homepage":"http://commonchemistry.org","registryIdentifier":"MIR:00000237"},"REFSEQ":{"commonName":"RefSeq","uris":["urn:miriam:refseq"],"homepage":"http://www.ncbi.nlm.nih.gov/projects/RefSeq/","registryIdentifier":"MIR:00000039"},"WORM_BASE":{"commonName":"WormBase","uris":["urn:miriam:wormbase"],"homepage":"http://wormbase.bio2rdf.org/fct","registryIdentifier":"MIR:00000027"},"MI_R_BASE_SEQUENCE":{"commonName":"miRBase Sequence Database","uris":["urn:miriam:mirbase"],"homepage":"http://www.mirbase.org/","registryIdentifier":"MIR:00000078"},"TAIR_LOCUS":{"commonName":"TAIR Locus","uris":["urn:miriam:tair.locus"],"homepage":"http://arabidopsis.org/index.jsp","registryIdentifier":"MIR:00000050"},"PHARM":{"commonName":"PharmGKB Pathways","uris":["urn:miriam:pharmgkb.pathways"],"homepage":"http://www.pharmgkb.org/","registryIdentifier":"MIR:00000089"},"PDB":{"commonName":"Protein Data Bank","uris":["urn:miriam:pdb"],"homepage":"http://www.pdbe.org/","registryIdentifier":"MIR:00000020"},"PANTHER":{"commonName":"PANTHER Family","uris":["urn:miriam:panther.family","urn:miriam:panther"],"homepage":"http://www.pantherdb.org/","registryIdentifier":"MIR:00000060"},"TAXONOMY":{"commonName":"Taxonomy","uris":["urn:miriam:taxonomy"],"homepage":"http://www.ncbi.nlm.nih.gov/taxonomy/","registryIdentifier":"MIR:00000006"},"UNIGENE":{"commonName":"UniGene","uris":["urn:miriam:unigene"],"homepage":"http://www.ncbi.nlm.nih.gov/unigene","registryIdentifier":"MIR:00000346"},"HGNC":{"commonName":"HGNC","uris":["urn:miriam:hgnc"],"homepage":"http://www.genenames.org","registryIdentifier":"MIR:00000080"},"HGNC_SYMBOL":{"commonName":"HGNC Symbol","uris":["urn:miriam:hgnc.symbol"],"homepage":"http://www.genenames.org","registryIdentifier":"MIR:00000362"},"COG":{"commonName":"Clusters of Orthologous Groups","uris":["urn:miriam:cogs"],"homepage":"https://www.ncbi.nlm.nih.gov/COG/","registryIdentifier":"MIR:00000296"},"WIKIPATHWAYS":{"commonName":"WikiPathways","uris":["urn:miriam:wikipathways"],"homepage":"http://www.wikipathways.org/","registryIdentifier":"MIR:00000076"},"HMDB":{"commonName":"HMDB","uris":["urn:miriam:hmdb"],"homepage":"http://www.hmdb.ca/","registryIdentifier":"MIR:00000051"},"CHEMSPIDER":{"commonName":"ChemSpider","uris":["urn:miriam:chemspider"],"homepage":"http://www.chemspider.com//","registryIdentifier":"MIR:00000138"},"ENSEMBL":{"commonName":"Ensembl","uris":["urn:miriam:ensembl"],"homepage":"www.ensembl.org","registryIdentifier":"MIR:00000003"},"GO":{"commonName":"Gene Ontology","uris":["urn:miriam:obo.go","urn:miriam:go"],"homepage":"http://amigo.geneontology.org/amigo","registryIdentifier":"MIR:00000022"},"KEGG_REACTION":{"commonName":"Kegg Reaction","uris":["urn:miriam:kegg.reaction"],"homepage":"http://www.genome.jp/kegg/reaction/","registryIdentifier":"MIR:00000014"},"KEGG_ORTHOLOGY":{"commonName":"KEGG Orthology","uris":["urn:miriam:kegg.orthology"],"homepage":"http://www.genome.jp/kegg/ko.html","registryIdentifier":"MIR:00000116"},"PUBCHEM":{"commonName":"PubChem-compound","uris":["urn:miriam:pubchem.compound"],"homepage":"http://pubchem.ncbi.nlm.nih.gov/","registryIdentifier":"MIR:00000034"},"MESH_2012":{"commonName":"MeSH 2012","uris":["urn:miriam:mesh.2012","urn:miriam:mesh"],"homepage":"http://www.nlm.nih.gov/mesh/","registryIdentifier":"MIR:00000270"},"MGD":{"commonName":"Mouse Genome Database","uris":["urn:miriam:mgd"],"homepage":"http://www.informatics.jax.org/","registryIdentifier":"MIR:00000037"},"ENTREZ":{"commonName":"Entrez Gene","uris":["urn:miriam:ncbigene","urn:miriam:entrez.gene"],"homepage":"http://www.ncbi.nlm.nih.gov/gene","registryIdentifier":"MIR:00000069"},"PUBCHEM_SUBSTANCE":{"commonName":"PubChem-substance","uris":["urn:miriam:pubchem.substance"],"homepage":"http://pubchem.ncbi.nlm.nih.gov/","registryIdentifier":"MIR:00000033"},"CCDS":{"commonName":"Consensus CDS","uris":["urn:miriam:ccds"],"homepage":"http://www.ncbi.nlm.nih.gov/CCDS/","registryIdentifier":"MIR:00000375"},"KEGG_GENES":{"commonName":"Kegg Genes","uris":["urn:miriam:kegg.genes","urn:miriam:kegg.genes:hsa"],"homepage":"http://www.genome.jp/kegg/genes.html","registryIdentifier":"MIR:00000070"},"TOXICOGENOMIC_CHEMICAL":{"commonName":"Toxicogenomic Chemical","uris":["urn:miriam:ctd.chemical"],"homepage":"http://ctdbase.org/","registryIdentifier":"MIR:00000098"},"SGD":{"commonName":"Saccharomyces Genome Database","uris":["urn:miriam:sgd"],"homepage":"http://www.yeastgenome.org/","registryIdentifier":"MIR:00000023"},"KEGG_COMPOUND":{"commonName":"Kegg Compound","uris":["urn:miriam:kegg.compound"],"homepage":"http://www.genome.jp/kegg/ligand.html","registryIdentifier":"MIR:00000013"},"INTERPRO":{"commonName":"InterPro","uris":["urn:miriam:interpro"],"homepage":"http://www.ebi.ac.uk/interpro/","registryIdentifier":"MIR:00000011"},"UNKNOWN":{"commonName":"Unknown","uris":[],"homepage":null,"registryIdentifier":null},"DRUGBANK":{"commonName":"DrugBank","uris":["urn:miriam:drugbank"],"homepage":"http://www.drugbank.ca/","registryIdentifier":"MIR:00000102"},"PUBMED":{"commonName":"PubMed","uris":["urn:miriam:pubmed"],"homepage":"http://www.ncbi.nlm.nih.gov/PubMed/","registryIdentifier":"MIR:00000015"}},"options":[{"idObject":9,"type":"EMAIL_ADDRESS","value":"your.account@domain.com","valueType":"EMAIL","commonName":"E-mail address"},{"idObject":10,"type":"EMAIL_LOGIN","value":"your@l","valueType":"STRING","commonName":"E-mail server login"},{"idObject":11,"type":"EMAIL_PASSWORD","value":"email.secret.password","valueType":"PASSWORD","commonName":"E-mail server password"},{"idObject":13,"type":"EMAIL_IMAP_SERVER","value":"your.imap.domain.com","valueType":"STRING","commonName":"IMAP server"},{"idObject":12,"type":"EMAIL_SMTP_SERVER","value":"your.smtp.domain.com","valueType":"STRING","commonName":"SMTP server"},{"idObject":14,"type":"EMAIL_SMTP_PORT","value":"25","valueType":"INTEGER","commonName":"SMTP port"},{"idObject":6,"type":"DEFAULT_MAP","value":"sample","valueType":"STRING","commonName":"Default Project Id"},{"idObject":4,"type":"LOGO_IMG","value":"udl.png","valueType":"URL","commonName":"Logo icon"},{"idObject":3,"type":"LOGO_LINK","value":"http://wwwen.uni.lu/","valueType":"URL","commonName":"Logo link (after click)"},{"idObject":7,"type":"SEARCH_DISTANCE","value":"10","valueType":"DOUBLE","commonName":"Max distance for clicking on element (px)"},{"idObject":1,"type":"REQUEST_ACCOUNT_EMAIL","value":"your.email@domain.com","valueType":"EMAIL","commonName":"Email used for requesting an account"},{"idObject":8,"type":"SEARCH_RESULT_NUMBER","value":"100","valueType":"INTEGER","commonName":"Max number of results in search box. "},{"idObject":2,"type":"GOOGLE_ANALYTICS_IDENTIFIER","value":"","valueType":"STRING","commonName":"Google Analytics tracking ID used for statistics"},{"idObject":5,"type":"LOGO_TEXT","value":"University of Luxembourg","valueType":"STRING","commonName":"Logo description"},{"idObject":56,"type":"X_FRAME_DOMAIN","value":"http://localhost:8080/","valueType":"URL","commonName":"Domain allowed to connect via x-frame technology"},{"idObject":131,"type":"BIG_FILE_STORAGE_DIR","value":"minerva-big/","valueType":"STRING","commonName":"Path to store big files"},{"idObject":138,"type":"LEGEND_FILE_1","value":"resources/images/legend_a.png","valueType":"URL","commonName":"Legend 1 image file"},{"idObject":139,"type":"LEGEND_FILE_2","value":"resources/images/legend_b.png","valueType":"URL","commonName":"Legend 2 image file"},{"idObject":140,"type":"LEGEND_FILE_3","value":"resources/images/legend_c.png","valueType":"URL","commonName":"Legend 3 image file"},{"idObject":141,"type":"LEGEND_FILE_4","value":"resources/images/legend_d.png","valueType":"URL","commonName":"Legend 4 image file"},{"idObject":142,"type":"USER_MANUAL_FILE","value":"resources/other/user_guide.pdf","valueType":"URL","commonName":"User manual file"},{"idObject":205,"type":"MIN_COLOR_VAL","value":"FF0000","valueType":"COLOR","commonName":"Overlay color for negative values"},{"idObject":206,"type":"MAX_COLOR_VAL","value":"fbff00","valueType":"COLOR","commonName":"Overlay color for postive values"},{"idObject":218,"type":"SIMPLE_COLOR_VAL","value":"00ff40","valueType":"COLOR","commonName":"Overlay color when no values are defined"},{"idObject":239,"type":"NEUTRAL_COLOR_VAL","value":"0400ff","valueType":"COLOR","commonName":"Overlay color for value=0"}],"privilegeTypes":{"VIEW_PROJECT":{"commonName":"View project","valueType":"boolean","objectType":"Project"},"LAYOUT_MANAGEMENT":{"commonName":"Manage layouts","valueType":"boolean","objectType":"Project"},"PROJECT_MANAGEMENT":{"commonName":"Map management","valueType":"boolean","objectType":null},"CUSTOM_LAYOUTS":{"commonName":"Custom layouts","valueType":"int","objectType":null},"ADD_MAP":{"commonName":"Add project","valueType":"boolean","objectType":null},"LAYOUT_VIEW":{"commonName":"View layout","valueType":"boolean","objectType":"Layout"},"MANAGE_GENOMES":{"commonName":"Manage genomes","valueType":"boolean","objectType":null},"EDIT_COMMENTS_PROJECT":{"commonName":"Manage comments","valueType":"boolean","objectType":"Project"},"CONFIGURATION_MANAGE":{"commonName":"Manage configuration","valueType":"boolean","objectType":null},"USER_MANAGEMENT":{"commonName":"User management","valueType":"boolean","objectType":null}},"overlayTypes":[{"name":"GENERIC"},{"name":"GENETIC_VARIANT"}]} \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/bioEntities/elements/columns=id,bounds,modelId&id=345325&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/bioEntities/elements/columns=id,bounds,modelId&id=345325&token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..d5f468ea1cfe17ed8165bc6913a69cdf3ba51a7c --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/bioEntities/elements/columns=id,bounds,modelId&id=345325&token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +[{"modelId":16729,"bounds":{"x":148.0,"width":80.0,"y":172.0,"height":40.0},"id":345325}] \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/bioEntities/elements/id=345325&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/bioEntities/elements/id=345325&token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..21687ff560fd7b931a36f08a73d3c8121bc85c67 --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/bioEntities/elements/id=345325&token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +[{"elementId":"sa2","symbol":null,"formerSymbols":[],"other":{"structures":{},"structuralState":null,"modifications":[]},"notes":"","references":[],"modelId":16729,"synonyms":[],"fullName":null,"complexId":null,"type":"Protein","abbreviation":null,"compartmentId":null,"name":"x2","bounds":{"x":148.0,"width":80.0,"y":172.0,"height":40.0},"formula":null,"id":345325,"linkedSubmodel":null,"hierarchyVisibilityLevel":"0"}] \ No newline at end of file diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java index 534d8432b41e771f39fd170a54356001aa6cd48d..f7da34ff5dfc2d45ffe2881c0a8e5bd916aeb390 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java @@ -10,6 +10,7 @@ import java.util.Map; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Pair; +import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.ArrowTypeData; import lcsb.mapviewer.model.map.BioEntity; @@ -20,6 +21,7 @@ import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.InvalidColorSchemaException; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.Product; @@ -60,6 +62,8 @@ public class ColorModelCommand extends ModelCommand { */ private ElementUtils eu = new ElementUtils(); + private StringComparator stringComparator = new StringComparator(); + /** * Default constructor. * @@ -125,6 +129,9 @@ public class ColorModelCommand extends ModelCommand { if (schema.getName() != null) { return false; } + if (!modelMatch(reaction.getModelData(), schema)) { + return false; + } if (schema.getReactionIdentifier() != null && schema.getReactionIdentifier().equalsIgnoreCase(reaction.getIdReaction())) { @@ -150,6 +157,19 @@ public class ColorModelCommand extends ModelCommand { return false; } + private boolean modelMatch(ModelData model, ColorSchema schema) { + if (schema.getModelName() != null && !schema.getModelName().isEmpty()) { + if (model == null) { + logger.warn("Model of element is null..."); + return false; + } + if (stringComparator.compare(model.getName(), schema.getModelName()) != 0) { + return false; + } + } + return true; + } + /** * Applies color schema into the {@link Element}. * @@ -181,6 +201,9 @@ public class ColorModelCommand extends ModelCommand { */ protected boolean match(Element element, ColorSchema schema) { if (element instanceof Species) { + if (!modelMatch(element.getModelData(), schema)) { + return false; + } if (schema.getName() != null) { if (!element.getName().equalsIgnoreCase(schema.getName())) { return false; diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java index 6514aa1dc9b1550344228b8dfc1294502bfec864..d523a7c938e27f7168f6e8048cbb3e44e804c92f 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java @@ -362,4 +362,94 @@ public class ColorModelCommandTest extends CommandTestFunctions { } + @Test + public void testReactionColoringWithModelNotMatching() throws Exception { + try { + Model model = getModelForFile("testFiles/reactions_to_color.xml", false); + + ColorSchema schema = new GenericColorSchema(); + schema.setReactionIdentifier("re4"); + schema.setName(null); + schema.setModelName(model.getName() + "XXX"); + + Collection<ColorSchema> schemas = new ArrayList<>(); + schemas.add(schema); + + ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor); + Map<Object, ColorSchema> map = factory.getModifiedElements(); + assertEquals(0, map.values().size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testReactionColoringWithModelMatch() throws Exception { + try { + Model model = getModelForFile("testFiles/reactions_to_color.xml", false); + + ColorSchema schema = new GenericColorSchema(); + schema.setReactionIdentifier("re4"); + schema.setName(null); + schema.setModelName(model.getName()); + + Collection<ColorSchema> schemas = new ArrayList<>(); + schemas.add(schema); + + ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor); + Map<Object, ColorSchema> map = factory.getModifiedElements(); + assertEquals(1, map.values().size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testAliasColoringWithModelNotMatching() throws Exception { + try { + Model model = getModelForFile("testFiles/sample.xml", false); + + ColorSchema schema = new GenericColorSchema(); + schema.setName("CNC"); + schema.setModelName(model.getName() + "XXX"); + + Collection<ColorSchema> schemas = new ArrayList<>(); + schemas.add(schema); + + ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor); + Map<Object, ColorSchema> map = factory.getModifiedElements(); + assertEquals(0, map.values().size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testAliasColoringWithModelMatch() throws Exception { + try { + Model model = getModelForFile("testFiles/sample.xml", false); + + ColorSchema schema = new GenericColorSchema(); + schema.setName("CNC"); + schema.setModelName(model.getName()); + + Collection<ColorSchema> schemas = new ArrayList<>(); + schemas.add(schema); + + ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor); + Map<Object, ColorSchema> map = factory.getModifiedElements(); + assertEquals(1, map.values().size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java index 338903c6008fdb0375480c1a6fff5a42d915a294..7868c90745dee3732ee7dd8a534d7c27741c6855 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java @@ -97,6 +97,14 @@ public enum MiriamType { new String[] { "urn:miriam:cogs" }, // new Class<?>[] { Reaction.class }, "MIR:00000296"), // + /** + * Digital Object Identifier: http://www.doi.org/. + */ + DOI("Digital Object Identifier", // + "http://www.doi.org/", // + new String[] { "urn:miriam:doi" }, // + new Class<?>[] { Reaction.class }, "MIR:00000019"), // + /** * Drugbank database: http://www.drugbank.ca/. */ @@ -105,7 +113,7 @@ public enum MiriamType { new String[] { "urn:miriam:drugbank" }, // new Class<?>[] { Drug.class }, "MIR:00000102"), // /** - * Drugbank tagrets: http://www.drugbank.ca/targets. + * Drugbank targets: http://www.drugbank.ca/targets. */ DRUGBANK_TARGET_V4("DrugBank Target v4", // "http://www.drugbank.ca/targets", // @@ -490,8 +498,8 @@ public enum MiriamType { private List<Class<? extends BioEntity>> validClass = new ArrayList<>(); /** - * When class from this list is marked as "require at least one annotation" - * then annotation of this type is valid. + * When class from this list is marked as "require at least one annotation" then + * annotation of this type is valid. */ private List<Class<? extends BioEntity>> requiredClass = new ArrayList<>(); @@ -530,7 +538,8 @@ public enum MiriamType { * @param requiredClasses * {@link #requiredClasses} */ - MiriamType(String commonName, String dbHomePage, String[] uris, Class<?>[] classes, String registryIdentifier, Class<?>[] requiredClasses) { + MiriamType(String commonName, String dbHomePage, String[] uris, Class<?>[] classes, String registryIdentifier, + Class<?>[] requiredClasses) { this.commonName = commonName; this.dbHomepage = dbHomePage; for (String string : uris) { @@ -652,8 +661,8 @@ public enum MiriamType { * identifier in the format NAME:IDENTIFIER. Where NAME is the name * from {@link MiriamType#commonName} and IDENTIFIER is reasource * identifier. - * @return {@link MiriamData} representing generalIdentifier, when identifier - * is invalid InvalidArgumentException is thrown + * @return {@link MiriamData} representing generalIdentifier, when identifier is + * invalid InvalidArgumentException is thrown */ public static MiriamData getMiriamDataFromIdentifier(String generalIdentifier) { int index = generalIdentifier.indexOf(":"); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/ColorSchema.java b/model/src/main/java/lcsb/mapviewer/model/map/layout/ColorSchema.java index 4b2c13e3e2ee5ed59bbd8ffeff5e72869170bfbb..e4a4b1f2e2e1dcfecfcefd5151066e4b4e7850df 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/ColorSchema.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/layout/ColorSchema.java @@ -8,12 +8,13 @@ import java.util.List; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.species.Element; /** * Entry of coloring schema used for changing colors in the map. It allows to - * identify some elements by use of the filters (by name, type, etcs.) and - * contains information about the color that should be assigned to the fileter + * identify some elements by use of the filters (by name, type, etc.) and + * contains information about the color that should be assigned to the filter * elements. * * @author Piotr Gawron @@ -21,436 +22,449 @@ import lcsb.mapviewer.model.map.species.Element; */ public abstract class ColorSchema implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Name of the {@link Element Element}. If null - * then this field will be skiped. - */ - private String name = null; - - /** - * Identifier of the reaction to change the color. - */ - private String reactionIdentifier = null; - - /** - * Should the direction of highlighted reaction be reversed. - */ - private Boolean reverseReaction = null; - - /** - * Width of the line in the reaction. - */ - private Double lineWidth = null; - - /** - * In which compartments (identified by name) the element can occur. - */ - private List<String> compartments = new ArrayList<String>(); - - /** - * What types of element should be identified by this entry. - */ - private List<Class<? extends Element>> types = new ArrayList<>(); - - /** - * Value (-1..1 range) that is assigned to filtered elements (it will be - * transformed into color later on). Only one of the {@link #value} and - * {@link #color} can be set. - */ - private Double value = null; - - /** - * Color that is assigned to filtered elements. Only one of the {@link #value} - * and {@link #color} can be set. - */ - private Color color = null; - - /** - * General identifier that identifies the element. - */ - private String generalIdentifier = null; - - /** - * List of specific identifiers that filter the elements. - */ - private List<Pair<MiriamType, String>> identifierColumns = new ArrayList<>(); - - /** - * Number of elements matched by this entry. - */ - private int matches = 0; - - /** - * Short description of the entry. - */ - private String description; - - /** - * Default constructor. - */ - protected ColorSchema() { - } - - /** - * Initializes object by copying data from the parameter. - * - * @param original - * original object used for initialization - */ - protected ColorSchema(ColorSchema original) { - this.setName(original.getName()); - this.setReactionIdentifier(original.getReactionIdentifier()); - this.setReverseReaction(original.getReverseReaction()); - this.setLineWidth(original.getLineWidth()); - this.addCompartments(original.getCompartments()); - this.addTypes(original.getTypes()); - this.setValue(original.getValue()); - this.setColor(original.getColor()); - this.setGeneralIdentifier(original.getGeneralIdentifier()); - this.addIdentifierColumns(original.getIdentifierColumns()); - this.setMatches(original.getMatches()); - this.setDescription(original.getDescription()); - } - - /** - * Adds identifiers to {@link #identifierColumns} list. - * - * @param identifierColumnsList - * list of pairs defining type of identifier and the identifier value - */ - public void addIdentifierColumns(List<Pair<MiriamType, String>> identifierColumnsList) { - for (Pair<MiriamType, String> pair : identifierColumnsList) { - addIdentifierColumn(pair); - } - - } - - /** - * Adds class types to {@link #types} list. - * - * @param types2 - * list of classes to add - */ - public void addTypes(List<Class<? extends Element>> types2) { - for (Class<? extends Element> clazz : types2) { - addType(clazz); - } - } - - /** - * Adds compartment names to {@link #compartments} list. - * - * @param compartments2 - * elements to add - */ - public void addCompartments(String[] compartments2) { - for (String string : compartments2) { - compartments.add(string); - } - } - - /** - * Adds compartment names to {@link #compartments} list. - * - * @param compartments2 - * elements to add - */ - public void addCompartments(Collection<String> compartments2) { - for (String string : compartments2) { - compartments.add(string); - } - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(); - result.append("["); - if (name != null) { - result.append(name + ","); - } - if (compartments.size() > 0) { - result.append("("); - for (String comp : compartments) { - result.append(comp + ","); - } - result.append("),"); - } - if (types.size() > 0) { - result.append("("); - for (Class<?> clazz : types) { - result.append(clazz.getSimpleName() + ","); - } - result.append("),"); - } - if (value != null) { - result.append(value + ","); - } - if (color != null) { - result.append(color + ","); - } - if (generalIdentifier != null) { - result.append(generalIdentifier + ","); - } - if (types.size() > 0) { - result.append("("); - for (Pair<MiriamType, String> pair : identifierColumns) { - result.append(pair.getLeft() + "-" + pair.getRight() + ","); - } - result.append("),"); - } - result.append(matches + "]"); - return result.toString(); - } - - /** - * @return the name - * @see #name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - * @see #name - */ - public void setName(String name) { - if (name == null) { - this.name = null; - } else { - this.name = name.trim(); - } - } - - /** - * @return the compartments - * @see #compartments - */ - public List<String> getCompartments() { - return compartments; - } - - /** - * @param compartments - * the compartments to set - * @see #compartments - */ - public void setCompartments(List<String> compartments) { - this.compartments = compartments; - } - - /** - * @return the types - * @see #types - */ - public List<Class<? extends Element>> getTypes() { - return types; - } - - /** - * @param types - * the types to set - * @see #types - */ - public void setTypes(List<Class<? extends Element>> types) { - this.types = types; - } - - /** - * @return the value - * @see #value - */ - public Double getValue() { - return value; - } - - /** - * @param value - * the value to set - * @see #value - */ - public void setValue(Double value) { - this.value = value; - } - - /** - * @return the color - * @see #color - */ - public Color getColor() { - return color; - } - - /** - * @param color - * the color to set - * @see #color - */ - public void setColor(Color color) { - this.color = color; - } - - /** - * @return the generalIdentifier - * @see #generalIdentifier - */ - public String getGeneralIdentifier() { - return generalIdentifier; - } - - /** - * @param generalIdentifier - * the generalIdentifier to set - * @see #generalIdentifier - */ - public void setGeneralIdentifier(String generalIdentifier) { - this.generalIdentifier = generalIdentifier; - } - - /** - * @return the identifierColumns - * @see #identifierColumns - */ - public List<Pair<MiriamType, String>> getIdentifierColumns() { - return identifierColumns; - } - - /** - * @param identifierColumns - * the identifierColumns to set - * @see #identifierColumns - */ - public void setIdentifierColumns(List<Pair<MiriamType, String>> identifierColumns) { - this.identifierColumns = identifierColumns; - } - - /** - * @return the matches - * @see #matches - */ - public int getMatches() { - return matches; - } - - /** - * @param matches - * the matches to set - * @see #matches - */ - public void setMatches(int matches) { - this.matches = matches; - } - - /** - * Adds identifier to {@link #identifierColumns} list. - * - * @param pair - * pair defining type of identifier and the identifier value - */ - public void addIdentifierColumn(Pair<MiriamType, String> pair) { - identifierColumns.add(pair); - - } - - /** - * @return the reactionIdentifier - * @see #reactionIdentifier - */ - public String getReactionIdentifier() { - return reactionIdentifier; - } - - /** - * @param reactionIdentifier - * the reactionIdentifier to set - * @see #reactionIdentifier - */ - public void setReactionIdentifier(String reactionIdentifier) { - this.reactionIdentifier = reactionIdentifier; - } - - /** - * @return the lineWidth - * @see #lineWidth - */ - public Double getLineWidth() { - return lineWidth; - } - - /** - * @param lineWidth - * the lineWidth to set - * @see #lineWidth - */ - public void setLineWidth(Double lineWidth) { - this.lineWidth = lineWidth; - } - - /** - * @return the reverseReaction - * @see #reverseReaction - */ - public Boolean getReverseReaction() { - return reverseReaction; - } - - /** - * @param reverseReaction - * the reverseReaction to set - * @see #reverseReaction - */ - public void setReverseReaction(Boolean reverseReaction) { - this.reverseReaction = reverseReaction; - } - - /** - * Adds compartment name to {@link #compartments}. - * - * @param name - * compartment name - */ - public void addCompartment(String name) { - compartments.add(name); - } - - /** - * Adds class type to {@link #types} list. - * - * @param clazz - * class to add - */ - public void addType(Class<? extends Element> clazz) { - this.types.add(clazz); - } - - /** - * @return the description - * @see #description - */ - public String getDescription() { - return description; - } - - /** - * @param description - * the description to set - * @see #description - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Creates a copy of this object. - * - * @return copy of the object - */ - public abstract ColorSchema copy(); + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Name of the {@link Element Element}. If null then this field will be skipped. + */ + private String name = null; + + /** + * Name of the {@link Model} to which this schema should be limited. If null + * then this field will be skipped. + */ + private String modelName = null; + + /** + * Identifier of the reaction to change the color. + */ + private String reactionIdentifier = null; + + /** + * Should the direction of highlighted reaction be reversed. + */ + private Boolean reverseReaction = null; + + /** + * Width of the line in the reaction. + */ + private Double lineWidth = null; + + /** + * In which compartments (identified by name) the element can occur. + */ + private List<String> compartments = new ArrayList<String>(); + + /** + * What types of element should be identified by this entry. + */ + private List<Class<? extends Element>> types = new ArrayList<>(); + + /** + * Value (-1..1 range) that is assigned to filtered elements (it will be + * transformed into color later on). Only one of the {@link #value} and + * {@link #color} can be set. + */ + private Double value = null; + + /** + * Color that is assigned to filtered elements. Only one of the {@link #value} + * and {@link #color} can be set. + */ + private Color color = null; + + /** + * General identifier that identifies the element. + */ + private String generalIdentifier = null; + + /** + * List of specific identifiers that filter the elements. + */ + private List<Pair<MiriamType, String>> identifierColumns = new ArrayList<>(); + + /** + * Number of elements matched by this entry. + */ + private int matches = 0; + + /** + * Short description of the entry. + */ + private String description; + + /** + * Default constructor. + */ + protected ColorSchema() { + } + + /** + * Initializes object by copying data from the parameter. + * + * @param original + * original object used for initialization + */ + protected ColorSchema(ColorSchema original) { + this.setName(original.getName()); + this.setReactionIdentifier(original.getReactionIdentifier()); + this.setReverseReaction(original.getReverseReaction()); + this.setLineWidth(original.getLineWidth()); + this.addCompartments(original.getCompartments()); + this.addTypes(original.getTypes()); + this.setValue(original.getValue()); + this.setColor(original.getColor()); + this.setGeneralIdentifier(original.getGeneralIdentifier()); + this.addIdentifierColumns(original.getIdentifierColumns()); + this.setMatches(original.getMatches()); + this.setDescription(original.getDescription()); + } + + /** + * Adds identifiers to {@link #identifierColumns} list. + * + * @param identifierColumnsList + * list of pairs defining type of identifier and the identifier value + */ + public void addIdentifierColumns(List<Pair<MiriamType, String>> identifierColumnsList) { + for (Pair<MiriamType, String> pair : identifierColumnsList) { + addIdentifierColumn(pair); + } + + } + + /** + * Adds class types to {@link #types} list. + * + * @param types2 + * list of classes to add + */ + public void addTypes(List<Class<? extends Element>> types2) { + for (Class<? extends Element> clazz : types2) { + addType(clazz); + } + } + + /** + * Adds compartment names to {@link #compartments} list. + * + * @param compartments2 + * elements to add + */ + public void addCompartments(String[] compartments2) { + for (String string : compartments2) { + compartments.add(string); + } + } + + /** + * Adds compartment names to {@link #compartments} list. + * + * @param compartments2 + * elements to add + */ + public void addCompartments(Collection<String> compartments2) { + for (String string : compartments2) { + compartments.add(string); + } + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + result.append("["); + if (name != null) { + result.append(name + ","); + } + if (compartments.size() > 0) { + result.append("("); + for (String comp : compartments) { + result.append(comp + ","); + } + result.append("),"); + } + if (types.size() > 0) { + result.append("("); + for (Class<?> clazz : types) { + result.append(clazz.getSimpleName() + ","); + } + result.append("),"); + } + if (value != null) { + result.append(value + ","); + } + if (color != null) { + result.append(color + ","); + } + if (generalIdentifier != null) { + result.append(generalIdentifier + ","); + } + if (types.size() > 0) { + result.append("("); + for (Pair<MiriamType, String> pair : identifierColumns) { + result.append(pair.getLeft() + "-" + pair.getRight() + ","); + } + result.append("),"); + } + result.append(matches + "]"); + return result.toString(); + } + + /** + * @return the name + * @see #name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + * @see #name + */ + public void setName(String name) { + if (name == null) { + this.name = null; + } else { + this.name = name.trim(); + } + } + + /** + * @return the compartments + * @see #compartments + */ + public List<String> getCompartments() { + return compartments; + } + + /** + * @param compartments + * the compartments to set + * @see #compartments + */ + public void setCompartments(List<String> compartments) { + this.compartments = compartments; + } + + /** + * @return the types + * @see #types + */ + public List<Class<? extends Element>> getTypes() { + return types; + } + + /** + * @param types + * the types to set + * @see #types + */ + public void setTypes(List<Class<? extends Element>> types) { + this.types = types; + } + + /** + * @return the value + * @see #value + */ + public Double getValue() { + return value; + } + + /** + * @param value + * the value to set + * @see #value + */ + public void setValue(Double value) { + this.value = value; + } + + /** + * @return the color + * @see #color + */ + public Color getColor() { + return color; + } + + /** + * @param color + * the color to set + * @see #color + */ + public void setColor(Color color) { + this.color = color; + } + + /** + * @return the generalIdentifier + * @see #generalIdentifier + */ + public String getGeneralIdentifier() { + return generalIdentifier; + } + + /** + * @param generalIdentifier + * the generalIdentifier to set + * @see #generalIdentifier + */ + public void setGeneralIdentifier(String generalIdentifier) { + this.generalIdentifier = generalIdentifier; + } + + /** + * @return the identifierColumns + * @see #identifierColumns + */ + public List<Pair<MiriamType, String>> getIdentifierColumns() { + return identifierColumns; + } + + /** + * @param identifierColumns + * the identifierColumns to set + * @see #identifierColumns + */ + public void setIdentifierColumns(List<Pair<MiriamType, String>> identifierColumns) { + this.identifierColumns = identifierColumns; + } + + /** + * @return the matches + * @see #matches + */ + public int getMatches() { + return matches; + } + + /** + * @param matches + * the matches to set + * @see #matches + */ + public void setMatches(int matches) { + this.matches = matches; + } + + /** + * Adds identifier to {@link #identifierColumns} list. + * + * @param pair + * pair defining type of identifier and the identifier value + */ + public void addIdentifierColumn(Pair<MiriamType, String> pair) { + identifierColumns.add(pair); + + } + + /** + * @return the reactionIdentifier + * @see #reactionIdentifier + */ + public String getReactionIdentifier() { + return reactionIdentifier; + } + + /** + * @param reactionIdentifier + * the reactionIdentifier to set + * @see #reactionIdentifier + */ + public void setReactionIdentifier(String reactionIdentifier) { + this.reactionIdentifier = reactionIdentifier; + } + + /** + * @return the lineWidth + * @see #lineWidth + */ + public Double getLineWidth() { + return lineWidth; + } + + /** + * @param lineWidth + * the lineWidth to set + * @see #lineWidth + */ + public void setLineWidth(Double lineWidth) { + this.lineWidth = lineWidth; + } + + /** + * @return the reverseReaction + * @see #reverseReaction + */ + public Boolean getReverseReaction() { + return reverseReaction; + } + + /** + * @param reverseReaction + * the reverseReaction to set + * @see #reverseReaction + */ + public void setReverseReaction(Boolean reverseReaction) { + this.reverseReaction = reverseReaction; + } + + /** + * Adds compartment name to {@link #compartments}. + * + * @param name + * compartment name + */ + public void addCompartment(String name) { + compartments.add(name); + } + + /** + * Adds class type to {@link #types} list. + * + * @param clazz + * class to add + */ + public void addType(Class<? extends Element> clazz) { + this.types.add(clazz); + } + + /** + * @return the description + * @see #description + */ + public String getDescription() { + return description; + } + + /** + * @param description + * the description to set + * @see #description + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Creates a copy of this object. + * + * @return copy of the object + */ + public abstract ColorSchema copy(); + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/Layout.java b/model/src/main/java/lcsb/mapviewer/model/map/layout/Layout.java index 672b1feca43b0fdcc3d2ceae6e0fd1cf974e6614..acb3b4612a6dce1f24b2671530cd8ec2e95ea777 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/Layout.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/layout/Layout.java @@ -34,7 +34,7 @@ import lcsb.mapviewer.model.user.User; @Entity public class Layout implements Serializable { /** - * + * */ private static final long serialVersionUID = 1L; @@ -143,7 +143,7 @@ public class Layout implements Serializable { /** * Constructor that initializes object with basic parameters. - * + * * @param title * title of the layout * @param directory @@ -159,7 +159,7 @@ public class Layout implements Serializable { /** * Constructor that initializes object with the copy of the data from parameter. - * + * * @param layout * from this object the data will be initialized */ @@ -180,7 +180,7 @@ public class Layout implements Serializable { /** * Prepares a copy of layout. - * + * * @return copy of layout */ public Layout copy() { @@ -398,7 +398,7 @@ public class Layout implements Serializable { /** * When this layout is connected to the top model in complex models then this * method adds layout of a submodel. - * + * * @param layout * layout of a submodel */ @@ -409,7 +409,7 @@ public class Layout implements Serializable { /** * Sets {@link #model}. - * + * * @param model * new {@link #model} value */ diff --git a/persist/src/db/11.0.7/fix_db_20180118.sql b/persist/src/db/11.0.7/fix_db_20180118.sql new file mode 100644 index 0000000000000000000000000000000000000000..a33b6ad89d4881c84fb355b8c56d309760e66b70 --- /dev/null +++ b/persist/src/db/11.0.7/fix_db_20180118.sql @@ -0,0 +1 @@ +-- empty file to force directory to be commited to git repo diff --git a/persist/src/main/java/lcsb/mapviewer/persist/dao/BaseDao.java b/persist/src/main/java/lcsb/mapviewer/persist/dao/BaseDao.java index 02afc0199a9e39022bc90935372407560d5c4b3b..c6b2da557941c4337a9178d4a4da31b5c2177218 100644 --- a/persist/src/main/java/lcsb/mapviewer/persist/dao/BaseDao.java +++ b/persist/src/main/java/lcsb/mapviewer/persist/dao/BaseDao.java @@ -3,11 +3,13 @@ package lcsb.mapviewer.persist.dao; import java.util.List; import org.apache.log4j.Logger; +import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; +import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.persist.DbUtils; /** @@ -21,273 +23,302 @@ import lcsb.mapviewer.persist.DbUtils; */ public abstract class BaseDao<T> { - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(BaseDao.class); + /** + * Default class logger. + */ + private static Logger logger = Logger.getLogger(BaseDao.class); - /** - * Sometimes objects have a flag that indicate that the object was removed - * from the system (but is still there because of foreign keys etc). This - * column determines the name of the column. If its set to null then such - * column doesn't exist. - */ - private String removableColumn = null; + /** + * Sometimes objects have a flag that indicate that the object was removed from + * the system (but is still there because of foreign keys etc). This column + * determines the name of the column. If its set to null then such column + * doesn't exist. + */ + private String removableColumn = null; - /** - * Class of the object that DAO works on. - */ - private Class<? extends T> clazz; + /** + * Class of the object that DAO works on. + */ + private Class<? extends T> clazz; - /** - * Default constructor. - * - * @param theClass - * class of the object that DAO will work on - */ - public BaseDao(Class<? extends T> theClass) { - this.clazz = theClass; - } + /** + * Default constructor. + * + * @param theClass + * class of the object that DAO will work on + */ + public BaseDao(Class<? extends T> theClass) { + this.clazz = theClass; + } - /** - * Default constructor. - * - * @param theClass - * class of the object that DAO will work on - * @param removableColumn - * determines the column in the object table that indicates if object - * should be considered as removed or not (see also: - * {@link #removableColumn}. - * - */ - public BaseDao(Class<? extends T> theClass, String removableColumn) { - this(theClass); - this.removableColumn = removableColumn; - } + /** + * Default constructor. + * + * @param theClass + * class of the object that DAO will work on + * @param removableColumn + * determines the column in the object table that indicates if object + * should be considered as removed or not (see also: + * {@link #removableColumn}. + * + */ + public BaseDao(Class<? extends T> theClass, String removableColumn) { + this(theClass); + this.removableColumn = removableColumn; + } - /** - * Utils that help to manage the sessions in custom multithreaded - * implementation. - */ - @Autowired - private DbUtils dbUtils; + /** + * Utils that help to manage the sessions in custom multithreaded + * implementation. + */ + @Autowired + private DbUtils dbUtils; - /** - * Adds object to the database. - * - * @param object - * object to add to database - */ - public void add(T object) { - getSession().save(object); - if (dbUtils.isAutoFlush()) { - getSession().flush(); - } - } + /** + * Adds object to the database. + * + * @param object + * object to add to database + */ + public void add(T object) { + getSession().save(object); + if (dbUtils.isAutoFlush()) { + getSession().flush(); + } + } - /** - * Flush connection with database. - */ - public void flush() { - getSession().flush(); - } + /** + * Flush connection with database. + */ + public void flush() { + getSession().flush(); + } - /** - * Commit current transaction. - */ - public void commit() { - if (!dbUtils.isCustomSessionForCurrentThread()) { - logger.warn("Manual commit with spring managed session!", new Exception()); - } + /** + * Commit current transaction. + */ + public void commit() { + if (!dbUtils.isCustomSessionForCurrentThread()) { + logger.warn("Manual commit with spring managed session!", new Exception()); + } - getSession().getTransaction().commit(); - getSession().beginTransaction(); - } + getSession().getTransaction().commit(); + getSession().beginTransaction(); + } - /** - * Returns current session. - * - * @return session for current thread - */ - protected Session getSession() { - return dbUtils.getSessionForCurrentThread(); - } + /** + * Returns current session. + * + * @return session for current thread + */ + protected Session getSession() { + return dbUtils.getSessionForCurrentThread(); + } - /** - * Update object in the database. - * - * @param object - * object to be updated - */ - public void update(T object) { - getSession().update(object); - if (dbUtils.isAutoFlush()) { - getSession().flush(); - } - } + /** + * Update object in the database. + * + * @param object + * object to be updated + */ + public void update(T object) { + getSession().update(object); + if (dbUtils.isAutoFlush()) { + getSession().flush(); + } + } - /** - * Removes object from the database. - * - * @param object - * object to be removed from database - */ - public void delete(T object) { - getSession().delete(object); - if (dbUtils.isAutoFlush()) { - getSession().flush(); - } - } + /** + * Removes object from the database. + * + * @param object + * object to be removed from database + */ + public void delete(T object) { + getSession().delete(object); + if (dbUtils.isAutoFlush()) { + getSession().flush(); + } + } - /** - * "Disconnects" object with the element in database. From this point on we - * cannot update/delete it in the database. - * - * @param object - * object that should be evicted - */ - public void evict(T object) { - getSession().evict(object); - if (dbUtils.isAutoFlush()) { - getSession().flush(); - } - } + /** + * "Disconnects" object with the element in database. From this point on we + * cannot update/delete it in the database. + * + * @param object + * object that should be evicted + */ + public void evict(T object) { + getSession().evict(object); + if (dbUtils.isAutoFlush()) { + getSession().flush(); + } + } - /** - * Returns number of elements in the table for this object. - * - * @return number of all elements in database - */ - public long getCount() { - if (removableColumn == null) { - return (Long) getSession().createCriteria(this.clazz).setProjection(Projections.rowCount()).uniqueResult(); - } else { - return (Long) getSession().createCriteria(this.clazz).add(Restrictions.eq(removableColumn, false)).setProjection(Projections.rowCount()).uniqueResult(); - } - } + /** + * Returns number of elements in the table for this object. + * + * @return number of all elements in database + */ + public long getCount() { + if (removableColumn == null) { + return (Long) getSession().createCriteria(this.clazz).setProjection(Projections.rowCount()).uniqueResult(); + } else { + return (Long) getSession().createCriteria(this.clazz).add(Restrictions.eq(removableColumn, false)) + .setProjection(Projections.rowCount()).uniqueResult(); + } + } - /** - * Returns an element that has a key parameter equal to value. If there is - * more than one element than one of them will be returned. If there is no - * such element then <code>null</code> is returned. - * - * @param key - * which parameter will filter the data - * @param value - * what must be the value of parameter key - * @return element that fulfill T.key=value criteria - */ - @SuppressWarnings("unchecked") - protected T getByParameter(String key, Object value) { - List<?> list = getSession() - .createQuery(" from " + this.clazz.getSimpleName() + " where " + key + " = :param_val " + removableAndStatemant()).setParameter("param_val", value) - .list(); - if (list.size() == 0) { - return null; - } else { - return (T) list.get(0); - } - } + /** + * Returns an element that has a key parameter equal to value. If there is more + * than one element than one of them will be returned. If there is no such + * element then <code>null</code> is returned. + * + * @param key + * which parameter will filter the data + * @param value + * what must be the value of parameter key + * @return element that fulfill T.key=value criteria + */ + @SuppressWarnings("unchecked") + protected T getByParameter(String key, Object value) { + List<?> list = getSession() + .createQuery( + " from " + this.clazz.getSimpleName() + " where " + key + " = :param_val " + removableAndStatemant()) + .setParameter("param_val", value).list(); + if (list.size() == 0) { + return null; + } else { + return (T) list.get(0); + } + } - /** - * Returns the list of elements that havae a key parameter equal to value. - * - * @param key - * which parameter will filter the data - * @param value - * what must be the value of parameter key - * @return list of elements that fulfill T.key=value criteria - */ - @SuppressWarnings("unchecked") - protected List<T> getElementsByParameter(String key, Object value) { - List<?> list = getSession() - .createQuery(" from " + this.clazz.getSimpleName() + " where " + key + " = :param_val " + removableAndStatemant()).setParameter("param_val", value) - .list(); - return (List<T>) list; - } + /** + * Returns the list of elements that have a key parameter equal to value. + * + * @param key + * which parameter will filter the data + * @param value + * what must be the value of parameter key + * @return list of elements that fulfill T.key=value criteria + */ + @SuppressWarnings("unchecked") + protected List<T> getElementsByParameter(String key, Object value) { + List<?> list = getSession() + .createQuery( + " from " + this.clazz.getSimpleName() + " where " + key + " = :param_val " + removableAndStatemant()) + .setParameter("param_val", value).list(); + return (List<T>) list; + } - /** - * Returns element with the id given as parameter. - * - * @param id - * database identifier - * @return object width identifier given as parameter - */ - @SuppressWarnings("unchecked") - public T getById(int id) { - List<?> list = getSession().createQuery(" from " + this.clazz.getSimpleName() + " where id=? " + removableAndStatemant()).setParameter(0, id).list(); - if (list.size() == 0) { - return null; - } else { - return (T) list.get(0); - } - } + @SuppressWarnings("unchecked") + protected List<T> getElementsByParameters(List<Pair<String, Object>> params) { + String queryString = " from " + this.clazz.getSimpleName() + " where "; + boolean firstParam = true; + for (Pair<String, Object> param : params) { + String key = param.getLeft(); + if (!firstParam) { + queryString += " AND "; + } + queryString += key + " = :param_val_" + key + " "; - /** - * Returns list of all object in db. - * - * @return list of all object in db - */ - @SuppressWarnings("unchecked") - public List<T> getAll() { - List<?> list = getSession().createQuery(" from " + this.clazz.getSimpleName() + " " + removableStatemant()).list(); - return (List<T>) list; - } + firstParam = false; + } + queryString += removableAndStatemant(); + Query query = getSession().createQuery(queryString); + for (Pair<String, Object> param : params) { + String key = param.getLeft(); + Object value = param.getRight(); + query = query.setParameter("param_val_" + key, value); + } + List<?> list = query.list(); + return (List<T>) list; + } - /** - * Removes all elements from the database. - */ - public void clearTable() { - String stringQuery = "DELETE FROM " + this.clazz.getSimpleName(); - getSession().createQuery(stringQuery).executeUpdate(); - if (dbUtils.isAutoFlush()) { - getSession().flush(); - } - } + /** + * Returns element with the id given as parameter. + * + * @param id + * database identifier + * @return object width identifier given as parameter + */ + @SuppressWarnings("unchecked") + public T getById(int id) { + List<?> list = getSession() + .createQuery(" from " + this.clazz.getSimpleName() + " where id=? " + removableAndStatemant()) + .setParameter(0, id).list(); + if (list.size() == 0) { + return null; + } else { + return (T) list.get(0); + } + } - /** - * Refresh object with the new data taken from database. - * - * @param object - * object to be refreshed - */ - public void refresh(Object object) { - getSession().refresh(object); - } + /** + * Returns list of all object in db. + * + * @return list of all object in db + */ + @SuppressWarnings("unchecked") + public List<T> getAll() { + List<?> list = getSession().createQuery(" from " + this.clazz.getSimpleName() + " " + removableStatemant()).list(); + return (List<T>) list; + } - /** - * @return the clazz - */ - protected Class<? extends T> getClazz() { - return clazz; - } + /** + * Removes all elements from the database. + */ + public void clearTable() { + String stringQuery = "DELETE FROM " + this.clazz.getSimpleName(); + getSession().createQuery(stringQuery).executeUpdate(); + if (dbUtils.isAutoFlush()) { + getSession().flush(); + } + } - /** - * Returns part of HQL statement responsible for {@link #removableColumn}. - * - * @return part of HQL statement responsible for {@link #removableColumn}. - */ - protected String removableAndStatemant() { - if (removableColumn == null) { - return ""; - } else { - return " AND " + removableColumn + " = false "; - } - } + /** + * Refresh object with the new data taken from database. + * + * @param object + * object to be refreshed + */ + public void refresh(Object object) { + getSession().refresh(object); + } - /** - * Returns part of HQL statement responsible for {@link #removableColumn} - * (without sql AND). - * - * @return part of HQL statement responsible for {@link #removableColumn} - * (without sql AND). - */ - protected String removableStatemant() { - if (removableColumn == null) { - return ""; - } else { - return " WHERE " + removableColumn + " = false "; - } - } + /** + * @return the clazz + */ + protected Class<? extends T> getClazz() { + return clazz; + } + + /** + * Returns part of HQL statement responsible for {@link #removableColumn}. + * + * @return part of HQL statement responsible for {@link #removableColumn}. + */ + protected String removableAndStatemant() { + if (removableColumn == null) { + return ""; + } else { + return " AND " + removableColumn + " = false "; + } + } + + /** + * Returns part of HQL statement responsible for {@link #removableColumn} + * (without sql AND). + * + * @return part of HQL statement responsible for {@link #removableColumn} + * (without sql AND). + */ + protected String removableStatemant() { + if (removableColumn == null) { + return ""; + } else { + return " WHERE " + removableColumn + " = false "; + } + } } diff --git a/persist/src/main/java/lcsb/mapviewer/persist/dao/map/LayoutDao.java b/persist/src/main/java/lcsb/mapviewer/persist/dao/map/LayoutDao.java index 11fb912fdff420b04c871a2f3979c9c9a3742a6a..e464248cdda8d07df887438b05d64d76336474f2 100644 --- a/persist/src/main/java/lcsb/mapviewer/persist/dao/map/LayoutDao.java +++ b/persist/src/main/java/lcsb/mapviewer/persist/dao/map/LayoutDao.java @@ -1,86 +1,101 @@ -package lcsb.mapviewer.persist.dao.map; - -import java.util.List; - -import org.apache.log4j.Logger; -import org.hibernate.Criteria; -import org.hibernate.criterion.Projections; -import org.hibernate.criterion.Restrictions; - -import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.user.User; -import lcsb.mapviewer.persist.dao.BaseDao; - -/** - * Data access object for {@link Layout} class. - * - * @author Piotr Gawron - * - */ -public class LayoutDao extends BaseDao<Layout> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(LayoutDao.class); - - /** - * Default constructor. - */ - public LayoutDao() { - super(Layout.class); - } - - /** - * Lists layouts for the model. - * - * @param model - * for this model layouts will be listed - * @return list of layouts for the model - */ - public List<Layout> getLayoutsByModel(Model model) { - List<Layout> layouts = getElementsByParameter("model_iddb", model.getId()); - for (Layout layout : layouts) { - refresh(layout); - } - return layouts; - } - - /** - * Return number of layouts created by the user. - * - * @param user - * the user - * @return number of layouts created by the user - */ - public long getCountByUser(User user) { - Criteria crit = getSession().createCriteria(this.getClazz()); - crit.setProjection(Projections.rowCount()); - crit.add(Restrictions.eq("creator", user)); - crit.createAlias("model", "m"); - crit.add(Restrictions.sizeLe("m.parentModels", 0)); - return (Long) crit.uniqueResult(); - } - - /** - * Returns layout identified by name and model. - * - * @param model - * model where the layouts lay on - * @param name - * name of the layout - * @return layout - */ - public Layout getLayoutByName(Model model, String name) { - List<Layout> layouts = getElementsByParameter("model_iddb", model.getId()); - for (Layout layout : layouts) { - refresh(layout); - if (layout.getTitle().equals(name)) { - return layout; - } - } - return null; - } -} +package lcsb.mapviewer.persist.dao.map; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.hibernate.Criteria; +import org.hibernate.criterion.Projections; +import org.hibernate.criterion.Restrictions; + +import lcsb.mapviewer.common.Pair; +import lcsb.mapviewer.model.map.layout.Layout; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.user.User; +import lcsb.mapviewer.persist.dao.BaseDao; + +/** + * Data access object for {@link Layout} class. + * + * @author Piotr Gawron + * + */ +public class LayoutDao extends BaseDao<Layout> { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(LayoutDao.class); + + /** + * Default constructor. + */ + public LayoutDao() { + super(Layout.class); + } + + /** + * Lists layouts for the model. + * + * @param model + * for this model layouts will be listed + * @return list of layouts for the model + */ + public List<Layout> getLayoutsByModel(Model model) { + List<Layout> layouts = getElementsByParameter("model_iddb", model.getId()); + for (Layout layout : layouts) { + refresh(layout); + } + return layouts; + } + + public List<Layout> getLayoutsByModel(Model model, User creator, Boolean isPublic) { + List<Pair<String, Object>> params = new ArrayList<>(); + params.add(new Pair<String, Object>("model_iddb", model.getId())); + if (isPublic != null) { + params.add(new Pair<String, Object>("publicLayout", isPublic)); + } + if (creator != null) { + params.add(new Pair<String, Object>("creator_iddb", creator.getId())); + } + List<Layout> layouts = getElementsByParameters(params); + return layouts; + } + + /** + * Return number of layouts created by the user. + * + * @param user + * the user + * @return number of layouts created by the user + */ + public long getCountByUser(User user) { + Criteria crit = getSession().createCriteria(this.getClazz()); + crit.setProjection(Projections.rowCount()); + crit.add(Restrictions.eq("creator", user)); + crit.createAlias("model", "m"); + crit.add(Restrictions.sizeLe("m.parentModels", 0)); + return (Long) crit.uniqueResult(); + } + + /** + * Returns layout identified by name and model. + * + * @param model + * model where the layouts lay on + * @param name + * name of the layout + * @return layout + */ + public Layout getLayoutByName(Model model, String name) { + List<Layout> layouts = getElementsByParameter("model_iddb", model.getId()); + for (Layout layout : layouts) { + refresh(layout); + if (layout.getTitle().equals(name)) { + return layout; + } + } + return null; + } +} diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java index ddc1e5f3bcd551a012a6e360d367029ab974f488..3e56dd04c2c760331cb683e5a3cbb1cb0bb3ad9a 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java @@ -107,7 +107,7 @@ public class LayoutService implements ILayoutService { /** * Service used to access logs. - * + * * @see ILogService */ @Autowired @@ -172,30 +172,14 @@ public class LayoutService implements ILayoutService { @Override public List<LayoutView> getCustomLayouts(Model model, User user, Boolean publicOverlay, User creator) { + // TODO remove publicOverlay and creator params List<LayoutView> result = new ArrayList<>(); if (model == null || user == null) { return result; } - List<Layout> layouts = layoutDao.getLayoutsByModel(model); + List<Layout> layouts = layoutDao.getLayoutsByModel(model, user, false); for (Layout layout : layouts) { - boolean toAdd = true; - if (creator != null) { - if (layout.getCreator() == null) { - toAdd = false; - } else if (!layout.getCreator().getId().equals(creator.getId())) { - toAdd = false; - } - } - if (publicOverlay != null) { - if (!publicOverlay.equals(layout.isPublicLayout())) { - toAdd = false; - } - } - if (toAdd) { - if (userCanViewOverlay(layout, user)) { - result.add(layoutViewFactory.create(layout)); - } - } + result.add(layoutViewFactory.create(layout)); } Collections.sort(result, LayoutView.ID_COMPARATOR); return result; @@ -648,7 +632,7 @@ public class LayoutService implements ILayoutService { /** * Sends notification email that layout was removed. - * + * * @param projectId * identifier of the project * @param layoutName @@ -667,7 +651,7 @@ public class LayoutService implements ILayoutService { /** * Sends notification email that layout was generated. - * + * * @param params * list of {@link CreateLayoutParams params} used for layout creation * @param schemas @@ -706,7 +690,7 @@ public class LayoutService implements ILayoutService { /** * Prepares table with statistics about coloring. - * + * * @param schemas * schemas that were used for coloring * @param scr @@ -738,7 +722,7 @@ public class LayoutService implements ILayoutService { * {@link ColorSchema} sometimes contains merged value from few rows. This * method split single {@link ColorSchema} object to simple flat objects that * can be serialiazed in a simple tab separated file. - * + * * @param originalSchema * original {@link ColorSchema} objcet that we want to spli into flat * objects @@ -763,7 +747,7 @@ public class LayoutService implements ILayoutService { /** * Prepares tab separated {@link String} represenation of {@link ColorSchema}. - * + * * @param columns * columns that should be outputed in the result String * @param schema @@ -791,7 +775,7 @@ public class LayoutService implements ILayoutService { /** * Returns String representing data of {@link GenericColorSchema} that should * appear in a given {@link ColorSchemaColumn}. - * + * * @param schema * object for which data will be returned * @param column @@ -808,6 +792,8 @@ public class LayoutService implements ILayoutService { sb.append("\t"); } else if (column.equals(ColorSchemaColumn.NAME)) { sb.append(schema.getName() + "\t"); + } else if (column.equals(ColorSchemaColumn.MODEL_NAME)) { + sb.append(schema.getModelName() + "\t"); } else if (column.equals(ColorSchemaColumn.VALUE)) { sb.append(schema.getValue() + "\t"); } else if (column.equals(ColorSchemaColumn.COMPARTMENT)) { @@ -846,7 +832,7 @@ public class LayoutService implements ILayoutService { /** * Returns String representing data of {@link GeneVariationColorSchema} that * should appear in a given {@link ColorSchemaColumn}. - * + * * @param schema * object for which data will be returned * @param column @@ -863,6 +849,8 @@ public class LayoutService implements ILayoutService { sb.append("\t"); } else if (column.equals(ColorSchemaColumn.NAME)) { sb.append(schema.getName() + "\t"); + } else if (column.equals(ColorSchemaColumn.MODEL_NAME)) { + sb.append(schema.getModelName() + "\t"); } else if (column.equals(ColorSchemaColumn.VALUE)) { sb.append(schema.getValue() + "\t"); } else if (column.equals(ColorSchemaColumn.COMPARTMENT)) { @@ -921,7 +909,7 @@ public class LayoutService implements ILayoutService { /** * Returns byte array containing data from original input file that was used to * generate the layout. - * + * * @param layoutId * identifier of layout for which we want to retrieve original file * data diff --git a/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java b/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java index 2f358661b267053ed1a0db66055ad48d1d5e005c..0176a0da7e7e1832c80d4e7c0c93cde974ef9066 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java @@ -157,6 +157,7 @@ public class ColorSchemaReader { Integer colorColumn = schemaColumns.get(ColorSchemaColumn.COLOR); Integer contigColumn = schemaColumns.get(ColorSchemaColumn.CONTIG); Integer nameColumn = schemaColumns.get(ColorSchemaColumn.NAME); + Integer modelNameColumn = schemaColumns.get(ColorSchemaColumn.MODEL_NAME); Integer identifierColumn = schemaColumns.get(ColorSchemaColumn.IDENTIFIER); Integer variantIdentifierColumn = schemaColumns.get(ColorSchemaColumn.VARIANT_IDENTIFIER); Integer allelFrequencyColumn = schemaColumns.get(ColorSchemaColumn.ALLEL_FREQUENCY); @@ -202,6 +203,9 @@ public class ColorSchemaReader { if (nameColumn != null) { processNameColumn(schema, values[nameColumn]); } + if (modelNameColumn != null) { + processModelNameColumn(schema, values[modelNameColumn]); + } if (compartmentColumn != null) { processCompartmentColumn(schema, values[compartmentColumn]); } @@ -328,6 +332,12 @@ public class ColorSchemaReader { schema.setName(content); } } + private void processModelNameColumn(ColorSchema schema, String content) { + if (!content.isEmpty()) { + schema.setModelName(content); + } + } + /** * Sets proper compartment names to {@link ColorSchema} from cell content. @@ -463,6 +473,7 @@ public class ColorSchemaReader { Integer valueColumn = schemaColumns.get(ColorSchemaColumn.VALUE); Integer colorColumn = schemaColumns.get(ColorSchemaColumn.COLOR); Integer nameColumn = schemaColumns.get(ColorSchemaColumn.NAME); + Integer modelNameColumn = schemaColumns.get(ColorSchemaColumn.MODEL_NAME); Integer identifierColumn = schemaColumns.get(ColorSchemaColumn.IDENTIFIER); Integer reactionIdentifierColumn = schemaColumns.get(ColorSchemaColumn.REACTION_IDENTIFIER); Integer compartmentColumn = schemaColumns.get(ColorSchemaColumn.COMPARTMENT); @@ -499,6 +510,9 @@ public class ColorSchemaReader { if (nameColumn != null) { processNameColumn(schema, values[nameColumn]); } + if (modelNameColumn != null) { + processModelNameColumn(schema, values[modelNameColumn]); + } if (valueColumn != null) { schema.setValue(parseValueColumn(values[valueColumn], errorPrefix)); } @@ -729,6 +743,9 @@ public class ColorSchemaReader { if (schema.getName() != null) { result.add(ColorSchemaColumn.NAME); } + if (schema.getModelName() != null) { + result.add(ColorSchemaColumn.MODEL_NAME); + } if (schema.getReactionIdentifier() != null) { result.add(ColorSchemaColumn.REACTION_IDENTIFIER); } diff --git a/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaXlsxReader.java b/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaXlsxReader.java index f852f697bcb65ecf669503a0bd3a3022d3010e0a..be39f1a333b1a6a9ec4e9834831ebf26574d978c 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaXlsxReader.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaXlsxReader.java @@ -41,285 +41,302 @@ import lcsb.mapviewer.services.utils.data.ColorSchemaColumn; * */ public class ColorSchemaXlsxReader { - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private Logger logger = Logger.getLogger(ColorSchemaXlsxReader.class); + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private Logger logger = Logger.getLogger(ColorSchemaXlsxReader.class); - /** - * @param fileName - * file name - * @param sheetName - * sheet name. - * @return list of ColorSchema. - * @throws IOException - * exception related to opening the input stream. - * @throws InvalidColorSchemaException - * invalid color schema exception. - */ - public Collection<ColorSchema> readColorSchema(String fileName, String sheetName) throws IOException, InvalidColorSchemaException { - ColorParser colorParser = new ColorParser(); - List<ColorSchema> result = new ArrayList<>(); - FileInputStream file = null; - Workbook workbook = null; + /** + * @param fileName + * file name + * @param sheetName + * sheet name. + * @return list of ColorSchema. + * @throws IOException + * exception related to opening the input stream. + * @throws InvalidColorSchemaException + * invalid color schema exception. + */ + public Collection<ColorSchema> readColorSchema(String fileName, String sheetName) + throws IOException, InvalidColorSchemaException { + ColorParser colorParser = new ColorParser(); + List<ColorSchema> result = new ArrayList<>(); + FileInputStream file = null; + Workbook workbook = null; - try { - file = new FileInputStream(fileName); - // Using XSSF for xlsx format, for xls use HSSF - // <-Interface, accepts both HSSF and XSSF. - if (FilenameUtils.getExtension(fileName).equalsIgnoreCase("xls")) { - workbook = new HSSFWorkbook(file); - } else if (FilenameUtils.getExtension(fileName).equalsIgnoreCase("xlsx")) { - workbook = new XSSFWorkbook(file); - } else { - throw new IllegalArgumentException("Received file does not have a standard excel extension."); - } - Sheet sheet = null; - if (sheetName == null) { - sheet = workbook.getSheetAt(0); - } else { - sheet = workbook.getSheet(sheetName); - } - DataFormat fmt = workbook.createDataFormat(); - CellStyle textStyle = workbook.createCellStyle(); - textStyle.setDataFormat(fmt.getFormat("@")); + try { + file = new FileInputStream(fileName); + // Using XSSF for xlsx format, for xls use HSSF + // <-Interface, accepts both HSSF and XSSF. + if (FilenameUtils.getExtension(fileName).equalsIgnoreCase("xls")) { + workbook = new HSSFWorkbook(file); + } else if (FilenameUtils.getExtension(fileName).equalsIgnoreCase("xlsx")) { + workbook = new XSSFWorkbook(file); + } else { + throw new IllegalArgumentException("Received file does not have a standard excel extension."); + } + Sheet sheet = null; + if (sheetName == null) { + sheet = workbook.getSheetAt(0); + } else { + sheet = workbook.getSheet(sheetName); + } + DataFormat fmt = workbook.createDataFormat(); + CellStyle textStyle = workbook.createCellStyle(); + textStyle.setDataFormat(fmt.getFormat("@")); - Iterator<Row> rowIterator = sheet.iterator(); - Integer valueColumn = null; - Integer colorColumn = null; - Integer nameColumn = null; - Integer identifierColumn = null; - Integer reactionIdentifierColumn = null; - Integer compartmentColumn = null; - Integer typeColumn = null; - Integer lineWidthColumn = null; - Integer reverseReactionColumn = null; - List<Pair<MiriamType, Integer>> foundCustomIdentifiers = new ArrayList<Pair<MiriamType, Integer>>(); - int lineIndex = 0; - Map<ColorSchemaColumn, Integer> foundSchemaColumns = new HashMap<ColorSchemaColumn, Integer>(); - while (rowIterator.hasNext()) { - Row row = rowIterator.next(); - Cell cell = row.getCell(0, Row.RETURN_BLANK_AS_NULL); - if (cell == null) { - continue; - } else { - cell.setCellType(Cell.CELL_TYPE_STRING); - if (cell.getStringCellValue().startsWith("#")) { - continue; - } - } - lineIndex++; - if (lineIndex == 1) { + Iterator<Row> rowIterator = sheet.iterator(); + Integer valueColumn = null; + Integer colorColumn = null; + Integer nameColumn = null; + Integer modelNameColumn = null; + Integer identifierColumn = null; + Integer reactionIdentifierColumn = null; + Integer compartmentColumn = null; + Integer typeColumn = null; + Integer lineWidthColumn = null; + Integer reverseReactionColumn = null; + List<Pair<MiriamType, Integer>> foundCustomIdentifiers = new ArrayList<Pair<MiriamType, Integer>>(); + int lineIndex = 0; + Map<ColorSchemaColumn, Integer> foundSchemaColumns = new HashMap<ColorSchemaColumn, Integer>(); + while (rowIterator.hasNext()) { + Row row = rowIterator.next(); + Cell cell = row.getCell(0, Row.RETURN_BLANK_AS_NULL); + if (cell == null) { + continue; + } else { + cell.setCellType(Cell.CELL_TYPE_STRING); + if (cell.getStringCellValue().startsWith("#")) { + continue; + } + } + lineIndex++; + if (lineIndex == 1) { - Map<String, MiriamType> acceptableIdentifiers = new HashMap<String, MiriamType>(); - for (MiriamType type : MiriamType.values()) { - acceptableIdentifiers.put(type.getCommonName().toLowerCase(), type); - } + Map<String, MiriamType> acceptableIdentifiers = new HashMap<String, MiriamType>(); + for (MiriamType type : MiriamType.values()) { + acceptableIdentifiers.put(type.getCommonName().toLowerCase(), type); + } - Iterator<Cell> cellIterator = row.cellIterator(); - int columnIndex = 0; - while (cellIterator.hasNext()) { - columnIndex++; - sheet.setDefaultColumnStyle(columnIndex, textStyle); - cell = cellIterator.next(); - cell.setCellType(Cell.CELL_TYPE_STRING); - String value = cell.getStringCellValue(); - boolean found = false; - for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { - if (value.trim().equalsIgnoreCase(schemaColumn.getTitle())) { - foundSchemaColumns.put(schemaColumn, columnIndex - 1); - found = true; - break; - } - } - if (!found) { - if (acceptableIdentifiers.keySet().contains(value.toLowerCase())) { - foundCustomIdentifiers.add(new Pair<MiriamType, Integer>(acceptableIdentifiers.get(value.toLowerCase()), columnIndex - 1)); - } else { - String columnNames = ""; - for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { - columnNames += schemaColumn.getTitle() + ", "; - } - for (String string : acceptableIdentifiers.keySet()) { - columnNames += ", " + string; - } - throw new InvalidColorSchemaException("Unknown column type: " + value + ". Acceptable column name: " + columnNames); - } - } - } - valueColumn = foundSchemaColumns.get(ColorSchemaColumn.VALUE); - colorColumn = foundSchemaColumns.get(ColorSchemaColumn.COLOR); - nameColumn = foundSchemaColumns.get(ColorSchemaColumn.NAME); - identifierColumn = foundSchemaColumns.get(ColorSchemaColumn.IDENTIFIER); - reactionIdentifierColumn = foundSchemaColumns.get(ColorSchemaColumn.REACTION_IDENTIFIER); - compartmentColumn = foundSchemaColumns.get(ColorSchemaColumn.COMPARTMENT); - typeColumn = foundSchemaColumns.get(ColorSchemaColumn.TYPE); - lineWidthColumn = foundSchemaColumns.get(ColorSchemaColumn.LINE_WIDTH); - reverseReactionColumn = foundSchemaColumns.get(ColorSchemaColumn.REVERSE_REACTION); + Iterator<Cell> cellIterator = row.cellIterator(); + int columnIndex = 0; + while (cellIterator.hasNext()) { + columnIndex++; + sheet.setDefaultColumnStyle(columnIndex, textStyle); + cell = cellIterator.next(); + cell.setCellType(Cell.CELL_TYPE_STRING); + String value = cell.getStringCellValue(); + boolean found = false; + for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { + if (value.trim().equalsIgnoreCase(schemaColumn.getTitle())) { + foundSchemaColumns.put(schemaColumn, columnIndex - 1); + found = true; + break; + } + } + if (!found) { + if (acceptableIdentifiers.keySet().contains(value.toLowerCase())) { + foundCustomIdentifiers.add( + new Pair<MiriamType, Integer>(acceptableIdentifiers.get(value.toLowerCase()), columnIndex - 1)); + } else { + String columnNames = ""; + for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { + columnNames += schemaColumn.getTitle() + ", "; + } + for (String string : acceptableIdentifiers.keySet()) { + columnNames += ", " + string; + } + throw new InvalidColorSchemaException( + "Unknown column type: " + value + ". Acceptable column name: " + columnNames); + } + } + } + valueColumn = foundSchemaColumns.get(ColorSchemaColumn.VALUE); + colorColumn = foundSchemaColumns.get(ColorSchemaColumn.COLOR); + nameColumn = foundSchemaColumns.get(ColorSchemaColumn.NAME); + modelNameColumn = foundSchemaColumns.get(ColorSchemaColumn.MODEL_NAME); + identifierColumn = foundSchemaColumns.get(ColorSchemaColumn.IDENTIFIER); + reactionIdentifierColumn = foundSchemaColumns.get(ColorSchemaColumn.REACTION_IDENTIFIER); + compartmentColumn = foundSchemaColumns.get(ColorSchemaColumn.COMPARTMENT); + typeColumn = foundSchemaColumns.get(ColorSchemaColumn.TYPE); + lineWidthColumn = foundSchemaColumns.get(ColorSchemaColumn.LINE_WIDTH); + reverseReactionColumn = foundSchemaColumns.get(ColorSchemaColumn.REVERSE_REACTION); - if (valueColumn != null && colorColumn != null) { - throw new InvalidColorSchemaException("Schema can contain only one of these two columns: "); - } + if (valueColumn != null && colorColumn != null) { + throw new InvalidColorSchemaException("Schema can contain only one of these two columns: "); + } - if (nameColumn == null && identifierColumn == null && foundCustomIdentifiers.size() == 0 && reactionIdentifierColumn == null) { - throw new InvalidColorSchemaException("One of these columns is obligatory: name, identifier, reactionIdentifier"); - } + if (nameColumn == null && identifierColumn == null && foundCustomIdentifiers.size() == 0 + && reactionIdentifierColumn == null) { + throw new InvalidColorSchemaException( + "One of these columns is obligatory: name, identifier, reactionIdentifier"); + } - if (valueColumn == null && colorColumn == null) { - throw new InvalidColorSchemaException("Schema must contain one of these two columns: value, name"); - } + if (valueColumn == null && colorColumn == null) { + throw new InvalidColorSchemaException("Schema must contain one of these two columns: value, name"); + } - } else { - ColorSchema schema = new GenericColorSchema(); - if (nameColumn != null) { - schema.setName(row.getCell(nameColumn).getStringCellValue()); - } - if (valueColumn != null) { - try { - cell = row.getCell(valueColumn); - cell.setCellType(Cell.CELL_TYPE_STRING); - schema.setValue(Double.parseDouble(cell.getStringCellValue().replace(",", "."))); - } catch (Exception e) { - throw new InvalidColorSchemaException("[Line " + lineIndex + "] Problem with parsing value for value column. Cell value" + cell); - } - if (schema.getValue() > 1 + Configuration.EPSILON || schema.getValue() < -1 - Configuration.EPSILON) { - throw new InvalidColorSchemaException( - "[Line " + lineIndex + "] Value " + schema.getValue() + " out of range. Only values between -1 and 1 are allowed."); - } - } - if (compartmentColumn != null) { - String value = row.getCell(compartmentColumn).getStringCellValue(); - if (value != null) { - String[] compartments = value.split(","); - schema.addCompartments(compartments); - } - } - if (typeColumn != null) { - String value = row.getCell(typeColumn).getStringCellValue(); - if (value != null) { - String[] types = value.split(","); - for (String string : types) { - SpeciesMapping mapping = SpeciesMapping.getMappingByString(string); - if (mapping != null) { - schema.addType(mapping.getModelClazz()); - } else { - throw new InvalidColorSchemaException("Unknown class type: " + string + "."); - } - } - } - } - if (colorColumn != null) { - schema.setColor(colorParser.parse(row.getCell(colorColumn).getStringCellValue())); - } - if (reactionIdentifierColumn != null) { - schema.setReactionIdentifier(row.getCell(reactionIdentifierColumn).getStringCellValue()); - } - if (lineWidthColumn != null) { - cell = row.getCell(lineWidthColumn); - cell.setCellType(Cell.CELL_TYPE_STRING); - String value = cell.getStringCellValue(); - if (value != null && !value.trim().isEmpty()) { - try { - schema.setLineWidth(Double.parseDouble(value.replace(",", "."))); - } catch (NumberFormatException e) { - throw new InvalidColorSchemaException("[Line " + lineIndex + "] Problem with parsing value: \"" + value + "\""); - } - } - } - if (reverseReactionColumn != null) { - cell = row.getCell(reverseReactionColumn); - if (cell != null) { - cell.setCellType(Cell.CELL_TYPE_STRING); - schema.setReverseReaction("true".equalsIgnoreCase(cell.getStringCellValue())); - } - } - if (identifierColumn != null) { - cell = row.getCell(identifierColumn); - if (cell != null && !cell.getStringCellValue().trim().isEmpty()) { - MiriamConnector miriamConnector = new MiriamConnector(); - String value = cell.getStringCellValue().trim(); - if (miriamConnector.isValidIdentifier(value)) { - schema.setGeneralIdentifier(value); - } else { - throw new InvalidColorSchemaException("[Line " + lineIndex + "]" + " Invalid identifier: " + value); - } - } - } - for (Pair<MiriamType, Integer> pair : foundCustomIdentifiers) { - cell = row.getCell(pair.getRight()); - if (cell != null) { - schema.addIdentifierColumn(new Pair<MiriamType, String>(pair.getLeft(), cell.getStringCellValue())); - } - } + } else { + ColorSchema schema = new GenericColorSchema(); + if (nameColumn != null) { + schema.setName(row.getCell(nameColumn).getStringCellValue()); + } + if (modelNameColumn != null) { + schema.setModelName(row.getCell(modelNameColumn).getStringCellValue()); + } + if (valueColumn != null) { + try { + cell = row.getCell(valueColumn); + cell.setCellType(Cell.CELL_TYPE_STRING); + schema.setValue(Double.parseDouble(cell.getStringCellValue().replace(",", "."))); + } catch (Exception e) { + throw new InvalidColorSchemaException( + "[Line " + lineIndex + "] Problem with parsing value for value column. Cell value" + cell); + } + if (schema.getValue() > 1 + Configuration.EPSILON || schema.getValue() < -1 - Configuration.EPSILON) { + throw new InvalidColorSchemaException("[Line " + lineIndex + "] Value " + schema.getValue() + + " out of range. Only values between -1 and 1 are allowed."); + } + } + if (compartmentColumn != null) { + String value = row.getCell(compartmentColumn).getStringCellValue(); + if (value != null) { + String[] compartments = value.split(","); + schema.addCompartments(compartments); + } + } + if (typeColumn != null) { + String value = row.getCell(typeColumn).getStringCellValue(); + if (value != null) { + String[] types = value.split(","); + for (String string : types) { + SpeciesMapping mapping = SpeciesMapping.getMappingByString(string); + if (mapping != null) { + schema.addType(mapping.getModelClazz()); + } else { + throw new InvalidColorSchemaException("Unknown class type: " + string + "."); + } + } + } + } + if (colorColumn != null) { + schema.setColor(colorParser.parse(row.getCell(colorColumn).getStringCellValue())); + } + if (reactionIdentifierColumn != null) { + schema.setReactionIdentifier(row.getCell(reactionIdentifierColumn).getStringCellValue()); + } + if (lineWidthColumn != null) { + cell = row.getCell(lineWidthColumn); + cell.setCellType(Cell.CELL_TYPE_STRING); + String value = cell.getStringCellValue(); + if (value != null && !value.trim().isEmpty()) { + try { + schema.setLineWidth(Double.parseDouble(value.replace(",", "."))); + } catch (NumberFormatException e) { + throw new InvalidColorSchemaException( + "[Line " + lineIndex + "] Problem with parsing value: \"" + value + "\""); + } + } + } + if (reverseReactionColumn != null) { + cell = row.getCell(reverseReactionColumn); + if (cell != null) { + cell.setCellType(Cell.CELL_TYPE_STRING); + schema.setReverseReaction("true".equalsIgnoreCase(cell.getStringCellValue())); + } + } + if (identifierColumn != null) { + cell = row.getCell(identifierColumn); + if (cell != null && !cell.getStringCellValue().trim().isEmpty()) { + MiriamConnector miriamConnector = new MiriamConnector(); + String value = cell.getStringCellValue().trim(); + if (miriamConnector.isValidIdentifier(value)) { + schema.setGeneralIdentifier(value); + } else { + throw new InvalidColorSchemaException("[Line " + lineIndex + "]" + " Invalid identifier: " + value); + } + } + } + for (Pair<MiriamType, Integer> pair : foundCustomIdentifiers) { + cell = row.getCell(pair.getRight()); + if (cell != null) { + schema.addIdentifierColumn(new Pair<MiriamType, String>(pair.getLeft(), cell.getStringCellValue())); + } + } - if ((schema.getValue() != null && schema.getColor() != null) || (schema.getValue() == null && schema.getColor() == null)) { - throw new InvalidColorSchemaException("Value or Color is needed not both"); - } + if ((schema.getValue() != null && schema.getColor() != null) + || (schema.getValue() == null && schema.getColor() == null)) { + throw new InvalidColorSchemaException("Value or Color is needed not both"); + } - if (schema.getName() == null && schema.getGeneralIdentifier() == null && foundCustomIdentifiers.size() == 0 - && schema.getReactionIdentifier() == null) { - throw new InvalidColorSchemaException("One of these columns values is obligatory: name, identifier, reactionIdentifier"); - } - result.add(schema); - } - } - } finally { - try { - if (file != null) { - file.close(); - } - if (workbook != null) { - workbook.close(); - } - } catch (Exception e) { + if (schema.getName() == null && schema.getGeneralIdentifier() == null && foundCustomIdentifiers.size() == 0 + && schema.getReactionIdentifier() == null) { + throw new InvalidColorSchemaException( + "One of these columns values is obligatory: name, identifier, reactionIdentifier"); + } + result.add(schema); + } + } + } finally { + try { + if (file != null) { + file.close(); + } + if (workbook != null) { + workbook.close(); + } + } catch (Exception e) { - } - } - return result; + } + } + return result; - } + } - /** - * Returns list of columns that should be printed for given coloring schemas. - * - * @param schemas - * list of schemas - * @return list of columns that should be printed (were set in the coloring - * schemas) - */ - public Collection<ColorSchemaColumn> getSetColorSchemaColumns(Collection<ColorSchema> schemas) { - Set<ColorSchemaColumn> result = new HashSet<ColorSchemaColumn>(); - for (ColorSchema schema : schemas) { - if (schema.getColor() != null) { - result.add(ColorSchemaColumn.COLOR); - } - if (schema.getCompartments().size() > 0) { - result.add(ColorSchemaColumn.COMPARTMENT); - } - if (schema.getGeneralIdentifier() != null || schema.getIdentifierColumns().size() > 0) { - result.add(ColorSchemaColumn.IDENTIFIER); - } - if (schema.getLineWidth() != null) { - result.add(ColorSchemaColumn.LINE_WIDTH); - } - if (schema.getName() != null) { - result.add(ColorSchemaColumn.NAME); - } - if (schema.getReactionIdentifier() != null) { - result.add(ColorSchemaColumn.REACTION_IDENTIFIER); - } - if (schema.getReverseReaction() != null) { - result.add(ColorSchemaColumn.REVERSE_REACTION); - } - if (schema.getTypes().size() > 0) { - result.add(ColorSchemaColumn.TYPE); - } - if (schema.getValue() != null) { - result.add(ColorSchemaColumn.VALUE); - } - } - return result; - } + /** + * Returns list of columns that should be printed for given coloring schemas. + * + * @param schemas + * list of schemas + * @return list of columns that should be printed (were set in the coloring + * schemas) + */ + public Collection<ColorSchemaColumn> getSetColorSchemaColumns(Collection<ColorSchema> schemas) { + Set<ColorSchemaColumn> result = new HashSet<ColorSchemaColumn>(); + for (ColorSchema schema : schemas) { + if (schema.getColor() != null) { + result.add(ColorSchemaColumn.COLOR); + } + if (schema.getCompartments().size() > 0) { + result.add(ColorSchemaColumn.COMPARTMENT); + } + if (schema.getGeneralIdentifier() != null || schema.getIdentifierColumns().size() > 0) { + result.add(ColorSchemaColumn.IDENTIFIER); + } + if (schema.getLineWidth() != null) { + result.add(ColorSchemaColumn.LINE_WIDTH); + } + if (schema.getName() != null) { + result.add(ColorSchemaColumn.NAME); + } + if (schema.getModelName() != null) { + result.add(ColorSchemaColumn.MODEL_NAME); + } + if (schema.getReactionIdentifier() != null) { + result.add(ColorSchemaColumn.REACTION_IDENTIFIER); + } + if (schema.getReverseReaction() != null) { + result.add(ColorSchemaColumn.REVERSE_REACTION); + } + if (schema.getTypes().size() > 0) { + result.add(ColorSchemaColumn.TYPE); + } + if (schema.getValue() != null) { + result.add(ColorSchemaColumn.VALUE); + } + } + return result; + } } diff --git a/service/src/main/java/lcsb/mapviewer/services/utils/data/ColorSchemaColumn.java b/service/src/main/java/lcsb/mapviewer/services/utils/data/ColorSchemaColumn.java index 6792e10ef5b0ebff44da960be6ad99a953e9ab1f..a5a4025546064af5b3c53c2b64941f900d7408b5 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/data/ColorSchemaColumn.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/data/ColorSchemaColumn.java @@ -3,7 +3,6 @@ package lcsb.mapviewer.services.utils.data; import java.util.HashSet; import java.util.Set; - import lcsb.mapviewer.model.map.layout.ReferenceGenome; import lcsb.mapviewer.model.map.layout.ReferenceGenomeType; @@ -16,136 +15,141 @@ import lcsb.mapviewer.model.map.layout.ReferenceGenomeType; */ public enum ColorSchemaColumn { - /** - * Name of the element. - */ - NAME("name", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Value that will be transformed into new color. - * - * @see ColorSchemaColumn#COLOR - */ - VALUE("value", new ColorSchemaType[] { ColorSchemaType.GENERIC }), // - - /** - * In which compartment the element should be located. - */ - COMPARTMENT("compartment", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Class type of the element. - */ - TYPE("type", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // - - /** - * New element/reaction color. - */ - COLOR("color", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Identifier of the element. - */ - IDENTIFIER("identifier", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Reaction identifier. - */ - REACTION_IDENTIFIER("reactionIdentifier", new ColorSchemaType[] { ColorSchemaType.GENERIC }), // - - /** - * New line width of the reaction. - */ - LINE_WIDTH("lineWidth", new ColorSchemaType[] { ColorSchemaType.GENERIC }), // - - /** - * Position where gene variants starts. - */ - POSITION("position", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Original DNA of the variant. - */ - ORIGINAL_DNA("original_dna", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Alternative DNA of the variant. - */ - ALTERNATIVE_DNA("alternative_dna", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Short description of the entry. - */ - DESCRIPTION("description", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT, ColorSchemaType.GENERIC }), // - - /** - * Variant references. - */ - REFERENCES("references", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - /** - * What's the {@link ReferenceGenomeType}. - */ - REFERENCE_GENOME_TYPE("reference_genome_type", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - /** - * {@link ReferenceGenome#version Version} of the reference genome. - */ - REFERENCE_GENOME_VERSION("reference_genome_version", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Contig where variant was observed. - */ - CONTIG("contig", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - ALLEL_FREQUENCY("allel_frequency", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - VARIANT_IDENTIFIER("variant_identifier", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // - - /** - * Should the direction of reaction be reversed. - */ - REVERSE_REACTION("reverseReaction", new ColorSchemaType[] { ColorSchemaType.GENERIC }); // - - /** - * Default constructor that creates enum entry. - * - * @param title - * {@link #title} - * @param types - * list of {@link ColumnType types} where this column is allowed - */ - ColorSchemaColumn(String title, ColorSchemaType[] types) { - this.title = title; - for (ColorSchemaType colorSchemaType : types) { - this.types.add(colorSchemaType); - } - } - - /** - * Human readable title used in input file. - */ - private String title; - - /** - * Set of types where column is allowed. - */ - private Set<ColorSchemaType> types = new HashSet<>(); - - /** - * - * @return {@link #title} - */ - public String getTitle() { - return title; - } - - /** - * @return the types - * @see #types - */ - public Set<ColorSchemaType> getTypes() { - return types; - } + /** + * Name of the element. + */ + NAME("name", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Name of the element. + */ + MODEL_NAME("model_name", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Value that will be transformed into new color. + * + * @see ColorSchemaColumn#COLOR + */ + VALUE("value", new ColorSchemaType[] { ColorSchemaType.GENERIC }), // + + /** + * In which compartment the element should be located. + */ + COMPARTMENT("compartment", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Class type of the element. + */ + TYPE("type", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // + + /** + * New element/reaction color. + */ + COLOR("color", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Identifier of the element. + */ + IDENTIFIER("identifier", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Reaction identifier. + */ + REACTION_IDENTIFIER("reactionIdentifier", new ColorSchemaType[] { ColorSchemaType.GENERIC }), // + + /** + * New line width of the reaction. + */ + LINE_WIDTH("lineWidth", new ColorSchemaType[] { ColorSchemaType.GENERIC }), // + + /** + * Position where gene variants starts. + */ + POSITION("position", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Original DNA of the variant. + */ + ORIGINAL_DNA("original_dna", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Alternative DNA of the variant. + */ + ALTERNATIVE_DNA("alternative_dna", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Short description of the entry. + */ + DESCRIPTION("description", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT, ColorSchemaType.GENERIC }), // + + /** + * Variant references. + */ + REFERENCES("references", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + /** + * What's the {@link ReferenceGenomeType}. + */ + REFERENCE_GENOME_TYPE("reference_genome_type", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + /** + * {@link ReferenceGenome#version Version} of the reference genome. + */ + REFERENCE_GENOME_VERSION("reference_genome_version", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Contig where variant was observed. + */ + CONTIG("contig", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + ALLEL_FREQUENCY("allel_frequency", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + VARIANT_IDENTIFIER("variant_identifier", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), // + + /** + * Should the direction of reaction be reversed. + */ + REVERSE_REACTION("reverseReaction", new ColorSchemaType[] { ColorSchemaType.GENERIC }); // + + /** + * Default constructor that creates enum entry. + * + * @param title + * {@link #title} + * @param types + * list of {@link ColumnType types} where this column is allowed + */ + ColorSchemaColumn(String title, ColorSchemaType[] types) { + this.title = title; + for (ColorSchemaType colorSchemaType : types) { + this.types.add(colorSchemaType); + } + } + + /** + * Human readable title used in input file. + */ + private String title; + + /** + * Set of types where column is allowed. + */ + private Set<ColorSchemaType> types = new HashSet<>(); + + /** + * + * @return {@link #title} + */ + public String getTitle() { + return title; + } + + /** + * @return the types + * @see #types + */ + public Set<ColorSchemaType> getTypes() { + return types; + } } diff --git a/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugServiceTest.java index 22e941bf684ec9deec31982a0f01f9c89e2eb366..fb7154befa5071a9b6622e81cec2d8cf19e8dfc0 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugServiceTest.java @@ -31,236 +31,249 @@ import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.search.db.DbSearchCriteria; public class DrugServiceTest extends ServiceTestFunctions { - Logger logger = Logger.getLogger(DrugServiceTest.class); - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGetEmpty() throws Exception { - try { - Drug drug = drugService.getByName("blablablabla", new DbSearchCriteria()); - assertNull(drug); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testGetTargets() throws Exception { - try { - long count = searchHistoryDao.getCount(); - Model model = new ModelFullIndexed(null); - Project project = new Project(); - project.setProjectId("TesT"); - project.addModel(model); - Drug drug = drugService.getByName("Diazoxide", new DbSearchCriteria().model(model).ipAddress("ip")); - assertNotNull(drug); - assertNotNull(drug.getName()); - assertFalse(drug.getName().trim().equals("")); - assertNotNull(drug.getDescription()); - assertFalse(drug.getDescription().trim().equals("")); - - String hgnc1 = "SLC12A3"; - String hgnc2 = "KCNJ8"; - - boolean hgnc1Exists = false; - boolean hgnc2Exists = false; - - for (Target target : drug.getTargets()) { - for (MiriamData row : target.getGenes()) { - if (row.getResource().equalsIgnoreCase(hgnc1)) - hgnc1Exists = true; - if (row.getResource().equalsIgnoreCase(hgnc2)) - hgnc2Exists = true; - } - } - - assertTrue("Target " + hgnc1 + " doesn't exist in target list but should", hgnc1Exists); - assertTrue("Target " + hgnc2 + " doesn't exist in target list but should", hgnc2Exists); - - long count2 = searchHistoryDao.getCount(); - - assertEquals(count + 1, count2); - - assertEquals("YES", drug.getBloodBrainBarrier()); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testGetTargetsBySynonym() throws Exception { - try { - // search by synonym - Drug drug = drugService.getByName("Amantidine", new DbSearchCriteria().ipAddress("ip")); - // search by name - Drug drug2 = drugService.getByName("Amantadine", new DbSearchCriteria().ipAddress("ip")); - assertNotNull(drug); - assertNotNull(drug.getName()); - assertFalse(drug.getName().trim().equals("")); - assertNotNull(drug.getDescription()); - assertFalse(drug.getDescription().trim().equals("")); - - // number of targets should be the same - assertEquals(drug.getTargets().size(), drug2.getTargets().size()); - assertTrue(drug.getTargets().size() > 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testFindDrugSelegiline() throws Exception { - try { - Drug test = drugService.getByName("Selegiline", new DbSearchCriteria().ipAddress("ip").organisms(TaxonomyBackend.HUMAN_TAXONOMY)); - assertNotNull(test); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testDornaseAplha() throws Exception { - try { - Drug drug = drugService.getByName("Dornase alpha", new DbSearchCriteria()); - assertNotNull(drug.getName()); - assertEquals("N/A", drug.getBloodBrainBarrier()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testRapamycin() throws Exception { - try { - Drug drug = drugService.getByName("Rapamycin", new DbSearchCriteria()); - assertNotNull(drug.getName()); - assertEquals("NO", drug.getBloodBrainBarrier()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testSearchByElements() throws Exception { - try { - List<Element> elements = new ArrayList<>(); - List<Drug> drugs = drugService.getForTargets(elements, new DbSearchCriteria()); - assertNotNull(drugs); - assertEquals(0, drugs.size()); - - Protein protein = new GenericProtein("id"); - protein.setName("DRD2"); - protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "DRD2")); - elements.add(protein); - - drugs = drugService.getForTargets(elements, new DbSearchCriteria()); - assertNotNull(drugs); - assertTrue(drugs.size() > 0); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testSearchByElements2() throws Exception { - try { - List<Element> elements = new ArrayList<>(); - Protein protein = new GenericProtein("id"); - protein.setName("DRD2"); - protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "DRD2")); - elements.add(protein); - List<Drug> drugs = drugService.getForTargets(elements, new DbSearchCriteria().organisms(TaxonomyBackend.HUMAN_TAXONOMY)); - - assertNotNull(drugs); - assertTrue(drugs.size() > 0); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testSearchByElements3() throws Exception { - try { - List<Element> elements = new ArrayList<>(); - Protein protein = new GenericProtein("id"); - protein.setName("GLUD1"); - protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "GLUD1")); - protein.addMiriamData(new MiriamData(MiriamType.ENTREZ, "2746")); - elements.add(protein); - List<Drug> drugs = drugService.getForTargets(elements, new DbSearchCriteria()); - - assertNotNull(drugs); - assertTrue(drugs.size() > 0); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testObjectToDrugTargetList() throws Exception { - try { - Drug drug = drugService.getByName("AMANTADINE", new DbSearchCriteria()); - Drug drug2 = drugBankHTMLParser.findDrug("AMANTADINE"); - - assertTrue(drug2.getTargets().size() <= drug.getTargets().size()); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testAspirinToDrugTargetList() throws Exception { - try { - Drug drug = drugService.getByName("Aspirin", new DbSearchCriteria()); - Drug drug2 = drugBankHTMLParser.findDrug("Aspirin"); - - assertTrue(drug2.getTargets().size() <= drug.getTargets().size()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testAspirinSynonyms() throws Exception { - try { - Drug drug = drugService.getByName("Aspirin", new DbSearchCriteria()); - - Set<String> synonyms = new HashSet<String>(); - for (String string : drug.getSynonyms()) { - assertFalse("Duplicate entry in drug synonym: " + string, synonyms.contains(string)); - synonyms.add(string); - } - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + Logger logger = Logger.getLogger(DrugServiceTest.class); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetEmpty() throws Exception { + try { + Drug drug = drugService.getByName("blablablabla", new DbSearchCriteria()); + assertNull(drug); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetTargets() throws Exception { + try { + long count = searchHistoryDao.getCount(); + Model model = new ModelFullIndexed(null); + Project project = new Project(); + project.setProjectId("TesT"); + project.addModel(model); + Drug drug = drugService.getByName("Diazoxide", new DbSearchCriteria().model(model).ipAddress("ip")); + assertNotNull(drug); + assertNotNull(drug.getName()); + assertFalse(drug.getName().trim().equals("")); + assertNotNull(drug.getDescription()); + assertFalse(drug.getDescription().trim().equals("")); + + String hgnc1 = "SLC12A3"; + String hgnc2 = "KCNJ8"; + + boolean hgnc1Exists = false; + boolean hgnc2Exists = false; + + for (Target target : drug.getTargets()) { + for (MiriamData row : target.getGenes()) { + if (row.getResource().equalsIgnoreCase(hgnc1)) + hgnc1Exists = true; + if (row.getResource().equalsIgnoreCase(hgnc2)) + hgnc2Exists = true; + } + } + + assertTrue("Target " + hgnc1 + " doesn't exist in target list but should", hgnc1Exists); + assertTrue("Target " + hgnc2 + " doesn't exist in target list but should", hgnc2Exists); + + long count2 = searchHistoryDao.getCount(); + + assertEquals(count + 1, count2); + + assertEquals("YES", drug.getBloodBrainBarrier()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetTargetsBySynonym() throws Exception { + try { + // search by synonym + Drug drug = drugService.getByName("Amantidine", new DbSearchCriteria().ipAddress("ip")); + // search by name + Drug drug2 = drugService.getByName("Amantadine", new DbSearchCriteria().ipAddress("ip")); + assertNotNull(drug); + assertNotNull(drug.getName()); + assertFalse(drug.getName().trim().equals("")); + assertNotNull(drug.getDescription()); + assertFalse(drug.getDescription().trim().equals("")); + + // number of targets should be the same + assertEquals(drug.getTargets().size(), drug2.getTargets().size()); + assertTrue(drug.getTargets().size() > 0); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testFindDrugSelegiline() throws Exception { + try { + Drug test = drugService.getByName("Selegiline", + new DbSearchCriteria().ipAddress("ip").organisms(TaxonomyBackend.HUMAN_TAXONOMY)); + assertNotNull(test); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testDornaseAplha() throws Exception { + try { + Drug drug = drugService.getByName("Dornase alpha", new DbSearchCriteria()); + assertNotNull(drug.getName()); + assertEquals("N/A", drug.getBloodBrainBarrier()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testRapamycin() throws Exception { + try { + Drug drug = drugService.getByName("Rapamycin", new DbSearchCriteria()); + assertNotNull(drug.getName()); + assertEquals("NO", drug.getBloodBrainBarrier()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testSearchByElements() throws Exception { + try { + List<Element> elements = new ArrayList<>(); + List<Drug> drugs = drugService.getForTargets(elements, new DbSearchCriteria()); + assertNotNull(drugs); + assertEquals(0, drugs.size()); + + Protein protein = new GenericProtein("id"); + protein.setName("DRD2"); + protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "DRD2")); + elements.add(protein); + + drugs = drugService.getForTargets(elements, new DbSearchCriteria()); + assertNotNull(drugs); + assertTrue(drugs.size() > 0); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testSearchByElements2() throws Exception { + try { + List<Element> elements = new ArrayList<>(); + Protein protein = new GenericProtein("id"); + protein.setName("DRD2"); + protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "DRD2")); + elements.add(protein); + List<Drug> drugs = drugService.getForTargets(elements, + new DbSearchCriteria().organisms(TaxonomyBackend.HUMAN_TAXONOMY)); + + assertNotNull(drugs); + assertTrue(drugs.size() > 0); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testSearchByElements3() throws Exception { + try { + List<Element> elements = new ArrayList<>(); + Protein protein = new GenericProtein("id"); + protein.setName("GLUD1"); + protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "GLUD1")); + protein.addMiriamData(new MiriamData(MiriamType.ENTREZ, "2746")); + elements.add(protein); + List<Drug> drugs = drugService.getForTargets(elements, new DbSearchCriteria()); + + assertNotNull(drugs); + assertTrue(drugs.size() > 0); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testObjectToDrugTargetList() throws Exception { + try { + Drug drug = drugService.getByName("AMANTADINE", new DbSearchCriteria()); + Drug drug2 = drugBankHTMLParser.findDrug("AMANTADINE"); + + assertTrue(drug2.getTargets().size() <= drug.getTargets().size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testAspirinToDrugTargetList() throws Exception { + try { + Drug drug = drugService.getByName("Aspirin", new DbSearchCriteria()); + Drug drug2 = drugBankHTMLParser.findDrug("Aspirin"); + + assertTrue(drug2.getTargets().size() <= drug.getTargets().size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testAspirinSynonyms() throws Exception { + try { + Drug drug = drugService.getByName("Aspirin", new DbSearchCriteria()); + + Set<String> synonyms = new HashSet<String>(); + for (String string : drug.getSynonyms()) { + assertFalse("Duplicate entry in drug synonym: " + string, synonyms.contains(string)); + synonyms.add(string); + } + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetSuggestedQueryList() throws Exception { + try { + List<String> result = drugService.getSuggestedQueryList(new Project(), null); + assertEquals(0, result.size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } } diff --git a/web/src/main/webapp/WEB-INF/resources/log4j.properties b/web/src/main/webapp/WEB-INF/resources/log4j.properties index 2dd44999683a1660220521669ce42700cc847713..cce0380c86937576a3e43eb5c8567cfe25a20c0f 100644 --- a/web/src/main/webapp/WEB-INF/resources/log4j.properties +++ b/web/src/main/webapp/WEB-INF/resources/log4j.properties @@ -33,3 +33,6 @@ log4j.logger.lcsb.mapviewer.db.model.map.reaction.ReactionComparator=warn log4j.logger.lcsb.mapviewer.db.model.map.species.ProteinComparator=warn log4j.logger.lcsb.mapviewer.db.model.map.layout.alias.ComplexAliasComparator=warn log4j.logger.lcsb.mapviewer.db.model.map.Element=info + +#Silence miriam debug logs +log4j.logger.uk.ac.ebi.miriam.lib=warn diff --git a/web/src/main/webapp/index.xhtml b/web/src/main/webapp/index.xhtml index 7dd60ad0c641af31c616d06de5529e70948704bd..4173a0d9b725208930f7bba7f48de251ed0d5583 100644 --- a/web/src/main/webapp/index.xhtml +++ b/web/src/main/webapp/index.xhtml @@ -38,7 +38,7 @@ function initMap(){ customMap = result; document.title = result.getProject().getName(); }).catch(function(rejectReason){ - minerva.GuiConnector.alert(rejectReason); + minerva.GuiConnector.alert(rejectReason, true); }); }