diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 4c28b1a898a0f0bc507b93f8f5393d172709fe73..4824b8026319a8fb303971008a7d59a816d58bd6 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,2 @@ eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 encoding/<project>=UTF-8 diff --git a/CellDesigner-plugin/src/main/resources/empty.txt b/CellDesigner-plugin/src/main/resources/empty.txt new file mode 100644 index 0000000000000000000000000000000000000000..e45f025b4e3a8b4af265accb372955b7774d589f --- /dev/null +++ b/CellDesigner-plugin/src/main/resources/empty.txt @@ -0,0 +1 @@ +EMPTY file to force git to push the folder \ No newline at end of file diff --git a/README.md b/README.md index ebefb9ef5ec76f5bf38e152f5aca93d1c6982b9f..861648d99c5e64126470d7438abf13c19892bd67 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,16 @@ curl -X GET --cookie "MINERVA_AUTH_TOKEN=xxxxxxxx" http://pg-sandbox.uni.lu/mine ``` #### (sub)Maps +* List of (sub)maps in a project + * URL: `/projects/{projectId}/models/` + * Method: GET + * Parameters: + * `projectId` - identifier of the project + * Example: +``` +curl -X GET --cookie "MINERVA_AUTH_TOKEN=xxxxxxxx" "http://pg-sandbox.uni.lu/minerva/api/projects/pdmap_dec15/models/" +``` + * Download map as a model file (ie. in CellDesigner format) * URL: `/projects/{projectId}/models/{modelId}:downloadModel` * Method: GET diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/data/Drug.java b/annotation/src/main/java/lcsb/mapviewer/annotation/data/Drug.java index 697ad02a904a580178ce464bb012bce957264988..e8e58449730796316d63035ba6726cad84e9cc1b 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/data/Drug.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/data/Drug.java @@ -112,11 +112,15 @@ public class Drug implements Serializable, TargettingStructure { for (Target t : targets) { if (t.getSource() != null) { result.append(t.getSource().getResource() + "|" + t.getName() + "|" + t.getGenes()); + } else { + result.append("N/A |" + t.getName() + "|" + t.getGenes()); } - result.append("\nReferences:"); + result.append(" (References:"); for (MiriamData md : t.getReferences()) { - result.append(md.getResource()); + result.append(md.getResource() + ","); } + result.append(")+\n"); + } return result.toString(); } diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java index 7cae5de69da970c92262fe42c47ea5c0be0d4203..45c6daa1ebe3375bfb63983866742ab91bd960b3 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java @@ -3,6 +3,7 @@ package lcsb.mapviewer.annotation.services; import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -111,11 +112,6 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { @Autowired private HgncAnnotator hgncAnnotator; - /** - * Object used to access information about organism taxonomy. - */ - @Autowired - private TaxonomyBackend taxonomyBackend; /** * Default constructor. @@ -180,7 +176,7 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("organism")) { // node with information abou organism - target.setOrganism(taxonomyBackend.getByName(node.getTextContent())); + target.setOrganism(getTaxonomyBackend().getByName(node.getTextContent())); } else if (node.getNodeName().equalsIgnoreCase("pref_name")) { // node with information about name target.setName(node.getTextContent()); @@ -541,9 +537,9 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { } @Override - public List<Drug> getDrugListByTarget(MiriamData target) throws DrugSearchException { - List<Drug> result = new ArrayList<Drug>(); - List<MiriamData> uniprotData = new ArrayList<MiriamData>(); + public List<Drug> getDrugListByTarget(MiriamData target, Collection<MiriamData> organisms) throws DrugSearchException { + List<Drug> result = new ArrayList<>(); + List<MiriamData> uniprotData = new ArrayList<>(); if (MiriamType.HGNC_SYMBOL.equals(target.getDataType())) { try { uniprotData = hgncAnnotator.hgncToUniprot(target); @@ -561,7 +557,10 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { logger.warn("Too many uniprot ids. Only first will be taken"); } try { - String page = getWebPageContent(URL_TARGET_FROM_UNIPROT + uniprotData.get(0).getResource()); + String url = URL_TARGET_FROM_UNIPROT + uniprotData.get(0).getResource(); + logger.debug(url); + + String page = getWebPageContent(url); Set<String> drugNames = new HashSet<>(); Document document = getXmlDocumentFromString(page); @@ -573,14 +572,17 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("target")) { - Node chemblTargetIdNode = getNode("target_chembl_id", node); - MiriamData targetMiriam = new MiriamData(MiriamType.CHEMBL_TARGET, chemblTargetIdNode.getTextContent()); - List<Drug> drugs = getDrugsByChemblTarget(targetMiriam); - for (Drug drug : drugs) { - // don't add duplicates - if (!drugNames.contains(drug.getName())) { - drugNames.add(drug.getName()); - result.add(drug); + String organismName = getNode("organism", node).getTextContent(); + if (organismMatch(organismName, organisms)) { + Node chemblTargetIdNode = getNode("target_chembl_id", node); + MiriamData targetMiriam = new MiriamData(MiriamType.CHEMBL_TARGET, chemblTargetIdNode.getTextContent()); + List<Drug> drugs = getDrugsByChemblTarget(targetMiriam); + for (Drug drug : drugs) { + // don't add duplicates + if (!drugNames.contains(drug.getName())) { + drugNames.add(drug.getName()); + result.add(drug); + } } } } @@ -597,6 +599,7 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { } + /** * Returns list of drugs found by target identified in the paramter. * @@ -664,23 +667,6 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { super.setWebPageDownloader(webPageDownloader); } - /** - * @return the taxonomyBackend - * @see #taxonomyBackend - */ - protected TaxonomyBackend getTaxonomyBackend() { - return taxonomyBackend; - } - - /** - * @param taxonomyBackend - * the taxonomyBackend to set - * @see #taxonomyBackend - */ - protected void setTaxonomyBackend(TaxonomyBackend taxonomyBackend) { - this.taxonomyBackend = taxonomyBackend; - } - /** * @return the hgncAnnotator * @see #hgncAnnotator 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 74e38ec3bfe6defa7e5fe0c90198a253b4d56a3c..df03d1175cb14e1d072df7f3eb0649473bf1d2b6 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChemicalParser.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChemicalParser.java @@ -12,6 +12,7 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang3.SerializationException; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.w3c.dom.Node; @@ -353,8 +354,12 @@ public class ChemicalParser extends CachableInterface implements IExternalServic // look for chemical in the cache Node chemicalNode = super.getCacheNode(getIdentifier(diseaseID, chemicalId)); if (chemicalNode != null && chemicalNode.hasChildNodes()) { - result = chemicalSerializer.xmlToObject(chemicalNode); - return result; + try { + result = chemicalSerializer.xmlToObject(chemicalNode); + return result; + } catch (SerializationException e) { + logger.error(e, e); + } } try { String diseaseQuery = DISEASE_URL + diseaseID.getResource(); 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 64d4f11adc23464be114a36f4f4eb37902a1f814..5e8ca1b99ace1e532f9a70cf9ab6648713e14031 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugAnnotation.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugAnnotation.java @@ -6,10 +6,14 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; + import lcsb.mapviewer.annotation.cache.CachableInterface; import lcsb.mapviewer.annotation.cache.XmlSerializer; import lcsb.mapviewer.annotation.data.Drug; import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.MiriamType; /** * Abstract class with some functionalities used by class accessing drug @@ -20,11 +24,22 @@ import lcsb.mapviewer.model.map.MiriamData; */ public abstract class DrugAnnotation extends CachableInterface { + /** + * Default class logger. + */ + private Logger logger = Logger.getLogger(DrugAnnotation.class); + /** * Object that allows to serialize {@link Drug} elements into xml string and * deserialize xml into {@link Drug} objects. */ - private XmlSerializer<Drug> drugSerializer; + private XmlSerializer<Drug> drugSerializer; + + /** + * Object used to access information about organism taxonomy. + */ + @Autowired + private TaxonomyBackend taxonomyBackend; /** * Default constructor. Initializes structures used for transforming @@ -54,12 +69,28 @@ public abstract class DrugAnnotation extends CachableInterface { * * @param target * {@link MiriamData} describing target + * @param organisms + * list of organisms to which results should be limited (when no + * organisms defined filtering will be turned off) * @return list of drugs * @throws DrugSearchException * thrown when there are problems with finding drug */ - public abstract List<Drug> getDrugListByTarget(MiriamData target) throws DrugSearchException; + public abstract List<Drug> getDrugListByTarget(MiriamData target, Collection<MiriamData> organisms) throws DrugSearchException; + + /** + * Returns list of drugs that target protein. + * + * @param target + * {@link MiriamData} describing target + * @return list of drugs + * @throws DrugSearchException + * thrown when there are problems with finding drug + */ + public List<Drug> getDrugListByTarget(MiriamData target) throws DrugSearchException { + return getDrugListByTarget(target, new ArrayList<>()); + } /** * Returns list of drugs that target at least one protein from the parameter @@ -67,11 +98,14 @@ public abstract class DrugAnnotation extends CachableInterface { * * @param targets * list of {@link MiriamData} describing targets + * @param organisms + * list of organisms to which results should be limited (when no + * organisms defined filtering will be turned off) * @return list of drugs * @throws DrugSearchException * thrown when there are problems with connection to drug database */ - public List<Drug> getDrugListByTargets(Collection<MiriamData> targets) throws DrugSearchException { + public List<Drug> getDrugListByTargets(Collection<MiriamData> targets, Collection<MiriamData> organisms) throws DrugSearchException { List<Drug> result = new ArrayList<Drug>(); Set<String> set = new HashSet<String>(); Set<MiriamData> searchedResult = new HashSet<MiriamData>(); @@ -80,7 +114,7 @@ public abstract class DrugAnnotation extends CachableInterface { continue; } searchedResult.add(md); - List<Drug> drugs = getDrugListByTarget(md); + List<Drug> drugs = getDrugListByTarget(md, organisms); for (Drug drug : drugs) { if (!set.contains(drug.getSources().get(0).getResource())) { result.add(drug); @@ -93,6 +127,20 @@ public abstract class DrugAnnotation extends CachableInterface { return result; } + /** + * Returns list of drugs that target at least one protein from the parameter + * list. + * + * @param targets + * list of {@link MiriamData} describing targets + * @return list of drugs + * @throws DrugSearchException + * thrown when there are problems with connection to drug database + */ + public List<Drug> getDrugListByTargets(Collection<MiriamData> targets) throws DrugSearchException { + return getDrugListByTargets(targets, new ArrayList<>()); + } + /** * @return the drugSerializer * @see #drugSerializer @@ -110,4 +158,46 @@ public abstract class DrugAnnotation extends CachableInterface { this.drugSerializer = drugSerializer; } + /** + * Checks if organism name matches list of organisms. + * + * @param organismName + * name of the organism (should be something recognizable by + * {@link MiriamType#TAXONOMY} db). + * @param organisms + * list of organisms + * @return <code>false</code> if organisName couldn't be found in organisms + * list. If organismName is null or empty or list of organisms is + * empty true will be returned + */ + protected boolean organismMatch(String organismName, Collection<MiriamData> organisms) { + if (organismName == null || organismName.isEmpty() || organisms.size() == 0) { + return true; + } + try { + MiriamData organism = taxonomyBackend.getByName(organismName); + return organisms.contains(organism); + } catch (TaxonomySearchException e) { + logger.error("Problem with taxonomy search for: " + organismName, e); + return true; + } + } + + /** + * @return the taxonomyBackend + * @see #taxonomyBackend + */ + public TaxonomyBackend getTaxonomyBackend() { + return taxonomyBackend; + } + + /** + * @param taxonomyBackend + * the taxonomyBackend to set + * @see #taxonomyBackend + */ + public void setTaxonomyBackend(TaxonomyBackend taxonomyBackend) { + this.taxonomyBackend = taxonomyBackend; + } + } diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParser.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParser.java index cb9b4ac8032611e54f010bf40c662521b5f111be..de70f2f49512d700cc2a4348d59833f1168a960d 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParser.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParser.java @@ -1,8 +1,10 @@ package lcsb.mapviewer.annotation.services; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -107,12 +109,6 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi */ private Pattern targetPattern = Pattern.compile("(?<=\"/biodb/bio_entities/)([\\s\\S]*?)(?=\")"); - /** - * Object used to access information about organism taxonomy. - */ - @Autowired - private TaxonomyBackend taxonomyBackend; - /** * Default constructor. */ @@ -305,79 +301,41 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi List<Target> getTargetsForDrug(String page) throws DrugSearchException { List<Target> result = new ArrayList<>(); try { - int i, j; + int pageStart; Target target = new Target(); target.setType(TargetType.SINGLE_PROTEIN); - i = page.indexOf("<div class=\"target well well"); + pageStart = page.indexOf("<div class=\"target well well"); int end = page.indexOf("<div class=\"enzyme well well"); if (end < 0) { - end = page.indexOf("<tr id=\"comments\">"); + end = page.indexOf("<div class=\"carrier well well"); if (end < 0) { - end = page.length() - 1; + end = page.indexOf("<div class=\"transporter well well"); + + if (end < 0) { + end = page.indexOf("<tr id=\"comments\">"); + if (end < 0) { + end = page.length() - 1; + } + } } } - i = page.indexOf("Details</a></div>", i); - while (i > 0 && i < end) { - int kindIndex = page.indexOf("<dt>Kind</dt><dd>", i); - kindIndex += "<dt>Kind</dt><dd>".length(); - int endKindIndex = page.indexOf("</dd>", kindIndex); - String type = ""; - if (kindIndex > 0 && endKindIndex > kindIndex) { - type = page.substring(kindIndex, endKindIndex); + pageStart = page.indexOf("Details</a></div>", pageStart); + while (pageStart > 0 && pageStart < end) { + int targetStart = page.indexOf("</div><strong>", pageStart); + int nextTargetStart = page.indexOf("</div><strong>", targetStart + 1); + if (nextTargetStart < 0) { + nextTargetStart = end; } - if (type.trim().equalsIgnoreCase("Protein")) { - i = page.indexOf("/biodb/polypeptides/", i); - i += "/biodb/polypeptides/".length(); - target = new Target(); - target.setType(TargetType.SINGLE_PROTEIN); - - // Getting ID && Name - j = page.indexOf('"', i); - String uniprotId = page.substring(i, j); - MiriamData uniprotTarget = new MiriamData(MiriamType.UNIPROT, uniprotId); - MiriamData hgncTarget = uniprotAnnotator.uniProtToHgnc(uniprotTarget); - if (hgncTarget != null) { - target.addGene(hgncTarget); - } else { - target.addGene(uniprotTarget); - } - i = j + 2; - j = page.indexOf("</", i); - String name = StringEscapeUtils.unescapeHtml4(page.substring(i, j)); - target.setName(name); - - // Getting Organism - i = page.indexOf("Organism</dt><dd>", i); - i = i + "Organism</dt><dd>".length(); - j = page.indexOf("</dd>", i); - target.setOrganism(taxonomyBackend.getByName(page.substring(i, j))); - - // Getting References - i = page.indexOf("<strong>References</strong>", i); - if (i > 0 && i < end) { - int nextI = Math.min(page.indexOf("Details</a></div>", i), end); - if (nextI < 0) { - nextI = end; - } - target.addReferences(getPubmedFromRef(page.substring(i, nextI))); - i = nextI; - } else { - i = end; - } + target = parseTarget(page.substring(targetStart, nextTargetStart)); + if (target != null) { result.add(target); - } else { - i = kindIndex; - logger.warn("Unknown target type: " + type + ". Skipping."); - int nextI = Math.min(page.indexOf("Details</a></div>", i), end); - if (nextI < 0) { - nextI = end; - } - i = nextI; } + pageStart = nextTargetStart; + } } catch (TaxonomySearchException e) { throw new DrugSearchException("Problem with finidng information about organism", e); @@ -387,6 +345,67 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi return result; } + /** + * Parse html info about target into {@link Target} structure. + * + * @param htmlPage + * string with html content + * @return {@link Target} for given html content + * @throws UniprotSearchException + * thrown when there is a problem with accessing uniprot db + * @throws TaxonomySearchException + * thrown when there is a problem with accessing taxonomy db + */ + protected Target parseTarget(String htmlPage) throws UniprotSearchException, TaxonomySearchException { + int kindIndex = htmlPage.indexOf("<dt>Kind</dt><dd>"); + kindIndex += "<dt>Kind</dt><dd>".length(); + int endKindIndex = htmlPage.indexOf("</dd>"); + String type = ""; + if (kindIndex > 0 && endKindIndex > kindIndex) { + type = htmlPage.substring(kindIndex, endKindIndex); + } + if (type.trim().equalsIgnoreCase("Protein")) { + int uniprotIdStart = htmlPage.indexOf("/biodb/polypeptides/") + "/biodb/polypeptides/".length(); + Target result = new Target(); + result.setType(TargetType.SINGLE_PROTEIN); + + // Getting ID && Name + int uniprotIdEnd = htmlPage.indexOf('"', uniprotIdStart); + String uniprotId = htmlPage.substring(uniprotIdStart, uniprotIdEnd); + MiriamData uniprotTarget = new MiriamData(MiriamType.UNIPROT, uniprotId); + MiriamData hgncTarget = uniprotAnnotator.uniProtToHgnc(uniprotTarget); + if (hgncTarget != null) { + result.addGene(hgncTarget); + } else { + result.addGene(uniprotTarget); + } + + int nameStart = uniprotIdEnd + 2; + int nameEnd = htmlPage.indexOf("</", uniprotIdStart); + String name = StringEscapeUtils.unescapeHtml4(htmlPage.substring(nameStart, nameEnd)); + result.setName(name); + + // Getting Organism + int organismStart = htmlPage.indexOf("Organism</dt><dd>", nameEnd) + "Organism</dt><dd>".length(); + int organismEnd = htmlPage.indexOf("</dd>", organismStart); + result.setOrganism(getTaxonomyBackend().getByName(htmlPage.substring(organismStart, organismEnd))); + + // Getting References + int referencesStart = htmlPage.indexOf("<strong>References</strong>", organismEnd); + if (referencesStart > 0) { + int referencesEnd = Math.min(htmlPage.indexOf("Details</a></div>", referencesStart), htmlPage.length()); + if (referencesEnd < 0) { + referencesEnd = htmlPage.length(); + } + result.addReferences(getPubmedFromRef(htmlPage.substring(referencesStart, referencesEnd))); + } + return result; + } else { + logger.warn("Unknown target type: " + type + ". Skipping."); + return null; + } + } + /** * Finds information about drug in drugbank database. * @@ -414,6 +433,7 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi result = new Drug(); result.addSource(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.DRUGBANK, tmp)); result.setName(super.cleanHtml(findNameInText(inputLine))); + break; } } @@ -435,6 +455,10 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi result.setBloodBrainBarrier(getBloodBrainBarrier(page)); result.setApproved(getApproved(page)); + + if (!nameMatch(result, name)) { + result = null; + } } } catch (IOException e) { throw new DrugSearchException(e); @@ -442,6 +466,35 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi return result; } + /** + * Check if drug data mateches with the search name. + * + * @param drug + * drug to be checked + * @param name + * name of the drug that we were looking for + * @return true if if drug data matches with the search name + */ + private boolean nameMatch(Drug drug, String name) { + Set<String> foundNames = new HashSet<>(); + foundNames.add(drug.getName()); + foundNames.addAll(drug.getSynonyms()); + foundNames.addAll(drug.getBrandNames()); + String lowerCaseName; + try { + lowerCaseName = java.net.URLDecoder.decode(name, "UTF-8").toLowerCase().replaceAll("[^A-Za-z0-9]", ""); + } catch (UnsupportedEncodingException e) { + lowerCaseName = name.toLowerCase().replaceAll("[^A-Za-z0-9]", ""); + } + for (String string : foundNames) { + String query = string.toLowerCase().replaceAll("[^A-Za-z0-9]", ""); + if (query.contains(lowerCaseName)) { + return true; + } + } + return false; + } + /** * Finds blood brain barrier info about drug in the webpage content. * @@ -554,40 +607,51 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi } @Override - public List<Drug> getDrugListByTarget(MiriamData target) throws DrugSearchException { - List<Drug> result = new ArrayList<Drug>(); - if (target == null) { + public List<Drug> getDrugListByTarget(MiriamData targetMiriamData, Collection<MiriamData> organisms) throws DrugSearchException { + List<Drug> result = new ArrayList<>(); + if (targetMiriamData == null) { return result; } - if (!(MiriamType.HGNC_SYMBOL.equals(target.getDataType()))) { + if (!(MiriamType.HGNC_SYMBOL.equals(targetMiriamData.getDataType()))) { throw new InvalidArgumentException("Only " + MiriamType.HGNC_SYMBOL + " type is accepted"); } - String url = URL_TARGETS + target.getResource(); + String url = URL_TARGETS + targetMiriamData.getResource(); - String page; try { - page = getWebPageContent(url); - } catch (IOException e) { - throw new DrugSearchException("Cannot access drug database", e); - } + String page = getWebPageContent(url); - Set<String> drugNames = new HashSet<String>(); + Set<String> drugNames = new HashSet<>(); - Matcher matcher = targetPattern.matcher(page); - while (matcher.find()) { - String drugbankTargetId = matcher.group(0); - drugNames.addAll(getDrugNamesForTarget(new MiriamData(MiriamType.DRUGBANK_TARGET_V4, drugbankTargetId), target)); - } - for (String string : drugNames) { - Drug drug = findDrug(string); - if (drug == null) { - logger.warn("Cannot find drug that should be there: " + string); - } else { - result.add(drug); + Matcher matcher = targetPattern.matcher(page); + while (matcher.find()) { + String drugbankTargetId = matcher.group(0); + drugNames.addAll(getDrugNamesForTarget(new MiriamData(MiriamType.DRUGBANK_TARGET_V4, drugbankTargetId), targetMiriamData, organisms)); + } + for (String string : drugNames) { + Drug drug = findDrug(string); + if (drug == null) { + logger.warn("Cannot find drug that should be there: " + string); + } else { + boolean targets = false; + for (Target target : drug.getTargets()) { + for (MiriamData gene : target.getGenes()) { + if (gene.equals(targetMiriamData)) { + targets = true; + } + } + } + if (targets) { + result.add(drug); + } else { + logger.debug("Skipping drug that doesn't target required target. Drug name: " + drug.getName() + "; target: " + targetMiriamData); + } + } } - } - return result; + return result; + } catch (IOException e) { + throw new DrugSearchException("Cannot access drug database", e); + } } /** @@ -600,32 +664,36 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi * identifier of the target using {@link MiriamType#HGNC_SYMBOL}, * used for verification if the target really points to proper * protein/gene + * @param organisms + * list of organisms to which results should be limited (when no + * organisms defined filtering will be turned off) * @return list of drugs that target this target * @throws DrugSearchException * thrown when there are problems with connection to DrugBank * database */ - private Set<String> getDrugNamesForTarget(MiriamData drugbankTarget, MiriamData hgncTarget) throws DrugSearchException { + private Set<String> getDrugNamesForTarget(MiriamData drugbankTarget, MiriamData hgncTarget, Collection<MiriamData> organisms) throws DrugSearchException { if (!MiriamType.DRUGBANK_TARGET_V4.equals(drugbankTarget.getDataType())) { throw new InvalidArgumentException("drugbankTarget must be of type: " + MiriamType.DRUGBANK_TARGET_V4); } try { - Set<String> drugNames = new HashSet<String>(); + Set<String> drugNames = new HashSet<>(); + String url = URL_TARGET_DETAIL + drugbankTarget.getResource(); - String page = getWebPageContent(URL_TARGET_DETAIL + drugbankTarget.getResource()); + String page = getWebPageContent(url); - int id = page.indexOf("<th>DrugBank ID</th>"); - if (id < 0) { + int idPosition = page.indexOf("<th>DrugBank ID</th>"); + if (idPosition < 0) { throw new DrugSearchException("Problematic web page for target: " + drugbankTarget + "(" + hgncTarget + ")"); } - int i = page.indexOf("/polypeptides/"); + int protienLinkPosition = page.indexOf("/polypeptides/"); // sometimes there might not be an element - if (i >= 0) { - i = i + "/polypeptides/".length(); // 20; - int j = page.indexOf('"', i); - String uniprotId = page.substring(i, j); + if (protienLinkPosition >= 0) { + protienLinkPosition = protienLinkPosition + "/polypeptides/".length(); // 20; + int j = page.indexOf('"', protienLinkPosition); + String uniprotId = page.substring(protienLinkPosition, j); MiriamData uniprotMiriam = new MiriamData(MiriamType.UNIPROT, uniprotId); MiriamData hgncMiriam = uniprotAnnotator.uniProtToHgnc(uniprotMiriam); if (hgncMiriam == null || !hgncMiriam.equals(hgncTarget)) { @@ -638,7 +706,18 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi return drugNames; } - Matcher matcher = drugNamePattern.matcher(page.substring(id)); + int organismPosition = page.indexOf("Organism<"); + if (organismPosition >= 0) { + int organismStart = page.indexOf("<td>", organismPosition) + "<td>".length(); + int organismEnd = page.indexOf("<", organismStart + 1); + String organismName = page.substring(organismStart, organismEnd); + if (!organismMatch(organismName, organisms)) { + logger.debug("Organism doesn't match. Found" + organismName + ". Expected: " + organisms); + return drugNames; + } + } + + Matcher matcher = drugNamePattern.matcher(page.substring(idPosition)); while (matcher.find()) { drugNames.add(matcher.group(1)); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java index 7c28ab4f17f65dc43031067f609509afd2d17ed2..84761857a50fbc4efc25089dc24a2445fd8e7350 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java @@ -19,9 +19,9 @@ import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** - * Interface that allows to annotate {@link BioEntity elements} in the - * system. Different implementation use different resources to perform - * annotation. They can annotate different types of elements. + * Interface that allows to annotate {@link BioEntity elements} in the system. + * Different implementation use different resources to perform annotation. They + * can annotate different types of elements. * * @author Piotr Gawron * @@ -31,7 +31,7 @@ public abstract class ElementAnnotator extends CachableInterface { /** * Default class logger. */ - private final Logger logger = Logger.getLogger(ElementAnnotator.class); + private final Logger logger = Logger.getLogger(ElementAnnotator.class); /** * List of classes that can be annotated by this {@link IElementAnnotator @@ -42,7 +42,7 @@ public abstract class ElementAnnotator extends CachableInterface { /** * Should be this annotator used as a default annotator. */ - private boolean isDefault = false; + private boolean isDefault = false; /** * Default constructor. @@ -61,8 +61,7 @@ public abstract class ElementAnnotator extends CachableInterface { if (BioEntity.class.isAssignableFrom(validClass)) { addValidClass((Class<? extends BioEntity>) validClass); } else { - throw new InvalidArgumentException( - "Cannot pass class of type: " + validClass + ". Only classes extending " + BioEntity.class + " are accepted."); + throw new InvalidArgumentException("Cannot pass class of type: " + validClass + ". Only classes extending " + BioEntity.class + " are accepted."); } } this.isDefault = isDefault; @@ -193,7 +192,7 @@ public abstract class ElementAnnotator extends CachableInterface { List<String> sortedSynonyms = new ArrayList<>(); sortedSynonyms.addAll(synonyms); Collections.sort(sortedSynonyms); - + element.setSynonyms(sortedSynonyms); } else { logger.warn(prefix + "Synonyms don't match: \"" + synonyms + "\", \"" + element.getSynonyms() + "\""); @@ -227,10 +226,12 @@ public abstract class ElementAnnotator extends CachableInterface { * value to set */ protected void setDescription(BioEntity element, String description) { - if (element.getNotes() == null || element.getNotes().equals("") || element.getNotes().equals(description)) { - element.setNotes(description); - } else if (!element.getNotes().toLowerCase().contains(description.toLowerCase())) { - element.setNotes(element.getNotes() + "\n" + description); + if (description != null) { + if (element.getNotes() == null || element.getNotes().equals("") || element.getNotes().equals(description)) { + element.setNotes(description); + } else if (!element.getNotes().toLowerCase().contains(description.toLowerCase())) { + element.setNotes(element.getNotes() + "\n" + description); + } } } 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 4ac8160718ce1fe15a0f85b6cabbaed1ee1351f7..27cd669cc89e4ef80fd72248a15226dfb7a12941 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 @@ -41,7 +41,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi /** * Version of the rest API that is supported by this annotator. */ - static final String SUPPORTED_VERSION = "6.0"; + static final String SUPPORTED_VERSION = "6.1"; /** * Url address of ensembl restfull service. diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java index c740c3f3fa0e9fae5d47100b87491e9eb4935292..e4a7a7f4a1d3bcc2424bf920836d942e82385420 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java @@ -140,7 +140,7 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService { result = new Go(); } - String accessUrl = getMc().getUrlString(md) + "&format=oboxml"; + String accessUrl = "https://www.ebi.ac.uk/QuickGO-Old/GTerm?id=" + md.getResource() + "&format=oboxml"; try { String tmp = getWebPageContent(accessUrl); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java index cb0f6f29cabaf8446a498780297f37051675ab39..90b26f72ff4c3f6524a35975e7ed10abda0e9bde 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java @@ -694,6 +694,34 @@ public class ChEMBLParserTest extends AnnotationTestFunctions { } + @Test + public void testFindDrugByHgncTargetAndFilteredOutByOrganism() throws Exception { + try { + List<MiriamData> organisms = new ArrayList<>(); + organisms.add(new MiriamData(MiriamType.TAXONOMY, "-1")); + List<Drug> drugs = chemblParser.getDrugListByTarget(new MiriamData(MiriamType.HGNC_SYMBOL, "GRIN3B"), organisms); + assertNotNull(drugs); + assertEquals("No drugs for this organisms should be found", 0, drugs.size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testFindDrugByHgncTargetAndFilteredByOrganism() throws Exception { + try { + List<MiriamData> organisms = new ArrayList<>(); + organisms.add(TaxonomyBackend.HUMAN_TAXONOMY); + List<Drug> drugs = chemblParser.getDrugListByTarget(new MiriamData(MiriamType.HGNC_SYMBOL, "GRIN3B"), organisms); + assertNotNull(drugs); + assertTrue(drugs.size() > 0); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testFindDrugsByRepeatingHgncTargets() throws Exception { try { diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugAnnotationTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugAnnotationTest.java index d80c1c51c617a8802e68cd0eb1cb8b27f6925997..45ca75b80eaba935ebe495c9ddcd5ba7bb905e94 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugAnnotationTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugAnnotationTest.java @@ -2,6 +2,7 @@ package lcsb.mapviewer.annotation.services; import static org.junit.Assert.assertEquals; +import java.util.Collection; import java.util.List; import org.apache.log4j.Logger; @@ -47,7 +48,7 @@ public class DrugAnnotationTest extends AnnotationTestFunctions { } @Override - public List<Drug> getDrugListByTarget(MiriamData target) { + public List<Drug> getDrugListByTarget(MiriamData target, Collection<MiriamData> organisms) { // TODO Auto-generated method stub return null; } 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 fd9c324da1ea09802c52807d9d464f1da6af730e..92e47385e96e2b236654cd938046a279d230d407 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java @@ -92,7 +92,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { } @Test - public void test3FindDrug() throws Exception { + public void testFindRapamycin() throws Exception { try { // finding synonym Drug rapamycinDrug = drugBankHTMLParser.findDrug("Rapamycin"); @@ -100,8 +100,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { assertEquals("Sirolimus", rapamycinDrug.getName()); assertEquals("DB00877", rapamycinDrug.getSources().get(0).getResource()); assertTrue(rapamycinDrug.getBloodBrainBarrier().equalsIgnoreCase("NO")); - boolean res = rapamycinDrug.getDescription().contains( - "A macrolide compound obtained from Streptomyces hygroscopicus that acts by selectively blocking the transcriptional activation of cytokines thereby inhibiting cytokine production. It is bioactive only when bound to immunophilins. Sirolimus is a potent immunosuppressant and possesses both antifungal and antineoplastic properties. [PubChem]"); + boolean res = rapamycinDrug.getDescription().contains("A macrolide compound obtained from Streptomyces"); assertTrue(res); assertEquals(3, rapamycinDrug.getTargets().size()); @@ -197,18 +196,6 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { } } - // at some point this search threw exception - @Test - public void testFindDrugKainicAcid() throws Exception { - try { - Drug test = drugBankHTMLParser.findDrug("kainic acid"); - assertNotNull(test); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - @Test public void testFindDrugAmantadineWithBrandNames() throws Exception { try { @@ -302,6 +289,76 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { } } + @Test + public void testFindDrugByTFTarget() throws Exception { + try { + List<Drug> drugs = drugBankHTMLParser.getDrugListByTarget(new MiriamData(MiriamType.HGNC_SYMBOL, "TF")); + assertNotNull(drugs); + for (Drug drug : drugs) { + assertFalse(drug.getName().equalsIgnoreCase("Iron saccharate")); + } + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testFindAluminiumByName() throws Exception { + try { + Drug drug = drugBankHTMLParser.findDrug("Aluminium"); + assertTrue(drug.getName().equalsIgnoreCase("Aluminium")); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testFindBIIB054ByName() throws Exception { + try { + Drug drug = drugBankHTMLParser.findDrug("BIIB054"); + if (drug != null) { + // check if are not pointint to BIIB021 + assertFalse(drug.getSources().get(0).getResource().equalsIgnoreCase("DB12359")); + } + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testFindDrugByHgncTargetAndFilteredOutByOrganism() throws Exception { + try { + List<MiriamData> organisms = new ArrayList<>(); + organisms.add(new MiriamData(MiriamType.TAXONOMY, "-1")); + List<Drug> drugs = drugBankHTMLParser.getDrugListByTarget(new MiriamData(MiriamType.HGNC_SYMBOL, "NFKB2"), organisms); + assertNotNull(drugs); + assertEquals("No drugs for this organisms should be found", 0, drugs.size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testFindDrugByHgncTargetAndFilteredByOrganism() throws Exception { + try { + List<MiriamData> organisms = new ArrayList<>(); + organisms.add(TaxonomyBackend.HUMAN_TAXONOMY); + List<Drug> drugs = drugBankHTMLParser.getDrugListByTarget(new MiriamData(MiriamType.HGNC_SYMBOL, "NFKB2"), organisms); + assertNotNull(drugs); + assertTrue(drugs.size() > 0); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testFindDrugByInvalidTarget() throws Exception { try { @@ -438,12 +495,30 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { @Test public void testFindIbuprofen() throws Exception { try { - Drug test = drugBankHTMLParser.findDrug("Ibuprofen"); - assertNotNull(test); - assertEquals("Ibuprofen", test.getName()); - assertEquals("DB01050", test.getSources().get(0).getResource()); - assertNotNull(test.getDescription()); - assertEquals(8, test.getTargets().size()); + Drug drug = drugBankHTMLParser.findDrug("Ibuprofen"); + assertNotNull(drug); + assertEquals("Ibuprofen", drug.getName()); + assertEquals("DB01050", drug.getSources().get(0).getResource()); + assertNotNull(drug.getDescription()); + assertTrue(drug.getTargets().size() >= 8); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testFindIronSaccharate() throws Exception { + try { + Drug drug = drugBankHTMLParser.findDrug("Iron saccharate"); + assertNotNull(drug); + MiriamData tfProtein = new MiriamData(MiriamType.HGNC_SYMBOL, "TF"); + for (Target target : drug.getTargets()) { + for (MiriamData md : target.getGenes()) { + assertFalse("TF is a carrier, not a target", md.equals(tfProtein)); + } + } } catch (Exception e) { e.printStackTrace(); @@ -683,4 +758,13 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { assertEquals(uniprotAnnotator, parser.getUniprotAnnotator()); } + @Test + public void parseTarget() throws Exception { + String content = super.readFile("testFiles/drugbank/target-html-part.html"); + Target target = drugBankHTMLParser.parseTarget(content); + assertNotNull(target); + assertEquals(2, target.getReferences().size()); + assertEquals("Galactoside O-acetyltransferase", target.getName()); + } + } diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java index a02974da7d865847f035cc1e0541374f4a667b8d..1dac8112d686798431180401071b4f4eb5eefaf0 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java @@ -85,6 +85,14 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { assertEquals(0, getWarnings().size()); } + @Test + public void testSetEmptyDescription() { + GenericProtein species = new GenericProtein("id"); + species.setNotes("X"); + annotator.setDescription(species, null); + assertEquals("X", species.getNotes()); + } + @Test public void testSetNotMatchingIchi() { Ion species = new Ion("id"); diff --git a/annotation/testFiles/drugbank/target-html-part.html b/annotation/testFiles/drugbank/target-html-part.html new file mode 100644 index 0000000000000000000000000000000000000000..904b85d584b169214b805142c54bcfe4808355a3 --- /dev/null +++ b/annotation/testFiles/drugbank/target-html-part.html @@ -0,0 +1 @@ +</div><strong>1. <a href="/biodb/polypeptides/P07464">Galactoside O-acetyltransferase</a></strong></div><div class="panel-body"><dl class="dl-horizontal"><dt>Kind</dt><dd>Protein</dd><dt>Organism</dt><dd>Escherichia coli (strain K12)</dd><dt>Pharmacological action</dt><dd><strong class="label label-warning">unknown</strong></dd></dl><dl class="dl-horizontal"><dt>General Function:</dt><dd>Galactoside o-acetyltransferase activity</dd><dt>Specific Function:</dt><dd>May assist cellular detoxification by acetylating non-metabolizable pyranosides, thereby preventing their reentry into the cell.</dd><dt>Gene Name:</dt><dd>lacA</dd><dt>Uniprot ID:</dt><dd><a target="_blank" class="wishart-link-out" href="http://www.uniprot.org/uniprot/P07464">P07464 <span class="glyphicon glyphicon-new-window"> </span></a></dd><dt>Uniprot Name:</dt><dd>Galactoside O-acetyltransferase</dd><dt>Molecular Weight:</dt><dd>22798.89 Da</dd></dl><h5><strong>References</strong></h5><blockquote class="references"><ol class="cite-this-references"><li id="reference-A1713">Overington JP, Al-Lazikani B, Hopkins AL: How many drug targets are there? Nat Rev Drug Discov. 2006 Dec;5(12):993-6. [<a target="_blank" class="wishart-link-out" href="http://www.ncbi.nlm.nih.gov/pubmed/17139284">PubMed:17139284 <span class="glyphicon glyphicon-new-window"> </span></a>] </li><li id="reference-A1715">Imming P, Sinning C, Meyer A: Drugs, their targets and the nature and number of drug targets. Nat Rev Drug Discov. 2006 Oct;5(10):821-34. [<a target="_blank" class="wishart-link-out" href="http://www.ncbi.nlm.nih.gov/pubmed/17016423">PubMed:17016423 <span class="glyphicon glyphicon-new-window"> </span></a>] </li></ol></blockquote></div></div><div class="panel panel-default" id="BE0000574"><div class="panel-heading"><div class="pull-right"><a class="btn btn-primary btn-xs" href="/biodb/polypeptides/P04035"><span class="glyphicon glyphicon-list"> </span> Details</a> \ No newline at end of file diff --git a/commons/src/main/java/lcsb/mapviewer/common/XmlParser.java b/commons/src/main/java/lcsb/mapviewer/common/XmlParser.java index 4df8104320ccd3743bcbc57472b3bd42ccc85d28..451deb265f68c530d378655394d234e67e1cec2a 100644 --- a/commons/src/main/java/lcsb/mapviewer/common/XmlParser.java +++ b/commons/src/main/java/lcsb/mapviewer/common/XmlParser.java @@ -190,7 +190,10 @@ public class XmlParser { */ protected Document getXmlDocumentFromInputSource(final InputSource stream) throws InvalidXmlSchemaException { try { - return db.parse(stream); + synchronized (db) { // DocumentBuilder cannot parse few objects at the + // same time + return db.parse(stream); + } } catch (SAXException e) { throw new InvalidXmlSchemaException("Problem with xml parser", e); } catch (IOException e) { diff --git a/commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java b/commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java index f76dce4edb7f08ab22821bdf6633a1e4a7bff89a..f78e460818ca7672354874b712036e714d35a789 100644 --- a/commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java +++ b/commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java @@ -1,6 +1,8 @@ package lcsb.mapviewer.common.geometry; import java.awt.Color; +import java.util.HashMap; +import java.util.Map; import lcsb.mapviewer.common.exception.InvalidArgumentException; @@ -56,4 +58,17 @@ public class ColorParser { Integer.valueOf(string.substring(COLOR_SUBSTRING_START_BLUE, COLOR_STRING_LENGTH), HEX_BASE)); } } + + /** + * Converts color into list of atributes. + * + * @param color color to convert + * @return map with list of color attributes + */ + public Map<String, Object> colorToMap(Color color) { + Map<String, Object> result = new HashMap<>(); + result.put("alpha", color.getAlpha()); + result.put("rgb", color.getRGB()); + return result; + } } diff --git a/converter-CellDesigner/src/main/resources/empty.txt b/converter-CellDesigner/src/main/resources/empty.txt new file mode 100644 index 0000000000000000000000000000000000000000..e45f025b4e3a8b4af265accb372955b7774d589f --- /dev/null +++ b/converter-CellDesigner/src/main/resources/empty.txt @@ -0,0 +1 @@ +EMPTY file to force git to push the folder \ No newline at end of file diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java index 036d3b221f8cdf631b18cf7b2a5c5c09f1f50541..fcf44102362777f98200ed90612f1a7c2173dc4d 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java @@ -68,7 +68,7 @@ import lcsb.mapviewer.modelutils.map.ElementUtils; * */ public abstract class AbstractImageGenerator { - + /** * Class that allows to check if element is visible (or transparent) when * drawing. It's used to filter out invisible elements when drawing @@ -205,6 +205,8 @@ public abstract class AbstractImageGenerator { */ private Color maxColor = Color.BLACK; + private Color simpleColor = Color.BLACK; + /** * @param scale * scale to set @@ -533,6 +535,10 @@ public abstract class AbstractImageGenerator { return maxColor; } + public Color getSimpleColor() { + return simpleColor; + } + /** * Returns {@link Color} that should be used for drawing overlays with * minimum value. @@ -566,6 +572,17 @@ public abstract class AbstractImageGenerator { return this; } + /** + * @param simpleColor + * simpleColor to set + * @return object with all parameters + * @see #simpleColor + */ + public Params simpleColor(Color simpleColor) { + this.simpleColor = simpleColor; + return this; + } + /** * @return the sbgn * @see #sbgn @@ -585,6 +602,12 @@ public abstract class AbstractImageGenerator { return this; } + public Params colorExtractor(ColorExtractor colorExtractor) { + return minColor(colorExtractor.getMinColor()).// + maxColor(colorExtractor.getMaxColor()).// + simpleColor(colorExtractor.getSimpleColor()); + } + } /** @@ -653,7 +676,7 @@ public abstract class AbstractImageGenerator { this.level = params.getLevel(); this.scale = params.getScale(); - colorExtractor = new ColorExtractor(params.getMinColor(), params.getMaxColor()); + colorExtractor = new ColorExtractor(params.getMinColor(), params.getMaxColor(), params.getSimpleColor()); // set border frame extended by a margin border = new Rectangle2D.Double( diff --git a/converter-graphics/src/main/resources/empty.txt b/converter-graphics/src/main/resources/empty.txt new file mode 100644 index 0000000000000000000000000000000000000000..e45f025b4e3a8b4af265accb372955b7774d589f --- /dev/null +++ b/converter-graphics/src/main/resources/empty.txt @@ -0,0 +1 @@ +EMPTY file to force git to push the folder \ No newline at end of file diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java index 59f4964c758ef2dd761a65abd1d6196885e54d99..13aac7e4274322704c0f9a06b4f4c245a59a844d 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java @@ -26,7 +26,7 @@ public class ConverterTest { @Test public void test() { try { - ColorExtractor colorExtractor = new ColorExtractor(Color.BLUE, Color.RED); + ColorExtractor colorExtractor = new ColorExtractor(Color.BLUE, Color.RED, Color.BLUE); new BioEntityConverterImpl(new BottomSquareCompartment("id1"), colorExtractor); new BioEntityConverterImpl(new TopSquareCompartment("id2"), colorExtractor); new BioEntityConverterImpl(new LeftSquareCompartment("id3"), colorExtractor); diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImplTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImplTest.java index 206b3f332fb0d63ef640fdf71e63047a057b906b..68060ae78364070ca6f49d320a3be1e10cb31bc1 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImplTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImplTest.java @@ -27,7 +27,7 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class BioEntityConverterImplTest { - ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); + ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE); @AfterClass public static void tearDownAfterClass() throws Exception { diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java index 1bdacdc9d7ea94ec4328ca4f6305873286000a4a..3b8f0499b32142579e6ae3bd38d58823a2b4bea4 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java @@ -22,7 +22,7 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class SpeciesConverterTest { - ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); + ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE); @Before public void setUp() throws Exception { diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverterTest.java index f5f24088412eedb983923420f2cb1cac7a9f5ea6..6c54f92d23fed16523dfe9f89515ff52b7483d2b 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverterTest.java @@ -40,7 +40,7 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class ReactionConverterTest extends GraphicsTestFunctions { - ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); + ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE); @Before public void setUp() throws Exception { diff --git a/frontend-js/.settings/org.eclipse.core.resources.prefs b/frontend-js/.settings/org.eclipse.core.resources.prefs index 4c28b1a898a0f0bc507b93f8f5393d172709fe73..4824b8026319a8fb303971008a7d59a816d58bd6 100644 --- a/frontend-js/.settings/org.eclipse.core.resources.prefs +++ b/frontend-js/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,2 @@ eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 encoding/<project>=UTF-8 diff --git a/frontend-js/src/main/css/global.css b/frontend-js/src/main/css/global.css index 20ef80f885b05cda5c056edb2ab4d064f6ef5e35..727a2b54e03f78686e3312f28d23b53758f6aab9 100644 --- a/frontend-js/src/main/css/global.css +++ b/frontend-js/src/main/css/global.css @@ -137,13 +137,12 @@ border-right: 1px solid #9DE1F8; } -.legendBox { +.minerva-legend { position: absolute; bottom: 10px; right: 10px; box-shadow: 0 3px 20px #999999; border-top: 6px solid #017DA7; - padding-top: 15px; } .searchPanel { @@ -227,16 +226,6 @@ transition: all 0.4s ease-in-out 0s; } -.leftPanelClass { - display: table-cell; - position: relative; - float: left; - border: none; - background-color: #ffffff; - width: 357px; - height: 100%; -} - /* twitter typeahead */ .tt-query /* UPDATE: newer versions use tt-input instead of tt-query */ { @@ -397,4 +386,95 @@ table.minerva-window-drug-table, table.minerva-window-drug-table th, table.minerva-window-drug-table td { padding: 2px; border: 1px solid black; +} + +.minerva-left-panel { + display: table-cell; + position: relative; + float: left; + border: none; + background-color: #ffffff; + width: 357px; + height: 100%; +} + +.minerva-left-panel .minerva-help-button { + position: absolute; + top: 35px; + right: 35px; + width: 18px; +} + +.minerva-left-panel .minerva-label, .minerva-element-info-div .minerva-label + { + font-weight: 900; + line-height: 24px; +} + +.minerva-annotation-row-odd { + padding: 5px; + background-color: #EAEAEA; +} + +.minerva-annotation-row-even { + padding: 5px; + background-color: #ffffff; +} + +.minerva-overview-button { + color: #FFFFFF; + height: 36px; + line-height: 35px; + padding: 0 18px; + margin: 0; + border: none; + background-color: #017DA7; + font-size: 13px; + font-weight: 900; + border-right: 1px solid #9DE1F8; + cursor: pointer; + transition: background-color 0.4s ease-in-out 0s; +} + +.minerva-overview-button:hover { + background-color: #01536D; + transition: background-color 0.4s ease-in-out 0s; +} + +.minerva-top-checkbox-div { + height: 36px; + vertical-align: top; + font-size: 13px; + font-weight: 900; + color: #ffffff; + display: inline; + width: auto; + float: left; + text-align: left; + padding: 0 0 0 15px; + margin: 0; +} + +.minerva-top-checkbox-div label { + padding: 0 15px 0 5px; + font-size: 11px; + line-height: 35px; + display: inline; + float: left; +} + +.minerva-top-checkbox-div input { + margin-top: 12px; + display: inline; + float: left; +} + +.minerva-overlay-dialog div[style*="display: table-cell"] { + padding: 2px; + vertical-align: top; +} + +.minerva-open-submap-button { + padding: 2px; + margin: 2px; } \ No newline at end of file diff --git a/frontend-js/src/main/js/ConfigurationType.js b/frontend-js/src/main/js/ConfigurationType.js index defc30720f30b40ee06e0236b61d8fd0fe4954b5..aa792f821a083b1e4dfbb66bbb720ca43a89ff2f 100644 --- a/frontend-js/src/main/js/ConfigurationType.js +++ b/frontend-js/src/main/js/ConfigurationType.js @@ -8,6 +8,7 @@ var ConfigurationType = { LEGEND_FILES : "LEGEND_FILES", MIN_COLOR_VAL : "MIN_COLOR_VAL", MAX_COLOR_VAL : "MAX_COLOR_VAL", + SIMPLE_COLOR_VAL : "SIMPLE_COLOR_VAL", SEARCH_DISTANCE : "SEARCH_DISTANCE", USER_MANUAL_FILE : "USER_MANUAL_FILE", }; diff --git a/frontend-js/src/main/js/Functions.js b/frontend-js/src/main/js/Functions.js index 14e71695de597639a821311fe11c0355169ccb25..c2594abb1575f2dc79df84ec36093fc7b7c2b701 100644 --- a/frontend-js/src/main/js/Functions.js +++ b/frontend-js/src/main/js/Functions.js @@ -170,17 +170,23 @@ Functions.overlayToColor = function(elementOverlay) { if (elementOverlay === null || elementOverlay === undefined) { return Promise.reject("elementOverlay cannot be null!"); } else if (elementOverlay.color !== undefined && elementOverlay.color !== null) { - return Promise.resolve(self.intToColorString(elementOverlay.color.value)); - } else if (elementOverlay.value !== undefined && elementOverlay.value !== null) { + return Promise.resolve(self.intToColorString(elementOverlay.color.rgb)); + } else { var ratio = 0; var promiseColor = null; - if (elementOverlay.value < 0) { - ratio = -elementOverlay.value; - promiseColor = ServerConnector.getMinOverlayColorInt(); + if (elementOverlay.value !== undefined && elementOverlay.value !== null) { + if (elementOverlay.value < 0) { + ratio = -elementOverlay.value; + promiseColor = ServerConnector.getMinOverlayColorInt(); + } else { + ratio = elementOverlay.value; + promiseColor = ServerConnector.getMaxOverlayColorInt(); + } } else { - ratio = elementOverlay.value; - promiseColor = ServerConnector.getMaxOverlayColorInt(); + ratio = 1; + promiseColor = ServerConnector.getSimpleOverlayColorInt(); } + return promiseColor.then(function(color) { ratio = 1 - ratio; @@ -207,8 +213,6 @@ Functions.overlayToColor = function(elementOverlay) { color = red | green | blue; return self.intToColorString(color); }); - } else { - return Promise.reject("elementOverlay doesn't have neither color nor value set!"); } }; diff --git a/frontend-js/src/main/js/GuiConnector.js b/frontend-js/src/main/js/GuiConnector.js index e391ef730155f466ce161a34e66b823a4ce4cc13..e51c5b6b697fda9026ec54db304a36b194e7ae37 100644 --- a/frontend-js/src/main/js/GuiConnector.js +++ b/frontend-js/src/main/js/GuiConnector.js @@ -28,6 +28,17 @@ GuiConnector.yPos = 0; GuiConnector.init = function() { var self = this; + if (!String.prototype.endsWith) { + String.prototype.endsWith = function(pattern) { + var d = this.length - pattern.length; + return d >= 0 && this.lastIndexOf(pattern) === d; + }; + } + var isIE = /* @cc_on!@ */false || !!document.documentMode; + + if (isIE) { + alert("This webpage works well with Chrome, Firefox and Safari."); + } // bootstrap tab initialization $("ul.nav-tabs a").click(function(e) { e.preventDefault(); diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index 98798955d4ee3490de9e7670627cc097cf20089a..88b8109a4d4e84649e92eba0f963f543d44feb37 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -21,6 +21,7 @@ var InvalidCredentialsError = require('./InvalidCredentialsError'); var LayoutAlias = require('./map/data/LayoutAlias'); var LayoutData = require('./map/data/LayoutData'); var LayoutReaction = require('./map/data/LayoutReaction'); +var MapModel = require('./map/data/MapModel'); var MiRna = require('./map/data/MiRna'); var NetworkError = require('./NetworkError'); var Project = require('./map/data/Project'); @@ -62,6 +63,24 @@ ServerConnector.getMinOverlayColorInt = function() { }); }; +ServerConnector.getSimpleOverlayColorInt = function() { + var self = this; + var userColor; + return self.getLoggedUser().then(function(user) { + userColor = user.getSimpleColor(); + return self.getConfigurationParam(ConfigurationType.SIMPLE_COLOR_VAL); + }).then(function(systemSimpleColor) { + var color = userColor; + if (userColor === null || userColor === undefined || userColor === "") { + color = systemSimpleColor; + } + color = parseInt(color, 16); + /* jslint bitwise: true */ + color = (color & 0xFFFFFF); + return color; + }); +}; + ServerConnector.getMaxOverlayColorInt = function() { var self = this; var userColor; @@ -606,6 +625,23 @@ ServerConnector.getConfigurationParam = function(paramId) { }); }; +ServerConnector.getModels = function(projectId) { + var queryParams = {}; + var filterParams = {}; + var project; + var self = this; + return self.getProjectId(projectId).then(function(result) { + queryParams.projectId = result; + return self.readFile(self.getModelsUrl(queryParams, filterParams)); + }).then(function(content) { + var models = []; + var parsedJson = JSON.parse(content); + for (var i = 0; i < parsedJson.length; i++) { + models.push(new MapModel(parsedJson[i])); + } + return models; + }); +}; ServerConnector.getProject = function(projectId) { var queryParams = {}; var filterParams = {}; @@ -616,6 +652,9 @@ ServerConnector.getProject = function(projectId) { return self.readFile(self.getProjectsUrl(queryParams, filterParams)); }).then(function(content) { project = new Project(content); + return self.getModels(projectId); + }).then(function(models) { + project.setModel(models[0]); return self.getOverlays(projectId); }).then(function(overlays) { project.getModel().addLayouts(overlays); diff --git a/frontend-js/src/main/js/gui/ContextMenu.js b/frontend-js/src/main/js/gui/ContextMenu.js index 80d2ed8064b8ea7e2b6680b56392eddb2bd4485e..420598dfe77cc82dd727406192805b3fa06cdf94 100644 --- a/frontend-js/src/main/js/gui/ContextMenu.js +++ b/frontend-js/src/main/js/gui/ContextMenu.js @@ -129,7 +129,7 @@ ContextMenu.prototype.createExportAsModelSubmenu = function() { }); var submenu = new SubMenu({ element : li, - name : "Export as model", + name : "Export as map", customMap : self.getMap() }); diff --git a/frontend-js/src/main/js/gui/Panel.js b/frontend-js/src/main/js/gui/Panel.js index 01694ae6a03233188fca8f40598725b3c766f0a6..d4c85402ef7ad3016073ef23f540018e21145813 100644 --- a/frontend-js/src/main/js/gui/Panel.js +++ b/frontend-js/src/main/js/gui/Panel.js @@ -56,7 +56,7 @@ Panel.prototype.createHelpButton = function() { var self = this; var helpTipButton = Functions.createElement({ type : "button", - style : "position: absolute; top:5px; right: 5px;width:18px", + className : "minerva-help-button", content : '<span class="ui-icon ui-icon-help" style="margin-left: -0.5em;"/>', }); helpTipButton.onclick = function() { @@ -186,6 +186,10 @@ Panel.prototype.assignDialogOptions = function(div, params) { dialog.dialog('option', 'modal', params[key]); } else if (key === "buttons") { dialog.dialog('option', 'buttons', params[key]); + } else if (key === "className") { + dialog.dialog('option', 'dialogClass', params[key]); + } else if (key === "title") { + dialog.dialog('option', 'title', params[key]); } else { throw new Error("Unknown dialog param: " + key + " - " + params[key]); } @@ -215,7 +219,8 @@ Panel.prototype.openDialog = function(content, options) { close : function() { contentDiv.style.display = "none"; $(this).dialog('destroy'); - } + }, + dialogClass : options.className, }); this.assignDialogOptions(div, options); @@ -258,23 +263,26 @@ Panel.prototype.onresize = function() { // compute the width (we can only compute it for visible elements) var size = 100000; - $(".pre-scrollable", self.getElement()).each(function(index, element) { - if ($(element).is(":visible")) { - size = Math.min(size, footerPosition - $(element).offset().top); - } - }); - if ($(self.getElement()).hasClass("pre-scrollable") && $(self.getElement()).is(":visible")) { - size = Math.min(size, footerPosition - $(self.getElement()).offset().top); - } - if (size !== 100000) { + if ($(self.getElement()).is(":visible")) { + $(".pre-scrollable", self.getElement()).each(function(index, element) { - $(element).css('max-height', size); - $(element).css('height', size); + if ($(element).is(":visible")) { + size = Math.min(size, footerPosition - $(element).offset().top); + } }); - } - if ($(self.getElement()).hasClass("pre-scrollable") && $(self.getElement()).is(":visible")) { - $(self.getElement()).css('max-height', size); - $(self.getElement()).css('height', size); + if ($(self.getElement()).hasClass("pre-scrollable") && $(self.getElement()).is(":visible")) { + size = Math.min(size, footerPosition - $(self.getElement()).offset().top); + } + if (size !== 100000) { + $(".pre-scrollable", self.getElement()).each(function(index, element) { + $(element).css('max-height', size); + $(element).css('height', size); + }); + } + if ($(self.getElement()).hasClass("pre-scrollable") && $(self.getElement()).is(":visible")) { + $(self.getElement()).css('max-height', size); + $(self.getElement()).css('height', size); + } } }; diff --git a/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js b/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js index c4d88d5c80e481bde40f40bdd27c1e0207b859f3..8507144de26b29a5772c6c48cd759cd7e7e6fd60 100644 --- a/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js @@ -14,7 +14,7 @@ function AbstractPanel(params) { Panel.call(this, params); var self = this; - this._initializeGui(); + this._initializeGui(params.placeholder); this.setOverlayDb(self.getMap().getOverlayByName(params.panelName)); this._createEventHandlers(); @@ -63,7 +63,7 @@ AbstractPanel.prototype._createEventHandlers = function() { }; -AbstractPanel.prototype._initializeGui = function() { +AbstractPanel.prototype._initializeGui = function(placeholder) { var searchQueryDiv = Functions.createElement({ type : "div", name : "searchQuery", @@ -81,33 +81,38 @@ AbstractPanel.prototype._initializeGui = function() { this.setControlElement(PanelControlElementType.SEARCH_LABEL, searchLabel); var searchInputDiv = Functions.createElement({ - type : "div", - style : "display:table" + type : "table", }); searchQueryDiv.appendChild(searchInputDiv); + + var searchInputRow = Functions.createElement({ + type : "tr", + }); + searchInputDiv.appendChild(searchInputRow); + var searchInputCell = Functions.createElement({ - type : "div", - style : "display:table-cell" + type : "td", }); - searchInputDiv.appendChild(searchInputCell); + searchInputRow.appendChild(searchInputCell); var searchInput = Functions.createElement({ type : "input", name : "searchInput", className : "input-field typeahead" }); + if (placeholder !== undefined) { + searchInput.placeholder = placeholder; + } searchInputCell.appendChild(searchInput); this.setControlElement(PanelControlElementType.SEARCH_INPUT, searchInput); var searchButtonCell = Functions.createElement({ - type : "div", - style : "display:table-cell" + type : "td", }); - searchInputDiv.appendChild(searchButtonCell); + searchInputRow.appendChild(searchButtonCell); var searchButton = Functions.createElement({ type : "a", - className : "searchButton", content : '<img src="resources/images/icons/search.png"/>' }); searchButton.href = "#"; @@ -259,7 +264,9 @@ AbstractPanel.prototype.createTargetRow = function(target, icon) { iconColumn.style.verticalAlign = "middle"; iconColumn.style.textAlign = "center"; result.appendChild(iconColumn); + var submaps = []; if (target.getTargetElements().length > 0) { + var submapAddedIds = []; iconColumn.appendChild(guiUtils.createIcon(icon)); var checkbox = document.createElement('input'); checkbox.type = "checkbox"; @@ -270,6 +277,14 @@ AbstractPanel.prototype.createTargetRow = function(target, icon) { }; iconColumn.appendChild(checkbox); + var elements = target.getTargetElements(); + for (var i = 0; i < elements.length; i++) { + var elementId = elements[i].getModelId(); + if (elementId !== self.getMap().getId() && !submapAddedIds[elementId]) { + submaps.push(elementId); + submapAddedIds[elementId] = true; + } + } } var descColumn = document.createElement("td"); @@ -283,6 +298,25 @@ AbstractPanel.prototype.createTargetRow = function(target, icon) { descColumn.appendChild(guiUtils.createAnnotations("References: ", target.getReferences(), { showType : false, })); + if (submaps.length > 0) { + descColumn.appendChild(guiUtils.createLabel("Available in submaps: ")); + for (i = 0; i < submaps.length; i++) { + var model = self.getMap().getSubmapById(submaps[i]).getModel(); + var onclick = function() { + var id = model.getId(); + return function() { + self.getMap().openSubmap(id); + } + }(); + var button = Functions.createElement({ + type : "button", + className : "minerva-open-submap-button", + content : model.getName(), + onclick : onclick, + }); + descColumn.appendChild(button); + } + } return result; }; diff --git a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js index 5db01ad841b2dc1dc8f7428376b5aba98ddfb968..cf773acd3bffa346f359b3b7b75b89102a20e36d 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js @@ -15,6 +15,7 @@ function ChemicalPanel(params) { + '<p>only curated associations between genes and chemicals with direct evidence to ' + 'Parkinson Disease (<a href="http://bioportal.bioontology.org/ontologies/1351?p=terms&conceptid=D010300" target="_blank">D010300</a>) are displayed</p>' + '<p>separate multiple search by semicolon'; + params.placeholder = "full chemical name (CTD)"; AbstractDbPanel.call(this, params); diff --git a/frontend-js/src/main/js/gui/leftPanel/DrugPanel.js b/frontend-js/src/main/js/gui/leftPanel/DrugPanel.js index 20a384be921a318c8d6965ec2d7b6c351b3ebaf1..a5f84ab26d2c22976ef5b5a4b967cdd467ac7660 100644 --- a/frontend-js/src/main/js/gui/leftPanel/DrugPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/DrugPanel.js @@ -13,6 +13,8 @@ function DrugPanel(params) { params.helpTip = '<p>source: <a target="_drugbank" href="http://www.drugbank.ca/">DrugBank</a> and ' + '<a target="_drugbank" href="https://www.ebi.ac.uk/chembl/">ChEMBL</a></p>' + "<p>use of drug names, synonyms and brand names is supported<p>separate multiple search by semicolon</p>"; + params.placeholder = "drug, synonym, brand name"; + AbstractDbPanel.call(this, params); } DrugPanel.prototype = Object.create(AbstractDbPanel.prototype); diff --git a/frontend-js/src/main/js/gui/leftPanel/GenericSearchPanel.js b/frontend-js/src/main/js/gui/leftPanel/GenericSearchPanel.js index b5a417fba5aefe83e9b3d9fd9c59e26a570bd121..c14a59f39dee736b78b145184ff2235606cf9643 100644 --- a/frontend-js/src/main/js/gui/leftPanel/GenericSearchPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/GenericSearchPanel.js @@ -17,6 +17,7 @@ function GenericSearchPanel(params) { params.helpTip = "<p>search tab allows to search for particular elements or interactions in the map</p>" + "<p>perfect match tick box active: only terms with an exact match to the query will be returned</p>" + "<p>separate multiple search by semicolon</p>"; + params.placeholder = "keyword"; AbstractDbPanel.call(this, params); @@ -65,14 +66,15 @@ GenericSearchPanel.prototype.createReactionElement = function(reaction) { var td = document.createElement("td"); result.appendChild(td); - var div = guiUtils.createReactionElement(reaction); + var div = guiUtils.createReactionElement({ + reaction : reaction + }); div.appendChild(guiUtils.createSeparator()); td.appendChild(div); return result; }; - GenericSearchPanel.prototype.createAliasElement = function(alias, icon) { var self = this; var guiUtils = self.getGuiUtils(); @@ -80,7 +82,10 @@ GenericSearchPanel.prototype.createAliasElement = function(alias, icon) { var result = document.createElement("tr"); var td = document.createElement("td"); result.appendChild(td); - var div = guiUtils.createAliasElement(alias, icon); + var div = guiUtils.createAliasElement({ + alias : alias, + icon : icon + }); div.appendChild(guiUtils.createSeparator()); td.appendChild(div); diff --git a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js index f18f2b865d84e35015b5656314857b96e7ed6b29..c5c25e7d03ed6ba2d631d5eb242eaabe8ece8cfa 100644 --- a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js +++ b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js @@ -27,7 +27,7 @@ GuiUtils.prototype.getConfiguration = function() { GuiUtils.prototype.createLabel = function(value) { var result = document.createElement("span"); result.innerHTML = value; - result.className = "searchDescriptionLabel"; + result.className = "minerva-label"; return result; }; @@ -135,6 +135,8 @@ GuiUtils.prototype.createAnnotationLink = function(annotation, showType) { }; GuiUtils.prototype.createAnnotations = function(label, value, options) { + var self = this; + var inline = false; if (options !== undefined) { if (options.inline !== undefined) { @@ -142,13 +144,14 @@ GuiUtils.prototype.createAnnotations = function(label, value, options) { } } var result = document.createElement("div"); + result.appendChild(self.createLabel(label)); if (value !== undefined && value.length > 0) { - var self = this; - result.appendChild(self.createLabel(label)); if (!inline) { result.appendChild(self.createNewLine()); } result.appendChild(self.createAnnotationList(value, options)); + } else { + result.appendChild(self.createLabelText("No annotations")); } return result; }; @@ -182,9 +185,9 @@ GuiUtils.prototype.createAnnotationList = function(annotations, options) { var row = document.createElement("div"); row.style.height = "26px"; if (i % 2 === 0) { - row.className = "annotationRowOdd"; + row.className = "minerva-annotation-row-odd"; } else { - row.className = "annotationRowEven"; + row.className = "minerva-annotation-row-even"; } var header = document.createElement("div"); header.style.width = "24px"; @@ -241,7 +244,6 @@ GuiUtils.prototype.createParamLine = function(label, value) { var self = this; result.appendChild(self.createLabel(label)); result.appendChild(self.createLabelText(value)); - result.appendChild(self.createNewLine()); } return result; }; @@ -263,8 +265,7 @@ GuiUtils.prototype.createArrayParamLine = function(label, value) { if (value !== undefined && value.length > 0) { var self = this; result.appendChild(self.createLabel(label)); - result.appendChild(self.createLabelText(value.join(","))); - result.appendChild(self.createNewLine()); + result.appendChild(self.createLabelText(value.join(", "))); } return result; }; @@ -303,19 +304,25 @@ GuiUtils.prototype.createTableRow = function(elements) { return row; }; -GuiUtils.prototype.createReactionElement = function(reaction) { +GuiUtils.prototype.createReactionElement = function(params) { + var reaction = params.reaction; + var showTitle = ((params.showTitle === undefined) || params.showTitle); var self = this; var div = document.createElement("div"); - div.appendChild(self.createLabel("Reaction: " + reaction.getReactionId())); - if (reaction.getModelId() !== self.getMap().getId()) { - div.appendChild(self.createSubMapLink("In submodel: ", reaction.getModelId())); + if (showTitle) { + div.appendChild(self.createLabel("Reaction: " + reaction.getReactionId())); + if (reaction.getModelId() !== self.getMap().getId()) { + div.appendChild(self.createSubMapLink("In submodel: ", reaction.getModelId())); + } } if (reaction.getLinkedSubmodelId() !== null && reaction.getLinkedSubmodelId() !== undefined) { div.appendChild(self.createSubMapLink("Associated submodel: ", reaction.getLinkedSubmodelId())); } - div.appendChild(self.createNewLine()); + if (showTitle) { + div.appendChild(self.createNewLine()); + } div.appendChild(self.createParamLine("Type: ", reaction.getType())); div.appendChild(self.createParamLine("Symbol: ", reaction.getSymbol())); @@ -336,23 +343,29 @@ GuiUtils.prototype.createReactionElement = function(reaction) { return div; }; -GuiUtils.prototype.createAliasElement = function(alias, icon) { +GuiUtils.prototype.createAliasElement = function(params) { + var alias = params.alias; + var icon = params.icon; + var showTitle = ((params.showTitle === undefined) || params.showTitle); var self = this; var div = document.createElement("div"); - if (icon !== undefined) { - div.appendChild(this.createIcon(icon)); - } + if (showTitle) { + if (icon !== undefined) { + div.appendChild(this.createIcon(icon)); + } - div.appendChild(this.createParamLine(alias.getType() + ": ", alias.getName())); - if (alias.getModelId() !== self.getMap().getId()) { - div.appendChild(self.createSubMapLink("In submodel: ", alias.getModelId())); + div.appendChild(this.createParamLine(alias.getType() + ": ", alias.getName())); + if (alias.getModelId() !== self.getMap().getId()) { + div.appendChild(self.createSubMapLink("In submodel: ", alias.getModelId())); + } } - if (alias.getLinkedSubmodelId() !== null && alias.getLinkedSubmodelId() !== undefined) { div.appendChild(self.createSubMapLink("Associated submodel: ", alias.getLinkedSubmodelId())); } - div.appendChild(self.createNewLine(3)); + if (showTitle) { + div.appendChild(self.createNewLine(3)); + } div.appendChild(self.createParamLine("Full name: ", alias.getFullName())); div.appendChild(self.createParamLine("Symbol: ", alias.getSymbol())); diff --git a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js index 25057e24cbab79b0d7f4aeab8e6e760d37e2c549..fe553ab1f70c2fad8f51b4989e9e637f37b62b97 100644 --- a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js @@ -84,6 +84,7 @@ LeftPanel.prototype._createPanelGui = function() { name : "elementInfoDiv", type : "div", style : "background-color:#f3f3f3", + className : "minerva-element-info-div", }); self.elementInfoDiv = elementInfoDiv; @@ -187,6 +188,7 @@ LeftPanel.prototype.showElementDetails = function(element) { div.innerHTML = self.prepareElementDetailsContent(bioEntity).innerHTML; $(div).dialog("open"); $(div).dialog("option", "title", self.getElementTitle(bioEntity)); + $(div).scrollTop(0); }); } else { $(div).dialog("close"); @@ -198,9 +200,15 @@ LeftPanel.prototype.prepareElementDetailsContent = function(bioEntity) { var guiUtils = new GuiUtils(this.getMap().getConfiguration()); guiUtils.setMap(this.getMap()); if (bioEntity instanceof Reaction) { - return guiUtils.createReactionElement(bioEntity); + return guiUtils.createReactionElement({ + reaction : bioEntity, + showTitle : false, + }); } else if (bioEntity instanceof Alias) { - return guiUtils.createAliasElement(bioEntity); + return guiUtils.createAliasElement({ + alias : bioEntity, + showTitle : false, + }); } else if (bioEntity instanceof PointData) { return Functions.createElement({ type : "div" diff --git a/frontend-js/src/main/js/gui/leftPanel/MiRnaPanel.js b/frontend-js/src/main/js/gui/leftPanel/MiRnaPanel.js index ae466919fd4a3994ce538f350e53f883cc76a16a..4cc29424ce41f56ce2d4e8af922f71db85bb63e3 100644 --- a/frontend-js/src/main/js/gui/leftPanel/MiRnaPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/MiRnaPanel.js @@ -13,6 +13,7 @@ function MiRnaPanel(params) { params.helpTip = '<p>source: <a target="_mirtarbase" href="http://mirtarbase.mbc.nctu.edu.tw/">miRTarBase</a></p>' + '<p>use only mature sequence IDs according to <a target="_mirbase" href="http://www.mirbase.org">www.mirbase.org</a> (e.g., hsa-miR-125a-3p)</p>' + '<p>only targets with strong evidence as defined by miRTarBase are displayed<p>separate multiple search by semicolon</p>'; + params.placeholder = "mature seq. ID (miRTarBase)"; AbstractDbPanel.call(this, params); } MiRnaPanel.prototype = Object.create(AbstractDbPanel.prototype); diff --git a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js index 9f64f2e1b9ea1371e404cc3fac833e9a745c33fe..750b0204fbffab3b17c7259789963e037479ce4f 100644 --- a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js @@ -161,9 +161,9 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) { checkbox.checked = checked; checkbox.onclick = function() { if (this.checked) { - return self.getMap().openDataOverlay(overlay.getId()); + return self.getMap().openDataOverlay(overlay.getId()).then(null, GuiConnector.alert); } else { - return self.getMap().removeSelectedLayout(overlay.getId()); + return self.getMap().removeSelectedLayout(overlay.getId()).then(null, GuiConnector.alert); } }; viewTd.appendChild(checkbox); @@ -208,6 +208,7 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) { editTd.appendChild(editButton); result.appendChild(editTd); } + result.title = overlay.getDescription(); return result; }; @@ -215,13 +216,13 @@ OverlayPanel.prototype.openEditOverlayDialog = function(overlay) { var self = this; var guiUtils = self.getGuiUtils(); var content = document.createElement("fieldset"); - content.appendChild(guiUtils.createLabel("Name")); var nameInput = guiUtils.createInputText(overlay.getName()); - content.appendChild(nameInput); + var row = guiUtils.createTableRow([ guiUtils.createLabel("Name: "), nameInput ]); + content.appendChild(row); - content.appendChild(guiUtils.createLabel("Description")); var descriptionInput = guiUtils.createTextArea(overlay.getDescription()); - content.appendChild(descriptionInput); + row = guiUtils.createTableRow([ guiUtils.createLabel("Description: "), descriptionInput ]); + content.appendChild(row); var buttons = [ { text : "SAVE", @@ -260,6 +261,8 @@ OverlayPanel.prototype.openEditOverlayDialog = function(overlay) { self.openDialog(content, { id : overlay.getId(), buttons : buttons, + title : "Data overlay: " + overlay.getName(), + className : "minerva-overlay-dialog", }); }; @@ -282,59 +285,63 @@ OverlayPanel.prototype.refresh = function() { } return ServerConnector.getOverlays(); - }).then(function(customOverlays) { + }).then( + function(customOverlays) { - var id = self.getMap().getGoogleMap().getMapTypeId().substring(2); - selectedOverlay[id] = true; + var id = self.getMap().getGoogleMap().getMapTypeId().substring(2); + selectedOverlay[id] = true; - self.clear(); + self.clear(); - var generalOverlays = []; - var overlay; + var generalOverlays = []; + var overlay; - var overlays = self.getMap().getLayouts(); - for (var i = 0; i < overlays.length; i++) { - overlay = overlays[i]; - if (overlay.getCreator() === undefined || overlay.getCreator() === "") { - generalOverlays.push(overlay); - } - } + var overlays = self.getMap().getLayouts(); + for (var i = 0; i < overlays.length; i++) { + overlay = overlays[i]; + if (overlay.getCreator() === undefined || overlay.getCreator() === "") { + generalOverlays.push(overlay); + } + } - var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE); - table.appendChild(self.createTableHeader()); + var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE); + table.appendChild(self.createTableHeader()); - var body = document.createElement("tbody"); - table.appendChild(body); - for (i = 0; i < generalOverlays.length; i++) { - overlay = generalOverlays[i]; - body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()])); - } + var body = document.createElement("tbody"); + table.appendChild(body); + for (i = 0; i < generalOverlays.length; i++) { + overlay = generalOverlays[i]; + body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()])); + } - var title = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE); - var addButton = self.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON); - if (user.getLogin() === "anonymous") { - title.innerHTML = 'YOU ARE NOT LOGGED IN. PLEASE, <a href="#">LOG IN</a> TO UPLOAD AND VIEW CUSTOM OVERLAYS'; - $(title).find("a")[0].onclick = function() { - return self.getParent().getLoginDialog().open(); - }; - addButton.style.display = "none"; - } else { - title.innerHTML = self.getCustomOverlaysMessage(); - addButton.style.display = "block"; + var title = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE); + var addButton = self.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON); + if (user.getLogin() === "anonymous") { + title.innerHTML = 'YOU ARE NOT LOGGED IN. PLEASE, <a href="#">LOG IN</a>' + + 'TO UPLOAD AND VIEW CUSTOM OVERLAYS<br/><center><button>LOGIN</button></center>'; + var openLoginDialog = function() { + return self.getParent().getLoginDialog().open(); + }; + $(title).find("a")[0].onclick = openLoginDialog; + $(title).find("button")[0].onclick = openLoginDialog; + addButton.style.display = "none"; + } else { + title.innerHTML = self.getCustomOverlaysMessage(); + addButton.style.display = "block"; - table = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE); - table.appendChild(self.createTableHeader(true)); + table = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE); + table.appendChild(self.createTableHeader(true)); - body = document.createElement("tbody"); - table.appendChild(body); - for (i = 0; i < customOverlays.length; i++) { - overlay = customOverlays[i]; - body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()])); - } - } + body = document.createElement("tbody"); + table.appendChild(body); + for (i = 0; i < customOverlays.length; i++) { + overlay = customOverlays[i]; + body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()])); + } + } - self.onresize(); - }); + self.onresize(); + }); }; OverlayPanel.prototype.setCustomOverlaysMessage = function(customOverlaysMessage) { @@ -422,7 +429,7 @@ OverlayPanel.prototype.openAddOverlayDialog = function() { content.appendChild(fileInput); content.appendChild(guiUtils.createNewLine()); - content.appendChild(guiUtils.createLabel("Or provide list of elements here: ")); + content.appendChild(guiUtils.createLabel("Or provide list of elements here (one per line): ")); content.appendChild(guiUtils.createNewLine()); contentInput = guiUtils.createTextArea(); content.appendChild(contentInput); diff --git a/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js b/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js index 79ba6d65c87e6cae67c9ccf7b5d459cde775bbcb..391ba195a7ff15e8676951f8a6988cb737df3f14 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js @@ -228,7 +228,9 @@ ProjectInfoPanel.prototype.refresh = function() { projectNameText.innerHTML = project.getName(); projectVersionText.innerHTML = project.getVersion(); projectDescriptionText.innerHTML = project.getDescription(); - projectPublicationsText.innerHTML = project.getPublicationCount(); + return ServerConnector.getProjectStatistics(); + }).then(function(statistics) { + projectPublicationsText.innerHTML = statistics.getPublicationCount(); return ServerConnector.getLoggedUser(); }).then(function(user) { self.showUserProfilePage(user); @@ -304,7 +306,7 @@ ProjectInfoPanel.prototype._createUserDataTab = function() { type : "span", name : "emailValue" }); - this.setControlElement(PanelControlElementType.USER_TAB_EMAIL_TEXT, emailText); + self.setControlElement(PanelControlElementType.USER_TAB_EMAIL_TEXT, emailText); userDataDiv.appendChild(guiUtils.createTableRow([ emailLabel, emailText ])); var centerTag = Functions.createElement({ @@ -318,8 +320,8 @@ ProjectInfoPanel.prototype._createUserDataTab = function() { content : "LOGOUT" }); centerTag.appendChild(logoutButton); - this.setControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON, logoutButton); - this.setControlElement(PanelControlElementType.USER_TAB_USER_DIV, userDataDiv); + self.setControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON, logoutButton); + self.setControlElement(PanelControlElementType.USER_TAB_USER_DIV, userDataDiv); var loginTabDiv = Functions.createElement({ type : "div", @@ -327,10 +329,14 @@ ProjectInfoPanel.prototype._createUserDataTab = function() { className : "searchPanel", style : "display:none", content : '<h3><img src="./resources/images/profile.png" border="0" align="left"/>' - + '<br/>User data</h3><br/>YOU ARE NOT LOGGED IN.' + + '<br/>User data</h3><br/>YOU ARE NOT LOGGED IN.<br/>' + '<center><button>LOGIN</button></center>', }); - this.getElement().appendChild(loginTabDiv); - this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_DIV, loginTabDiv); + $(loginTabDiv).find("button")[0].onclick = function() { + return self.getParent().getLoginDialog().open(); + }; + + self.getElement().appendChild(loginTabDiv); + self.setControlElement(PanelControlElementType.USER_TAB_LOGIN_DIV, loginTabDiv); }; diff --git a/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js b/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js index 6cd57ed65f59b57d3a21bb05bf08b2a7c788c275..82882484556107073d65cc8dafe744b8654ae00b 100644 --- a/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js +++ b/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js @@ -64,51 +64,62 @@ PublicationListDialog.prototype._dataTableAjaxCall = function(data, callback) { sortColumn : self.getColumnsDefinition()[data.order[0].column].name, sortOrder : data.order[0].dir, search : data.search.value, - }) - .then( - function(publicationList) { - var out = []; - var allElements = []; - for (var i = 0; i < publicationList.data.length; i++) { - var publication = publicationList.data[i].publication.article; - var elements = publicationList.data[i].elements; - - var row = []; - row[0] = "<a href='" + publication.link + "'>" + publication.id + "</a>"; - row[1] = publication.title; - row[2] = publication.authors.join(); - row[3] = publication.journal; - row[4] = publication.year; - row[5] = "<div>"; - for (var j = 0; j < elements.length; j++) { - row[5] += "<a name='" + elements[j].id + "' href='#'>" + elements[j].type + ":" + elements[j].id - + "</a>, "; - allElements.push(new IdentifiedElement(elements[j])); - } - row[5] += "</div>"; - out.push(row); - } - callback({ - draw : data.draw, - recordsTotal : publicationList.totalSize, - recordsFiltered : publicationList.filteredSize, - data : out, - }); - var promises = []; - allElements.forEach(function(element) { - promises.push(self.getMap().getSubmapById(element.getModelId()).getModel().getByIdentifiedElement( - element, true).then(function(elementData) { - var name = null; - if (elementData instanceof Alias) { - name = elementData.getName(); - } else if (elementData instanceof Reaction) { - name = elementData.getReactionId(); - } - $("a[name=" + elementData.getId() + "]", $(self.getElement())).html(name); - })); - }); - return Promise.all(promises); - }); + }).then(function(publicationList) { + var out = []; + var allElements = []; + for (var i = 0; i < publicationList.data.length; i++) { + var publication = publicationList.data[i].publication.article; + var elements = publicationList.data[i].elements; + + var row = []; + row[0] = "<a href='" + publication.link + "'>" + publication.id + "</a>"; + row[1] = publication.title; + row[2] = publication.authors.join(); + row[3] = publication.journal; + row[4] = publication.year; + row[5] = "<div>"; + for (var j = 0; j < elements.length; j++) { + row[5] += "<a name='" + elements[j].id + "' href='#'>" + elements[j].type + ":" + elements[j].id + "</a>, "; + allElements.push(new IdentifiedElement(elements[j])); + } + row[5] += "</div>"; + out.push(row); + } + callback({ + draw : data.draw, + recordsTotal : publicationList.totalSize, + recordsFiltered : publicationList.filteredSize, + data : out, + }); + var promises = []; + allElements.forEach(function(element) { + var model = self.getMap().getSubmapById(element.getModelId()).getModel(); + promises.push(model.getByIdentifiedElement(element, true).then(function(elementData) { + var name = null; + if (elementData instanceof Alias) { + name = elementData.getName(); + } else if (elementData instanceof Reaction) { + name = elementData.getReactionId(); + } + $("a[name=" + elementData.getId() + "]", $(self.getElement())).html(name); + var onclick = function() { + var searchOverlay = self.getMap().getOverlayByName("search"); + var query; + if (element.getType() === "ALIAS") { + query = "element:" + element.getId(); + } else { + query = "reaction:" + element.getId(); + } + self.getMap().openSubmap(elementData.getModelId()); + return searchOverlay.searchByQuery(query, true, true).then(function() { + $(self.getElement()).dialog("close"); + }).then(null, GuiConnector.alert); + } + $("a[name=" + elementData.getId() + "]", $(self.getElement())).click(onclick); + })); + }); + return Promise.all(promises); + }); }; PublicationListDialog.prototype.show = function() { diff --git a/frontend-js/src/main/js/gui/leftPanel/SearchPanel.js b/frontend-js/src/main/js/gui/leftPanel/SearchPanel.js index 2c6dd1d01175c4334b09e38afff3694948794be5..fd9775099dc73153100940b9447cbe81b7036017 100644 --- a/frontend-js/src/main/js/gui/leftPanel/SearchPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/SearchPanel.js @@ -4,7 +4,7 @@ var Promise = require("bluebird"); /* exported logger */ -var AbstractGuiElement = require('../AbstractGuiElement'); +var Panel = require('../Panel'); var ChemicalPanel = require('./ChemicalPanel'); var DrugPanel = require('./DrugPanel'); var MiRnaPanel = require('./MiRnaPanel'); @@ -14,7 +14,8 @@ var Functions = require('../../Functions'); var logger = require('../../logger'); function SearchPanel(params) { - AbstractGuiElement.call(this, params); + params.panelName = "global-search"; + Panel.call(this, params); var self = this; this._tabIdCount = 0; @@ -24,7 +25,7 @@ function SearchPanel(params) { } -SearchPanel.prototype = Object.create(AbstractGuiElement.prototype); +SearchPanel.prototype = Object.create(Panel.prototype); SearchPanel.prototype.constructor = SearchPanel; SearchPanel.prototype._createPanelGui = function() { diff --git a/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js b/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js index c2d97a382de1e6442537821301fc4eb7f49f6bbd..2cc077f69fd8abf2e46f9c7ff7f9b4576981d163 100644 --- a/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js @@ -46,13 +46,14 @@ SubmapPanel.prototype.createRow = function(model) { var openTd = document.createElement("td"); if (model.getId() !== self.getMap().getId()) { - var button = document.createElement("button"); var img = guiUtils.createIcon("icons/search.png"); - button.appendChild(img); - button.onclick = function() { + var link = document.createElement("a"); + link.href = "#"; + link.onclick = function() { self.getMap().openSubmap(model.getId()); }; - openTd.appendChild(button); + link.appendChild(img); + openTd.appendChild(link); } result.appendChild(openTd); @@ -69,9 +70,11 @@ SubmapPanel.prototype.createTableHeader = function() { nameTd.innerHTML = "Name"; row.appendChild(nameTd); - var viewTd = document.createElement("th"); - viewTd.innerHTML = "View"; - row.appendChild(viewTd); + row.appendChild(Functions.createElement({ + type : "th", + style : "width: 60px;", + content : "View" + })); result.appendChild(row); return result; @@ -125,10 +128,14 @@ SubmapPanel.prototype.createTable = function(models, type) { result.appendChild(table); table.appendChild(self.createTableHeader()); + var tableBody = Functions.createElement({ + type : "tbody", + }); + table.appendChild(tableBody); + for (var i = 0; i < models.length; i++) { - table.appendChild(self.createRow(models[i])); + tableBody.appendChild(self.createRow(models[i])); } - return result; }; diff --git a/frontend-js/src/main/js/gui/topMenu/TopMenu.js b/frontend-js/src/main/js/gui/topMenu/TopMenu.js index af684e2a404a5b4a4fd22333096a77e8261e91ad..cd80bd94f685681a1b457fa460fef4e6ebeeb845 100644 --- a/frontend-js/src/main/js/gui/topMenu/TopMenu.js +++ b/frontend-js/src/main/js/gui/topMenu/TopMenu.js @@ -69,9 +69,9 @@ TopMenu.prototype._createGui = function() { var showOverviewButton = Functions.createElement({ type : "button", - className : "overview_button", + className : "minerva-overview-button", name : "showOverviewButton", - content : "<i class='fa fa-sitemap' style='font-size:18px; font-weight:400; padding-right:10px;'/>SHOW OVERVIEW", + content : "<i class='fa fa-sitemap' style='font-size:18px; font-weight:400; padding-right:10px;'></i><span >SHOW OVERVIEW</span>", style : "display:none", }); showOverviewDiv.appendChild(showOverviewButton); @@ -85,7 +85,7 @@ TopMenu.prototype._createGui = function() { var div4checkboxes = Functions.createElement({ type : "div", - className : "div4checkboxes", + className : "minerva-top-checkbox-div", }); rightHeaderMenuDiv.appendChild(div4checkboxes); @@ -117,7 +117,7 @@ TopMenu.prototype._createGui = function() { var refreshCommentButton = Functions.createElement({ type : "button", - className : "overview_button", + className : "minerva-overview-button", name : "refreshCommentButton", content : "<i class='fa fa-refresh' style='font-size:21px; font-weight:400;'></i>", style : "display:none", @@ -127,7 +127,7 @@ TopMenu.prototype._createGui = function() { var clearButton = Functions.createElement({ type : "button", - className : "overview_button", + className : "minerva-overview-button", name : "clearButton", content : "<i class='fa fa-times' style='font-size:18px; font-weight:300; padding-right:10px;'></i>CLEAR", }); diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js index b2af8d23694c21c81f4677e476285575e75434b1..10cc77ed9362755a3ff84256833118259b58f1df 100644 --- a/frontend-js/src/main/js/map/AbstractCustomMap.js +++ b/frontend-js/src/main/js/map/AbstractCustomMap.js @@ -604,7 +604,7 @@ AbstractCustomMap.prototype._showSelectedLayout = function(layoutId, index, leng startX : startX, endX : endX, onClick : [ function() { - return self._openInfoWindowForIdentifiedElement(element, surface.getGoogleMarker()); + return self._openInfoWindowForAlias(aliasData, surface.getGoogleMarker()); }, function() { return self.getTopMap().callListeners("onBioEntityClick", element); } ] @@ -625,7 +625,7 @@ AbstractCustomMap.prototype._showSelectedLayout = function(layoutId, index, leng reaction : reactionData, map : self, onClick : [ function() { - return self._openInfoWindowForIdentifiedElement(element, surface.getGoogleMarker()); + return self._openInfoWindowForReaction(reactionData, surface.getGoogleMarker()); }, function() { return self.getTopMap().callListeners("onBioEntityClick", element); } ], @@ -673,7 +673,7 @@ AbstractCustomMap.prototype._openInfoWindowForAlias = function(alias, googleMark var infoWindow = this.getAliasInfoWindowById(alias.getId()); if (infoWindow !== null && infoWindow !== undefined) { if (!infoWindow.isOpened()) { - infoWindow.open(); + infoWindow.open(googleMarker); } else { logger.warn("Info window for alias: " + alias.getId() + " is already opened"); } @@ -731,28 +731,6 @@ AbstractCustomMap.prototype._refreshInfoWindows = function() { return Promise.all(promises); }; -/** - * Opens {@link AbstractInfoWindow} for a marker. - * - * @param marker - * marker for which we are opening window - */ -AbstractCustomMap.prototype._openInfoWindowForIdentifiedElement = function(element, googleMarker) { - var self = this; - if (element.getType() === "ALIAS") { - return self.getModel().getByIdentifiedElement(element).then(function(alias) { - return self._openInfoWindowForAlias(alias, googleMarker); - }); - } else if (element.getType() === "POINT") { - return self._openInfoWindowForPoint(new PointData(element), googleMarker); - } else if (element.getType() === "REACTION") { - return self.getModel().getByIdentifiedElement(element).then(function(reaction) { - return self._openInfoWindowForReaction(reaction, googleMarker); - }); - } else { - throw new Error("Unknown element type: " + element.getType()); - } -}; /** * Opens {@link ReactionInfoWindow} for given reaction identifier. @@ -765,7 +743,7 @@ AbstractCustomMap.prototype._openInfoWindowForReaction = function(reaction, goog var self = this; if (infoWindow !== null && infoWindow !== undefined) { if (!infoWindow.isOpened()) { - infoWindow.open(); + infoWindow.open(googleMarker); } else { logger.warn("Info window for reaction: " + reaction.getId() + " is already opened"); } @@ -791,7 +769,7 @@ AbstractCustomMap.prototype._openInfoWindowForPoint = function(pointData, google var infoWindow = this.getPointInfoWindowById(pointData.getId()); if (infoWindow !== null && infoWindow !== undefined) { if (!infoWindow.isOpened()) { - infoWindow.open(); + infoWindow.open(googleMarker); } else { logger.warn("Info window for point: " + pointData.getId() + " is already opened"); } diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index 0e01282e60f3618470eb463fc29119c3b838e3fc..0ad9cc8620eaeeb7886d310f8cc178f3ceb9571d 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -16,6 +16,7 @@ var ControlType = require('./ControlType'); var CustomMapOptions = require('./CustomMapOptions'); var IdentifiedElement = require('./data/IdentifiedElement'); var LayoutData = require('./data/LayoutData'); +var PointData = require('./data/PointData'); var PointMarker = require('./marker/PointMarker'); var Reaction = require('./data/Reaction'); var ReactionMarker = require('./marker/ReactionMarker'); @@ -1316,4 +1317,28 @@ CustomMap.prototype.createSurfaceForDbOverlay = function(element, dbOverlay) { } }; +/** + * Opens {@link AbstractInfoWindow} for a marker. + * + * @param marker + * marker for which we are opening window + */ +CustomMap.prototype._openInfoWindowForIdentifiedElement = function(element, googleMarker) { + var self = this; + var submap = self.getSubmapById(element.getModelId()); + if (element.getType() === "ALIAS") { + return submap.getModel().getByIdentifiedElement(element).then(function(alias) { + return submap._openInfoWindowForAlias(alias, googleMarker); + }); + } else if (element.getType() === "POINT") { + return submap._openInfoWindowForPoint(new PointData(element), googleMarker); + } else if (element.getType() === "REACTION") { + return submap.getModel().getByIdentifiedElement(element).then(function(reaction) { + return submap._openInfoWindowForReaction(reaction, googleMarker); + }); + } else { + throw new Error("Unknown element type: " + element.getType()); + } +}; + module.exports = CustomMap; diff --git a/frontend-js/src/main/js/map/Submap.js b/frontend-js/src/main/js/map/Submap.js index 0a5e1df5d5930dad25aea669ba06cee9ad347c41..ea36bbea10d201196e5516b7b2abf9a66e7d5607 100644 --- a/frontend-js/src/main/js/map/Submap.js +++ b/frontend-js/src/main/js/map/Submap.js @@ -1,5 +1,7 @@ "use strict"; +/* exported logger */ + var logger = require('../logger'); var AbstractCustomMap = require('./AbstractCustomMap'); var CustomMapOptions = require('./CustomMapOptions'); @@ -62,11 +64,18 @@ Submap.prototype.open = function(htmlTag) { mapDiv.style.height = "100%"; contentDiv.appendChild(mapDiv); - $(self.htmlTag).dialog("open"); - $(self.htmlTag).dialog('option', 'title', self.getModel().getName()); + $(self.htmlTag).dialog({ + title : self.getModel().getName(), + width : Math.floor(window.innerWidth * 2 / 3), + height : Math.floor(window.innerHeight * 2 / 3), + position : { + my : "center", + at : "center", + of : $(self.getTopMap().getElement()), + }, + }); - $(self.htmlTag).dialog("option", "width", Math.floor(window.innerWidth * 2 / 3)); - $(self.htmlTag).dialog("option", "height", Math.floor(window.innerHeight * 2 / 3)); + $(self.htmlTag).dialog("open"); self.setGoogleMap(new google.maps.Map(mapDiv, mapOptions)); self._createMapChangedCallbacks(); @@ -99,7 +108,6 @@ Submap.prototype.open = function(htmlTag) { self.initialized = true; } else { $(self.htmlTag).dialog("open"); - } }; @@ -110,26 +118,6 @@ Submap.prototype.openDataOverlay = function(identifier) { } }; -Submap.prototype.loadSubmapConfiguration = function() { - var self = this; - var onConfigurationReload = function() { - var submodelFound = false; - for (var i = 0; i < self.getTopMap().configuration.SUBMODELS.length && (!submodelFound); i++) { - if (self.getTopMap().configuration.SUBMODELS[i].getId() === self.getId()) { - self.configuration = self.getTopMap().configuration.SUBMODELS[i]; - submodelFound = true; - } - } - if (!submodelFound) { - throw "Cannot find configuration for submodel " + self.getId(); - } - logger.debug("Submodel config reloaded: " + self.getId()); - }; - - onConfigurationReload(); - this.getTopMap().configuration.addListener("onreload", onConfigurationReload); -}; - Submap.prototype.getTopMap = function() { return this.getCustomMap(); }; diff --git a/frontend-js/src/main/js/map/data/Project.js b/frontend-js/src/main/js/map/data/Project.js index 8abcdd1b5265bc3c8432ce6b75c092cc4cdeb505..85c8b64da14a8553eceaf4cf340c7ba1c023a057 100644 --- a/frontend-js/src/main/js/map/data/Project.js +++ b/frontend-js/src/main/js/map/data/Project.js @@ -5,6 +5,8 @@ var ObjectWithListeners = require('../../ObjectWithListeners'); var Annotation = require("./Annotation"); var Model = require('./MapModel'); +var logger = require('../../logger'); + function Project(data) { // call super constructor ObjectWithListeners.call(this); @@ -53,8 +55,6 @@ Project.prototype.loadFromData = function(data) { this.setOrganism(data.organism); this.setPublicationCount(data.publicationCount); - this.setModel(new Model(data.map)); - this.callListeners("onreload"); } }; diff --git a/frontend-js/src/main/js/map/data/ProjectStatistics.js b/frontend-js/src/main/js/map/data/ProjectStatistics.js index d905df46d6122a4f7b4b30f4360a90da862f0bba..e30fe8b0cbb34f7021b6e3fabec5dd60cc5bda45 100644 --- a/frontend-js/src/main/js/map/data/ProjectStatistics.js +++ b/frontend-js/src/main/js/map/data/ProjectStatistics.js @@ -12,6 +12,7 @@ function ProjectStatistics(data, configuration) { this.setReactionAnnotations(data.reactionAnnotations, configuration); this.setElementAnnotations(data.elementAnnotations, configuration); + this.setPublicationCount(data.publications, configuration); } ProjectStatistics.prototype = Object.create(ObjectWithListeners.prototype); @@ -49,4 +50,11 @@ ProjectStatistics.prototype.getElementAnnotations = function() { return this._elementAnnotations; }; +ProjectStatistics.prototype.setPublicationCount = function(count) { + this._publicationsCount = count; +}; +ProjectStatistics.prototype.getPublicationCount = function() { + return this._publicationsCount; +}; + module.exports = ProjectStatistics; diff --git a/frontend-js/src/main/js/map/data/User.js b/frontend-js/src/main/js/map/data/User.js index 48398247f9155faaaee8a27c86a6e1ded54e4ed3..cd41f7d7f9760ec82f889fe2618259a19fc1c792 100644 --- a/frontend-js/src/main/js/map/data/User.js +++ b/frontend-js/src/main/js/map/data/User.js @@ -13,6 +13,7 @@ function User(javaObject) { this.setPrivileges(javaObject.privileges); this.setMinColor(javaObject.minColor); this.setMaxColor(javaObject.maxColor); + this.setSimpleColor(javaObject.simpleColor); } User.prototype.setLogin = function(login) { @@ -63,6 +64,14 @@ User.prototype.getMinColor = function() { return this._minColor; }; +User.prototype.setSimpleColor = function(simpleColor) { + this._simpleColor = simpleColor; +}; + +User.prototype.getSimpleColor = function() { + return this._simpleColor; +}; + User.prototype.setMaxColor = function(maxColor) { this._maxColor = maxColor; }; diff --git a/frontend-js/src/main/js/map/overlay/AbstractTargettingDbOverlay.js b/frontend-js/src/main/js/map/overlay/AbstractTargettingDbOverlay.js index 219bb87a6a290c07eb508c4df0a181bf132db807..bea8fbcd5f13470f77968f373a273b9cf7818a32 100644 --- a/frontend-js/src/main/js/map/overlay/AbstractTargettingDbOverlay.js +++ b/frontend-js/src/main/js/map/overlay/AbstractTargettingDbOverlay.js @@ -131,6 +131,7 @@ AbstractTargettingDbOverlay.prototype.getDetailDataByIdentifiedElement = functio }); } else { return new Promise(function(resolve) { + var drugNames = []; var result = []; var queries = self.getQueries(); for (var i = 0; i < queries.length; i++) { @@ -144,8 +145,9 @@ AbstractTargettingDbOverlay.prototype.getDetailDataByIdentifiedElement = functio for (var k = 0; k < targets.length; k++) { var elements = targets[k].getTargetElements(); for (var l = 0; l < elements.length; l++) { - if (element.equals(elements[l])) { + if (element.equals(elements[l]) && drugNames[drug.getName()] === undefined) { result.push(drug); + drugNames[drug.getName()] = true; } } } diff --git a/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js b/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js index 4a8d7b2b58163fef9b6d66e2d86e1f80a379e5a6..d657fd6bceeb294d0f01cd2440652bce567ba8d7 100644 --- a/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js +++ b/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js @@ -15,6 +15,9 @@ function AbstractOverlayElement(params) { self.registerListenerType("onClick"); self.setCustomMap(params.map); + if (params.element !== undefined && params.element !== null) { + self.setIdentifiedElement(params.element); + } self._googleMapObjects = []; if (params.onClick !== undefined) { @@ -42,7 +45,7 @@ AbstractOverlayElement.prototype.getBounds = function() { for (var i = 0; i < this.getGoogleMapObjects().length; i++) { bounds.extend(this.getGoogleMapObjects()[i].getBounds().getSouthWest()); bounds.extend(this.getGoogleMapObjects()[i].getBounds().getNorthEast()); - } + } return bounds; }; @@ -96,6 +99,10 @@ AbstractOverlayElement.prototype.getIdentifiedElement = function() { return this._identifiedElement; }; +AbstractOverlayElement.prototype.getModelId = function() { + return this.getIdentifiedElement().getModelId(); +}; + AbstractOverlayElement.prototype.updateIdentifiedElement = function(identifiedElement) { if (identifiedElement.getColor() !== undefined) { this.setColor(identifiedElement.getColor()); @@ -106,6 +113,18 @@ AbstractOverlayElement.prototype.setIdentifiedElement = function(identifiedEleme this._identifiedElement = identifiedElement; }; +AbstractOverlayElement.prototype.getBounds = function() { + var self = this; + var bounds = new google.maps.LatLngBounds(); + for (var i = 0; i < self.getGoogleMapObjects().length; i++) { + var elementBounds = self.getGoogleMapObjects()[i].getBounds(); + bounds.extend(elementBounds.getNorthEast()); + bounds.extend(elementBounds.getSouthWest()); + } + + return bounds; +}; + /** * Returns {@link AbstractCustomMap} where surface is located. * diff --git a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js index c20b3693b97aae709a9af3502508464d1e1163d8..e807019a6f9036c35e5b01b0f11f8e609005d31d 100644 --- a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js +++ b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js @@ -1,5 +1,7 @@ "use strict"; +var Promise = require("bluebird"); + var logger = require('../../logger'); var Functions = require('../../Functions'); @@ -32,19 +34,17 @@ function AbstractInfoWindow(params) { var onOverlayFullViewChanged = function(e) { var self = e.object; // first change the content of the element - return self.update().then( - function() { - if (e.newVal) { - var element = new IdentifiedElement({ - objectId : self.getElementId(), - modelId : self.getCustomMap().getId(), - type : self.getElementType() - }); - - return self.getCustomMap().getTopMap().retrieveOverlayDetailDataForElement(element, - self.getOverlayFullViewArray()); - } + return self.update().then(function() { + if (e.newVal) { + var element = new IdentifiedElement({ + objectId : self.getElementId(), + modelId : self.getCustomMap().getId(), + type : self.getElementType() }); + var topMap = self.getCustomMap().getTopMap(); + return topMap.retrieveOverlayDetailDataForElement(element, self.getOverlayFullViewArray()); + } + }); }; @@ -121,12 +121,15 @@ AbstractInfoWindow.prototype.isOpened = function() { /** * Opens Info Window. */ -AbstractInfoWindow.prototype.open = function() { +AbstractInfoWindow.prototype.open = function(newMarker) { var self = this; if (self.googleInfowindow === null) { logger.warn("Cannot open window."); return; } + if (newMarker !== undefined) { + self.setGoogleMarker(newMarker); + } self.googleInfowindow.open(self.getCustomMap().getGoogleMap(), self.getGoogleMarker()); return self.update().then(function() { @@ -222,7 +225,11 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function(overlay, data) { * @returns {String} with a div for drug overlay information */ AbstractInfoWindow.prototype._createDrugInfoDiv = function(overlay, data) { - return this._createTargetInfoDiv(overlay, data, "Interacting drugs"); + return this._createTargetInfoDiv({ + overlay : overlay, + data : data, + name : "Interacting drugs" + }); }; /** @@ -408,7 +415,11 @@ AbstractInfoWindow.prototype.update = function() { return this._updateContent(); }; -AbstractInfoWindow.prototype._createTargetInfoDiv = function(overlay, data, name) { +AbstractInfoWindow.prototype._createTargetInfoDiv = function(params) { + var overlay = params.overlay; + var data = params.data; + var name = params.name; + var self = this; var result = document.createElement("div"); @@ -472,6 +483,11 @@ AbstractInfoWindow.prototype._createTableForTargetDiv = function(data, overlay) table.appendChild(header); var row; + var onclick = function() { + // ';' enforces single query (in case there are ',' characters in the name) + return overlay.searchByQuery(this.innerHTML + ";"); + }; + var count = 0; for ( var searchId in data) { if (data.hasOwnProperty(searchId)) { @@ -491,10 +507,18 @@ AbstractInfoWindow.prototype._createTableForTargetDiv = function(data, overlay) } } } - row.appendChild(Functions.createElement({ + var link = Functions.createElement({ + type : "a", + onclick : onclick, + href : "#", + content : nameContent, + }); + + var nameTd = Functions.createElement({ type : "td", - content : nameContent - })); + }); + nameTd.appendChild(link); + row.appendChild(nameTd); var referencesCell = Functions.createElement({ type : "td", @@ -550,7 +574,11 @@ AbstractInfoWindow.prototype.getGuiUtils = function() { * @returns DOM element with a div for comment overlay information */ AbstractInfoWindow.prototype._createChemicalInfoDiv = function(overlay, data) { - return this._createTargetInfoDiv(overlay, data, "Interacting chemicals"); + return this._createTargetInfoDiv({ + overlay : overlay, + data : data, + name : "Interacting chemicals", + }); }; /** @@ -561,7 +589,11 @@ AbstractInfoWindow.prototype._createChemicalInfoDiv = function(overlay, data) { * @returns DOM element with a div for comment overlay information */ AbstractInfoWindow.prototype._createMiRnaInfoDiv = function(overlay, data) { - return this._createTargetInfoDiv(overlay, data, "Interacting Micro RNAs"); + return this._createTargetInfoDiv({ + overlay : overlay, + data : data, + name : "Interacting Micro RNAs" + }); }; /** diff --git a/frontend-js/src/main/js/minerva.js b/frontend-js/src/main/js/minerva.js index 94de429a75952adccd697d6c1bf4222f05d9c99c..f84281272aa732bf0a147b5856f517e54f7e5425 100644 --- a/frontend-js/src/main/js/minerva.js +++ b/frontend-js/src/main/js/minerva.js @@ -84,7 +84,7 @@ function createDivStructure(element) { var leftPanelDiv = functions.createElement({ type : "div", name : "leftPanelDiv", - className : "leftPanelClass", + className : "minerva-left-panel", }); element.appendChild(leftPanelDiv); var rightPanelDiv = functions.createElement({ @@ -116,7 +116,7 @@ function createDivStructure(element) { var legendDiv = functions.createElement({ type : "div", name : "legendDiv", - className : "legendBox", + className : "minerva-legend", style : "display:none", }); rightPanelContainerDiv.appendChild(legendDiv); diff --git a/frontend-js/src/test/js/Export-test.js b/frontend-js/src/test/js/Export-test.js index b58d6fca71246a0c0a62557156cf296066c4e244..f3ca1655401c87e20568d97e6619e4ca7afcfcf9 100644 --- a/frontend-js/src/test/js/Export-test.js +++ b/frontend-js/src/test/js/Export-test.js @@ -1,6 +1,7 @@ "use strict"; /* exported logger */ +/* exported assert */ var Export = require('../../main/js/Export'); var logger = require('./logger'); diff --git a/frontend-js/src/test/js/Functions-test.js b/frontend-js/src/test/js/Functions-test.js index 9595bf326be87b4c7f0e38f96f486ccd0a68cf7f..7951eb34d46a18abd620131c1aa744acc1faae8a 100644 --- a/frontend-js/src/test/js/Functions-test.js +++ b/frontend-js/src/test/js/Functions-test.js @@ -200,9 +200,7 @@ describe('functions', function() { it('overlayToColor with invalid arg 2', function() { return functions.overlayToColor({}).then(function(colorString) { - throw new Error('Promise was unexpectedly fulfilled. Result: ' + colorString); - }, function rejected(error) { - assert.ok(error.indexOf("elementOverlay doesn't have neither color nor value set") >= 0); + assert.ok(colorString); }); }); diff --git a/frontend-js/src/test/js/ServerConnector-test.js b/frontend-js/src/test/js/ServerConnector-test.js index cb575f3384c06e952ffdc550afeecff86a8a2011..730bca8fa4bf409b466d4fc8e62d3f2e90c18eac 100644 --- a/frontend-js/src/test/js/ServerConnector-test.js +++ b/frontend-js/src/test/js/ServerConnector-test.js @@ -2,11 +2,14 @@ require("./mocha-config.js"); +var Promise = require("bluebird"); + var HttpStatus = require('http-status-codes'); var Alias = require('../../main/js/map/data/Alias'); var Configuration = require('../../main/js/Configuration'); var LayoutAlias = require('../../main/js/map/data/LayoutAlias'); +var MapModel = require('../../main/js/map/data/MapModel'); var NetworkError = require('../../main/js/NetworkError'); var Project = require('../../main/js/map/data/Project'); var Reaction = require('../../main/js/map/data/Reaction'); @@ -32,6 +35,13 @@ describe('ServerConnector', function() { }); }); + it('getModels', function() { + return ServerConnector.getModels("sample").then(function(models) { + assert.equal(1, models.length); + assert.ok(models[0] instanceof MapModel); + }); + }); + it('getPublications', function() { return ServerConnector.getPublications().then(function(result) { assert.equal(result.totalSize, 1); diff --git a/frontend-js/src/test/js/google-map-mock.js b/frontend-js/src/test/js/google-map-mock.js index 82a07a1d2c995d455b0eeaa5db90bb80e00cd332..9db90a0a3a54e0ad45053aa394fcd35148c1086f 100644 --- a/frontend-js/src/test/js/google-map-mock.js +++ b/frontend-js/src/test/js/google-map-mock.js @@ -80,29 +80,32 @@ var google = { getNorthEast : function() { return data.ne; }, + getCenter : function() { + return new google.maps.LatLng((data.ne.lat() + data.sw.lat()) / 2, (data.ne.lng() + data.sw.lng()) / 2); + }, isEmpty : function() { - return ne === sw || (data.ne.lat() === sw.lat() && data.ne.lng() === sw.lng()); + return data.ne === data.sw || (data.ne.lat() === data.sw.lat() && data.ne.lng() === data.sw.lng()); }, extend : function(arg) { if (data.sw === undefined) { - data.sw = arg; + data.sw = new google.maps.LatLng(arg.lat(), arg.lng()); } else { if (arg.lng() < data.sw.lng()) { data.sw.longitude = arg.lng(); } if (arg.lat() < data.sw.lat()) { - data.sw.longitude = arg.lng(); + data.sw.latitude = arg.lat(); } } if (data.ne === undefined) { - data.ne = arg; + data.ne = new google.maps.LatLng(arg.lat(), arg.lng()); } else { if (arg.lng() > data.ne.lng()) { data.ne.longitude = arg.lng(); } if (arg.lat() > data.ne.lat()) { - data.ne.longitude = arg.lng(); + data.ne.latitude = arg.lat(); } } }, @@ -206,6 +209,7 @@ var google = { }, fitBounds : function(bounds) { this.setBounds(bounds); + this.setCenter(bounds.getCenter()); }, }; }, diff --git a/frontend-js/src/test/js/gui/OverviewDialog-test.js b/frontend-js/src/test/js/gui/OverviewDialog-test.js index f38ec2696df1b51fd8ef8380b736ced13285ad12..02fd8ab3ae0fc51989d32cce3beb388b34976e03 100644 --- a/frontend-js/src/test/js/gui/OverviewDialog-test.js +++ b/frontend-js/src/test/js/gui/OverviewDialog-test.js @@ -15,8 +15,8 @@ var logger = require('../logger'); describe('OverviewDialog', function() { it('open image', function() { - return ServerConnector.readFile("testFiles/projectWithImages.json").then(function(fileContent) { - var project = new Project(JSON.parse(fileContent)); + helper.setUrl("http://test/?id=complex_model_with_images"); + return ServerConnector.getProject().then(function(project) { var options = helper.createOptions(project); var map = new CustomMap(options); @@ -31,8 +31,8 @@ describe('OverviewDialog', function() { }); it('open invalid image', function() { - return ServerConnector.readFile("testFiles/projectWithImages.json").then(function(fileContent) { - var project = new Project(JSON.parse(fileContent)); + helper.setUrl("http://test/?id=complex_model_with_images"); + return ServerConnector.getProject().then(function(project) { var options = helper.createOptions(project); var map = new CustomMap(options); @@ -48,8 +48,8 @@ describe('OverviewDialog', function() { describe('openLink', function() { it('link to map', function() { - return ServerConnector.readFile("testFiles/projectWithImages.json").then(function(fileContent) { - var project = new Project(JSON.parse(fileContent)); + helper.setUrl("http://test/?id=complex_model_with_images"); + return ServerConnector.getProject().then(function(project) { var options = helper.createOptions(project); var map = new CustomMap(options); diff --git a/frontend-js/src/test/js/gui/leftPanel/AbstractPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/AbstractPanel-test.js index 75d5339b0557fa02c03926b295f6047a3a7cfc67..75339099c76ac7063ab79982aaf18916154a4af4 100644 --- a/frontend-js/src/test/js/gui/leftPanel/AbstractPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/AbstractPanel-test.js @@ -31,26 +31,36 @@ describe('AbstractDbPanel', function() { describe('createTargetRow', function() { it('target with elements', function() { var div = document.createElement("div"); - var map = helper.createCustomMap(); - map.registerDbOverlay(helper.createSearchDbOverlay(map)); + helper.setUrl("http://test/?id=complex_model_with_submaps"); + var map; - var panel = new AbstractDbPanel({ - element : div, - customMap : map, - panelName : "search", - }); + return ServerConnector.getProject().then(function(project) { + map = helper.createCustomMap(project); + map.registerDbOverlay(helper.createSearchDbOverlay(map)); + + var panel = new AbstractDbPanel({ + element : div, + customMap : map, + panelName : "search", + }); - var target = new Target({ - targetElements : [ { - id : 329168, - modelId : 15781, - type : "ALIAS" - } ], - references : [], - targetParticipants : [], + var target = new Target({ + targetElements : [ { + id : 345337, + modelId : 16731, + type : "ALIAS" + }, { + id : 345338, + modelId : 16731, + type : "ALIAS" + } ], + references : [], + targetParticipants : [], + }); + var htmlTag = panel.createTargetRow(target, "empty.png"); + assert.ok(htmlTag); + assert.equal(1, $(".minerva-open-submap-button", $(htmlTag)).length) }); - var htmlTag = panel.createTargetRow(target, "empty.png"); - assert.ok(htmlTag); }); }); }); 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 0b096d11d03720499b37f0a277fe2d4430b16b41..c57e0c966530bbb71dca0fb2d9a65e65eccdf773 100644 --- a/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js @@ -48,7 +48,9 @@ describe('GuiUtils', function() { var guiUtils = new GuiUtils(); guiUtils.setMap(map); - var aliasDiv = guiUtils.createAliasElement(alias); + var aliasDiv = guiUtils.createAliasElement({ + alias : alias + }); assert.ok(aliasDiv.innerHTML); }); @@ -61,7 +63,7 @@ describe('GuiUtils', function() { var res = guiUtils.createLabelText(); assert.notOk(res.innerHTML); }); - + it('createSubMapLink', function() { var map = helper.createCustomMap(); @@ -71,7 +73,6 @@ describe('GuiUtils', function() { var res = guiUtils.createSubMapLink("TEST", map.getId()); assert.ok(res.innerHTML); }); - it('createPostTranslationalModifications', function() { var alias = helper.createAlias(); @@ -104,12 +105,14 @@ describe('GuiUtils', function() { var guiUtils = new GuiUtils(); guiUtils.setMap(map); - + var reaction = helper.createReaction(map); var reactionType = "XX TYPE"; reaction.setType(reactionType); - assert.ok(guiUtils.createReactionElement(reaction).innerHTML.indexOf(reactionType) >= 0); + assert.ok(guiUtils.createReactionElement({ + reaction : reaction + }).innerHTML.indexOf(reactionType) >= 0); }); }); @@ -123,10 +126,14 @@ describe('GuiUtils', function() { var alias = helper.createAlias(map); alias.setFullName("xxx"); - assert.ok(guiUtils.createAliasElement(alias).innerHTML.indexOf("Full name") >= 0); + assert.ok(guiUtils.createAliasElement({ + alias : alias + }).innerHTML.indexOf("Full name") >= 0); alias.setFullName(""); - assert.ok(guiUtils.createAliasElement(alias).innerHTML.indexOf("Full name") === -1); + assert.ok(guiUtils.createAliasElement({ + alias : alias + }).innerHTML.indexOf("Full name") === -1); }); }); diff --git a/frontend-js/src/test/js/map/AbstractCustomMap-test.js b/frontend-js/src/test/js/map/AbstractCustomMap-test.js index 9cb8fd652fe4cf8fae027a151c54f4972e2ce6d9..178bbea0fa09cf46f300e4e2efce9a3a2637a043 100644 --- a/frontend-js/src/test/js/map/AbstractCustomMap-test.js +++ b/frontend-js/src/test/js/map/AbstractCustomMap-test.js @@ -3,6 +3,7 @@ var Promise = require("bluebird"); var AliasMarker = require('../../../main/js/map/marker/AliasMarker'); +var AliasSurface = require('../../../main/js/map/surface/AliasSurface'); var AbstractCustomMap = require('../../../main/js/map/AbstractCustomMap'); var PointData = require('../../../main/js/map/data/PointData'); var PointMarker = require('../../../main/js/map/marker/PointMarker'); @@ -281,83 +282,6 @@ describe('AbstractCustomMap', function() { }); - describe("_openInfoWindowForIdentifiedElement", function() { - it("for AliasMarker", function() { - var map; - var alias, marker; - return ServerConnector.getProject().then(function(project) { - map = helper.createCustomMap(project); - return map.getModel().getAliasById(329171); - }).then(function(result) { - alias = result; - - var identifiedElement = new IdentifiedElement(alias); - identifiedElement.setIcon("empty.png"); - - marker = new AliasMarker({ - element : identifiedElement, - map : map - }); - - return marker.init(); - }).then(function() { - assert.equal(null, map.getAliasInfoWindowById(alias.getId())); - return map._openInfoWindowForIdentifiedElement(marker).then(function() { - assert.ok(map.getAliasInfoWindowById(alias.getId())); - }); - }); - - }); - it("for ReactionMarker", function() { - var map; - var reaction, marker; - return ServerConnector.getProject().then(function(project) { - map = helper.createCustomMap(project); - return map.getModel().getReactionById(153510); - }).then(function(result) { - reaction = result; - - marker = new ReactionMarker({ - element : new IdentifiedElement(reaction), - map : map - }); - return marker.init(); - }).then(function() { - assert.equal(null, map.getReactionInfoWindowById(reaction.getId())); - return map._openInfoWindowForIdentifiedElement(marker); - }).then(function() { - assert.ok(map.getReactionInfoWindowById(reaction.getId())); - }); - - }); - it("for PointMarker", function() { - - var mockObject = helper.createAbstractCustomMap(); - - mockObject.getTopMap = function() { - return mockObject; - }; - mockObject.getOverlayDataForPoint = function() { - return Promise.resolve([]); - }; - - var point = new google.maps.Point(2, 3.45); - var pointData = new PointData(point, 15781); - - var pointMarker = new PointMarker({ - element : new IdentifiedElement(pointData), - map : mockObject - }); - - return pointMarker.init().then(function() { - assert.equal(null, mockObject.getPointInfoWindowById(pointData.getId())); - return mockObject._openInfoWindowForIdentifiedElement(pointMarker.getIdentifiedElement()); - }).then(function() { - assert.ok(mockObject.getPointInfoWindowById(pointData.getId())); - }); - }); - }); - it("_openInfoWindowForReaction", function() { var mockObject = helper.createAbstractCustomMap(); @@ -387,4 +311,31 @@ describe('AbstractCustomMap', function() { assert.ok(map.isDebug()); }); + it("fitBounds", function() { + var map = helper.createCustomMap(); + var alias = helper.createAlias(map); + var ie = new IdentifiedElement(alias); + var marker = new AliasMarker({ + map : map, + element : ie + }); + var surface = new AliasSurface({ + map : map, + element : ie, + gmapObj : new google.maps.Rectangle({ + map : map.getGoogleMap(), + bounds : new google.maps.LatLngBounds(new google.maps.LatLng(0, 0), new google.maps.LatLng(0.5, 1)), + }) + }); + + var markers = [ marker, surface ]; + return marker.init().then(function() { + + var center = map.getGoogleMap().getCenter(); + map.fitBounds(markers); + var center2 = map.getGoogleMap().getCenter(); + assert.ok(center.lat() !== center2.lat() || center.lng() !== center2.lng()); + }) + }); + }); diff --git a/frontend-js/src/test/js/map/CustomMap-test.js b/frontend-js/src/test/js/map/CustomMap-test.js index 3f2bbadec5fa92d7d7bc588ee50ea60fed2193d2..3c434c3198f62fb471c0981e85acc049982341f4 100644 --- a/frontend-js/src/test/js/map/CustomMap-test.js +++ b/frontend-js/src/test/js/map/CustomMap-test.js @@ -4,11 +4,15 @@ var Promise = require("bluebird"); require("../mocha-config.js"); +var AliasMarker = require('../../../main/js/map/marker/AliasMarker'); var AliasSurface = require('../../../main/js/map/surface/AliasSurface'); var Comment = require('../../../main/js/map/data/Comment'); var CustomMap = require('../../../main/js/map/CustomMap'); var IdentifiedElement = require('../../../main/js/map/data/IdentifiedElement'); var MapContextMenu = require('../../../main/js/gui/MapContextMenu'); +var PointData = require('../../../main/js/map/data/PointData'); +var PointMarker = require('../../../main/js/map/marker/PointMarker'); +var ReactionMarker = require('../../../main/js/map/marker/ReactionMarker'); var ReactionSurface = require('../../../main/js/map/surface/ReactionSurface'); var SelectionContextMenu = require('../../../main/js/gui/SelectionContextMenu'); @@ -900,4 +904,78 @@ describe('CustomMap', function() { }); + describe("_openInfoWindowForIdentifiedElement", function() { + it("for AliasMarker", function() { + var map; + var alias, marker; + return ServerConnector.getProject().then(function(project) { + map = helper.createCustomMap(project); + return map.getModel().getAliasById(329171); + }).then(function(result) { + alias = result; + + var identifiedElement = new IdentifiedElement(alias); + identifiedElement.setIcon("empty.png"); + + marker = new AliasMarker({ + element : identifiedElement, + map : map + }); + + return marker.init(); + }).then(function() { + assert.equal(null, map.getAliasInfoWindowById(alias.getId())); + return map._openInfoWindowForIdentifiedElement(marker).then(function() { + assert.ok(map.getAliasInfoWindowById(alias.getId())); + }); + }); + + }); + it("for ReactionMarker", function() { + var map; + var reaction, marker; + return ServerConnector.getProject().then(function(project) { + map = helper.createCustomMap(project); + return map.getModel().getReactionById(153510); + }).then(function(result) { + reaction = result; + + marker = new ReactionMarker({ + element : new IdentifiedElement(reaction), + map : map + }); + return marker.init(); + }).then(function() { + assert.equal(null, map.getReactionInfoWindowById(reaction.getId())); + return map._openInfoWindowForIdentifiedElement(marker); + }).then(function() { + assert.ok(map.getReactionInfoWindowById(reaction.getId())); + }); + + }); + it("for PointMarker", function() { + + var mockObject = helper.createCustomMap(); + + mockObject.getOverlayDataForPoint = function() { + return Promise.resolve([]); + }; + + var point = new google.maps.Point(2, 3.45); + var pointData = new PointData(point, mockObject.getId()); + + var pointMarker = new PointMarker({ + element : new IdentifiedElement(pointData), + map : mockObject + }); + + return pointMarker.init().then(function() { + assert.equal(null, mockObject.getPointInfoWindowById(pointData.getId())); + return mockObject._openInfoWindowForIdentifiedElement(pointMarker.getIdentifiedElement()); + }).then(function() { + assert.ok(mockObject.getPointInfoWindowById(pointData.getId())); + }); + }); + }); + }); diff --git a/frontend-js/src/test/js/map/data/Project-test.js b/frontend-js/src/test/js/map/data/Project-test.js index 169244b48a1131b378b33f36307fc6e0fd9efd62..e2857d6e12091c92a1132fc01f45f5e7cbf5881b 100644 --- a/frontend-js/src/test/js/map/data/Project-test.js +++ b/frontend-js/src/test/js/map/data/Project-test.js @@ -8,70 +8,38 @@ var chai = require('chai'); var assert = chai.assert; describe('Project', function() { - it("contructor", function() { - return ServerConnector.readFile("testFiles/project.json").then(function(res) { - var project = new Project(res); - assert.ok(project); - - assert.equal(project.getVersion(), "0"); - assert.equal(project.getId(), 14898); - assert.equal(project.getName(), "UNKNOWN DISEASE MAP"); - assert.equal(project.getProjectId(), "sample"); - assert.equal(project.getDescription(), ""); - assert.deepEqual(project.getOverviewImages(), []); - - var model = project.getModel(); - assert.equal(model.getName(), "UNKNOWN DISEASE MAP2"); - assert.equal(model.getId(), 15781); - assert.equal(model.getTileSize(), 256); - assert.equal(model.getWidth(), 1305); - assert.equal(model.getHeight(), 473); - assert.equal(model.getMinZoom(), 2); - assert.equal(model.getMaxZoom(), 5); - assert.equal(model.getLayoutsData().length, 3); - - assert.equal(model.getCenterLatLng().lat(), 79.18277721779353); - assert.equal(model.getCenterLatLng().lng(), -135.06093781915757); - assert.equal(model.getTopLeftLatLng().lat(), 85.05112877980659); - assert.equal(model.getTopLeftLatLng().lng(), -180.0); - assert.equal(model.getBottomRightLatLng().lat(), 81.26928406550978); - assert.equal(model.getBottomRightLatLng().lng(), -90.0); - - assert.equal(logger.getWarnings().length, 0); + describe("constructor", function() { + it("default", function() { + return ServerConnector.readFile("testFiles/apiCalls/projects/sample/token=MOCK_TOKEN_ID&").then(function(res) { + var project = new Project(res); + assert.ok(project); + + assert.equal(project.getVersion(), "0"); + assert.equal(project.getId(), 14898); + assert.equal(project.getName(), "UNKNOWN DISEASE MAP"); + assert.equal(project.getProjectId(), "sample"); + assert.equal(project.getDescription(), ""); + assert.deepEqual(project.getOverviewImages(), []); + + assert.equal(logger.getWarnings().length, 0); + }); }); - }); - it("contructor from Project obj", function() { - return ServerConnector.readFile("testFiles/project.json").then(function(res) { - var tmpProject = new Project(res); - - var project = new Project(tmpProject); - assert.ok(project); - - assert.equal(project.getVersion(), "0"); - assert.equal(project.getId(), 14898); - assert.equal(project.getName(), "UNKNOWN DISEASE MAP"); - assert.equal(project.getProjectId(), "sample"); - assert.equal(project.getDescription(), ""); - assert.deepEqual(project.getOverviewImages(), []); - - var model = project.getModel(); - assert.equal(model.getName(), "UNKNOWN DISEASE MAP2"); - assert.equal(model.getId(), 15781); - assert.equal(model.getTileSize(), 256); - assert.equal(model.getWidth(), 1305); - assert.equal(model.getHeight(), 473); - assert.equal(model.getMinZoom(), 2); - assert.equal(model.getMaxZoom(), 5); - assert.equal(model.getLayoutsData().length, 3); - - assert.equal(model.getCenterLatLng().lat(), 79.18277721779353); - assert.equal(model.getCenterLatLng().lng(), -135.06093781915757); - assert.equal(model.getTopLeftLatLng().lat(), 85.05112877980659); - assert.equal(model.getTopLeftLatLng().lng(), -180.0); - assert.equal(model.getBottomRightLatLng().lat(), 81.26928406550978); - assert.equal(model.getBottomRightLatLng().lng(), -90.0); - - assert.equal(logger.getWarnings().length, 0); + it("from Project obj", function() { + return ServerConnector.readFile("testFiles/apiCalls/projects/sample/token=MOCK_TOKEN_ID&").then(function(res) { + var tmpProject = new Project(res); + + var project = new Project(tmpProject); + assert.ok(project); + + assert.equal(project.getVersion(), "0"); + assert.equal(project.getId(), 14898); + assert.equal(project.getName(), "UNKNOWN DISEASE MAP"); + assert.equal(project.getProjectId(), "sample"); + assert.equal(project.getDescription(), ""); + assert.deepEqual(project.getOverviewImages(), []); + + assert.equal(logger.getWarnings().length, 0); + }); }); }); }); diff --git a/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js b/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js index afea449132adc624f75f1540bfeed7d844da90b9..8559d76ad1ff18fff31471ed623829383214dd22 100644 --- a/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js +++ b/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js @@ -125,6 +125,32 @@ describe('AliasInfoWindow', function() { }); }); + it("createChemicalOverlayInfoDiv", function() { + var map, ie, aliasWindow, oc; + return ServerConnector.getProject().then(function(project) { + map = helper.createCustomMap(project); + + oc = helper.createChemicalDbOverlay(map); + + ie = new IdentifiedElement({ + id : 329170, + modelId : map.getId(), + type : "ALIAS" + }); + + return map.getModel().getByIdentifiedElement(ie, true); + }).then(function(alias) { + aliasWindow = new AliasInfoWindow({ + alias : alias, + map : map + }); + return oc.getDetailDataByIdentifiedElement(ie, true); + }).then(function(data) { + var overlayDiv = aliasWindow.createOverlayInfoDiv(oc, data); + assert.ok(functions.isDomElement(overlayDiv)); + }); + }); + it("createCommentOverlayInfoDiv", function() { var map = helper.createCustomMap(); diff --git a/frontend-js/src/test/js/minerva-test.js b/frontend-js/src/test/js/minerva-test.js index 9425790ab9708720eff2d41940ace5093fffc956..6d989ae49367d46f79e121cd6197df6d322d0d2f 100644 --- a/frontend-js/src/test/js/minerva-test.js +++ b/frontend-js/src/test/js/minerva-test.js @@ -55,8 +55,8 @@ describe('minerva global', function() { }); it('create with overview', function() { - return ServerConnectorMock.readFile("testFiles/projectWithImages.json").then(function(fileContent) { - var project = new Project(JSON.parse(fileContent)); + helper.setUrl("http://test/?id=complex_model_with_images"); + return ServerConnectorMock.getProject().then(function(project) { var options = helper.createOptions(project); return minerva.create(options); diff --git a/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/models/all/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/models/all/token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..f71a795beacd84a38018bf292dc4d7906885f882 --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/models/all/token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +[{"version":null,"name":"main","idObject":19397,"tileSize":256,"width":495,"height":357,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":17987,"modelId":19397,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":17988,"modelId":19397,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":17989,"modelId":19397,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty0","creator":"","inputDataAvailable":"false"}],"submodels":[{"version":null,"name":"s3","idObject":19399,"tileSize":256,"width":421,"height":315,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":17978,"modelId":19399,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested3","creator":"","inputDataAvailable":"false"},{"idObject":17979,"modelId":19399,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal3","creator":"","inputDataAvailable":"false"},{"idObject":17980,"modelId":19399,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty3","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19139766235872,"lng":-135.10688836104512},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.06362505154212,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s2","idObject":19400,"tileSize":256,"width":451,"height":253,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":17984,"modelId":19400,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested2","creator":"","inputDataAvailable":"false"},{"idObject":17985,"modelId":19400,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal2","creator":"","inputDataAvailable":"false"},{"idObject":17986,"modelId":19400,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty2","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19006423440219,"lng":-135.09977827050997},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":78.0903352323621,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s1","idObject":19398,"tileSize":256,"width":571,"height":276,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":17981,"modelId":19398,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested1","creator":"","inputDataAvailable":"false"},{"idObject":17982,"modelId":19398,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal1","creator":"","inputDataAvailable":"false"},{"idObject":17983,"modelId":19398,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty1","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.18613072613702,"lng":-135.07880910683014},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":79.44906929997262,"lng":-90.0},"submodelType":"PATHWAY"}],"centerLatLng":{"lat":79.18840067864828,"lng":-135.0909090909091},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.71754541589858,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s3","idObject":19399,"tileSize":256,"width":421,"height":315,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":17978,"modelId":19399,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested3","creator":"","inputDataAvailable":"false"},{"idObject":17979,"modelId":19399,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal3","creator":"","inputDataAvailable":"false"},{"idObject":17980,"modelId":19399,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty3","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19139766235872,"lng":-135.10688836104512},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.06362505154212,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s2","idObject":19400,"tileSize":256,"width":451,"height":253,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":17984,"modelId":19400,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested2","creator":"","inputDataAvailable":"false"},{"idObject":17985,"modelId":19400,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal2","creator":"","inputDataAvailable":"false"},{"idObject":17986,"modelId":19400,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty2","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19006423440219,"lng":-135.09977827050997},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":78.0903352323621,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s1","idObject":19398,"tileSize":256,"width":571,"height":276,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":17981,"modelId":19398,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested1","creator":"","inputDataAvailable":"false"},{"idObject":17982,"modelId":19398,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal1","creator":"","inputDataAvailable":"false"},{"idObject":17983,"modelId":19398,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty1","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.18613072613702,"lng":-135.07880910683014},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":79.44906929997262,"lng":-90.0},"submodelType":"UNKNOWN"}] \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/statistics/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/statistics/token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..0e57e7d5d1106a9458b581f9737c13c30df655a7 --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/statistics/token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +{"reactionAnnotations":{"UNKNOWN":0,"MI_R_BASE_SEQUENCE":0,"WORM_BASE":0,"COG":0,"HGNC":0,"MIR_TAR_BASE_MATURE_SEQUENCE":0,"CHEBI":0,"DRUGBANK_TARGET_V4":0,"KEGG_ORTHOLOGY":0,"KEGG_COMPOUND":0,"PUBMED":0,"PHARM":0,"CAS":0,"REFSEQ":0,"WIKIPATHWAYS":0,"UNIPROT_ISOFORM":0,"OMIM":0,"UNIGENE":0,"TOXICOGENOMIC_CHEMICAL":0,"MESH_2012":0,"WIKIPEDIA":0,"HGNC_SYMBOL":0,"ENTREZ":0,"MI_R_BASE_MATURE_SEQUENCE":0,"CHEMBL_COMPOUND":0,"MGD":0,"PANTHER":0,"GO":0,"UNIPROT":0,"SGD":0,"WIKIDATA":0,"CCDS":0,"PUBCHEM":0,"EC":0,"HMDB":0,"INTERPRO":0,"DRUGBANK":0,"KEGG_PATHWAY":0,"TAXONOMY":0,"ENSEMBL_PLANTS":0,"TAIR_LOCUS":0,"KEGG_GENES":0,"REACTOME":0,"ENSEMBL":0,"KEGG_REACTION":0,"PUBCHEM_SUBSTANCE":0,"CHEMSPIDER":0,"PFAM":0,"CHEMBL_TARGET":0},"elementAnnotations":{"UNKNOWN":0,"MI_R_BASE_SEQUENCE":0,"WORM_BASE":0,"COG":0,"HGNC":0,"MIR_TAR_BASE_MATURE_SEQUENCE":0,"CHEBI":0,"DRUGBANK_TARGET_V4":0,"KEGG_ORTHOLOGY":0,"KEGG_COMPOUND":0,"PUBMED":0,"PHARM":0,"CAS":0,"REFSEQ":0,"WIKIPATHWAYS":0,"UNIPROT_ISOFORM":0,"OMIM":0,"UNIGENE":0,"TOXICOGENOMIC_CHEMICAL":0,"MESH_2012":0,"WIKIPEDIA":0,"HGNC_SYMBOL":0,"ENTREZ":0,"MI_R_BASE_MATURE_SEQUENCE":0,"CHEMBL_COMPOUND":0,"MGD":0,"PANTHER":0,"GO":0,"UNIPROT":0,"SGD":0,"WIKIDATA":0,"CCDS":0,"PUBCHEM":0,"EC":0,"HMDB":0,"INTERPRO":0,"DRUGBANK":0,"KEGG_PATHWAY":0,"TAXONOMY":0,"ENSEMBL_PLANTS":0,"TAIR_LOCUS":0,"KEGG_GENES":0,"REACTOME":0,"ENSEMBL":0,"KEGG_REACTION":0,"PUBCHEM_SUBSTANCE":0,"CHEMSPIDER":0,"PFAM":0,"CHEMBL_TARGET":0},"publications":0} \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/token=MOCK_TOKEN_ID& index e8518f0cb3b6d40abeee366be090671826e24444..9693fbe4938f164fba86283f3d950368e5bfc432 100644 --- a/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/token=MOCK_TOKEN_ID& +++ b/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/token=MOCK_TOKEN_ID& @@ -1 +1 @@ -{"version":"0","disease":null,"organism":null,"idObject":18115,"name":"UNKNOWN DISEASE MAP","projectId":"complex_model_with_images","description":"","map":{"version":null,"name":"main","idObject":19397,"tileSize":256,"width":495,"height":357,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":17987,"modelId":19397,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":17988,"modelId":19397,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":17989,"modelId":19397,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty0","creator":"","inputDataAvailable":"false"}],"submodels":[{"version":null,"name":"s3","idObject":19399,"tileSize":256,"width":421,"height":315,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":17978,"modelId":19399,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested3","creator":"","inputDataAvailable":"false"},{"idObject":17979,"modelId":19399,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal3","creator":"","inputDataAvailable":"false"},{"idObject":17980,"modelId":19399,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty3","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19139766235872,"lng":-135.10688836104512},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.06362505154212,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s2","idObject":19400,"tileSize":256,"width":451,"height":253,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":17984,"modelId":19400,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested2","creator":"","inputDataAvailable":"false"},{"idObject":17985,"modelId":19400,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal2","creator":"","inputDataAvailable":"false"},{"idObject":17986,"modelId":19400,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty2","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19006423440219,"lng":-135.09977827050997},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":78.0903352323621,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s1","idObject":19398,"tileSize":256,"width":571,"height":276,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":17981,"modelId":19398,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested1","creator":"","inputDataAvailable":"false"},{"idObject":17982,"modelId":19398,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal1","creator":"","inputDataAvailable":"false"},{"idObject":17983,"modelId":19398,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty1","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.18613072613702,"lng":-135.07880910683014},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":79.44906929997262,"lng":-90.0},"submodelType":"PATHWAY"}],"centerLatLng":{"lat":79.18840067864828,"lng":-135.0909090909091},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.71754541589858,"lng":-90.0},"submodelType":"UNKNOWN"},"publicationCount":0,"overviewImageViews":[{"idObject":1261,"filename":"fbdbe43de73fe38f62889b89cb863adb/sub_image.png","width":963,"height":639,"links":[{"idObject":2369,"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":1,"latLng":{"lat":84.89177465079632,"lng":-161.8181818181818},"modelLinkId":19397,"imageLinkId":null,"query":null,"type":"OverviewModelLink"}]},{"idObject":1262,"filename":"fbdbe43de73fe38f62889b89cb863adb/test.png","width":963,"height":639,"links":[{"idObject":2370,"polygon":[{"x":10.0,"y":10.0},{"x":100.0,"y":10.0},{"x":100.0,"y":100.0},{"x":10.0,"y":100.0}],"zoomLevel":null,"latLng":null,"modelLinkId":null,"imageLinkId":1261,"query":null,"type":"OverviewImageLink"},{"idObject":2371,"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":0,"latLng":{"lat":84.89177465079632,"lng":-178.1818181818182},"modelLinkId":19397,"imageLinkId":null,"query":null,"type":"OverviewModelLink"}]}],"topOverviewImage":{"idObject":1262,"filename":"fbdbe43de73fe38f62889b89cb863adb/test.png","width":963,"height":639,"links":[{"idObject":2370,"polygon":[{"x":10.0,"y":10.0},{"x":100.0,"y":10.0},{"x":100.0,"y":100.0},{"x":10.0,"y":100.0}],"zoomLevel":null,"latLng":null,"modelLinkId":null,"imageLinkId":1261,"query":null,"type":"OverviewImageLink"},{"idObject":2371,"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":0,"latLng":{"lat":84.89177465079632,"lng":-178.1818181818182},"modelLinkId":19397,"imageLinkId":null,"query":null,"type":"OverviewModelLink"}]}} \ No newline at end of file +{"version":"0","disease":null,"organism":null,"idObject":18115,"name":"UNKNOWN DISEASE MAP","projectId":"complex_model_with_images","description":"","overviewImageViews":[{"idObject":1261,"filename":"fbdbe43de73fe38f62889b89cb863adb/sub_image.png","width":963,"height":639,"links":[{"idObject":2369,"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":1,"latLng":{"lat":84.89177465079632,"lng":-161.8181818181818},"modelLinkId":19397,"imageLinkId":null,"query":null,"type":"OverviewModelLink"}]},{"idObject":1262,"filename":"fbdbe43de73fe38f62889b89cb863adb/test.png","width":963,"height":639,"links":[{"idObject":2370,"polygon":[{"x":10.0,"y":10.0},{"x":100.0,"y":10.0},{"x":100.0,"y":100.0},{"x":10.0,"y":100.0}],"zoomLevel":null,"latLng":null,"modelLinkId":null,"imageLinkId":1261,"query":null,"type":"OverviewImageLink"},{"idObject":2371,"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":0,"latLng":{"lat":84.89177465079632,"lng":-178.1818181818182},"modelLinkId":19397,"imageLinkId":null,"query":null,"type":"OverviewModelLink"}]}],"topOverviewImage":{"idObject":1262,"filename":"fbdbe43de73fe38f62889b89cb863adb/test.png","width":963,"height":639,"links":[{"idObject":2370,"polygon":[{"x":10.0,"y":10.0},{"x":100.0,"y":10.0},{"x":100.0,"y":100.0},{"x":10.0,"y":100.0}],"zoomLevel":null,"latLng":null,"modelLinkId":null,"imageLinkId":1261,"query":null,"type":"OverviewImageLink"},{"idObject":2371,"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":0,"latLng":{"lat":84.89177465079632,"lng":-178.1818181818182},"modelLinkId":19397,"imageLinkId":null,"query":null,"type":"OverviewModelLink"}]}} \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..19fa38ecdf18b5a74896e1113d84f726663b9f9b --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/models/all/token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +[{"version":null,"name":"main","idObject":16728,"tileSize":256,"width":515,"height":362,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":14959,"modelId":16728,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":14960,"modelId":16728,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":14961,"modelId":16728,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty0","creator":"","inputDataAvailable":"false"},{"idObject":18083,"modelId":16728,"name":"C:\\fakepath\\a.txt","description":"","status":"OK","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/.18083","creator":"","inputDataAvailable":"true"}],"submodels":[{"version":null,"name":"s1","idObject":16729,"tileSize":256,"width":571,"height":276,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":14953,"modelId":16729,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested3","creator":"","inputDataAvailable":"false"},{"idObject":14954,"modelId":16729,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal3","creator":"","inputDataAvailable":"false"},{"idObject":14955,"modelId":16729,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty3","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.18613072613702,"lng":-135.07880910683014},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":79.44906929997262,"lng":-90.0},"submodelType":"PATHWAY"},{"version":null,"name":"s2","idObject":16731,"tileSize":256,"width":451,"height":253,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":14956,"modelId":16731,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested1","creator":"","inputDataAvailable":"false"},{"idObject":14957,"modelId":16731,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal1","creator":"","inputDataAvailable":"false"},{"idObject":14958,"modelId":16731,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty1","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19006423440219,"lng":-135.09977827050997},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":78.0903352323621,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s3","idObject":16730,"tileSize":256,"width":421,"height":315,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":14950,"modelId":16730,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested2","creator":"","inputDataAvailable":"false"},{"idObject":14951,"modelId":16730,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal2","creator":"","inputDataAvailable":"false"},{"idObject":14952,"modelId":16730,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty2","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19139766235872,"lng":-135.10688836104512},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.06362505154212,"lng":-90.0},"submodelType":"UNKNOWN"}],"centerLatLng":{"lat":79.18773841616675,"lng":-135.0873786407767},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":75.1456787592211,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s1","idObject":16729,"tileSize":256,"width":571,"height":276,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":14953,"modelId":16729,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested3","creator":"","inputDataAvailable":"false"},{"idObject":14954,"modelId":16729,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal3","creator":"","inputDataAvailable":"false"},{"idObject":14955,"modelId":16729,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty3","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.18613072613702,"lng":-135.07880910683014},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":79.44906929997262,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s2","idObject":16731,"tileSize":256,"width":451,"height":253,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":14956,"modelId":16731,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested1","creator":"","inputDataAvailable":"false"},{"idObject":14957,"modelId":16731,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal1","creator":"","inputDataAvailable":"false"},{"idObject":14958,"modelId":16731,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty1","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19006423440219,"lng":-135.09977827050997},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":78.0903352323621,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s3","idObject":16730,"tileSize":256,"width":421,"height":315,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":14950,"modelId":16730,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested2","creator":"","inputDataAvailable":"false"},{"idObject":14951,"modelId":16730,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal2","creator":"","inputDataAvailable":"false"},{"idObject":14952,"modelId":16730,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty2","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19139766235872,"lng":-135.10688836104512},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.06362505154212,"lng":-90.0},"submodelType":"UNKNOWN"}] \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/token=MOCK_TOKEN_ID& index c5458476d93a09c500629a6926e4ed1fc194db12..b1da9104535a9829b0168df81a6e76e5ad56ebe0 100644 --- a/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/token=MOCK_TOKEN_ID& +++ b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/token=MOCK_TOKEN_ID& @@ -1 +1 @@ -{"version":"0","disease":null,"organism":null,"idObject":15763,"name":"UNKNOWN DISEASE MAP","projectId":"complex_model_with_submaps","description":"","map":{"version":null,"name":"main","idObject":16728,"tileSize":256,"width":515,"height":362,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":14959,"modelId":16728,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":14960,"modelId":16728,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":14961,"modelId":16728,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty0","creator":"","inputDataAvailable":"false"},{"idObject":18083,"modelId":16728,"name":"C:\\fakepath\\a.txt","description":"","status":"OK","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/.18083","creator":"","inputDataAvailable":"true"}],"submodels":[{"version":null,"name":"s1","idObject":16729,"tileSize":256,"width":571,"height":276,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":14953,"modelId":16729,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested3","creator":"","inputDataAvailable":"false"},{"idObject":14954,"modelId":16729,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal3","creator":"","inputDataAvailable":"false"},{"idObject":14955,"modelId":16729,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty3","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.18613072613702,"lng":-135.07880910683014},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":79.44906929997262,"lng":-90.0},"submodelType":"PATHWAY"},{"version":null,"name":"s2","idObject":16731,"tileSize":256,"width":451,"height":253,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":14956,"modelId":16731,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested1","creator":"","inputDataAvailable":"false"},{"idObject":14957,"modelId":16731,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal1","creator":"","inputDataAvailable":"false"},{"idObject":14958,"modelId":16731,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty1","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19006423440219,"lng":-135.09977827050997},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":78.0903352323621,"lng":-90.0},"submodelType":"UNKNOWN"},{"version":null,"name":"s3","idObject":16730,"tileSize":256,"width":421,"height":315,"minZoom":2,"maxZoom":3,"layouts":[{"idObject":14950,"modelId":16730,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_nested2","creator":"","inputDataAvailable":"false"},{"idObject":14951,"modelId":16730,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_normal2","creator":"","inputDataAvailable":"false"},{"idObject":14952,"modelId":16730,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"0e6072e4c8d73a05d8bd8ec873761725/_empty2","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.19139766235872,"lng":-135.10688836104512},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.06362505154212,"lng":-90.0},"submodelType":"UNKNOWN"}],"centerLatLng":{"lat":79.18773841616675,"lng":-135.0873786407767},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":75.1456787592211,"lng":-90.0},"submodelType":"UNKNOWN"},"publicationCount":0,"overviewImageViews":[],"topOverviewImage":null} \ No newline at end of file +{"version":"0","disease":null,"organism":null,"idObject":15763,"name":"UNKNOWN DISEASE MAP","projectId":"complex_model_with_submaps","description":"","overviewImageViews":[],"topOverviewImage":null} \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/drug_target_sample/models/all/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/drug_target_sample/models/all/token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..467d548b152ac46815ebc2a84145cc57e5cf5726 --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/drug_target_sample/models/all/token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +[{"version":null,"name":"UNKNOWN DISEASE MAP","idObject":20637,"tileSize":256,"width":1305,"height":473,"minZoom":2,"maxZoom":5,"layouts":[{"idObject":19771,"modelId":20637,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"77aacd78e20c6a6610f696eb1f1aa4b0/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":19772,"modelId":20637,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"77aacd78e20c6a6610f696eb1f1aa4b0/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":19773,"modelId":20637,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"77aacd78e20c6a6610f696eb1f1aa4b0/_empty0","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.18277721779353,"lng":-135.06093781915757},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":81.26928406550978,"lng":-90.0},"submodelType":"UNKNOWN"}] \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/drug_target_sample/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/drug_target_sample/token=MOCK_TOKEN_ID& index 685f9b480c96e79a9b15dcbc156de9be0b8e0d01..d75e17d06d3be7226cd2b024dec6fa18a18ddc46 100644 --- a/frontend-js/testFiles/apiCalls/projects/drug_target_sample/token=MOCK_TOKEN_ID& +++ b/frontend-js/testFiles/apiCalls/projects/drug_target_sample/token=MOCK_TOKEN_ID& @@ -1 +1 @@ -{"version":"0","disease":null,"organism":{"resource":"9606","link":"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=9606","id":1104514,"type":"TAXONOMY"},"idObject":19186,"name":"UNKNOWN DISEASE MAP","projectId":"drug_target_sample","description":"","map":{"version":null,"name":"UNKNOWN DISEASE MAP","idObject":20637,"tileSize":256,"width":1305,"height":473,"minZoom":2,"maxZoom":5,"layouts":[{"idObject":19771,"modelId":20637,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"77aacd78e20c6a6610f696eb1f1aa4b0/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":19772,"modelId":20637,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"77aacd78e20c6a6610f696eb1f1aa4b0/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":19773,"modelId":20637,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"77aacd78e20c6a6610f696eb1f1aa4b0/_empty0","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.18277721779353,"lng":-135.06093781915757},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":81.26928406550978,"lng":-90.0},"submodelType":"UNKNOWN"},"publicationCount":1,"overviewImageViews":[],"topOverviewImage":null} \ No newline at end of file +{"version":"0","disease":null,"organism":{"resource":"9606","link":"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=9606","id":1104514,"type":"TAXONOMY"},"idObject":19186,"name":"UNKNOWN DISEASE MAP","projectId":"drug_target_sample","description":"","overviewImageViews":[],"topOverviewImage":null} \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/empty/models/all/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/empty/models/all/token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..f8279f50e7be0d3d028d263f8b48e72c2d1263cc --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/empty/models/all/token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +[{"version":null,"name":"UNKNOWN DISEASE MAP","idObject":20638,"tileSize":256,"width":600,"height":400,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":19774,"modelId":20638,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"a2e4822a98337283e39f7b60acf85ec9/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":19775,"modelId":20638,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"a2e4822a98337283e39f7b60acf85ec9/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":19776,"modelId":20638,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"a2e4822a98337283e39f7b60acf85ec9/_empty0","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.17133464081945,"lng":-135.0},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":75.95934455387827,"lng":-90.0},"submodelType":"UNKNOWN"}] \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/empty/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/empty/token=MOCK_TOKEN_ID& index 077f4046876b04b2dfe564856ee549086d9e321c..6660298ee7b57a49c063c5521f5afde74fc2d644 100644 --- a/frontend-js/testFiles/apiCalls/projects/empty/token=MOCK_TOKEN_ID& +++ b/frontend-js/testFiles/apiCalls/projects/empty/token=MOCK_TOKEN_ID& @@ -1 +1 @@ -{"version":"0","disease":null,"organism":null,"idObject":19187,"name":"UNKNOWN DISEASE MAP","projectId":"empty","description":"","map":{"version":null,"name":"UNKNOWN DISEASE MAP","idObject":20638,"tileSize":256,"width":600,"height":400,"minZoom":2,"maxZoom":4,"layouts":[{"idObject":19774,"modelId":20638,"name":"Pathways and compartments","description":null,"status":"Not available","progress":"0.00","directory":"a2e4822a98337283e39f7b60acf85ec9/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":19775,"modelId":20638,"name":"Network","description":null,"status":"Not available","progress":"0.00","directory":"a2e4822a98337283e39f7b60acf85ec9/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":19776,"modelId":20638,"name":"Empty","description":null,"status":"Not available","progress":"0.00","directory":"a2e4822a98337283e39f7b60acf85ec9/_empty0","creator":"","inputDataAvailable":"false"}],"submodels":[],"centerLatLng":{"lat":79.17133464081945,"lng":-135.0},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":75.95934455387827,"lng":-90.0},"submodelType":"UNKNOWN"},"publicationCount":0,"overviewImageViews":[],"topOverviewImage":null} \ No newline at end of file +{"version":"0","disease":null,"organism":null,"idObject":19187,"name":"UNKNOWN DISEASE MAP","projectId":"empty","description":"","overviewImageViews":[],"topOverviewImage":null} \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/sample/models/all/bioEntities/elements/id=329170&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/sample/models/all/bioEntities/elements/id=329170&token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..d3d1247da764fa32a2dcf2cbd39efb15d277beef --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/sample/models/all/bioEntities/elements/id=329170&token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +[{"elementId":"sa32","symbol":null,"formerSymbols":[],"other":{"structuralState":null,"modifications":[]},"notes":"","references":[{"resource":"622","link":"http://www.ncbi.nlm.nih.gov/gene/622","id":860352,"type":"ENTREZ"}],"modelId":15781,"synonyms":[],"fullName":null,"complexId":null,"type":"Protein","abbreviation":null,"compartmentId":null,"name":"BDH1","bounds":{"x":1225.7682370820667,"width":80.0,"y":66.0,"height":40.0},"formula":null,"id":329170,"linkedSubmodel":null,"hierarchyVisibilityLevel":"0"}] \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/sample/models/all/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/sample/models/all/token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000000000000000000000000000000000..ffb8ec95f2a609c97a1b0d277e0062d9dea90941 --- /dev/null +++ b/frontend-js/testFiles/apiCalls/projects/sample/models/all/token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +[{"version":null,"name":"UNKNOWN DISEASE MAP","idObject":15781,"tileSize":256,"width":1305,"height":473,"minZoom":2,"maxZoom":5,"layouts":[{"idObject":14081,"modelId":15781,"name":"Pathways and compartments","description":"","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":14082,"modelId":15781,"name":"Network","description":"","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":14083,"modelId":15781,"name":"Empty","description":"","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_empty0","creator":"","inputDataAvailable":"false"},{"idObject":18076,"modelId":15781,"name":"C:\\fakepath\\test.txt","description":"xxx","status":"OK","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/.18076","creator":"","inputDataAvailable":"true"},{"idObject":18077,"modelId":15781,"name":"xxx","description":"yyy","status":"OK","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/.18077","creator":"","inputDataAvailable":"true"}],"submodels":[],"centerLatLng":{"lat":79.18277721779353,"lng":-135.06093781915757},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":81.26928406550978,"lng":-90.0},"submodelType":"UNKNOWN"}] \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/sample/statistics/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/sample/statistics/token=MOCK_TOKEN_ID& index 929cc68f9c59295ea64afef542c1b3a3ef16caa7..e486585b45d892ed464f93acc9ccc8d3eeed2fff 100644 --- a/frontend-js/testFiles/apiCalls/projects/sample/statistics/token=MOCK_TOKEN_ID& +++ b/frontend-js/testFiles/apiCalls/projects/sample/statistics/token=MOCK_TOKEN_ID& @@ -1 +1 @@ -{"reactionAnnotations":{"SGD":0,"HGNC_SYMBOL":0,"GO":0,"MI_R_BASE_SEQUENCE":0,"MIR_TAR_BASE_MATURE_SEQUENCE":0,"REACTOME":2,"ENSEMBL":0,"OMIM":0,"CHEBI":0,"KEGG_COMPOUND":0,"DRUGBANK":0,"UNIGENE":0,"KEGG_ORTHOLOGY":0,"CHEMBL_TARGET":0,"WORM_BASE":0,"ENSEMBL_PLANTS":0,"REFSEQ":0,"ENTREZ":0,"UNKNOWN":0,"MI_R_BASE_MATURE_SEQUENCE":0,"UNIPROT_ISOFORM":0,"COG":0,"TAXONOMY":0,"KEGG_REACTION":0,"TOXICOGENOMIC_CHEMICAL":0,"CHEMSPIDER":0,"TAIR_LOCUS":0,"UNIPROT":0,"PHARM":0,"CCDS":0,"HGNC":0,"WIKIPEDIA":0,"HMDB":0,"PANTHER":0,"WIKIDATA":0,"PUBCHEM_SUBSTANCE":0,"CAS":0,"KEGG_PATHWAY":0,"MGD":0,"PUBMED":1,"CHEMBL_COMPOUND":0,"PFAM":0,"MESH_2012":0,"EC":0,"PUBCHEM":0,"DRUGBANK_TARGET_V4":0,"WIKIPATHWAYS":0,"INTERPRO":0,"KEGG_GENES":0},"elementAnnotations":{"SGD":0,"HGNC_SYMBOL":0,"GO":0,"MI_R_BASE_SEQUENCE":0,"MIR_TAR_BASE_MATURE_SEQUENCE":0,"REACTOME":4,"ENSEMBL":0,"OMIM":0,"CHEBI":0,"KEGG_COMPOUND":0,"DRUGBANK":0,"UNIGENE":0,"KEGG_ORTHOLOGY":0,"CHEMBL_TARGET":0,"WORM_BASE":0,"ENSEMBL_PLANTS":0,"REFSEQ":5,"ENTREZ":2,"UNKNOWN":0,"MI_R_BASE_MATURE_SEQUENCE":0,"UNIPROT_ISOFORM":0,"COG":0,"TAXONOMY":0,"KEGG_REACTION":0,"TOXICOGENOMIC_CHEMICAL":0,"CHEMSPIDER":0,"TAIR_LOCUS":0,"UNIPROT":0,"PHARM":1,"CCDS":0,"HGNC":1,"WIKIPEDIA":0,"HMDB":0,"PANTHER":0,"WIKIDATA":0,"PUBCHEM_SUBSTANCE":0,"CAS":0,"KEGG_PATHWAY":0,"MGD":0,"PUBMED":0,"CHEMBL_COMPOUND":0,"PFAM":0,"MESH_2012":0,"EC":0,"PUBCHEM":0,"DRUGBANK_TARGET_V4":0,"WIKIPATHWAYS":0,"INTERPRO":0,"KEGG_GENES":1}} \ No newline at end of file +{"reactionAnnotations":{"UNKNOWN":0,"MI_R_BASE_SEQUENCE":0,"WORM_BASE":0,"COG":0,"HGNC":0,"MIR_TAR_BASE_MATURE_SEQUENCE":0,"CHEBI":0,"DRUGBANK_TARGET_V4":0,"KEGG_ORTHOLOGY":0,"KEGG_COMPOUND":0,"PUBMED":1,"PHARM":0,"CAS":0,"REFSEQ":0,"WIKIPATHWAYS":0,"UNIPROT_ISOFORM":0,"OMIM":0,"UNIGENE":0,"TOXICOGENOMIC_CHEMICAL":0,"MESH_2012":0,"WIKIPEDIA":0,"HGNC_SYMBOL":0,"ENTREZ":0,"MI_R_BASE_MATURE_SEQUENCE":0,"CHEMBL_COMPOUND":0,"MGD":0,"PANTHER":0,"GO":0,"UNIPROT":0,"SGD":0,"WIKIDATA":0,"CCDS":0,"PUBCHEM":0,"EC":0,"HMDB":0,"INTERPRO":0,"DRUGBANK":0,"KEGG_PATHWAY":0,"TAXONOMY":0,"ENSEMBL_PLANTS":0,"TAIR_LOCUS":0,"KEGG_GENES":0,"REACTOME":2,"ENSEMBL":0,"KEGG_REACTION":0,"PUBCHEM_SUBSTANCE":0,"CHEMSPIDER":0,"PFAM":0,"CHEMBL_TARGET":0},"elementAnnotations":{"UNKNOWN":0,"MI_R_BASE_SEQUENCE":0,"WORM_BASE":0,"COG":0,"HGNC":1,"MIR_TAR_BASE_MATURE_SEQUENCE":0,"CHEBI":0,"DRUGBANK_TARGET_V4":0,"KEGG_ORTHOLOGY":0,"KEGG_COMPOUND":0,"PUBMED":0,"PHARM":1,"CAS":0,"REFSEQ":5,"WIKIPATHWAYS":0,"UNIPROT_ISOFORM":0,"OMIM":0,"UNIGENE":0,"TOXICOGENOMIC_CHEMICAL":0,"MESH_2012":0,"WIKIPEDIA":0,"HGNC_SYMBOL":0,"ENTREZ":2,"MI_R_BASE_MATURE_SEQUENCE":0,"CHEMBL_COMPOUND":0,"MGD":0,"PANTHER":0,"GO":0,"UNIPROT":0,"SGD":0,"WIKIDATA":0,"CCDS":0,"PUBCHEM":0,"EC":0,"HMDB":0,"INTERPRO":0,"DRUGBANK":0,"KEGG_PATHWAY":0,"TAXONOMY":0,"ENSEMBL_PLANTS":0,"TAIR_LOCUS":0,"KEGG_GENES":1,"REACTOME":4,"ENSEMBL":0,"KEGG_REACTION":0,"PUBCHEM_SUBSTANCE":0,"CHEMSPIDER":0,"PFAM":0,"CHEMBL_TARGET":0},"publications":1} \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/sample/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/sample/token=MOCK_TOKEN_ID& index de46921fd2d951aa249b764d214c912789761b19..2854eb409636931a81242b5c1ea33fbc3b784969 100644 --- a/frontend-js/testFiles/apiCalls/projects/sample/token=MOCK_TOKEN_ID& +++ b/frontend-js/testFiles/apiCalls/projects/sample/token=MOCK_TOKEN_ID& @@ -1 +1 @@ -{"version":"0","disease":{"resource":"D010300","link":"http://bioportal.bioontology.org/ontologies/1351?p=terms&conceptid=D010300","id":1104479,"type":"MESH_2012"},"organism":{"resource":"1570291","link":"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=1570291","id":1104480,"type":"TAXONOMY"},"idObject":14898,"name":"UNKNOWN DISEASE MAP","projectId":"sample","description":"","map":{"version":null,"name":"UNKNOWN DISEASE MAP","idObject":15781,"tileSize":256,"width":1305,"height":473,"minZoom":2,"maxZoom":5,"layouts":[{"idObject":14081,"modelId":15781,"name":"Pathways and compartments","description":"","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_nested0","creator":"","inputDataAvailable":"false"},{"idObject":14082,"modelId":15781,"name":"Network","description":"","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_normal0","creator":"","inputDataAvailable":"false"},{"idObject":14083,"modelId":15781,"name":"Empty","description":"","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_empty0","creator":"","inputDataAvailable":"false"},{"idObject":18076,"modelId":15781,"name":"C:\\fakepath\\test.txt","description":"xxx","status":"OK","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/.18076","creator":"","inputDataAvailable":"true"},{"idObject":18077,"modelId":15781,"name":"xxx","description":"yyy","status":"OK","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/.18077","creator":"","inputDataAvailable":"true"}],"submodels":[],"centerLatLng":{"lat":79.18277721779353,"lng":-135.06093781915757},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":81.26928406550978,"lng":-90.0},"submodelType":"UNKNOWN"},"publicationCount":1,"overviewImageViews":[],"topOverviewImage":null} \ No newline at end of file +{"version":"0","disease":{"resource":"D010300","link":"http://bioportal.bioontology.org/ontologies/1351?p=terms&conceptid=D010300","id":1104479,"type":"MESH_2012"},"organism":{"resource":"1570291","link":"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=1570291","id":1104480,"type":"TAXONOMY"},"idObject":14898,"name":"UNKNOWN DISEASE MAP","projectId":"sample","description":"","overviewImageViews":[],"topOverviewImage":null} \ No newline at end of file diff --git a/frontend-js/testFiles/project.json b/frontend-js/testFiles/project.json deleted file mode 100644 index fa052d1df622691b47b04d680c0f29b38e866157..0000000000000000000000000000000000000000 --- a/frontend-js/testFiles/project.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"0","idObject":14898,"name":"UNKNOWN DISEASE MAP","projectId":"sample","description":"","map":{"name":"UNKNOWN DISEASE MAP2","idObject":15781,"tileSize":256,"width":1305,"height":473,"minZoom":2,"maxZoom":5,"layouts":[{"modelId":15781,"name":"Pathways and compartments","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_nested0","creator":"","inputDataAvailable":"false","idObject":14081},{"modelId":15781,"name":"Network","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_normal0","creator":"","inputDataAvailable":"false","idObject":14082},{"modelId":15781,"name":"Empty","status":"Not available","progress":"0.00","directory":"5e8ff9bf55ba3508199d22e984129be6/_empty0","creator":"","inputDataAvailable":"false","idObject":14083}],"submodels":[],"centerLatLng":{"lat":79.18277721779353,"lng":-135.06093781915757},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":81.26928406550978,"lng":-90.0}},"overviewImageViews":[]} \ No newline at end of file diff --git a/frontend-js/testFiles/projectWithImages.json b/frontend-js/testFiles/projectWithImages.json deleted file mode 100644 index b989ec48df62f47ce57be130dd7028861f6240a5..0000000000000000000000000000000000000000 --- a/frontend-js/testFiles/projectWithImages.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"0","idObject":18115,"name":"UNKNOWN DISEASE MAP","projectId":"complex_model_with_images","description":"","map":{"name":"main","idObject":19397,"tileSize":256,"width":495,"height":357,"minZoom":2,"maxZoom":3,"layouts":[{"modelId":19397,"name":"Pathways and compartments","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested0","creator":"","inputDataAvailable":"false","idObject":17987},{"modelId":19397,"name":"Network","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal0","creator":"","inputDataAvailable":"false","idObject":17988},{"modelId":19397,"name":"Empty","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty0","creator":"","inputDataAvailable":"false","idObject":17989}],"submodels":[{"name":"s2","idObject":19400,"tileSize":256,"width":451,"height":253,"minZoom":2,"maxZoom":3,"layouts":[{"modelId":19400,"name":"Pathways and compartments","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested2","creator":"","inputDataAvailable":"false","idObject":17984},{"modelId":19400,"name":"Network","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal2","creator":"","inputDataAvailable":"false","idObject":17985},{"modelId":19400,"name":"Empty","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty2","creator":"","inputDataAvailable":"false","idObject":17986}],"submodels":[],"centerLatLng":{"lat":79.19006423440219,"lng":-135.09977827050997},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":78.0903352323621,"lng":-90.0}},{"name":"s3","idObject":19399,"tileSize":256,"width":421,"height":315,"minZoom":2,"maxZoom":3,"layouts":[{"modelId":19399,"name":"Pathways and compartments","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested3","creator":"","inputDataAvailable":"false","idObject":17978},{"modelId":19399,"name":"Network","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal3","creator":"","inputDataAvailable":"false","idObject":17979},{"modelId":19399,"name":"Empty","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty3","creator":"","inputDataAvailable":"false","idObject":17980}],"submodels":[],"centerLatLng":{"lat":79.19139766235872,"lng":-135.10688836104512},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.06362505154212,"lng":-90.0}},{"name":"s1","idObject":19398,"tileSize":256,"width":571,"height":276,"minZoom":2,"maxZoom":4,"layouts":[{"modelId":19398,"name":"Pathways and compartments","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_nested1","creator":"","inputDataAvailable":"false","idObject":17981},{"modelId":19398,"name":"Network","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_normal1","creator":"","inputDataAvailable":"false","idObject":17982},{"modelId":19398,"name":"Empty","status":"Not available","progress":"0.00","directory":"fbdbe43de73fe38f62889b89cb863adb/_empty1","creator":"","inputDataAvailable":"false","idObject":17983}],"submodels":[],"centerLatLng":{"lat":79.18613072613702,"lng":-135.07880910683014},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":79.44906929997262,"lng":-90.0}}],"centerLatLng":{"lat":79.18840067864828,"lng":-135.0909090909091},"topLeftLatLng":{"lat":85.05112877980659,"lng":-180.0},"bottomRightLatLng":{"lat":74.71754541589858,"lng":-90.0}},"overviewImageViews":[{"filename":"fbdbe43de73fe38f62889b89cb863adb/sub_image.png","width":963,"height":639,"links":[{"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":1,"latLng":{"lat":84.89177465079632,"lng":-161.8181818181818},"modelLinkId":19397,"type":"OverviewModelLink","idObject":2369}],"idObject":1261},{"filename":"fbdbe43de73fe38f62889b89cb863adb/test.png","width":963,"height":639,"links":[{"polygon":[{"x":10.0,"y":10.0},{"x":100.0,"y":10.0},{"x":100.0,"y":100.0},{"x":10.0,"y":100.0}],"imageLinkId":1261,"type":"OverviewImageLink","idObject":2370},{"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":0,"latLng":{"lat":84.89177465079632,"lng":-178.1818181818182},"modelLinkId":19397,"type":"OverviewModelLink","idObject":2371}],"idObject":1262}],"topOverviewImage":{"filename":"fbdbe43de73fe38f62889b89cb863adb/test.png","width":963,"height":639,"links":[{"polygon":[{"x":10.0,"y":10.0},{"x":100.0,"y":10.0},{"x":100.0,"y":100.0},{"x":10.0,"y":100.0}],"imageLinkId":1261,"type":"OverviewImageLink","idObject":2370},{"polygon":[{"x":200.0,"y":200.0},{"x":200.0,"y":400.0},{"x":400.0,"y":400.0},{"x":400.0,"y":200.0}],"zoomLevel":0,"latLng":{"lat":84.89177465079632,"lng":-178.1818181818182},"modelLinkId":19397,"type":"OverviewModelLink","idObject":2371}],"idObject":1262}} \ No newline at end of file diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/ClearColorModelCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/ClearColorModelCommand.java index 891434f015e8b5a93073963b4f34532f7317c20f..64a211a66469f91641e9b2555a2a4d5af16eb6a4 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ClearColorModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ClearColorModelCommand.java @@ -26,7 +26,7 @@ public class ClearColorModelCommand extends ModelCommand { */ public ClearColorModelCommand(Model model) { super(model); - colorModelCommand = new ColorModelCommand(model, new ArrayList<>(), new ColorExtractor(Color.WHITE, Color.WHITE)); + colorModelCommand = new ColorModelCommand(model, new ArrayList<>(), new ColorExtractor(Color.WHITE, Color.WHITE, Color.WHITE)); } @Override diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/ColorExtractor.java b/model-command/src/main/java/lcsb/mapviewer/commands/ColorExtractor.java index 1a6d5d5d31976885404440319dab3dc8e4304507..0638978854921b447bdf5ec20ae3cff3865c5cff 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ColorExtractor.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ColorExtractor.java @@ -24,6 +24,8 @@ public class ColorExtractor { */ private Color maxColor; + private Color simpleColor; + /** * Default constructor. * @@ -34,12 +36,13 @@ public class ColorExtractor { * Color that should be used for max values of * {@link ColorSchema#value} */ - public ColorExtractor(Color minColor, Color maxColor) { - if (minColor == null || maxColor == null) { + public ColorExtractor(Color minColor, Color maxColor, Color simpleColor) { + if (minColor == null || maxColor == null || simpleColor == null) { throw new InvalidArgumentException("Parameters cannot be null"); } this.minColor = minColor; this.maxColor = maxColor; + this.simpleColor = simpleColor; } /** @@ -53,6 +56,8 @@ public class ColorExtractor { public Color getNormalizedColor(ColorSchema colorSchema) { if (colorSchema.getColor() != null) { return colorSchema.getColor(); + } else if (colorSchema.getValue() == null) { + return simpleColor; } else { return getColorForValue(colorSchema.getValue()); } @@ -93,4 +98,8 @@ public class ColorExtractor { public Color getMaxColor() { return maxColor; } + + public Color getSimpleColor() { + return simpleColor; + } } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/SemanticZoomLevelMatcher.java b/model-command/src/main/java/lcsb/mapviewer/commands/SemanticZoomLevelMatcher.java index 38920e1caed5f00fc4017059749400b3a141f9e0..8e55dbd35a707a07aa425b9c166fb372d61f951e 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/SemanticZoomLevelMatcher.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/SemanticZoomLevelMatcher.java @@ -3,7 +3,11 @@ package lcsb.mapviewer.commands; import org.apache.log4j.Logger; public class SemanticZoomLevelMatcher { - Logger logger = Logger.getLogger(SemanticZoomLevelMatcher.class); + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private Logger logger = Logger.getLogger(SemanticZoomLevelMatcher.class); /** * Checks if level belongs to the range defined in 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 14d934650b6eec46884d8f889e27d8e8472fcbbc..8bc1cd05cba8f5a21e96fb2a700abbe6dcf54369 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java @@ -31,7 +31,7 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class ColorModelCommandTest extends CommandTestFunctions { Logger logger = Logger.getLogger(ColorModelCommandTest.class); - ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); + ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE); @Before public void setUp() throws Exception { diff --git a/model/src/main/java/lcsb/mapviewer/model/user/ConfigurationElementType.java b/model/src/main/java/lcsb/mapviewer/model/user/ConfigurationElementType.java index 71e8845ee329681ac3b0d57562ef0826288abc30..8ff0f95344526a7e9e12cd455af360f510d71a1d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/user/ConfigurationElementType.java +++ b/model/src/main/java/lcsb/mapviewer/model/user/ConfigurationElementType.java @@ -126,7 +126,12 @@ public enum ConfigurationElementType { /** * Color used for positive overlay values. */ - MAX_COLOR_VAL("Overlay color for postive values", "0000FF", ConfigurationElementEditType.COLOR, false); + MAX_COLOR_VAL("Overlay color for postive values", "0000FF", ConfigurationElementEditType.COLOR, false), + + /** + * Color used for undefined overlay values. + */ + SIMPLE_COLOR_VAL("Overlay color when no values are defined", "00FF00", ConfigurationElementEditType.COLOR, false); /** * Default value of the configuration parameter (it will be used only when diff --git a/model/src/main/java/lcsb/mapviewer/model/user/User.java b/model/src/main/java/lcsb/mapviewer/model/user/User.java index 3cc421f8f51a6d229836e00d244be48821b286f4..216c7837dbf52005d912857520f45af158284698 100644 --- a/model/src/main/java/lcsb/mapviewer/model/user/User.java +++ b/model/src/main/java/lcsb/mapviewer/model/user/User.java @@ -80,6 +80,13 @@ public class User implements Serializable { */ private Color maxColor; + /** + * User defined color overriding system + * {@link ConfigurationElementType#SIMPLE_COLOR_VAL}. Used for coloring + * overlays without values and colors. + */ + private Color simpleColor; + /** * Is the user removed. */ @@ -309,4 +316,21 @@ public class User implements Serializable { this.maxColor = maxColor; } + /** + * @return the simpleColor + * @see #simpleColor + */ + public Color getSimpleColor() { + return simpleColor; + } + + /** + * @param simpleColor + * the simpleColor to set + * @see #simpleColor + */ + public void setSimpleColor(Color simpleColor) { + this.simpleColor = simpleColor; + } + } diff --git a/pathvisio/src/main/resources/empty.txt b/pathvisio/src/main/resources/empty.txt new file mode 100644 index 0000000000000000000000000000000000000000..e45f025b4e3a8b4af265accb372955b7774d589f --- /dev/null +++ b/pathvisio/src/main/resources/empty.txt @@ -0,0 +1 @@ +EMPTY file to force git to push the folder \ No newline at end of file diff --git a/persist/src/db/11/fix_db_20170725.sql b/persist/src/db/11/fix_db_20170725.sql new file mode 100644 index 0000000000000000000000000000000000000000..37a66ace4e369cad3a43817851e970acbd5eae04 --- /dev/null +++ b/persist/src/db/11/fix_db_20170725.sql @@ -0,0 +1,2 @@ +--simple color for coloring +alter table user_table add column simplecolor bytea; \ No newline at end of file diff --git a/persist/src/db/11/fix_db_20170731.sql b/persist/src/db/11/fix_db_20170731.sql new file mode 100644 index 0000000000000000000000000000000000000000..8e9c0ad40716340e825ff88d423c06d7ba536d9e --- /dev/null +++ b/persist/src/db/11/fix_db_20170731.sql @@ -0,0 +1,2 @@ +--drugbank targets issue +delete from cachequery where type in (select iddb from cache_type where classname = 'lcsb.mapviewer.annotation.services.DrugbankHTMLParser') and not query like 'http%'; diff --git a/quadTrees/src/main/resources/empty.txt b/quadTrees/src/main/resources/empty.txt new file mode 100644 index 0000000000000000000000000000000000000000..e45f025b4e3a8b4af265accb372955b7774d589f --- /dev/null +++ b/quadTrees/src/main/resources/empty.txt @@ -0,0 +1 @@ +EMPTY file to force git to push the folder \ No newline at end of file diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java index 7953a630b0d2524f8c4e3e7f80170b3e262ac62f..ac78d8b8d3665ee9c2839b91150ed323cc98d978 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java @@ -2,6 +2,7 @@ package lcsb.mapviewer.api; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -25,6 +26,7 @@ import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.interfaces.IModelService; +import lcsb.mapviewer.services.interfaces.IProjectService; import lcsb.mapviewer.services.interfaces.IUserService; import lcsb.mapviewer.services.search.ElementMatcher; import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; @@ -32,11 +34,18 @@ import lcsb.mapviewer.services.view.AnnotationView; @Transactional(value = "txManager") public abstract class BaseRestImpl { - Logger logger = Logger.getLogger(BaseRestImpl.class); + + /** + * Default class logger. + */ + private Logger logger = Logger.getLogger(BaseRestImpl.class); @Autowired private IModelService modelService; + @Autowired + private IProjectService projectService; + @Autowired private IUserService userService; @@ -74,8 +83,8 @@ public abstract class BaseRestImpl { }; protected Map<String, Object> createAnnotation(MiriamData annotation) { - Map<String, Object> result = new HashMap<>(); if (annotation != null && annotation.getDataType() != null) { + Map<String, Object> result = new HashMap<>(); if (annotation.getDataType().getUris().size() > 0) { try { result.put("link", miriamConnector.getUrlString(annotation)); @@ -94,8 +103,10 @@ public abstract class BaseRestImpl { result.put("type", annotation.getDataType().name()); result.put("resource", annotation.getResource()); result.put("id", annotation.getId()); + return result; + } else { + throw new InvalidArgumentException("invalid miriam data: " + annotation); } - return result; }; protected Map<String, Object> createAnnotation(AnnotationView annotation) { @@ -200,6 +211,23 @@ public abstract class BaseRestImpl { for (Target target : targets) { result.add(prepareTarget(target, models)); } + result.sort(new Comparator<Map<String, Object>>() { + + @Override + public int compare(Map<String, Object> o1, Map<String, Object> o2) { + List<?> targetedObjects1 = (List<?>) o1.get("targetElements"); + List<?> targetedObjects2 = (List<?>) o2.get("targetElements"); + Integer size1 = 0; + Integer size2 = 0; + if (targetedObjects1 != null) { + size1 = targetedObjects1.size(); + } + if (targetedObjects2 != null) { + size2 = targetedObjects2.size(); + } + return -size1.compareTo(size2); + } + }); return result; } @@ -238,5 +266,20 @@ public abstract class BaseRestImpl { } } + /** + * @return the projectService + * @see #projectService + */ + public IProjectService getProjectService() { + return projectService; + } + + /** + * @param projectService the projectService to set + * @see #projectService + */ + public void setProjectService(IProjectService projectService) { + this.projectService = projectService; + } } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectMetaData.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectMetaData.java index 0d79586f926aa1a0cae0f6dc42ef10b649002536..58365826a5a547972bb6fe8a927ff2aa6c017c76 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectMetaData.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectMetaData.java @@ -6,7 +6,6 @@ import java.util.Map; import org.apache.log4j.Logger; -import lcsb.mapviewer.services.view.AnnotationView; import lcsb.mapviewer.services.view.OverviewImageView; public class ProjectMetaData implements Serializable { @@ -48,10 +47,6 @@ public class ProjectMetaData implements Serializable { */ private String description; - private ModelMetaData map; - - private Integer publicationCount; - /** * List of overview images attached to this model. */ @@ -170,23 +165,6 @@ public class ProjectMetaData implements Serializable { this.projectId = projectId; } - /** - * @return the map - * @see #map - */ - public ModelMetaData getMap() { - return map; - } - - /** - * @param map - * the map to set - * @see #map - */ - public void setMap(ModelMetaData map) { - this.map = map; - } - /** * @return the idObject * @see #idObject @@ -237,22 +215,4 @@ public class ProjectMetaData implements Serializable { public void setOrganism(Map<String, Object> organism) { this.organism = organism; } - - /** - * @return the publicationCount - * @see #publicationCount - */ - public Integer getPublicationCount() { - return publicationCount; - } - - /** - * @param publicationCount - * the publicationCount to set - * @see #publicationCount - */ - public void setPublicationCount(Integer publicationCount) { - this.publicationCount = publicationCount; - } - } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java index cba3a43808693c1ebe96e3858c2a5b76aa157f2a..6f4f9a1d17c8a19eb9d1a9963ea161389d02424a 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java @@ -62,7 +62,6 @@ import lcsb.mapviewer.services.interfaces.IUserService; import lcsb.mapviewer.services.utils.ColorSchemaReader; import lcsb.mapviewer.services.utils.data.BuildInLayout; import lcsb.mapviewer.services.utils.gmap.CoordinationConverter; -import lcsb.mapviewer.services.view.AnnotationViewFactory; import lcsb.mapviewer.services.view.AuthenticationToken; import lcsb.mapviewer.services.view.OverviewImageViewFactory; @@ -130,7 +129,7 @@ public class ProjectRestImpl extends BaseRestImpl { result.setVersion(model.getMapVersion()); result.setDescription(model.getNotes()); - Set<OverviewImage> set = new HashSet<OverviewImage>(); + Set<OverviewImage> set = new HashSet<>(); set.addAll(model.getOverviewImages()); for (OverviewImage image : model.getOverviewImages()) { for (OverviewLink ol : image.getLinks()) { @@ -145,13 +144,6 @@ public class ProjectRestImpl extends BaseRestImpl { logger.warn("Cannot determine top level image. Taking first one. " + model.getOverviewImages().get(0).getFilename()); result.setTopOverviewImage(factory.create(model.getOverviewImages().get(0))); } - result.setMap(new ModelMetaData(model)); - - List<Model> models = new ArrayList<>(); - models.add(model); - models.addAll(model.getSubmodels()); - result.setPublicationCount(publicationsRestImpl.getPublications(models).size()); - } return result; @@ -313,8 +305,7 @@ public class ProjectRestImpl extends BaseRestImpl { level(level - Configuration.MIN_ZOOM_LEVEL).// nested(false).// automatically set nested view as invalid scale(scale).// - minColor(colorExtractor.getMinColor()).// - maxColor(colorExtractor.getMaxColor()).// + colorExtractor(colorExtractor).// sbgn(topModel.getProject().isSbgnFormat()).// model(colorModel); if (overlay != null) { @@ -436,6 +427,8 @@ public class ProjectRestImpl extends BaseRestImpl { } result.put("reactionAnnotations", reactionAnnotations); + + result.put("publications", publicationsRestImpl.getPublications(models).size()); return result; } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImpl.java index 702cb56cb24015b2109b31f7587346b44f66a22a..25c714b01695187487c30f571f98fa7d8dccb02f 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImpl.java @@ -36,7 +36,6 @@ public class ChemicalRestImpl extends BaseRestImpl { /** * Default class logger. */ - @SuppressWarnings("unused") private Logger logger = Logger.getLogger(ChemicalRestImpl.class); @Autowired @@ -120,7 +119,7 @@ public class ChemicalRestImpl extends BaseRestImpl { this.modelService = modelService; } - private Map<String, Object> prepareChemical(Chemical chemical, Set<String> columnsSet, List<Model> models) { + protected Map<String, Object> prepareChemical(Chemical chemical, Set<String> columnsSet, List<Model> models) { Map<String, Object> result = new HashMap<>(); String description = "Mesh term not available"; @@ -144,14 +143,18 @@ public class ChemicalRestImpl extends BaseRestImpl { } else if (column.equals("references")) { List<Map<String, Object>> references = new ArrayList<>(); references.add(createAnnotation(chemical.getChemicalId())); - references.add(createAnnotation(chemical.getCasID())); + if (chemical.getCasID() != null) { + references.add(createAnnotation(chemical.getCasID())); + } value = references; } else if (column.equals("directevidencereferences")) { value = createAnnotations(chemical.getDirectEvidencePublication()); } else if (column.equals("description")) { value = description; } else if (column.equals("directevidence")) { - value = chemical.getDirectEvidence().getValue(); + if (chemical.getDirectEvidence() != null) { + value = chemical.getDirectEvidence().getValue(); + } } else if (column.equals("synonyms")) { value = synonyms; } else if (column.equals("targets")) { @@ -164,7 +167,7 @@ public class ChemicalRestImpl extends BaseRestImpl { return result; } - private Set<String> createChemicalColumnSet(String columns) { + protected Set<String> createChemicalColumnSet(String columns) { Set<String> columnsSet = new HashSet<>(); if (columns.equals("")) { columnsSet.add("name"); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/drugs/DrugRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/drugs/DrugRestImpl.java index 85fed9a13c9f0af2de55ba2d27fbf0b93bcbbff6..a08a985d71237383216c776d64c2277356d19b05 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/drugs/DrugRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/drugs/DrugRestImpl.java @@ -22,7 +22,6 @@ import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.interfaces.IUserService; -import lcsb.mapviewer.services.search.ElementMatcher; import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; import lcsb.mapviewer.services.search.db.DbSearchCriteria; import lcsb.mapviewer.services.search.db.drug.IDrugService; @@ -35,19 +34,16 @@ public class DrugRestImpl extends BaseRestImpl { * Default class logger. */ @SuppressWarnings("unused") - private Logger logger = Logger.getLogger(DrugRestImpl.class); + private Logger logger = Logger.getLogger(DrugRestImpl.class); @Autowired - private IDrugService drugService; + private IDrugService drugService; @Autowired - private IModelService modelService; + private IModelService modelService; @Autowired - private IUserService userService; - - @Autowired - private ElementMatcher elementMatcher; + private IUserService userService; public List<Map<String, Object>> getDrugsByQuery(String token, String projectId, String columns, String query) throws SecurityException, QueryException { AuthenticationToken authenticationToken = userService.getToken(token); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/mirnas/MiRnaRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/mirnas/MiRnaRestImpl.java index 1d9f8fc7e6000f1e153f183877355f224b98fd99..3f0352abf05e0f668a86f494d30b1cd9b164e3a9 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/mirnas/MiRnaRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/mirnas/MiRnaRestImpl.java @@ -20,7 +20,6 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.SecurityException; -import lcsb.mapviewer.services.search.ElementMatcher; import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; import lcsb.mapviewer.services.search.db.DbSearchCriteria; import lcsb.mapviewer.services.search.db.mirna.IMiRNAService; @@ -33,13 +32,10 @@ public class MiRnaRestImpl extends BaseRestImpl { * Default class logger. */ @SuppressWarnings("unused") - private Logger logger = Logger.getLogger(MiRnaRestImpl.class); + private Logger logger = Logger.getLogger(MiRnaRestImpl.class); @Autowired - private IMiRNAService miRnaService; - - @Autowired - private ElementMatcher elementMatcher; + private IMiRNAService miRnaService; public List<Map<String, Object>> getMiRnasByQuery(String token, String projectId, String columns, String query) throws SecurityException, QueryException { AuthenticationToken authenticationToken = getUserService().getToken(token); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelController.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelController.java new file mode 100644 index 0000000000000000000000000000000000000000..1cecb23458d9dbb5021a4df738b7d44872f1474d --- /dev/null +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelController.java @@ -0,0 +1,44 @@ +package lcsb.mapviewer.api.projects.models; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.CookieValue; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import lcsb.mapviewer.api.BaseController; +import lcsb.mapviewer.api.ObjectNotFoundException; +import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.services.SecurityException; + +@RestController +public class ModelController extends BaseController { + @Autowired + private ModelRestImpl modelController; + + @RequestMapping(value = "/projects/{projectId:.+}/models/", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE }) + public List<ModelMetaData> getModels(// + @PathVariable(value = "projectId") String projectId, // + @CookieValue(value = Configuration.AUTH_TOKEN) String token // + ) throws SecurityException, ObjectNotFoundException { + return modelController.getModels(projectId, token); + } + + @RequestMapping(value = "/projects/{projectId:.+}/models/{modelId:.+}", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE }) + public Object getModel(// + @PathVariable(value = "modelId") String modelId, // + @PathVariable(value = "projectId") String projectId, // + @CookieValue(value = Configuration.AUTH_TOKEN) String token // + ) throws SecurityException, ObjectNotFoundException { + if (modelId.equals("*")) { + return modelController.getModels(projectId, token); + } else { + return modelController.getModel(projectId, modelId, token); + } + } + +} \ No newline at end of file diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ModelMetaData.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelMetaData.java similarity index 94% rename from rest-api/src/main/java/lcsb/mapviewer/api/projects/ModelMetaData.java rename to rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelMetaData.java index 273364a57e42d047251b7e1cf358cce2bcb69a54..62181d0b379a22f618a5cb6fa1d51622a282704e 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ModelMetaData.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelMetaData.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.api.projects; +package lcsb.mapviewer.api.projects.models; import java.awt.geom.Point2D; import java.io.Serializable; diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e2a747e9973f376d5fb3dd2c05c4f6796c3d3045 --- /dev/null +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java @@ -0,0 +1,58 @@ +package lcsb.mapviewer.api.projects.models; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.springframework.transaction.annotation.Transactional; + +import lcsb.mapviewer.api.BaseRestImpl; +import lcsb.mapviewer.api.ObjectNotFoundException; +import lcsb.mapviewer.model.Project; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.services.SecurityException; +import lcsb.mapviewer.services.view.AuthenticationToken; + +@Transactional(value = "txManager") +public class ModelRestImpl extends BaseRestImpl { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private Logger logger = Logger.getLogger(ModelRestImpl.class); + + public List<ModelMetaData> getModels(String projectId, String token) throws SecurityException, ObjectNotFoundException { + AuthenticationToken authenticationToken = getUserService().getToken(token); + Project project = getProjectService().getProjectByProjectId(projectId, authenticationToken); + if (project == null) { + throw new ObjectNotFoundException("Project with given id doesn't exist"); + } + List<ModelMetaData> result = createData(project, authenticationToken); + return result; + } + + public ModelMetaData getModel(String projectId, String modelId, String token) throws SecurityException, ObjectNotFoundException { + AuthenticationToken authenticationToken = getUserService().getToken(token); + Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); + Model submodel = model.getSubmodelById(modelId); + if (submodel == null) { + return null; + } else { + return new ModelMetaData(submodel); + } + } + + private List<ModelMetaData> createData(Project project, AuthenticationToken token) { + List<ModelMetaData> result = new ArrayList<>(); + Model model = getModelService().getLastModelByProjectId(project.getProjectId(), token); + + List<Model> models = new ArrayList<>(); + models.add(model); + models.addAll(model.getSubmodels()); + for (Model model2 : models) { + result.add(new ModelMetaData(model2)); + } + return result; + } +} diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/elements/ElementsRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/elements/ElementsRestImpl.java index 4c2875005877e07e6f058fca0da1452b9260da88..ab3c736a4d03e7e1946654dd837e2382f238c9bc 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/elements/ElementsRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/elements/ElementsRestImpl.java @@ -19,8 +19,6 @@ import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.field.ElementModification; -import lcsb.mapviewer.model.map.species.field.ModificationResidue; -import lcsb.mapviewer.model.map.species.field.RnaRegion; import lcsb.mapviewer.model.map.species.field.Structure; import lcsb.mapviewer.model.map.species.field.UniprotRecord; import lcsb.mapviewer.services.SecurityException; diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/publications/PublicationsRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/publications/PublicationsRestImpl.java index 1bab83b85dc597cfe316707de11b67229d6f8ed5..0d3e0349126edced91c82d2ad674c564cbd97505 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/publications/PublicationsRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/publications/PublicationsRestImpl.java @@ -2,7 +2,6 @@ package lcsb.mapviewer.api.projects.models.publications; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -33,7 +32,6 @@ import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.interfaces.ISearchService; import lcsb.mapviewer.services.interfaces.IUserService; -import lcsb.mapviewer.services.view.AnnotationViewFactory; import lcsb.mapviewer.services.view.OverviewImageViewFactory; @Transactional(value = "txManager") @@ -59,7 +57,7 @@ public class PublicationsRestImpl extends BaseRestImpl { @Autowired private OverviewImageViewFactory factory; - public SortedMap<MiriamData, List<BioEntity>> getPublications(List<Model> models) { + public SortedMap<MiriamData, List<BioEntity>> getPublications(Collection<Model> models) { SortedMap<MiriamData, List<BioEntity>> publications = new TreeMap<>(); for (Model modelData : models) { for (Element element : modelData.getElements()) { diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java index 0c2c7a6ea47a6108c58a00903ded58abedae174d..ec6bb96897cb4a0c4b6f3a8223ea59bc6be51813 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java @@ -47,11 +47,6 @@ public class OverlayRestImpl extends BaseRestImpl { */ private Logger logger = Logger.getLogger(OverlayRestImpl.class); - @Autowired - private IUserService userService; - - @Autowired - private IModelService modelService; @Autowired private ILayoutService layoutService; @@ -60,31 +55,14 @@ public class OverlayRestImpl extends BaseRestImpl { private LayoutDao layoutDao; public List<LayoutView> getOverlayList(String token, String projectId) throws SecurityException, QueryException { - AuthenticationToken authenticationToken = userService.getToken(token); - Model model = modelService.getLastModelByProjectId(projectId, authenticationToken); + AuthenticationToken authenticationToken = getUserService().getToken(token); + Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (model == null) { throw new QueryException("Project with given id doesn't exist"); } return layoutService.getCustomLayouts(model, token); } - /** - * @return the userService - * @see #userService - */ - public IUserService getUserService() { - return userService; - } - - /** - * @param userService - * the userService to set - * @see #userService - */ - public void setUserService(IUserService userService) { - this.userService = userService; - } - /** * @return the layoutService * @see #layoutService @@ -102,28 +80,11 @@ public class OverlayRestImpl extends BaseRestImpl { this.layoutService = layoutService; } - /** - * @return the modelService - * @see #modelService - */ - public IModelService getModelService() { - return modelService; - } - - /** - * @param modelService - * the modelService to set - * @see #modelService - */ - public void setModelService(IModelService modelService) { - this.modelService = modelService; - } - public List<Map<String, Object>> getOverlayElements(String token, String projectId, int overlayId, String columns) throws QueryException, SecurityException { List<Map<String, Object>> result = new ArrayList<>(); - AuthenticationToken authenticationToken = userService.getToken(token); + AuthenticationToken authenticationToken = getUserService().getToken(token); - Model model = modelService.getLastModelByProjectId(projectId, authenticationToken); + Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (model == null) { throw new QueryException("Project with given id doesn't exist"); } @@ -146,8 +107,8 @@ public class OverlayRestImpl extends BaseRestImpl { } public LayoutView getOverlayById(String token, String projectId, String overlayId) throws SecurityException, QueryException { - AuthenticationToken authenticationToken = userService.getToken(token); - Model model = modelService.getLastModelByProjectId(projectId, authenticationToken); + AuthenticationToken authenticationToken = getUserService().getToken(token); + Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (model == null) { throw new QueryException("Project with given id doesn't exist"); } @@ -155,8 +116,8 @@ public class OverlayRestImpl extends BaseRestImpl { } public FileEntry getOverlaySource(String token, String projectId, String overlayId) throws SecurityException, QueryException { - AuthenticationToken authenticationToken = userService.getToken(token); - Model model = modelService.getLastModelByProjectId(projectId, authenticationToken); + AuthenticationToken authenticationToken = getUserService().getToken(token); + Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (model == null) { throw new QueryException("Project with given id doesn't exist"); } @@ -175,8 +136,8 @@ public class OverlayRestImpl extends BaseRestImpl { } public LayoutView updateOverlay(String token, String projectId, String overlayId, Map<String, Object> overlayData) throws QueryException, SecurityException { - AuthenticationToken authenticationToken = userService.getToken(token); - Model model = modelService.getLastModelByProjectId(projectId, authenticationToken); + AuthenticationToken authenticationToken = getUserService().getToken(token); + Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (model == null) { throw new QueryException("Project with given id doesn't exist"); } @@ -184,7 +145,7 @@ public class OverlayRestImpl extends BaseRestImpl { throw new QueryException("overlay field cannot be undefined"); } Project project = model.getProject(); - boolean isAdmin = userService.userHasPrivilege(authenticationToken, PrivilegeType.LAYOUT_MANAGEMENT, project); + boolean isAdmin = getUserService().userHasPrivilege(authenticationToken, PrivilegeType.LAYOUT_MANAGEMENT, project); try { Integer id = Integer.valueOf(overlayId); Layout layout = layoutService.getLayoutDataById(id, authenticationToken); @@ -208,8 +169,8 @@ public class OverlayRestImpl extends BaseRestImpl { } public Map<String, Object> removeOverlay(String token, String projectId, String overlayId) throws QueryException, SecurityException, IOException { - AuthenticationToken authenticationToken = userService.getToken(token); - Model model = modelService.getLastModelByProjectId(projectId, authenticationToken); + AuthenticationToken authenticationToken = getUserService().getToken(token); + Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (model == null) { throw new ObjectNotFoundException("Project with given id doesn't exist"); } @@ -249,12 +210,12 @@ public class OverlayRestImpl extends BaseRestImpl { public LayoutView addOverlay(String token, String projectId, String name, String description, String content, String filename, String type) throws SecurityException, QueryException, IOException { - AuthenticationToken authenticationToken = userService.getToken(token); - User user = userService.getUserByToken(token); + AuthenticationToken authenticationToken = getUserService().getToken(token); + User user = getUserService().getUserByToken(token); if (Configuration.ANONYMOUS_LOGIN.equals(user.getLogin())) { throw new SecurityException("You have no privileges to add overlay"); } - Model model = modelService.getLastModelByProjectId(projectId, authenticationToken); + Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (model == null) { throw new QueryException("Project with given id doesn't exist"); } @@ -284,9 +245,9 @@ public class OverlayRestImpl extends BaseRestImpl { public Map<String, Object> getOverlayElement(String token, String projectId, Integer modelId, Integer overlayId, Integer elementId, String elementType, String columns) throws QueryException, SecurityException { - AuthenticationToken authenticationToken = userService.getToken(token); + AuthenticationToken authenticationToken = getUserService().getToken(token); - Model topModel = modelService.getLastModelByProjectId(projectId, authenticationToken); + Model topModel = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (topModel == null) { throw new QueryException("Project with given id doesn't exist"); } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java index 1aef78c3c4651cfd214cb0854984783a3ef8f0ce..bcd07b094b7ae9854fe2952e8f656493de13458f 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java @@ -76,6 +76,7 @@ public class UserRestImpl { columnsSet.add("email"); columnsSet.add("minColor"); columnsSet.add("maxColor"); + columnsSet.add("simpleColor"); columnsSet.add("removed"); columnsSet.add("privileges"); } else { @@ -105,6 +106,8 @@ public class UserRestImpl { value = user.getMinColor(); } else if (column.equals("maxcolor")) { value = user.getMaxColor(); + } else if (column.equals("simplecolor")) { + value = user.getSimpleColor(); } else if (column.equals("removed")) { value = user.isRemoved(); } else if (column.equals("privileges") && admin) { diff --git a/rest-api/src/main/resources/applicationContext-rest.xml b/rest-api/src/main/resources/applicationContext-rest.xml index 5cbacb6fc6473c8ce69a2acb2117cc956ad83528..2642267ee9757e4925f78b5142c8022365264033 100644 --- a/rest-api/src/main/resources/applicationContext-rest.xml +++ b/rest-api/src/main/resources/applicationContext-rest.xml @@ -15,6 +15,7 @@ <bean id="CommentRestImpl" class="lcsb.mapviewer.api.projects.comments.CommentRestImpl"/> <bean id="ProjectRestImpl" class="lcsb.mapviewer.api.projects.ProjectRestImpl"/> + <bean id="ModelRestImpl" class="lcsb.mapviewer.api.projects.models.ModelRestImpl"/> <bean id="BioEntitiesRestImpl" class="lcsb.mapviewer.api.projects.models.bioEntities.BioEntitiesRestImpl"/> <bean id="ChemicalRestImpl" class="lcsb.mapviewer.api.projects.chemicals.ChemicalRestImpl"/> <bean id="ElementsRestImpl" class="lcsb.mapviewer.api.projects.models.bioEntities.elements.ElementsRestImpl"/> diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/AllProjectTests.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/AllProjectTests.java index d79741c5e25c03a7d797206aead5653a624677be..60e3837712d839ffd77e188018a37d6f166f3601 100644 --- a/rest-api/src/test/java/lcsb/mapviewer/api/projects/AllProjectTests.java +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/AllProjectTests.java @@ -4,13 +4,15 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +import lcsb.mapviewer.api.projects.chemicals.AllChemicalTests; import lcsb.mapviewer.api.projects.drugs.AllDrugTests; import lcsb.mapviewer.api.projects.mirnas.AllMiRnaTests; import lcsb.mapviewer.api.projects.models.AllModelsTests; import lcsb.mapviewer.api.projects.overlays.AllOverlaysTests; @RunWith(Suite.class) -@SuiteClasses({ AllDrugTests.class, // +@SuiteClasses({ AllChemicalTests.class, // + AllDrugTests.class, // AllMiRnaTests.class, // AllModelsTests.class, // AllOverlaysTests.class, // diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/ModelMetaDataTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/ModelMetaDataTest.java index 521d3701fe25873c35726f782374abdef87d39f8..243de1dad24d1043b65385b0ad480c7f711c2be0 100644 --- a/rest-api/src/test/java/lcsb/mapviewer/api/projects/ModelMetaDataTest.java +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/ModelMetaDataTest.java @@ -9,7 +9,7 @@ import org.junit.Test; import com.google.gson.Gson; -import lcsb.mapviewer.api.projects.ModelMetaData; +import lcsb.mapviewer.api.projects.models.ModelMetaData; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/AllChemicalTests.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/AllChemicalTests.java new file mode 100644 index 0000000000000000000000000000000000000000..b673f23b80bc19b1cf4c22258ccf377958e36296 --- /dev/null +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/AllChemicalTests.java @@ -0,0 +1,11 @@ +package lcsb.mapviewer.api.projects.chemicals; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ ChemicalRestImplTest.class }) +public class AllChemicalTests { + +} diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImplTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..32b1acd9ede8099f67a72ad949d864f29c081051 --- /dev/null +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImplTest.java @@ -0,0 +1,65 @@ +package lcsb.mapviewer.api.projects.chemicals; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; + +import java.util.ArrayList; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; + +import lcsb.mapviewer.annotation.data.Chemical; +import lcsb.mapviewer.api.RestTestFunctions; +import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.services.interfaces.IModelService; + +public class ChemicalRestImplTest extends RestTestFunctions { + Logger logger = Logger.getLogger(ChemicalRestImplTest.class); + + @Autowired + + private ChemicalRestImpl _drugRestImpl; + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testPrepareChemical() throws Exception { + try { + Chemical chemical = new Chemical(); + chemical.setChemicalId(new MiriamData(MiriamType.MESH_2012, "D010300")); + Map<String, Object> result = _drugRestImpl.prepareChemical(chemical, _drugRestImpl.createChemicalColumnSet(""), new ArrayList<>()); + assertNotNull(result); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + protected ChemicalRestImpl createMockChemicalRest(String string) throws Exception { + Model model = super.getModelForFile(string, true); + IModelService mockModelService = Mockito.mock(IModelService.class); + Mockito.when(mockModelService.getLastModelByProjectId(anyString(), any())).thenReturn(model); + _drugRestImpl.setModelService(mockModelService); + return _drugRestImpl; + } + +} diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/drugs/DrugRestImplTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/drugs/DrugRestImplTest.java index ecdad6a03327a32a4f42ada6da3b709d121edb99..880479f85b67aba56a6e8497d0967e9453089d1d 100644 --- a/rest-api/src/test/java/lcsb/mapviewer/api/projects/drugs/DrugRestImplTest.java +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/drugs/DrugRestImplTest.java @@ -40,14 +40,14 @@ public class DrugRestImplTest extends RestTestFunctions { @Test @SuppressWarnings("unchecked") - public void testGetModelAsImage() throws Exception { + public void testGetDrugsByQuery() throws Exception { try { DrugRestImpl drugRestImpl = createMockProjectRest("testFiles/model/sample.xml"); Map<String, Object> result = drugRestImpl.getDrugsByQuery(token.getId(), "sample", "", "nadh").get(0); List<Map<String, Object>> references = (List<Map<String, Object>>) result.get("references"); Map<String, Object> reference = references.get(0); assertNotNull(reference.get("type")); - + } catch (Exception e) { e.printStackTrace(); throw e; diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/AllModelsTests.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/AllModelsTests.java index 58bce555cf36a931dfc0b2cc6857edcb846f6004..3cb26a74c6f9c5eded78255a02e75de3bd9b137f 100644 --- a/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/AllModelsTests.java +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/AllModelsTests.java @@ -10,7 +10,8 @@ import lcsb.mapviewer.api.projects.models.publications.AllPublicationsTests; @RunWith(Suite.class) @SuiteClasses({ // AllBioeEntitiesTests.class, // - AllPublicationsTests.class// + AllPublicationsTests.class, // + ModelRestImplTest.class,// }) public class AllModelsTests { diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/ModelRestImplTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/ModelRestImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8340abe87ecc4061b61e2ab7a6dcd37e9a994217 --- /dev/null +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/ModelRestImplTest.java @@ -0,0 +1,58 @@ +package lcsb.mapviewer.api.projects.models; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; + +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; + +import lcsb.mapviewer.api.RestTestFunctions; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.services.interfaces.IModelService; + +public class ModelRestImplTest extends RestTestFunctions { + + @Autowired + ModelRestImpl _projectRestImpl; + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testModels() throws Exception { + try { + ModelRestImpl modelRest = createMockProjectRest("testFiles/model/sample.xml"); + List<ModelMetaData> result = modelRest.getModels("sample", token.getId()); + assertEquals(1, result.size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + private ModelRestImpl createMockProjectRest(String string) throws Exception { + Model model = super.getModelForFile(string, true); + IModelService mockModelService = Mockito.mock(IModelService.class); + Mockito.when(mockModelService.getLastModelByProjectId(anyString(), any())).thenReturn(model); + _projectRestImpl.setModelService(mockModelService); + return _projectRestImpl; + } + +} 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 d1b2df719b2095c1424414e012dd19b1af3183d7..78513655c609304555e06f3ca6582b3cec52fca2 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java @@ -935,7 +935,7 @@ public class LayoutService implements ILayoutService { ColorSchemaReader reader = new ColorSchemaReader(); Collection<ColorSchema> schemas = reader.readColorSchema(getInputDataForLayout(layoutId, token)); // colors here are not important - ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK)); + ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK)); LightLayoutAliasViewFactory factory = new LightLayoutAliasViewFactory(); List<LightLayoutAliasView> result = new ArrayList<>(); for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) { @@ -957,7 +957,7 @@ public class LayoutService implements ILayoutService { ColorSchemaReader reader = new ColorSchemaReader(); Collection<ColorSchema> schemas = reader.readColorSchema(getInputDataForLayout(layoutId, token)); // colors here are not important - ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK)); + ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK)); LightLayoutReactionViewFactory factory = new LightLayoutReactionViewFactory(); List<LightLayoutReactionView> result = new ArrayList<>(); for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) { @@ -980,7 +980,7 @@ public class LayoutService implements ILayoutService { Collection<ColorSchema> schemas; schemas = reader.readColorSchema(getInputDataForLayout(layoutId, token)); // colors here are not important - ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK)); + ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK)); return command.getModifiedElements(); } catch (InvalidColorSchemaException e) { throw new InvalidStateException(e); @@ -1002,7 +1002,7 @@ public class LayoutService implements ILayoutService { Collection<ColorSchema> schemas; schemas = reader.readColorSchema(getInputDataForLayout(layoutId, token)); // colors here are not important - ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK)); + ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK)); FullLayoutAliasViewFactory factory = new FullLayoutAliasViewFactory(); List<FullLayoutAliasView> result = new ArrayList<>(); @@ -1059,7 +1059,7 @@ public class LayoutService implements ILayoutService { Collection<ColorSchema> schemas; schemas = reader.readColorSchema(getInputDataForLayout(layoutId, token)); // colors here are not important - ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK)); + ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK)); FullLayoutAliasViewFactory factory = new FullLayoutAliasViewFactory(); for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) { @@ -1085,7 +1085,7 @@ public class LayoutService implements ILayoutService { Collection<ColorSchema> schemas; schemas = reader.readColorSchema(getInputDataForLayout(layoutId, token)); // colors here are not important - ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK)); + ColorModelCommand command = new ColorModelCommand(model, schemas, new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK)); FullLayoutReactionViewFactory factory = new FullLayoutReactionViewFactory(); for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) { diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java b/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java index d202b0c4c8a7c2baada65e64b107a8b0c3a1150e..34186d37bba13fecb77bf1fad9c254e502f2796d 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java @@ -28,10 +28,10 @@ import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.model.map.species.Degraded; import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Gene; import lcsb.mapviewer.model.map.species.Ion; import lcsb.mapviewer.model.map.species.Phenotype; @@ -77,6 +77,12 @@ public class SearchService implements ISearchService { */ public static final String REACTION_SEARCH_PREFIX = "reaction"; + /** + * Prefix used in search by name interface to limit results only to + * {@link Element}. + */ + private static final String ELEMENT_SEARCH_PREFIX = "element"; + /** * Default class logger. */ @@ -240,6 +246,8 @@ public class SearchService implements ISearchService { return getReactionById(model, query.replaceFirst(REACTION_SEARCH_PREFIX, "").toLowerCase()); } else if (query.startsWith(SPECIES_SEARCH_PREFIX)) { result.add(fullAliasViewFactory.create(model.getElementByElementId(query.replaceFirst(SPECIES_SEARCH_PREFIX, "")))); + } else if (query.startsWith(ELEMENT_SEARCH_PREFIX)) { + return getElementById(model, query.replaceFirst(ELEMENT_SEARCH_PREFIX, "").toLowerCase()); } else { Set<Element> aliases = model.getElements(); @@ -309,14 +317,45 @@ public class SearchService implements ISearchService { private List<IHeavyView> getReactionById(Model model, String reactionId) { Set<Reaction> reactions = model.getReactions(); for (Reaction reaction : reactions) { - if (searchIndexer.getQueryStringForIndex(reaction.getIdReaction().toLowerCase(), new ArrayList<>()).equals(reactionId)) { return reactionToResultList(reaction); } + if (Integer.toString(reaction.getId()).equals(reactionId)) { + return reactionToResultList(reaction); + } } return new ArrayList<>(); } + /** + * Returns list with the element with a given id. If element with such id + * doesn't exist then empty list is returned. + * + * @param topModel + * where the search is performed + * @param elementId + * id of the element + * @return list that contains element with given id (or empty list if such + * element doesn't exist) + */ + private List<IHeavyView> getElementById(Model topModel, String elementId) { + List<IHeavyView> result = new ArrayList<>(); + + Set<Model> models = new HashSet<>(); + models.add(topModel); + models.addAll(topModel.getSubmodels()); + for (Model model : models) { + for (Element element : model.getElements()) { + if (searchIndexer.getQueryStringForIndex(element.getElementId().toLowerCase(), new ArrayList<>()).equals(elementId)) { + result.add(fullAliasViewFactory.create(element)); + } else if (Integer.toString(element.getId()).equals(elementId)) { + result.add(fullAliasViewFactory.create(element)); + } + } + } + return result; + } + /** * Transform {@link Reaction} into set of result entries. * diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/UserService.java b/service/src/main/java/lcsb/mapviewer/services/impl/UserService.java index 60730c63a4088df7770e1854b34ba1e050322421..83dd4bfa7a342e6a5d14683ff31b33b3bd1b0f0c 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/UserService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/UserService.java @@ -473,11 +473,13 @@ public class UserService implements IUserService { public ColorExtractor getColorExtractorForUser(User loggedUser) { Color colorMin = null; Color colorMax = null; + Color colorSimple = null; if (loggedUser != null) { User dbUser = getUserById(loggedUser.getId()); if (dbUser != null) { colorMin = dbUser.getMinColor(); colorMax = dbUser.getMaxColor(); + colorSimple = dbUser.getSimpleColor(); } } ColorParser parser = new ColorParser(); @@ -488,7 +490,10 @@ public class UserService implements IUserService { if (colorMax == null) { colorMax = parser.parse(configurationService.getConfigurationValue(ConfigurationElementType.MAX_COLOR_VAL)); } - return new ColorExtractor(colorMin, colorMax); + if (colorSimple == null) { + colorSimple = parser.parse(configurationService.getConfigurationValue(ConfigurationElementType.SIMPLE_COLOR_VAL)); + } + return new ColorExtractor(colorMin, colorMax, colorSimple); } /** diff --git a/service/src/main/java/lcsb/mapviewer/services/search/ElementMatcher.java b/service/src/main/java/lcsb/mapviewer/services/search/ElementMatcher.java index c947104992856bb393f310779a596aae011ba27f..1e01f40e07ec338fd685ea16271578579d6fa1d2 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/ElementMatcher.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/ElementMatcher.java @@ -103,8 +103,17 @@ public class ElementMatcher { return false; case OTHER: // in other case just compare names - String name = target.getGenes().get(0).getResource(); - return element.getName().equalsIgnoreCase(name); + String targetName = null; + if (target.getGenes().size() > 0) { + targetName = target.getGenes().get(0).getResource(); + } + if (targetName == null) { + targetName = target.getName(); + } + if (targetName == null) { + return false; + } + return element.getName().equalsIgnoreCase(targetName); default: throw new InvalidArgumentException("Unknown drug target type: " + target.getType()); } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java index b70b7bd0e6242fb11c95bfa3ffa91b5509224d1a..0a7a3244eacb3dc3dba1a2e3aa793323d4d9fc38 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java @@ -28,6 +28,7 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend /** * Default class logger. */ + @SuppressWarnings("unused") private final Logger logger = Logger.getLogger(SearchResultFactory.class); /** diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/DbSearchService.java b/service/src/main/java/lcsb/mapviewer/services/search/db/DbSearchService.java new file mode 100644 index 0000000000000000000000000000000000000000..43bdc10b273b2dae5058ab2cf180b02bac634abf --- /dev/null +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/DbSearchService.java @@ -0,0 +1,48 @@ +package lcsb.mapviewer.services.search.db; + +import java.util.HashSet; +import java.util.Set; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import lcsb.mapviewer.annotation.data.Target; +import lcsb.mapviewer.annotation.data.TargettingStructure; +import lcsb.mapviewer.annotation.services.PubmedParser; +import lcsb.mapviewer.annotation.services.PubmedSearchException; +import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; +import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.MiriamType; + +@Transactional(value = "txManager") +public abstract class DbSearchService { + + /** + * Service accessing + * <a href="http://europepmc.org/RestfulWebService">pubmed</a>. + */ + @Autowired + private PubmedParser pubmedParser; + + protected void cacheMiriamData(TargettingStructure targettingStructure) throws AnnotatorException { + Set<MiriamData> result = new HashSet<>(); + result.addAll(targettingStructure.getSources()); + for (Target target : targettingStructure.getTargets()) { + result.addAll(target.getGenes()); + result.addAll(target.getReferences()); + + } + + for (MiriamData miriamData : result) { + if (MiriamType.PUBMED.equals(miriamData.getDataType())) { + try { + pubmedParser.getPubmedArticleById(Integer.valueOf(miriamData.getResource())); + } catch (NumberFormatException | PubmedSearchException e) { + throw new AnnotatorException(e); + } + } + } + + } + +} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalService.java b/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalService.java index 7ada8d540a60128a2b971d5fbdf54f7d30ac57ff..94eaaef9c453f396703f1b202b8d475d9a936906 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalService.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalService.java @@ -17,12 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import lcsb.mapviewer.annotation.data.Chemical; -import lcsb.mapviewer.annotation.data.Target; -import lcsb.mapviewer.annotation.data.TargettingStructure; import lcsb.mapviewer.annotation.services.ChemicalParser; import lcsb.mapviewer.annotation.services.ChemicalSearchException; -import lcsb.mapviewer.annotation.services.PubmedParser; -import lcsb.mapviewer.annotation.services.PubmedSearchException; import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator; import lcsb.mapviewer.common.IProgressUpdater; @@ -38,6 +34,7 @@ import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.statistics.SearchType; import lcsb.mapviewer.services.interfaces.ISearchHistoryService; import lcsb.mapviewer.services.search.db.DbSearchCriteria; +import lcsb.mapviewer.services.search.db.DbSearchService; /** * Implementation of the service that allows access information about chemicals. @@ -46,7 +43,7 @@ import lcsb.mapviewer.services.search.db.DbSearchCriteria; * */ @Transactional(value = "txManager") -public class ChemicalService implements IChemicalService { +public class ChemicalService extends DbSearchService implements IChemicalService { /** * Default class logger. @@ -70,13 +67,6 @@ public class ChemicalService implements IChemicalService { @Autowired private HgncAnnotator hgncAnnotator; - /** - * Service accessing - * <a href="http://europepmc.org/RestfulWebService">pubmed</a>. - */ - @Autowired - private PubmedParser pubmedParser; - /** * Service that manages search history. */ @@ -323,25 +313,4 @@ public class ChemicalService implements IChemicalService { } } - private void cacheMiriamData(TargettingStructure targettingStructure) throws AnnotatorException { - Set<MiriamData> result = new HashSet<>(); - result.addAll(targettingStructure.getSources()); - for (Target target : targettingStructure.getTargets()) { - result.addAll(target.getGenes()); - result.addAll(target.getReferences()); - - } - - for (MiriamData miriamData : result) { - if (miriamData.getDataType().equals(MiriamType.PUBMED)) { - try { - pubmedParser.getPubmedArticleById(Integer.valueOf(miriamData.getResource())); - } catch (NumberFormatException | PubmedSearchException e) { - throw new AnnotatorException(e); - } - } - } - - } - } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugService.java b/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugService.java index e1bb55227d5eb21f88d83557c69df96d62a2e9e7..c220c2a4c102b82ea351dadb4c272f68aaad35e0 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugService.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugService.java @@ -13,12 +13,9 @@ import org.springframework.transaction.annotation.Transactional; import lcsb.mapviewer.annotation.data.Drug; import lcsb.mapviewer.annotation.data.Target; -import lcsb.mapviewer.annotation.data.TargettingStructure; import lcsb.mapviewer.annotation.services.ChEMBLParser; import lcsb.mapviewer.annotation.services.DrugSearchException; import lcsb.mapviewer.annotation.services.DrugbankHTMLParser; -import lcsb.mapviewer.annotation.services.PubmedParser; -import lcsb.mapviewer.annotation.services.PubmedSearchException; import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator; import lcsb.mapviewer.common.IProgressUpdater; @@ -33,6 +30,7 @@ import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.statistics.SearchType; import lcsb.mapviewer.services.interfaces.ISearchHistoryService; import lcsb.mapviewer.services.search.db.DbSearchCriteria; +import lcsb.mapviewer.services.search.db.DbSearchService; /** * Implementation of the service that allows access information about drugs. @@ -41,7 +39,7 @@ import lcsb.mapviewer.services.search.db.DbSearchCriteria; * */ @Transactional(value = "txManager") -public class DrugService implements IDrugService { +public class DrugService extends DbSearchService implements IDrugService { /** * Default class logger. @@ -67,13 +65,6 @@ public class DrugService implements IDrugService { @Autowired private HgncAnnotator hgncAnnotator; - /** - * Service accessing - * <a href="http://europepmc.org/RestfulWebService">pubmed</a>. - */ - @Autowired - private PubmedParser pubmedParser; - /** * Service that manages search history. */ @@ -282,14 +273,14 @@ public class DrugService implements IDrugService { } } try { - List<Drug> drugs = drugBankParser.getDrugListByTargets(targetsMiriam); + List<Drug> drugs = drugBankParser.getDrugListByTargets(targetsMiriam, searchCriteria.getOrganisms()); drugList.addAll(drugs); } catch (DrugSearchException e) { logger.error("Problem with accessing drugBank parser", e); } try { - List<Drug> drugs = chEMBLParser.getDrugListByTargets(targetsMiriam); + List<Drug> drugs = chEMBLParser.getDrugListByTargets(targetsMiriam, searchCriteria.getOrganisms()); drugList.addAll(drugs); } catch (DrugSearchException e) { logger.error("Problem with accessing chembl parser", e); @@ -348,23 +339,6 @@ public class DrugService implements IDrugService { this.searchHistoryService = searchHistoryService; } - /** - * @return the pubmedParser - * @see #pubmedParser - */ - public PubmedParser getPubmedParser() { - return pubmedParser; - } - - /** - * @param pubmedParser - * the pubmedParser to set - * @see #pubmedParser - */ - public void setPubmedParser(PubmedParser pubmedParser) { - this.pubmedParser = pubmedParser; - } - @Override public void cacheDataForModel(Model originalModel, IProgressUpdater iProgressUpdater) { logger.debug("Caching drug queries..."); @@ -386,9 +360,10 @@ public class DrugService implements IDrugService { } } double counter = 0.0; + List<MiriamData> organisms = new ArrayList<>(); for (MiriamData md : targetMiriams) { try { - List<Drug> chemicalList = drugBankParser.getDrugListByTarget(md); + List<Drug> chemicalList = drugBankParser.getDrugListByTarget(md, organisms); for (Drug chemical : chemicalList) { cacheMiriamData(chemical); } @@ -396,7 +371,7 @@ public class DrugService implements IDrugService { logger.error("Problem with accessing info about drugbank for target: " + md, e); } try { - List<Drug> chemicalList = chEMBLParser.getDrugListByTarget(md); + List<Drug> chemicalList = chEMBLParser.getDrugListByTarget(md, organisms); for (Drug chemical : chemicalList) { cacheMiriamData(chemical); } @@ -409,26 +384,4 @@ public class DrugService implements IDrugService { } } } - - private void cacheMiriamData(TargettingStructure targettingStructure) throws AnnotatorException { - Set<MiriamData> result = new HashSet<>(); - result.addAll(targettingStructure.getSources()); - for (Target target : targettingStructure.getTargets()) { - result.addAll(target.getGenes()); - result.addAll(target.getReferences()); - - } - - for (MiriamData miriamData : result) { - if (miriamData.getDataType().equals(MiriamType.PUBMED)) { - try { - pubmedParser.getPubmedArticleById(Integer.valueOf(miriamData.getResource())); - } catch (NumberFormatException | PubmedSearchException e) { - throw new AnnotatorException(e); - } - } - } - - } - } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAService.java b/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAService.java index 57ccbb24e684aa05fd347e39cc442cfdd3125d8a..136a1022424a2a323b18978ef40fa64aca9b8645 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAService.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAService.java @@ -15,11 +15,8 @@ import org.springframework.transaction.annotation.Transactional; import lcsb.mapviewer.annotation.data.MiRNA; import lcsb.mapviewer.annotation.data.Target; -import lcsb.mapviewer.annotation.data.TargettingStructure; import lcsb.mapviewer.annotation.services.MiRNAParser; import lcsb.mapviewer.annotation.services.MiRNASearchException; -import lcsb.mapviewer.annotation.services.PubmedParser; -import lcsb.mapviewer.annotation.services.PubmedSearchException; import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator; import lcsb.mapviewer.common.IProgressUpdater; @@ -34,6 +31,7 @@ import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.statistics.SearchType; import lcsb.mapviewer.services.interfaces.ISearchHistoryService; import lcsb.mapviewer.services.search.db.DbSearchCriteria; +import lcsb.mapviewer.services.search.db.DbSearchService; /** * Implementation of the service that allows access information about che. @@ -42,7 +40,7 @@ import lcsb.mapviewer.services.search.db.DbSearchCriteria; * */ @Transactional(value = "txManager") -public class MiRNAService implements IMiRNAService { +public class MiRNAService extends DbSearchService implements IMiRNAService { /** * Default class logger. @@ -68,13 +66,6 @@ public class MiRNAService implements IMiRNAService { @Autowired private ISearchHistoryService searchHistoryService; - /** - * Service accessing - * <a href="http://europepmc.org/RestfulWebService">pubmed</a>. - */ - @Autowired - private PubmedParser pubmedParser; - /** * Default constructor. */ @@ -243,25 +234,4 @@ public class MiRNAService implements IMiRNAService { } } - private void cacheMiriamData(TargettingStructure targettingStructure) throws AnnotatorException { - Set<MiriamData> result = new HashSet<>(); - result.addAll(targettingStructure.getSources()); - for (Target target : targettingStructure.getTargets()) { - result.addAll(target.getGenes()); - result.addAll(target.getReferences()); - - } - - for (MiriamData miriamData : result) { - if (miriamData.getDataType().equals(MiriamType.PUBMED)) { - try { - pubmedParser.getPubmedArticleById(Integer.valueOf(miriamData.getResource())); - } catch (NumberFormatException | PubmedSearchException e) { - throw new AnnotatorException(e); - } - } - } - - } - } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactory.java index e42bc74452ab802039cdd8f87ac09afeb0eff40f..c08811bee4ad4a6f7c1f75b4fd60143f0e862d03 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactory.java @@ -5,6 +5,7 @@ import org.apache.log4j.Logger; import com.google.gson.Gson; import lcsb.mapviewer.common.Pair; +import lcsb.mapviewer.common.geometry.ColorParser; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GeneVariationColorSchema; import lcsb.mapviewer.model.map.species.Element; @@ -18,18 +19,26 @@ import lcsb.mapviewer.services.utils.data.ColorSchemaType; * */ public class FullLayoutAliasViewFactory extends ElementViewFactory<Pair<Element, ColorSchema>, FullLayoutAliasView> { + + /** + * Parser to map color into object that can be returned to client side. + */ + private ColorParser parser = new ColorParser(); + /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(FullLayoutAliasViewFactory.class); + private static Logger logger = Logger.getLogger(FullLayoutAliasViewFactory.class); @Override public FullLayoutAliasView create(Pair<Element, ColorSchema> pair) { ColorSchema schema = pair.getRight(); FullLayoutAliasView result = new FullLayoutAliasView(pair.getLeft()); - result.setColor(schema.getColor()); + if (schema.getColor() != null) { + result.setColor(parser.colorToMap(schema.getColor())); + } result.setValue(schema.getValue()); result.setDescription(schema.getDescription()); if (schema instanceof GeneVariationColorSchema) { diff --git a/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasView.java b/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasView.java index bf8008175a72d11552548b7fc551cbeb968cf229..f4f8d5a612377b1428936b3d377afa5d1e692486 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasView.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasView.java @@ -1,6 +1,6 @@ package lcsb.mapviewer.services.search.layout; -import java.awt.Color; +import java.util.Map; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.search.ElementView; @@ -18,17 +18,17 @@ public class LightLayoutAliasView extends ElementView { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Value used to highlight {@link Element} in a a layout. */ - private Double value; + private Double value; /** * Color used to highlight {@link Element} in a layout. */ - private Color color; + private Map<String, Object> color; /** * Default constructor. @@ -68,7 +68,7 @@ public class LightLayoutAliasView extends ElementView { * @return the color * @see #color */ - public Color getColor() { + public Map<String, Object> getColor() { return color; } @@ -77,7 +77,7 @@ public class LightLayoutAliasView extends ElementView { * the color to set * @see #color */ - public void setColor(Color color) { + public void setColor(Map<String, Object> color) { this.color = color; } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactory.java index 0f37f3a0afe17a79edab2d9858bb2aed061e0d71..910a1b5a474907361138f8dbb12f91f18c58cc61 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactory.java @@ -5,6 +5,7 @@ import org.apache.log4j.Logger; import com.google.gson.Gson; import lcsb.mapviewer.common.Pair; +import lcsb.mapviewer.common.geometry.ColorParser; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.search.ElementViewFactory; @@ -16,16 +17,25 @@ import lcsb.mapviewer.services.search.ElementViewFactory; * */ public class LightLayoutAliasViewFactory extends ElementViewFactory<Pair<Element, ColorSchema>, LightLayoutAliasView> { + + /** + * Parser to map color into object that can be returned to client side. + */ + + private ColorParser parser = new ColorParser(); + /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(LightLayoutAliasViewFactory.class); + private static Logger logger = Logger.getLogger(LightLayoutAliasViewFactory.class); @Override public LightLayoutAliasView create(Pair<Element, ColorSchema> pair) { LightLayoutAliasView result = new LightLayoutAliasView(pair.getLeft()); - result.setColor(pair.getRight().getColor()); + if (pair.getRight().getColor() != null) { + result.setColor(parser.colorToMap(pair.getRight().getColor())); + } result.setValue(pair.getRight().getValue()); return result; } 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 94efeff004bd03caad4b272cf9f8d159c8d6bfa1..3d856d3868a883178a88bcc15e7f538993fa766c 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java @@ -573,7 +573,7 @@ public class ColorSchemaReader { String[] values = line.split("\t", -1); ColorSchema schema = new GenericColorSchema(); processNameColumn(schema, values[0]); - schema.setValue(1.0); + schema.setDescription(""); result.add(schema); line = br.readLine(); } diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/LayoutServiceTest2.java b/service/src/test/java/lcsb/mapviewer/services/impl/LayoutServiceTest2.java index 3d409a1875ba3518299d2c78f88b95ec5cc1d51c..0d39e9cb6d0e88baaf86092b6775bf51f84a09f7 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/LayoutServiceTest2.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/LayoutServiceTest2.java @@ -37,7 +37,7 @@ import lcsb.mapviewer.services.utils.data.ColorSchemaType; public class LayoutServiceTest2 { Logger logger = Logger.getLogger(LayoutServiceTest2.class); - ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); + ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE); @Before public void setUp() throws Exception { diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java index c6d48d10ac8341433d4fd917f1f09ee5a60fcee7..8dc37c8a7c57e7defae75f518845ffa12ca8b0bf 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java @@ -31,6 +31,7 @@ import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.model.map.species.Degraded; import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Gene; import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.Ion; @@ -50,7 +51,6 @@ import lcsb.mapviewer.services.utils.SearchIndexer; public class SearchServiceTest extends ServiceTestFunctions { static Logger logger = Logger.getLogger(SearchServiceTest.class); - private Model model = null; SearchIndexer indexer = new SearchIndexer(); Map<Class<?>, String> speciesSearchPrefix = new HashMap<Class<?>, String>(); @@ -75,9 +75,10 @@ public class SearchServiceTest extends ServiceTestFunctions { speciesSearchReversePrefix.put(prefix, clazz); } - protected void createFullModel() throws Exception { - model = getModelForFile("testFiles/searchModel.xml", false); + protected Model createFullModel() throws Exception { + Model model = getModelForFile("testFiles/searchModel.xml", false); model.setProject(new Project("unknown project")); + return model; } @After @@ -87,7 +88,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testSearchByName() throws Exception { try { - createFullModel(); + Model model = createFullModel(); long count = searchHistoryDao.getCount(); SearchElementResult result = searchService.searchByQuery(model, "reaction:re21", 50, null, "127.0.0.1"); @@ -109,7 +110,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testSearchByName2() throws Exception { try { - createFullModel(); + Model model = createFullModel(); SearchElementResult result = searchService.searchByQuery(model, "BAD:BCL-2", 50, null, "127.0.0.1"); assertNotNull(result); @@ -126,7 +127,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testSearchById() throws Exception { try { - createFullModel(); + Model model = createFullModel(); MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_HAS_VERSION, MiriamType.CAS, "123"); model.getElements().iterator().next().addMiriamData(md); SearchElementResult global = searchService.searchByQuery(model, "CAS:123", 50, null, "127.0.0.1"); @@ -138,10 +139,25 @@ public class SearchServiceTest extends ServiceTestFunctions { } } + @Test + public void testSearchByElementId() throws Exception { + try { + Model model = createFullModel(); + Element element =model.getElements().iterator().next(); + element.setId(907); + SearchElementResult global = searchService.searchByQuery(model, "element:907", 50, null, "127.0.0.1"); + assertNotNull(global); + assertEquals(1, global.size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testSearchByName4() throws Exception { try { - createFullModel(); + Model model = createFullModel(); SearchElementResult result = searchService.searchByQuery(model, "BC", 50, true, "127.0.0.1"); assertNotNull(result); @@ -166,7 +182,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testQueryName() throws Exception { try { - createFullModel(); + Model model = createFullModel(); SearchElementResult result = searchService.searchByQuery(model, indexer.getQueryStringForIndex("reaction:re21", new HashSet<>()), 50, null, "127.0.0.1"); assertNotNull(result); @@ -185,7 +201,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testQueryReactionId() throws Exception { try { - createFullModel(); + Model model = createFullModel(); model.getReactions().iterator().next().setIdReaction("R_x1"); SearchElementResult result = searchService.searchByQuery(model, indexer.getQueryStringForIndex("reaction:r_x1", new HashSet<>()), 50, null, "127.0.0.1"); @@ -199,10 +215,30 @@ public class SearchServiceTest extends ServiceTestFunctions { } } + @Test + public void testQueryReactionId2() throws Exception { + try { + Model model = createFullModel(); + Reaction reaction = model.getReactions().iterator().next(); + reaction.setId(154); + reaction.setIdReaction("test-name"); + SearchElementResult result = searchService.searchByQuery(model, indexer.getQueryStringForIndex("reaction:154", new HashSet<>()), 50, null, "127.0.0.1"); + + assertNotNull(result); + assertTrue(result.size() > 0); + FullReactionView resultReaction = (FullReactionView) result.get(0); + logger.debug(resultReaction.getName()); + assertTrue(resultReaction.getName().contains("test-name")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testQueryName2() throws Exception { try { - createFullModel(); + Model model = createFullModel(); model.getModelData().setId(-13); SearchElementResult result = searchService .searchByQuery(model, indexer.getQueryStringForIndex("BCL-2", speciesSearchReversePrefix.keySet()), 50, null, "127.0.0.1"); @@ -219,7 +255,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testQueryName3() throws Exception { try { - createFullModel(); + Model model = createFullModel(); SearchElementResult result = searchService.searchByQuery(model, "fdhgjkhdsfsdhfgfhsd", 50, null, "127.0.0.1"); assertNotNull(result); @@ -233,7 +269,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testQueryName4() throws Exception { try { - createFullModel(); + Model model = createFullModel(); SearchElementResult result = searchService .searchByQuery(model, indexer.getQueryStringForIndex("protein:BCL-2", speciesSearchReversePrefix.keySet()), 50, null, "127.0.0.1"); assertNotNull(result); @@ -249,7 +285,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testSearchClosest() throws Exception { try { - model = getModelForFile("testFiles/graph_path_example3.xml", true); + Model model = getModelForFile("testFiles/graph_path_example3.xml", true); List<BioEntity> elements = searchService.getClosestElements(model, new Point2D.Double(0, 0), 5, false); assertNotNull(elements); assertEquals(5, elements.size()); @@ -278,7 +314,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testSearchClosest2() throws Exception { try { - model = new ModelFullIndexed(null); + Model model = new ModelFullIndexed(null); GenericProtein protein1 = new GenericProtein("s1"); protein1.setWidth(20); protein1.setHeight(20); @@ -317,7 +353,7 @@ public class SearchServiceTest extends ServiceTestFunctions { @Test public void testSearchClosestWithEmptyModel() throws Exception { try { - model = new ModelFullIndexed(null); + Model model = new ModelFullIndexed(null); List<BioEntity> elements = searchService.getClosestElements(model, new Point2D.Double(0, 0), 5, false); assertNotNull(elements); assertEquals(0, elements.size()); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/AllSearchTests.java b/service/src/test/java/lcsb/mapviewer/services/search/AllSearchTests.java index 0073cd477c59c7639df3b1bd57795fbf69a7b87d..512a3b462cb76482a560273f03114acb946038b1 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/AllSearchTests.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/AllSearchTests.java @@ -13,7 +13,8 @@ import lcsb.mapviewer.services.search.layout.AllSearchLayoutTests; @SuiteClasses({ AllCommentTests.class, // AllSearchDbTests.class, // AllSearchDataTests.class, // - AllSearchLayoutTests.class,// + AllSearchLayoutTests.class, // + ElementMatcherTest.class, // }) public class AllSearchTests { diff --git a/service/src/test/java/lcsb/mapviewer/services/search/SearchResultFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/ElementMatcherTest.java similarity index 66% rename from service/src/test/java/lcsb/mapviewer/services/search/SearchResultFactoryTest.java rename to service/src/test/java/lcsb/mapviewer/services/search/ElementMatcherTest.java index 7a310be346eede812e93543470d29662e40af3fc..c34aa859e2cda767baf89001ebd4062493888e17 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/SearchResultFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/ElementMatcherTest.java @@ -1,60 +1,68 @@ -package lcsb.mapviewer.services.search; - -import static org.junit.Assert.assertTrue; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import lcsb.mapviewer.annotation.data.Chemical; -import lcsb.mapviewer.annotation.data.Target; -import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.model.map.species.Rna; -import lcsb.mapviewer.services.ServiceTestFunctions; -import lcsb.mapviewer.services.search.comment.FullCommentViewFactory; -import lcsb.mapviewer.services.search.db.DbSearchCriteria; -import lcsb.mapviewer.services.search.db.chemical.IChemicalService; - -public class SearchResultFactoryTest extends ServiceTestFunctions { - - Logger logger = Logger.getLogger(SearchResultFactoryTest.class); - - @Autowired - FullCommentViewFactory factory; - - @Autowired - IChemicalService chemicalService; - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testElementMatch() { - String geneName = "GDNF"; - Chemical view = chemicalService.getByName("Amphetamine", new DbSearchCriteria().disease(new MiriamData(MiriamType.MESH_2012, "D010300"))); - Target target = null; - for (Target t : view.getInferenceNetwork()) { - for (MiriamData row : t.getGenes()) { - if (row.getResource().equals(geneName)) { - target = t; - } - } - } - - Element element = new Rna("id"); - element.setName(geneName); - - assertTrue(factory.elementMatch(target, element)); - - } - -} +package lcsb.mapviewer.services.search; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import lcsb.mapviewer.annotation.data.Chemical; +import lcsb.mapviewer.annotation.data.Target; +import lcsb.mapviewer.annotation.data.TargetType; +import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.services.ServiceTestFunctions; +import lcsb.mapviewer.services.search.db.DbSearchCriteria; + +public class ElementMatcherTest extends ServiceTestFunctions { + + @Autowired + ElementMatcher elementMatcher; + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testMatchOther() { + Target target = new Target(); + + target.setType(TargetType.OTHER); + assertFalse(elementMatcher.elementMatch(target, new GenericProtein("s1"))); + } + + @Test + public void testElementMatch() { + String geneName = "GDNF"; + Chemical view = chemicalService.getByName("Amphetamine", new DbSearchCriteria().disease(new MiriamData(MiriamType.MESH_2012, "D010300"))); + Target target = null; + for (Target t : view.getInferenceNetwork()) { + for (MiriamData row : t.getGenes()) { + if (row.getResource().equals(geneName)) { + target = t; + } + } + } + + Element element = new Rna("id"); + element.setName(geneName); + + assertTrue(elementMatcher.elementMatch(target, element)); + + } + +} diff --git a/service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java b/service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java index 38c9407b576bc47ea3f6eb74f173dff5c0cee8e3..4553b58724e916c312df2e16878c6d6076091161 100644 --- a/service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java @@ -224,7 +224,7 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions { @Test public void testColoring3() throws Exception { try { - ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); + ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE); Model model = getModelForFile("testFiles/coloring/protein_to_color.xml", false); diff --git a/web/src/main/webapp/index.xhtml b/web/src/main/webapp/index.xhtml index f950f192d10f51a8dfaa31c11052bdc16080fdc7..086a2b1b27aeeeda422c626983d0a9a2d79269c6 100644 --- a/web/src/main/webapp/index.xhtml +++ b/web/src/main/webapp/index.xhtml @@ -47,10 +47,10 @@ function initMap(){ </script> </h:head> <h:body onload="initMap();" > +<h:outputStylesheet library="css" name="bootstrap.min.css"/> <h:outputStylesheet library="css" name="style.css"/> <h:outputStylesheet library="css" name="minerva.css" /> <h:outputStylesheet library="css" name="pileup.css"/> -<h:outputStylesheet library="css" name="bootstrap.min.css"/> <h:outputScript library="primefaces" name="jquery/jquery.js" target="head" /> <div id="minervaAppDiv" style="height: 100%;width: 100%;margin: 0;"/> diff --git a/web/src/main/webapp/resources/css/search.css b/web/src/main/webapp/resources/css/search.css index 5f9eae51172c413f0011fdbbf61bd1d15e2b77e7..b96ebd2589bd2cf77a53d8730adfb687c1e484dc 100644 --- a/web/src/main/webapp/resources/css/search.css +++ b/web/src/main/webapp/resources/css/search.css @@ -52,18 +52,3 @@ a.searchElementSubmodelLink { background: #ffffff; } -.searchDescriptionLabel { - font-weight: 900; - background: #ffffff; - line-height: 24px; -} - -.annotationRowOdd { - padding: 5px; - background-color: #EAEAEA; -} - -.annotationRowEven { - padding: 5px; - background-color: #ffffff; -} \ No newline at end of file diff --git a/web/src/main/webapp/resources/css/style.css b/web/src/main/webapp/resources/css/style.css index a47422dfd5be6de7fc1d75ddd13c0843f2a0f068..5b9d8758dc9ac33f1871c5ec80a41a4a62208dcd 100644 --- a/web/src/main/webapp/resources/css/style.css +++ b/web/src/main/webapp/resources/css/style.css @@ -1016,14 +1016,7 @@ ui-overlay-visible *{visibility:visible !important;} .ui-wizard-nav-next{float:right;} .ui-wizard-step-title{font-size:18px;margin:0 3px 0 0;padding:0.4em;float:left;} -.overview_button {color:#FFFFFF; height:36px; line-height:35px; padding:0 18px; margin:0; border:none; background-color:#017DA7; font-size:13px; font-weight:900; border-right:1px solid #9DE1F8; cursor:pointer; transition: background-color 0.4s ease-in-out 0s; } -.overview_button:hover {background-color:#01536D; transition: background-color 0.4s ease-in-out 0s; } - .rightHeaderMenu{height:36px; line-height:35px; font-size:13px; font-weight:900; color:#ffffff; display:inline; width:auto; float:right} -.div4checkboxes {height:36px; vertical-align:top; font-size:13px; font-weight:900; color:#ffffff; display:inline; width:auto; float:left; text-align:left; padding:0 0 0 15px; margin:0;} -.div4checkboxes label {padding:0 15px 0 5px; font-size:11px; line-height:35px; display:inline; float:left;} -.div4checkboxes input {margin-top:12px; display:inline; float:left;} - .ui-galleria-filmstrip {background-color:#21BDF1; padding:2px; height:68px; margin-top:0;} .ui-galleria-frame {border:1px solid #cccccc; height:34px !important;} diff --git a/web/src/test/java/lcsb/mapviewer/bean/ConfigurationBeanTest.java b/web/src/test/java/lcsb/mapviewer/bean/ConfigurationBeanTest.java index a75abab727b5737db2148f8b83116b39767a62a9..de78f41fcc601f02c197278c77d4208869803382 100644 --- a/web/src/test/java/lcsb/mapviewer/bean/ConfigurationBeanTest.java +++ b/web/src/test/java/lcsb/mapviewer/bean/ConfigurationBeanTest.java @@ -1,19 +1,6 @@ package lcsb.mapviewer.bean; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.model.user.ConfigurationElementType; -import lcsb.mapviewer.model.user.PrivilegeType; -import lcsb.mapviewer.model.user.User; -import lcsb.mapviewer.services.view.ConfigurationView; -import lcsb.mapviewer.services.view.ConfigurationViewFactory; -import lcsb.mapviewer.services.view.ProjectView; import org.apache.commons.lang3.SerializationUtils; import org.junit.After; @@ -21,15 +8,21 @@ import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.model.user.ConfigurationElementType; +import lcsb.mapviewer.model.user.PrivilegeType; +import lcsb.mapviewer.model.user.User; +import lcsb.mapviewer.services.view.ConfigurationViewFactory; + public class ConfigurationBeanTest extends WebTestFunctions { - ConfigurationBean cBean; - UserBean uBean; - String oldValue; - User user2; + ConfigurationBean cBean; + UserBean uBean; + String oldValue; + User user2; @Autowired - ConfigurationViewFactory configurationViewFactory; + ConfigurationViewFactory configurationViewFactory; @Before public void setUp() throws Exception { @@ -41,6 +34,7 @@ public class ConfigurationBeanTest extends WebTestFunctions { user2 = new User(); userService.addUser(user2); userService.setUserPrivilege(user2, PrivilegeType.CONFIGURATION_MANAGE); + userService.setUserPrivilege(user2, PrivilegeType.ADD_MAP); uBean.setLoggedUser(user2); oldValue = configurationService.getConfigurationValue(ConfigurationElementType.DEFAULT_MAP); @@ -54,35 +48,6 @@ public class ConfigurationBeanTest extends WebTestFunctions { configurationService.setConfigurationValue(ConfigurationElementType.DEFAULT_MAP, oldValue); } - @Test - public void test() throws Exception { - try { - cBean.refreshValues(null); - - assertTrue(cBean.getValues().size() > 0); - List<ConfigurationView> list = new ArrayList<ConfigurationView>(); - ConfigurationView element = configurationViewFactory.create(configurationDao.getByType(ConfigurationElementType.DEFAULT_MAP)); - element.setValue("sdfsa"); - list.add(element); - - // rollback should appear - cBean.setValues(list); - assertTrue(cBean.getValues().size() != 1); - - for (ProjectView row : projectService.getAllProjectViews()) { - if (row.getProjectId() == null) - continue; - element.setValue(row.getProjectId()); - cBean.setValues(list); - assertEquals(cBean.getValues(), list); - cBean.setValues(new ArrayList<ConfigurationView>()); - } - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - /** * Checks if bean implements {@link Serializable} properly. */