Skip to content

Commit

Permalink
start improving
Browse files Browse the repository at this point in the history
  • Loading branch information
drseb committed Feb 26, 2018
1 parent 3620fed commit 5805a14
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 75 deletions.
12 changes: 6 additions & 6 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/phenOwl"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.0">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.0">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
5 changes: 0 additions & 5 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.vaadin.integration.eclipse.addonStylesBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
Expand Down
2 changes: 1 addition & 1 deletion .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v8.0"/>
<runtime name="Apache Tomcat v9.0"/>
<fixed facet="jst.web"/>
<fixed facet="java"/>
<fixed facet="wst.jsdt.web"/>
Expand Down
3 changes: 3 additions & 0 deletions ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
<dependency org="org.vaadin.addons" name="googleanalyticstracker" rev="2.1.0" />
<dependency org="com.github.vaadin4qbanos" name="jsclipboard" rev="1.0.2" />
<dependency org="com.sebworks" name="vaadstrap" rev="0.1.2" />
<!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-distribution -->
<dependency org="net.sourceforge.owlapi" name="owlapi-distribution" rev="4.1.3"/>

</dependencies>
</ivy-module>
43 changes: 17 additions & 26 deletions src/hpoweb/HpowebUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

import java.util.Map;

import javax.servlet.annotation.WebServlet;

import org.semanticweb.owlapi.model.OWLClass;
import org.vaadin.googleanalytics.tracking.GoogleAnalyticsTracker;
import org.vaadin.viritin.fields.LazyComboBox;

import com.sebworks.vaadstrap.Col;
import com.sebworks.vaadstrap.ColMod;
import com.sebworks.vaadstrap.Container;
Expand Down Expand Up @@ -37,6 +31,12 @@
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;

import javax.servlet.annotation.WebServlet;

import org.semanticweb.owlapi.model.OWLClass;
import org.vaadin.googleanalytics.tracking.GoogleAnalyticsTracker;
import org.vaadin.viritin.fields.LazyComboBox;

import hpo.ItemId;
import hpoweb.data.HpData;
import hpoweb.data.dataprovider.IDiseaseDataProvider;
Expand Down Expand Up @@ -142,13 +142,11 @@ protected void init(VaadinRequest request) {
hpoClassTabFactory.addTermInfoElements(gridContainer, (IHpClassDataProvider) dataProvider);

addExtraButtons(gridContainer, (IHpClassDataProvider) dataProvider);
}
else if (dataProvider instanceof IDiseaseDataProvider) {
} else if (dataProvider instanceof IDiseaseDataProvider) {

DiseaseTabFactory diseaseTabFactory = new DiseaseTabFactory(tableUtils);
diseaseTabFactory.addDiseaseInfoElements(gridContainer, (IDiseaseDataProvider) dataProvider);
}
else if (dataProvider instanceof IGeneDataProvider) {
} else if (dataProvider instanceof IGeneDataProvider) {

GeneTabFactory geneTabFactory = new GeneTabFactory(tableUtils);
geneTabFactory.addGeneInfoElements(gridContainer, (IGeneDataProvider) dataProvider);
Expand All @@ -161,8 +159,7 @@ else if (dataProvider instanceof IGeneDataProvider) {
String ontologyVersion;
if (doParseHpo) {
ontologyVersion = hpData.getExtOwlOntology().getOntologyVersionIri().toString();
}
else
} else

{
ontologyVersion = "some ontology version here";
Expand All @@ -172,8 +169,8 @@ else if (dataProvider instanceof IGeneDataProvider) {
* Bottom part
*/
Label version = new Label("Ontology version: " + ontologyVersion);
Label copyright = new Label("Copyright 2017 - Sebastian Köhler & The Human Phenotype Ontology Project");
Link feedback = new Link("Question, Comments, Feedback: [email protected]", new ExternalResource("https://drseb.github.io/"));
Label copyright = new Label("Copyright 2018 - Sebastian Köhler & The Phenomics Group Berlin");
Link feedback = new Link("Contact: [email protected]", new ExternalResource("https://phenomics.github.io/"));
addLabelRow(gridContainer, version);
addLabelRow(gridContainer, copyright);
addLabelRow(gridContainer, feedback);
Expand Down Expand Up @@ -259,13 +256,11 @@ private IEntityDataProvider setupDataProvider(VaadinRequest request, Map<String,

if (doParseHpo) {
dataProvider = new HpClassDataProvider(hpClass, hpData);
}
else {
} else {
dataProvider = new FakeHpClassDataProvider();
}

}
else if (parameterMap.containsKey(CONSTANTS.geneRequestId)) {
} else if (parameterMap.containsKey(CONSTANTS.geneRequestId)) {

Integer geneId = parseGeneId(request);
if (geneId == null && doParseHpo) {
Expand All @@ -278,13 +273,11 @@ else if (parameterMap.containsKey(CONSTANTS.geneRequestId)) {
if (doParseHpo) {

dataProvider = new GeneDataProvider(geneId, hpData);
}
else {
} else {
dataProvider = new FakeGeneDataProvider();
}

}
else if (parameterMap.containsKey(CONSTANTS.diseaseRequestId)) {
} else if (parameterMap.containsKey(CONSTANTS.diseaseRequestId)) {

ItemId diseaseId = parseDiseaseId(request);
if (diseaseId == null && doParseHpo) {
Expand All @@ -296,12 +289,10 @@ else if (parameterMap.containsKey(CONSTANTS.diseaseRequestId)) {

if (doParseHpo) {
dataProvider = new DiseaseDataProvider(diseaseId, hpData);
}
else {
} else {
dataProvider = new FakeDiseaseDataProvider();
}
}
else {
} else {
new Notification("Invalid URL", "<br/><br/>You have to provide one URL parameter (" + CONSTANTS.hpRequestId + ","
+ CONSTANTS.geneRequestId + ", or " + CONSTANTS.diseaseRequestId + ") ! ", Notification.Type.WARNING_MESSAGE, true)
.show(Page.getCurrent());
Expand Down
88 changes: 51 additions & 37 deletions src/hpoweb/uicontent/tabs/hpoclass/HpoClassTabFactory.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
package hpoweb.uicontent.tabs.hpoclass;

import hpoweb.data.HpData;
import hpoweb.data.dataprovider.IHpClassDataProvider;
import hpoweb.uicontent.graph.GraphtestUI;
import hpoweb.uicontent.table.DiseaseGeneTableEntry;
import hpoweb.uicontent.table.GeneDiseaseTableEntry;
import hpoweb.uicontent.table.TableLabel;
import hpoweb.util.CONSTANTS;
import hpoweb.util.TableUtils;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;

import org.apache.commons.lang3.RandomStringUtils;
import org.semanticweb.owlapi.model.OWLClass;

import com.google.common.base.Joiner;
import com.sebworks.vaadstrap.Col;
import com.sebworks.vaadstrap.ColMod;
Expand All @@ -28,7 +16,18 @@
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;

import org.apache.commons.lang3.RandomStringUtils;
import org.semanticweb.owlapi.model.OWLClass;

import de.charite.phenowl.hpowl.util.OboUtil;
import hpoweb.data.HpData;
import hpoweb.data.dataprovider.IHpClassDataProvider;
import hpoweb.uicontent.graph.GraphtestUI;
import hpoweb.uicontent.table.DiseaseGeneTableEntry;
import hpoweb.uicontent.table.GeneDiseaseTableEntry;
import hpoweb.uicontent.table.TableLabel;
import hpoweb.util.CONSTANTS;
import hpoweb.util.TableUtils;

public class HpoClassTabFactory {

Expand Down Expand Up @@ -92,7 +91,12 @@ private VerticalLayout getAssociatedGenesTab(IHpClassDataProvider dataProvider)
VerticalLayout tableVL = new VerticalLayout();
tableVL.setSizeFull();

Label lab1 = new Label("Associated genes");
List<GeneDiseaseTableEntry> tableContent = dataProvider.getGeneDiseaseTableContent();

int numberOfDiseases = tableContent.size();

Label lab1 = new Label(numberOfDiseases + " associated genes");

lab1.addStyleName(ValoTheme.LABEL_LIGHT);
lab1.addStyleName("tab-content-header");
tableVL.addComponent(lab1);
Expand All @@ -103,17 +107,15 @@ private VerticalLayout getAssociatedGenesTab(IHpClassDataProvider dataProvider)
table.setSizeFull();
table.setHeight("275px");

List<GeneDiseaseTableEntry> tableContent = dataProvider.getGeneDiseaseTableContent();

int id = 0;
for (GeneDiseaseTableEntry entry : tableContent) {
TableLabel geneEntry = new TableLabel(entry.getGeneSymbol() + " (<a href='" + CONSTANTS.rootLocation + "?" + CONSTANTS.geneRequestId
+ "=" + entry.getGeneId() + "'>" + entry.getGeneId() + "</a>)", ContentMode.HTML);
TableLabel geneEntry = new TableLabel(entry.getGeneSymbol() + " (<a href='" + CONSTANTS.rootLocation + "?" + CONSTANTS.geneRequestId + "="
+ entry.getGeneId() + "'>" + entry.getGeneId() + "</a>)", ContentMode.HTML);

String diseasesString = tableUtils.getDiseasesAsHtmlString(entry.getAssociatedDiseases(), CONSTANTS.rootLocation);

TableLabel diseases = new TableLabel(diseasesString, ContentMode.HTML);
Integer itemId = new Integer(id++);
Integer itemId = Integer.valueOf(id++);
table.addItem(new Object[] { geneEntry, diseases }, itemId);
}

Expand All @@ -134,8 +136,12 @@ private VerticalLayout getAssociatedGenesTab(IHpClassDataProvider dataProvider)
private VerticalLayout getAssociatedDiseasesTab(IHpClassDataProvider dataProvider) {
VerticalLayout tableVL = new VerticalLayout();
tableVL.setSizeFull();
List<DiseaseGeneTableEntry> tableContent = dataProvider.getDiseaseGeneTableContent();

int numberOfDiseases = tableContent.size();

Label lab1 = new Label(numberOfDiseases + " associated diseases");

Label lab1 = new Label("Associated diseases");
lab1.addStyleName(ValoTheme.LABEL_LIGHT);
lab1.addStyleName("tab-content-header");
tableVL.addComponent(lab1);
Expand All @@ -147,18 +153,16 @@ private VerticalLayout getAssociatedDiseasesTab(IHpClassDataProvider dataProvide
table.setSizeFull();
table.setHeight("275px");

List<DiseaseGeneTableEntry> tableContent = dataProvider.getDiseaseGeneTableContent();

int id = 0;
for (DiseaseGeneTableEntry entry : tableContent) {
TableLabel diseaseid = new TableLabel("<a href='" + CONSTANTS.rootLocation + "?" + CONSTANTS.diseaseRequestId + "="
+ entry.getDiseaseId() + "'>" + entry.getDiseaseId() + "</a>", ContentMode.HTML);
TableLabel diseaseid = new TableLabel("<a href='" + CONSTANTS.rootLocation + "?" + CONSTANTS.diseaseRequestId + "=" + entry.getDiseaseId()
+ "'>" + entry.getDiseaseId() + "</a>", ContentMode.HTML);
TableLabel diseasename = new TableLabel(entry.getDiseaseName(), ContentMode.HTML);

String genesString = tableUtils.getGenesAsHtmlString(entry.getAssociatedGenes(), CONSTANTS.rootLocation);

TableLabel genes = new TableLabel(genesString, ContentMode.HTML);
Integer itemId = new Integer(id++);
Integer itemId = Integer.valueOf(id++);
table.addItem(new Object[] { diseaseid, diseasename, genes }, itemId);
}

Expand Down Expand Up @@ -186,9 +190,8 @@ private VerticalLayout getSynonymsVl(IHpClassDataProvider dataProvider) {

Collection<String> synonyms = dataProvider.getSynonyms();
if (synonyms.size() < 1) {
Label suggestSyn = new Label(
"Currently the HPO does not have any synonyms for this class. "
+ "Suggest a synonym at our <a href='https://github.com/obophenotype/human-phenotype-ontology/issues/' target='_new'>github tracker</a>",
Label suggestSyn = new Label("Currently the HPO does not have any synonyms for this class. "
+ "Suggest a synonym at our <a href='https://github.com/obophenotype/human-phenotype-ontology/issues/' target='_new'>github tracker</a>",
ContentMode.HTML);
suggestSyn.addStyleName("tab-content-content");
vl_syns.addComponent(suggestSyn);
Expand Down Expand Up @@ -223,8 +226,8 @@ private VerticalLayout getIdentifiersVl(IHpClassDataProvider dataProvider) {
* Secondary ID
*/
Label lab2 = new Label("Alternative IDs");
lab2.setDescription("These are other identifiers which are referring to the same HPO class. "
+ "These are introduced when classes are merged.");
lab2.setDescription(
"These are other identifiers which are referring to the same HPO class. " + "These are introduced when classes are merged.");
lab2.addStyleName(ValoTheme.LABEL_LIGHT);
lab2.addStyleName("tab-content-header");

Expand All @@ -240,8 +243,9 @@ private VerticalLayout getIdentifiersVl(IHpClassDataProvider dataProvider) {
* PURLs
*/
Label lab3 = new Label("PURL");
lab3.setDescription("This is a persistent URL. Please see <a href='https://en.wikipedia.org/wiki/Persistent_uniform_resource_locator' target='_new'>"
+ "this wikipedia article</a> for more information on PURLs.");
lab3.setDescription(
"This is a persistent URL. Please see <a href='https://en.wikipedia.org/wiki/Persistent_uniform_resource_locator' target='_new'>"
+ "this wikipedia article</a> for more information on PURLs.");
lab3.addStyleName(ValoTheme.LABEL_LIGHT);
lab3.addStyleName("tab-content-header");
Label iriLabel = new Label("<a href='" + dataProvider.getIRI() + "' target='_new'>" + dataProvider.getIRI() + "</a>", ContentMode.HTML);
Expand Down Expand Up @@ -282,7 +286,8 @@ private VerticalLayout getDefinitionsVl(IHpClassDataProvider dataProvider) {
* Logical def
*/
Label lab2 = new Label("Logical definition");
lab2.setDescription("This is a computer readable logical definition of the HPO class. If you want to learn more about this please see <a href='https://nar.oxfordjournals.org/content/42/D1/D966.full' target='_new'>https://nar.oxfordjournals.org/content/42/D1/D966.full</a>.");
lab2.setDescription(
"This is a computer readable logical definition of the HPO class. If you want to learn more about this please see <a href='https://nar.oxfordjournals.org/content/42/D1/D966.full' target='_new'>https://nar.oxfordjournals.org/content/42/D1/D966.full</a>.");
lab2.addStyleName(ValoTheme.LABEL_LIGHT);
lab2.addStyleName("tab-content-header");

Expand Down Expand Up @@ -317,8 +322,8 @@ private VerticalLayout getSubSuperClassesVl(IHpClassDataProvider dataProvider) {
Collection<String> superClassesHtmlString = convertToHtml(superClasses, CONSTANTS.rootLocation);
Collection<String> subClassesHtmlString = convertToHtml(subClasses, CONSTANTS.rootLocation);

addLabelsSupSub(superClassesHtmlString, "Superclasses", vlSubSuperClasses);
addLabelsSupSub(subClassesHtmlString, "Subclasses", vlSubSuperClasses);
addLabelsSupSub(superClassesHtmlString, "Superclasses", vlSubSuperClasses, superClasses);
addLabelsSupSub(subClassesHtmlString, "Subclasses", vlSubSuperClasses, subClasses);

vlSubSuperClasses.addStyleName("tab-content-vl");
return vlSubSuperClasses;
Expand All @@ -328,7 +333,7 @@ private VerticalLayout getSuperClassesVl(IHpClassDataProvider dataProvider) {
VerticalLayout vlSubSuperClasses = new VerticalLayout();
Collection<OWLClass> superClasses = dataProvider.getSuperClasses();
Collection<String> superClassesHtmlString = convertToHtml(superClasses, CONSTANTS.rootLocation);
addLabelsSupSub(superClassesHtmlString, "Superclasses", vlSubSuperClasses);
addLabelsSupSub(superClassesHtmlString, "Superclasses", vlSubSuperClasses, superClasses);
vlSubSuperClasses.addStyleName("tab-content-vl");
return vlSubSuperClasses;
}
Expand All @@ -337,12 +342,13 @@ private VerticalLayout getSubClassesVl(IHpClassDataProvider dataProvider) {
VerticalLayout vlSubSuperClasses = new VerticalLayout();
Collection<OWLClass> subClasses = dataProvider.getSubClasses();
Collection<String> subClassesHtmlString = convertToHtml(subClasses, CONSTANTS.rootLocation);
addLabelsSupSub(subClassesHtmlString, "Subclasses", vlSubSuperClasses);
addLabelsSupSub(subClassesHtmlString, "Subclasses", vlSubSuperClasses, subClasses);
vlSubSuperClasses.addStyleName("tab-content-vl");
return vlSubSuperClasses;
}

private void addLabelsSupSub(Collection<String> superClassesHtmlString, String string, VerticalLayout vlSubSuperClasses) {
private void addLabelsSupSub(Collection<String> superClassesHtmlString, String string, VerticalLayout vlSubSuperClasses,
Collection<OWLClass> classes) {
/*
* Super or sub classes
*/
Expand All @@ -356,6 +362,14 @@ private void addLabelsSupSub(Collection<String> superClassesHtmlString, String s
vlSubSuperClasses.addComponent(labelSuperclasses);
}

// for (OWLClass c : classes) {
// String id = OboUtil.IRI2ID(c.getIRI());
// String label = hpData.getExtOwlOntology().getLabel(c.getIRI());
// Button b = new Button(label);
// b.addClickListener(new UpdatePageClickListener(id, label));
// vlSubSuperClasses.addComponent(b);
// }

}

private Collection<String> convertToHtml(Collection<OWLClass> classes, String oldLocation) {
Expand Down
23 changes: 23 additions & 0 deletions src/hpoweb/util/UpdatePageClickListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package hpoweb.util;

import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Notification;

public class UpdatePageClickListener implements ClickListener {

private String id;
private String label;

public UpdatePageClickListener(String id, String label) {
this.id = id;
this.label = label;

}

@Override
public void buttonClick(ClickEvent event) {
Notification.show(id + " " + label);
}

}

0 comments on commit 5805a14

Please sign in to comment.