From dd35823e28a6a989722aff0b15b073dd94ad01e8 Mon Sep 17 00:00:00 2001
From: sernadela
Date: Tue, 18 Jun 2013 16:56:25 +0100
Subject: [PATCH 01/52] - Remove unused DiseaseCard code
---
.../coeus/api/plugins/OMIMPlugin.java | 314 ------------------
.../bioinformatics/coeus/common/Builder.java | 5 +-
.../coeus/data/connect/PluginFactory.java | 86 -----
.../coeus/ext/COEUSActionBeanContext.java | 62 ----
.../diseasecard/domain/Disease.java | 122 -------
5 files changed, 1 insertion(+), 588 deletions(-)
delete mode 100755 src/main/java/pt/ua/bioinformatics/coeus/api/plugins/OMIMPlugin.java
delete mode 100755 src/main/java/pt/ua/bioinformatics/coeus/data/connect/PluginFactory.java
delete mode 100755 src/main/java/pt/ua/bioinformatics/coeus/ext/COEUSActionBeanContext.java
delete mode 100755 src/main/java/pt/ua/bioinformatics/diseasecard/domain/Disease.java
diff --git a/src/main/java/pt/ua/bioinformatics/coeus/api/plugins/OMIMPlugin.java b/src/main/java/pt/ua/bioinformatics/coeus/api/plugins/OMIMPlugin.java
deleted file mode 100755
index 4e199b7..0000000
--- a/src/main/java/pt/ua/bioinformatics/coeus/api/plugins/OMIMPlugin.java
+++ /dev/null
@@ -1,314 +0,0 @@
-package pt.ua.bioinformatics.coeus.api.plugins;
-
-import au.com.bytecode.opencsv.CSVReader;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import pt.ua.bioinformatics.coeus.api.API;
-import pt.ua.bioinformatics.coeus.api.PrefixFactory;
-import pt.ua.bioinformatics.coeus.common.Boot;
-import pt.ua.bioinformatics.coeus.common.Config;
-import pt.ua.bioinformatics.coeus.data.Predicate;
-import pt.ua.bioinformatics.coeus.domain.Resource;
-import pt.ua.bioinformatics.diseasecard.domain.Disease;
-
-/**
- * DiseaseCard plugin for OMIM data handling.
- * Generates initial gene and disease dataset based on OMIM's morbid map.
- *
- *
- * @author pedrolopes
- */
-public class OMIMPlugin {
-
- private Resource res;
- private API api;
- private HashMap diseases;
- private HashMap genotypes;
-
- public HashMap getGenotypes() {
- return genotypes;
- }
-
- public void setGenotypes(HashMap genotypes) {
- this.genotypes = genotypes;
- }
-
- public HashMap getDiseases() {
- return diseases;
- }
-
- public void setDiseases(HashMap diseases) {
- this.diseases = diseases;
- }
-
- public Resource getRes() {
- return res;
- }
-
- public void setRes(Resource res) {
- this.res = res;
- }
-
- public OMIMPlugin(Resource res) {
- this.res = res;
- this.diseases = new HashMap();
- this.genotypes = new HashMap();
- this.api = Boot.getAPI();
- }
-
- /**
- * OMIMPlugin controller.
- * Workflow:
- * Load genotype information from OMIM genemap
- * Load phenotype information from OMIM morbidmap
- * Import loaded dataset into COEUS SDB
- *
- *
- */
- public void itemize() {
- if (loadGenotype() && loadPhenotype()) {
- triplify();
- }
- }
-
- /**
- * Loads genotype information from OMIM genemap into internal memory.
- *
- * @return success of the operation.
- */
- private boolean loadGenotype() {
- boolean success = true;
- try {
- //URL u = new URL("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/genemap");
- URL u = new URL("http://localhost/~pedrolopes/omim/genemap_small");
- BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream()));
- CSVReader reader = new CSVReader(in, '|');
- List genemap = reader.readAll();
- for (String[] genes : genemap) {
- Disease d = new Disease(genes[7], genes[9]);
- d.setLocation(genes[4]);
- genotypes.put(d.getOmimId(), d);
- String[] genelist = genes[5].split(", ");
- d.getGenes().addAll(Arrays.asList(genelist));
- }
- success = true;
- } catch (Exception ex) {
- if (Config.isDebug()) {
- System.out.println("[COEUS][OMIM] Unable to load genotype information from OMIM");
- Logger.getLogger(OMIMPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return success;
-
- }
-
- /**
- * Loads phenotype information from OMIM morbid into internal memory.
- *
- * @return success of the operation.
- */
- private boolean loadPhenotype() {
- boolean success = false;
- try {
- //URL u = new URL("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap");
- URL u = new URL("http://localhost/~pedrolopes/omim/morbidmap_small");
- BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream()));
- CSVReader reader = new CSVReader(in, '|');
- List morbidmap = reader.readAll();
- Pattern p = Pattern.compile("[0-9]{6}");
-
- for (String[] disease : morbidmap) {
- Disease d;
- Matcher m = p.matcher(disease[0]);
- String pheno_omim = "";
- String dis_name = "";
-
- try {
- if (m.find()) {
- pheno_omim = m.group(0);
- dis_name = disease[0].substring(0, disease[0].length() - 14);
-
- // check if disease is already on list
- if (diseases.containsKey(pheno_omim)) {
- d = diseases.get(pheno_omim);
- d.getNames().add(dis_name);
- Disease genotype = genotypes.get(disease[2]);
- if (!d.getGenotypes().contains(genotype)) {
- d.getGenotypes().add(genotype);
- }
- if (!genotype.getPhenotypes().contains(d)) {
- genotype.getPhenotypes().add(d);
- }
- String[] genelist = disease[1].split(", ");
- d.getGenes().addAll(Arrays.asList(genelist));
- } else {
- d = new Disease(dis_name, pheno_omim);
- d.setLocation(disease[3]);
- d.getNames().add(dis_name);
- diseases.put(pheno_omim, d);
- Disease genotype = genotypes.get(disease[2]);
- if (!d.getGenotypes().contains(genotype)) {
- d.getGenotypes().add(genotype);
- }
- if (!genotype.getPhenotypes().contains(d)) {
- genotype.getPhenotypes().add(d);
- }
- String[] genelist = disease[1].split(", ");
- d.getGenes().addAll(Arrays.asList(genelist));
- }
- // not a phenotype, add to only genotypes list
- } else {
- Disease genotype = genotypes.get(disease[2]);
- d = new Disease(disease[0], genotype.getOmimId());
- d.getNames().add(disease[0]);
- d.setLocation(disease[3]);
- if (!d.getGenotypes().contains(genotype)) {
- d.getGenotypes().add(genotype);
- }
- if (!genotype.getPhenotypes().contains(d)) {
- genotype.getPhenotypes().add(d);
- }
- diseases.put(d.getOmimId(), d);
- }
- } catch (Exception ex) {
- if (Config.isDebug()) {
- System.out.println("[COEUS][OMIM] Unable to load phenotype information from OMIM for " + disease[0]);
- Logger.getLogger(OMIMPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- success = true;
- } catch (Exception ex) {
- if (Config.isDebug()) {
- System.out.println("[COEUS][OMIM] Unable to load phenotype information from OMIM");
- Logger.getLogger(OMIMPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return success;
- }
-
- /**
- * Loads the in-memory data into COEUS SDB.
- * Workflow
- * Loads genotypes
- * Loads genes for each genotype
- * Loads genotypes for each genotype
- * Loads genes for each phenotype
- *
- *
- */
- public void triplify() {
- for (Disease genotype : genotypes.values()) {
- if (!genotype.getOmimId().equals("")) {
- try {
- String[] itemTmp = res.getIsResourceOf().getLabel().split("_");
- com.hp.hpl.jena.rdf.model.Resource geno_item = api.createResource(PrefixFactory.getURIForPrefix(Config.getKeyPrefix()) + itemTmp[1] + "_" + genotype.getOmimId());
- com.hp.hpl.jena.rdf.model.Resource geno_obj = api.createResource(PrefixFactory.getURIForPrefix(Config.getKeyPrefix()) + "Item");
- api.addStatement(geno_item, Predicate.get("rdf:type"), geno_obj);
-
- // set Item label
- api.addStatement(geno_item, Predicate.get("rdfs:label"), "omim_" + genotype.getOmimId());
-
- // associate Item with Concept
- com.hp.hpl.jena.rdf.model.Resource con = api.getResource(res.getIsResourceOf().getUri());
- api.addStatement(geno_item, Predicate.get("coeus:hasConcept"), con);
- api.addStatement(con, Predicate.get("coeus:isConceptOf"), geno_item);
-
- // add name/comment
- api.addStatement(geno_item, Predicate.get("rdfs:comment"), genotype.getName());
- api.addStatement(geno_item, Predicate.get("dc:description"), genotype.getName());
- for (String name : genotype.getNames()) {
- api.addStatement(geno_item, Predicate.get("diseasecard:name"), name);
- }
-
- api.addStatement(geno_item, Predicate.get("diseasecard:omim"), genotype.getOmimId());
- api.addStatement(geno_item, Predicate.get("diseasecard:chromosomalLocation"), genotype.getLocation());
-
- triplifyGenes(genotype.getGenes(), geno_item);
-
- for (Disease phenotype : genotype.getPhenotypes()) {
- com.hp.hpl.jena.rdf.model.Resource pheno_item = api.createResource(PrefixFactory.getURIForPrefix(Config.getKeyPrefix()) + itemTmp[1] + "_" + phenotype.getOmimId());
- com.hp.hpl.jena.rdf.model.Resource pheno_obj = api.createResource(PrefixFactory.getURIForPrefix(Config.getKeyPrefix()) + "Item");
- api.addStatement(pheno_item, Predicate.get("rdf:type"), pheno_obj);
-
- // set Item label
- api.addStatement(pheno_item, Predicate.get("rdfs:label"), "hgnc_" + phenotype.getOmimId());
-
- // associate Item with Concept
- com.hp.hpl.jena.rdf.model.Resource pheno_concept = api.getResource(res.getIsResourceOf().getUri());
- api.addStatement(pheno_item, Predicate.get("coeus:hasConcept"), pheno_concept);
- api.addStatement(pheno_concept, Predicate.get("coeus:isConceptOf"), pheno_item);
-
- // add name/comment
- api.addStatement(pheno_item, Predicate.get("rdfs:comment"), phenotype.getName());
- api.addStatement(pheno_item, Predicate.get("dc:description"), phenotype.getName());
- for (String name : phenotype.getNames()) {
- api.addStatement(pheno_item, Predicate.get("diseasecard:name"), name);
- }
- api.addStatement(pheno_item, Predicate.get("diseasecard:omim"), phenotype.getOmimId());
- api.addStatement(pheno_item, Predicate.get("diseasecard:chromosomalLocation"), phenotype.getLocation());
-
- //add diseasecard-specific info
- api.addStatement(pheno_item, Predicate.get("diseasecard:phenotype"), "true");
- api.addStatement(pheno_item, Predicate.get("diseasecard:hasGenotype"), geno_item);
- api.addStatement(geno_item, Predicate.get("diseasecard:hasPhenotype"), pheno_item);
-
- triplifyGenes(phenotype.getGenes(), pheno_item);
- }
-
- api.addStatement(geno_item, Predicate.get("diseasecard:genotype"), "true");
- } catch (Exception ex) {
- if (Config.isDebug()) {
- System.out.println("[COEUS][OMIM] Unable to triplify inmemory data");
- Logger.getLogger(OMIMPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- }
- }
-
- /**
- * Handles gene writing into COEUS SDB.
- *
- * @param genes the list of genes to insert.
- * @param item the item where the genes will be associated
- * (coeus:isAssociatedTo).
- */
- private void triplifyGenes(ArrayList genes, com.hp.hpl.jena.rdf.model.Resource item) {
- for (String gene : genes) {
- try {
- com.hp.hpl.jena.rdf.model.Resource gene_item = api.createResource(PrefixFactory.getURIForPrefix(Config.getKeyPrefix()) + "hgnc_" + gene);
- com.hp.hpl.jena.rdf.model.Resource gene_obj = api.createResource(PrefixFactory.getURIForPrefix(Config.getKeyPrefix()) + "Item");
- api.addStatement(gene_item, Predicate.get("rdf:type"), gene_obj);
-
- // set Item label
- api.addStatement(gene_item, Predicate.get("rdfs:label"), api.createResource("item_" + gene));
-
- // set Item title
- api.addStatement(gene_item, Predicate.get("dc:title"), gene.toUpperCase());
-
- // associate Item with Concept
- com.hp.hpl.jena.rdf.model.Resource gene_concept = api.getResource(PrefixFactory.getURIForPrefix(Config.getKeyPrefix()) + "concept_HGNC");
- api.addStatement(gene_item, Predicate.get("coeus:hasConcept"), gene_concept);
- api.addStatement(gene_concept, Predicate.get("coeus:isConceptOf"), gene_item);
- api.addStatement(gene_item, Predicate.get("coeus:isAssociatedTo"), item);
- api.addStatement(item, Predicate.get("coeus:isAssociatedTo"), gene_item);
-
- } catch (Exception ex) {
- if (Config.isDebug()) {
- System.out.println("[COEUS][OMIM] Unable to triplify gene information");
- Logger.getLogger(OMIMPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- }
-}
diff --git a/src/main/java/pt/ua/bioinformatics/coeus/common/Builder.java b/src/main/java/pt/ua/bioinformatics/coeus/common/Builder.java
index 0d53f1b..31d1816 100755
--- a/src/main/java/pt/ua/bioinformatics/coeus/common/Builder.java
+++ b/src/main/java/pt/ua/bioinformatics/coeus/common/Builder.java
@@ -10,7 +10,6 @@
import org.json.simple.parser.JSONParser;
import pt.ua.bioinformatics.coeus.data.connect.CSVFactory;
import pt.ua.bioinformatics.coeus.data.connect.LinkedDataFactory;
-import pt.ua.bioinformatics.coeus.data.connect.PluginFactory;
import pt.ua.bioinformatics.coeus.data.connect.RDFFactory;
import pt.ua.bioinformatics.coeus.data.connect.ResourceFactory;
import pt.ua.bioinformatics.coeus.data.connect.SPARQLFactory;
@@ -158,9 +157,7 @@ public static boolean readData(Resource r) {
ResourceFactory factory;
try {
if (!r.isBuilt()) {
- if (r.getPublisher().equalsIgnoreCase("plugin")) {
- factory = new PluginFactory(r);
- } else if (r.getPublisher().equalsIgnoreCase("csv")) {
+ if (r.getPublisher().equalsIgnoreCase("csv")) {
factory = new CSVFactory(r);
} else if (r.getPublisher().equalsIgnoreCase("xml")) {
factory = new XMLFactory(r);
diff --git a/src/main/java/pt/ua/bioinformatics/coeus/data/connect/PluginFactory.java b/src/main/java/pt/ua/bioinformatics/coeus/data/connect/PluginFactory.java
deleted file mode 100755
index 2a68860..0000000
--- a/src/main/java/pt/ua/bioinformatics/coeus/data/connect/PluginFactory.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package pt.ua.bioinformatics.coeus.data.connect;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import pt.ua.bioinformatics.coeus.api.API;
-import pt.ua.bioinformatics.coeus.api.plugins.OMIMPlugin;
-import pt.ua.bioinformatics.coeus.common.Boot;
-import pt.ua.bioinformatics.coeus.common.Config;
-import pt.ua.bioinformatics.coeus.data.Predicate;
-import pt.ua.bioinformatics.coeus.domain.Resource;
-
-/**
- * Data factory for transforming SPARQL data into RDF items using generic
- * Triplify.
- *
- * @author pedrolopes
- */
-public class PluginFactory implements ResourceFactory {
-
- private Resource res;
-
- public Resource getRes() {
- return res;
- }
-
- public void setRes(Resource res) {
- this.res = res;
- }
-
- public PluginFactory(Resource r) {
- this.res = r;
- }
-
- /**
- * Reads SPARQL data according to Resource information.
- * Workflow
- * Check if resource is starter/extends
- * Load SPARQL resource into ResultSet
- * Start Triplify with factory Resource
- * Get data for Item key into Triplify
- * Load data for each InheritedResource property into Triplify hashmap
- * based on SPARQL elements
- * Itemize single item
- *
- */
- public void read() {
- String[] divide = res.getEndpoint().split("://");
- String type = divide[0];
- try {
- if (type.equals("omim")) {
- OMIMPlugin omim = new OMIMPlugin(res);
- omim.itemize();
- }
- } catch (Exception ex) {
- if (Config.isDebug()) {
- System.out.println("[COEUS][SPARQLFactory] unable to load data for " + res.getUri());
- Logger.getLogger(PluginFactory.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
-
- /**
- * Updates the resource coeus:built property once the resource finished
- * building.
- *
- * @return success of the operation
- */
- public boolean save() {
- boolean success = false;
- try {
- API api = Boot.getAPI();
- com.hp.hpl.jena.rdf.model.Resource resource = api.getResource(this.res.getUri());
- api.addStatement(resource, Predicate.get("coeus:built"), true);
- success = true;
- if (Config.isDebug()) {
- System.out.println("[COEUS][API] Saved resource " + res.getUri());
- }
- } catch (Exception ex) {
- if (Config.isDebug()) {
- System.out.println("[COEUS][API] Unable to save resource " + res.getUri());
- Logger.getLogger(PluginFactory.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return success;
- }
-}
diff --git a/src/main/java/pt/ua/bioinformatics/coeus/ext/COEUSActionBeanContext.java b/src/main/java/pt/ua/bioinformatics/coeus/ext/COEUSActionBeanContext.java
deleted file mode 100755
index 9ba40d1..0000000
--- a/src/main/java/pt/ua/bioinformatics/coeus/ext/COEUSActionBeanContext.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package pt.ua.bioinformatics.coeus.ext;
-
-import java.util.ArrayList;
-import net.sourceforge.stripes.action.ActionBeanContext;
-import pt.ua.bioinformatics.diseasecard.domain.Disease;
-
-/**
- * Context Extender for COEUS Default Actions.
- * Enables the creation of custom context actions in ActionBeans, check
- * Stripes Docs for further information.
- *
- * @author pedrolopes
- */
-public class COEUSActionBeanContext extends ActionBeanContext {
-
- private static final String DISEASE = "disease";
-
- public void setDisease(String key, Object value) {
- getRequest().getSession().setAttribute(key, value);
- }
-
- public void setDisease(Object value) {
- getRequest().getSession().setAttribute(DISEASE, value);
- }
-
- public T getDisease() {
- return (T) getRequest().getSession().getAttribute(DISEASE);
- }
-
- public T getDisease(String key) {
- return (T) getRequest().getSession().getAttribute(key);
- }
-
- public T getDiseases() {
- return (T) getRequest().getSession().getAttribute(DISEASE);
- }
-
- public T getDiseases(String key) {
- return (T) getRequest().getSession().getAttribute(key);
- }
-
- public void setSearchResults(String key, ArrayList value) {
- getRequest().getSession().setAttribute(key, value);
- }
-
- public ArrayList getSearchResults(String key) {
- return (ArrayList) getRequest().getSession().getAttribute(key);
- }
-
- public void setCurrent(String key, Object value) {
- getRequest().getSession().setAttribute(key, value);
- }
-
- @SuppressWarnings("unchecked")
- public T getCurrent(String key) {
- return (T) getRequest().getSession().getAttribute(key);
- }
-}
diff --git a/src/main/java/pt/ua/bioinformatics/diseasecard/domain/Disease.java b/src/main/java/pt/ua/bioinformatics/diseasecard/domain/Disease.java
deleted file mode 100755
index 4045d22..0000000
--- a/src/main/java/pt/ua/bioinformatics/diseasecard/domain/Disease.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package pt.ua.bioinformatics.diseasecard.domain;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import pt.ua.bioinformatics.coeus.domain.Item;
-
-/**
- *
- * @author pedrolopes
- */
-public class Disease {
-
- private int id;
- private String name;
- private String omimId;
- private String location;
- private ArrayList genes = new ArrayList();
- private ArrayList names = new ArrayList();
- private ArrayList genotypes = new ArrayList();
- private ArrayList phenotypes = new ArrayList();
-
- public ArrayList getGenes() {
- return genes;
- }
-
- public String getOmimId() {
- return omimId;
- }
-
- public void setOmimId(String omim_id) {
- this.omimId = omim_id;
- }
-
- public void setGenes(ArrayList genes) {
- this.genes = genes;
- }
-
- public String getLocation() {
- return location;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public ArrayList getPhenotypes() {
- return phenotypes;
- }
-
- public void setPhenotypes(ArrayList phenotypes) {
- this.phenotypes = phenotypes;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public ArrayList getNames() {
- return names;
- }
-
- public void setNames(ArrayList names) {
- this.names = names;
- }
-
- /**
- * Loads Disease information from SDB based on its key - OMIM code.
- *
- * @param key
- */
- public Disease(int key) {
- this.id = key;
- this.omimId = String.valueOf(key);
- // this.omim = String.valueOf(key);
- try {
- } catch (Exception ex) {
- Logger.getLogger(Item.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public Disease(String name, String omim) {
- this.name = name;
- this.genotypes = new ArrayList();
- this.phenotypes = new ArrayList();
- this.names = new ArrayList();
- }
-
- public ArrayList getGenotypes() {
- return genotypes;
- }
-
- public void setGenotypes(ArrayList genotypes) {
- this.genotypes = genotypes;
- }
-
- @Override
- public String toString() {
- String response = "";
-
- response += this.omimId + "\t" + this.name;
- for (Disease s : genotypes) {
- response += "\n\t" + s.getName() + " > " + s.getOmimId();
- }
- response += "\n\tGenes";
-
- return response;
- }
-}
From f0f1f58baa742cfed7ecb999c91084645bb0cbce Mon Sep 17 00:00:00 2001
From: sernadela
Date: Thu, 20 Jun 2013 15:05:09 +0100
Subject: [PATCH 02/52] - Add security login to the manager setup
---
.../coeus/actions/SeedActionBean.java | 2 +-
src/main/resources/config.js | 14 ++--
src/main/resources/joseki.ttl | 2 +-
src/main/webapp/WEB-INF/web.xml | 42 +++++++++--
src/main/webapp/login.jsp | 72 +++++++++++++++++++
src/main/webapp/setup/html.jsp | 6 +-
src/main/webapp/setup/index.jsp | 1 -
7 files changed, 121 insertions(+), 18 deletions(-)
create mode 100644 src/main/webapp/login.jsp
diff --git a/src/main/java/pt/ua/bioinformatics/coeus/actions/SeedActionBean.java b/src/main/java/pt/ua/bioinformatics/coeus/actions/SeedActionBean.java
index 61d2aaa..0f1d77b 100644
--- a/src/main/java/pt/ua/bioinformatics/coeus/actions/SeedActionBean.java
+++ b/src/main/java/pt/ua/bioinformatics/coeus/actions/SeedActionBean.java
@@ -17,7 +17,7 @@
*
* @author sernadela
*/
-@UrlBinding("/seed/")
+@UrlBinding("/manager/")
public class SeedActionBean implements ActionBean{
private static final String VIEW="/setup/index.jsp";
private String name;
diff --git a/src/main/resources/config.js b/src/main/resources/config.js
index 481bca1..07f0d06 100644
--- a/src/main/resources/config.js
+++ b/src/main/resources/config.js
@@ -1,14 +1,14 @@
{
"config": {
-"name": "proteinator",
- "description": "COEUS Protein Data Aggregator (Proteinator)",
+"name": "coeus.NA",
+ "description": "COEUS News Aggregator",
"keyprefix":"coeus",
"version": "1.0a",
- "ontology": "http://bioinformatics.ua.pt/diseasecard/diseasecard.owl",
- "setup": "proteinator/setup.rdf",
- "sdb":"proteinator/sdb.ttl",
- "predicates":"proteinator/predicates.csv",
- "built": false,
+ "ontology": "http://bioinformatics.ua.pt/coeus/ontology/",
+ "setup": "newsaggregator/setup.rdf",
+ "sdb":"newsaggregator/sdb.ttl",
+ "predicates":"newsaggregator/predicates.csv",
+ "built": true,
"debug": true,
"apikey":"coeus|uavr",
"environment": "production"
diff --git a/src/main/resources/joseki.ttl b/src/main/resources/joseki.ttl
index 8f1b04f..c40d69c 100644
--- a/src/main/resources/joseki.ttl
+++ b/src/main/resources/joseki.ttl
@@ -43,7 +43,7 @@ sdb:Model rdfs:subClassOf ja:Model .
<#sdb> rdf:type sdb:DatasetStore ;
## Number of concurrent connections allowed to this dataset.
- joseki:poolSize 200;
+ joseki:poolSize 2;
sdb:store <#store> .
<#store> rdf:type sdb:Store ;
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index a12d0c5..1008314 100755
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -34,7 +34,8 @@
org.joseki.http.Servlet
org.joseki.rdfserver.config
- joseki.ttl
+
+ joseki.ttl
@@ -49,7 +50,8 @@
config-file
- classes/pubby.ttl
+
+ classes/pubby.ttl
@@ -64,13 +66,13 @@
de.fuberlin.wiwiss.pubby.servlets.PageURLServlet
1
-
+
WebURLServlet
de.fuberlin.wiwiss.pubby.servlets.PageURLServlet
1
-
+
WebURLServlet
/resource/*
@@ -120,9 +122,39 @@
- pt.ua.bioinformatics.coeus.common.HttpListener
+ pt.ua.bioinformatics.coeus.common.HttpListener
+
+
+
+
+ Secured Setup
+
+ /setup/*
+ /manager/*
+ GET
+ POST
+
+
+
+ Only managers use this app
+
+ manager-gui
+
+
+
+ manager-gui
+
+
+ FORM
+
+ /login.jsp
+ /login.jsp?f=error
+
+
+
+
index.jsp
diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp
new file mode 100644
index 0000000..456304f
--- /dev/null
+++ b/src/main/webapp/login.jsp
@@ -0,0 +1,72 @@
+
+<%@include file="/layout/style.jsp" %>
+
+
+<%
+ String err = request.getParameter("f");
+%>
+
+
+
+
+ Setup Login
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/setup/html.jsp b/src/main/webapp/setup/html.jsp
index 5e2b6ca..b2cb90a 100644
--- a/src/main/webapp/setup/html.jsp
+++ b/src/main/webapp/setup/html.jsp
@@ -25,9 +25,9 @@
- ">Home
+ ">Home
- ">Seed
+ ">Seed
Setup
@@ -40,7 +40,7 @@
-
">Management
+
">Management
">Documentation
diff --git a/src/main/webapp/setup/index.jsp b/src/main/webapp/setup/index.jsp
index 0a0cc85..1515728 100644
--- a/src/main/webapp/setup/index.jsp
+++ b/src/main/webapp/setup/index.jsp
@@ -20,7 +20,6 @@
From 747b2aeca749fe557089fe186f211327788d13fc Mon Sep 17 00:00:00 2001
From: sernadela
Date: Wed, 26 Jun 2013 17:10:49 +0100
Subject: [PATCH 03/52] - Setup: add entity support
---
.../coeus/actions/EntityActionBean.java | 68 ++++
...ActionBean.java => ManagerActionBean.java} | 25 +-
.../webapp/assets/js/bootstrap-tooltip.js | 361 ++++++++++++++++++
src/main/webapp/layout/script.jsp | 2 +-
src/main/webapp/setup/addentity.jsp | 204 ++++++++++
src/main/webapp/setup/html.jsp | 4 +-
src/main/webapp/setup/index.jsp | 139 ++++++-
src/main/webapp/setup/listentities.jsp | 109 ++++++
8 files changed, 891 insertions(+), 21 deletions(-)
create mode 100644 src/main/java/pt/ua/bioinformatics/coeus/actions/EntityActionBean.java
rename src/main/java/pt/ua/bioinformatics/coeus/actions/{SeedActionBean.java => ManagerActionBean.java} (61%)
create mode 100644 src/main/webapp/assets/js/bootstrap-tooltip.js
create mode 100644 src/main/webapp/setup/addentity.jsp
create mode 100644 src/main/webapp/setup/listentities.jsp
diff --git a/src/main/java/pt/ua/bioinformatics/coeus/actions/EntityActionBean.java b/src/main/java/pt/ua/bioinformatics/coeus/actions/EntityActionBean.java
new file mode 100644
index 0000000..8f2c4ab
--- /dev/null
+++ b/src/main/java/pt/ua/bioinformatics/coeus/actions/EntityActionBean.java
@@ -0,0 +1,68 @@
+package pt.ua.bioinformatics.coeus.actions;
+
+import net.sourceforge.stripes.action.ActionBean;
+import net.sourceforge.stripes.action.ActionBeanContext;
+import net.sourceforge.stripes.action.DefaultHandler;
+import net.sourceforge.stripes.action.ForwardResolution;
+import net.sourceforge.stripes.action.Resolution;
+import net.sourceforge.stripes.action.StreamingResolution;
+import net.sourceforge.stripes.action.UrlBinding;
+import pt.ua.bioinformatics.coeus.common.Config;
+
+/**
+ *
+ * @author pedrolopes
+ */
+@UrlBinding("/manager/entity/{query}")
+public class EntityActionBean implements ActionBean {
+ private static final String VIEW="/setup/listentities.jsp";
+ private static final String VIEWADD="/setup/addentity.jsp";
+ private ActionBeanContext context;
+ private String sub;
+ private String pred;
+ private String query;
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+
+ public String getPred() {
+ return pred;
+ }
+
+ public void setPred(String pred) {
+ this.pred = pred;
+ }
+
+ public String getSub() {
+ return sub;
+ }
+
+ public void setSub(String sub) {
+ this.sub = sub;
+ }
+
+ public void setContext(ActionBeanContext context) {
+ this.context = context;
+ }
+
+ public ActionBeanContext getContext() {
+ return context;
+ }
+
+ @DefaultHandler
+ public Resolution handle() {
+
+ if(query==null)
+ return new ForwardResolution(VIEW);
+ else if(query.equals("add")) return new ForwardResolution(VIEWADD);
+ else {
+ return new StreamingResolution("application/json", Config.getFile().toJSONString());
+ }
+ }
+}
diff --git a/src/main/java/pt/ua/bioinformatics/coeus/actions/SeedActionBean.java b/src/main/java/pt/ua/bioinformatics/coeus/actions/ManagerActionBean.java
similarity index 61%
rename from src/main/java/pt/ua/bioinformatics/coeus/actions/SeedActionBean.java
rename to src/main/java/pt/ua/bioinformatics/coeus/actions/ManagerActionBean.java
index 0f1d77b..b8b99bc 100644
--- a/src/main/java/pt/ua/bioinformatics/coeus/actions/SeedActionBean.java
+++ b/src/main/java/pt/ua/bioinformatics/coeus/actions/ManagerActionBean.java
@@ -9,7 +9,12 @@
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
+import net.sourceforge.stripes.action.StreamingResolution;
import net.sourceforge.stripes.action.UrlBinding;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import pt.ua.bioinformatics.coeus.common.Boot;
import pt.ua.bioinformatics.coeus.common.Config;
@@ -17,16 +22,30 @@
*
* @author sernadela
*/
-@UrlBinding("/manager/")
-public class SeedActionBean implements ActionBean{
+@UrlBinding("/manager/home/{param}")
+public class ManagerActionBean implements ActionBean{
private static final String VIEW="/setup/index.jsp";
private String name;
+ private String param;
private ActionBeanContext context;
@DefaultHandler
- public Resolution handle(){
+ public Resolution handle() throws ParseException{
setName(Config.getName());
+ if(param==null)
return new ForwardResolution(VIEW);
+ else {
+ Boot.start();
+ return new StreamingResolution("application/json", Config.getFile().toJSONString());
+ }
+ }
+
+ public String getParam() {
+ return param;
+ }
+
+ public void setParam(String param) {
+ this.param = param;
}
public String getName() {
diff --git a/src/main/webapp/assets/js/bootstrap-tooltip.js b/src/main/webapp/assets/js/bootstrap-tooltip.js
new file mode 100644
index 0000000..a3bbd58
--- /dev/null
+++ b/src/main/webapp/assets/js/bootstrap-tooltip.js
@@ -0,0 +1,361 @@
+/* ===========================================================
+ * bootstrap-tooltip.js v2.3.2
+ * http://twitter.github.com/bootstrap/javascript.html#tooltips
+ * Inspired by the original jQuery.tipsy by Jason Frame
+ * ===========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* TOOLTIP PUBLIC CLASS DEFINITION
+ * =============================== */
+
+ var Tooltip = function (element, options) {
+ this.init('tooltip', element, options)
+ }
+
+ Tooltip.prototype = {
+
+ constructor: Tooltip
+
+ , init: function (type, element, options) {
+ var eventIn
+ , eventOut
+ , triggers
+ , trigger
+ , i
+
+ this.type = type
+ this.$element = $(element)
+ this.options = this.getOptions(options)
+ this.enabled = true
+
+ triggers = this.options.trigger.split(' ')
+
+ for (i = triggers.length; i--;) {
+ trigger = triggers[i]
+ if (trigger == 'click') {
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
+ } else if (trigger != 'manual') {
+ eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
+ eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
+ }
+ }
+
+ this.options.selector ?
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
+ this.fixTitle()
+ }
+
+ , getOptions: function (options) {
+ options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
+
+ if (options.delay && typeof options.delay == 'number') {
+ options.delay = {
+ show: options.delay
+ , hide: options.delay
+ }
+ }
+
+ return options
+ }
+
+ , enter: function (e) {
+ var defaults = $.fn[this.type].defaults
+ , options = {}
+ , self
+
+ this._options && $.each(this._options, function (key, value) {
+ if (defaults[key] != value) options[key] = value
+ }, this)
+
+ self = $(e.currentTarget)[this.type](options).data(this.type)
+
+ if (!self.options.delay || !self.options.delay.show) return self.show()
+
+ clearTimeout(this.timeout)
+ self.hoverState = 'in'
+ this.timeout = setTimeout(function() {
+ if (self.hoverState == 'in') self.show()
+ }, self.options.delay.show)
+ }
+
+ , leave: function (e) {
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
+
+ if (this.timeout) clearTimeout(this.timeout)
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
+
+ self.hoverState = 'out'
+ this.timeout = setTimeout(function() {
+ if (self.hoverState == 'out') self.hide()
+ }, self.options.delay.hide)
+ }
+
+ , show: function () {
+ var $tip
+ , pos
+ , actualWidth
+ , actualHeight
+ , placement
+ , tp
+ , e = $.Event('show')
+
+ if (this.hasContent() && this.enabled) {
+ this.$element.trigger(e)
+ if (e.isDefaultPrevented()) return
+ $tip = this.tip()
+ this.setContent()
+
+ if (this.options.animation) {
+ $tip.addClass('fade')
+ }
+
+ placement = typeof this.options.placement == 'function' ?
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
+ this.options.placement
+
+ $tip
+ .detach()
+ .css({ top: 0, left: 0, display: 'block' })
+
+ this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
+
+ pos = this.getPosition()
+
+ actualWidth = $tip[0].offsetWidth
+ actualHeight = $tip[0].offsetHeight
+
+ switch (placement) {
+ case 'bottom':
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
+ break
+ case 'top':
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
+ break
+ case 'left':
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
+ break
+ case 'right':
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
+ break
+ }
+
+ this.applyPlacement(tp, placement)
+ this.$element.trigger('shown')
+ }
+ }
+
+ , applyPlacement: function(offset, placement){
+ var $tip = this.tip()
+ , width = $tip[0].offsetWidth
+ , height = $tip[0].offsetHeight
+ , actualWidth
+ , actualHeight
+ , delta
+ , replace
+
+ $tip
+ .offset(offset)
+ .addClass(placement)
+ .addClass('in')
+
+ actualWidth = $tip[0].offsetWidth
+ actualHeight = $tip[0].offsetHeight
+
+ if (placement == 'top' && actualHeight != height) {
+ offset.top = offset.top + height - actualHeight
+ replace = true
+ }
+
+ if (placement == 'bottom' || placement == 'top') {
+ delta = 0
+
+ if (offset.left < 0){
+ delta = offset.left * -2
+ offset.left = 0
+ $tip.offset(offset)
+ actualWidth = $tip[0].offsetWidth
+ actualHeight = $tip[0].offsetHeight
+ }
+
+ this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
+ } else {
+ this.replaceArrow(actualHeight - height, actualHeight, 'top')
+ }
+
+ if (replace) $tip.offset(offset)
+ }
+
+ , replaceArrow: function(delta, dimension, position){
+ this
+ .arrow()
+ .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
+ }
+
+ , setContent: function () {
+ var $tip = this.tip()
+ , title = this.getTitle()
+
+ $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
+ $tip.removeClass('fade in top bottom left right')
+ }
+
+ , hide: function () {
+ var that = this
+ , $tip = this.tip()
+ , e = $.Event('hide')
+
+ this.$element.trigger(e)
+ if (e.isDefaultPrevented()) return
+
+ $tip.removeClass('in')
+
+ function removeWithAnimation() {
+ var timeout = setTimeout(function () {
+ $tip.off($.support.transition.end).detach()
+ }, 500)
+
+ $tip.one($.support.transition.end, function () {
+ clearTimeout(timeout)
+ $tip.detach()
+ })
+ }
+
+ $.support.transition && this.$tip.hasClass('fade') ?
+ removeWithAnimation() :
+ $tip.detach()
+
+ this.$element.trigger('hidden')
+
+ return this
+ }
+
+ , fixTitle: function () {
+ var $e = this.$element
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
+ $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
+ }
+ }
+
+ , hasContent: function () {
+ return this.getTitle()
+ }
+
+ , getPosition: function () {
+ var el = this.$element[0]
+ return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
+ width: el.offsetWidth
+ , height: el.offsetHeight
+ }, this.$element.offset())
+ }
+
+ , getTitle: function () {
+ var title
+ , $e = this.$element
+ , o = this.options
+
+ title = $e.attr('data-original-title')
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
+
+ return title
+ }
+
+ , tip: function () {
+ return this.$tip = this.$tip || $(this.options.template)
+ }
+
+ , arrow: function(){
+ return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
+ }
+
+ , validate: function () {
+ if (!this.$element[0].parentNode) {
+ this.hide()
+ this.$element = null
+ this.options = null
+ }
+ }
+
+ , enable: function () {
+ this.enabled = true
+ }
+
+ , disable: function () {
+ this.enabled = false
+ }
+
+ , toggleEnabled: function () {
+ this.enabled = !this.enabled
+ }
+
+ , toggle: function (e) {
+ var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
+ self.tip().hasClass('in') ? self.hide() : self.show()
+ }
+
+ , destroy: function () {
+ this.hide().$element.off('.' + this.type).removeData(this.type)
+ }
+
+ }
+
+
+ /* TOOLTIP PLUGIN DEFINITION
+ * ========================= */
+
+ var old = $.fn.tooltip
+
+ $.fn.tooltip = function ( option ) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('tooltip')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.tooltip.Constructor = Tooltip
+
+ $.fn.tooltip.defaults = {
+ animation: true
+ , placement: 'top'
+ , selector: false
+ , template: ''
+ , trigger: 'hover focus'
+ , title: ''
+ , delay: 0
+ , html: false
+ , container: false
+ }
+
+
+ /* TOOLTIP NO CONFLICT
+ * =================== */
+
+ $.fn.tooltip.noConflict = function () {
+ $.fn.tooltip = old
+ return this
+ }
+
+}(window.jQuery);
diff --git a/src/main/webapp/layout/script.jsp b/src/main/webapp/layout/script.jsp
index 1c53370..f47fc58 100644
--- a/src/main/webapp/layout/script.jsp
+++ b/src/main/webapp/layout/script.jsp
@@ -33,4 +33,4 @@
document.body.appendChild(e);
}
-
\ No newline at end of file
+">
\ No newline at end of file
diff --git a/src/main/webapp/setup/addentity.jsp b/src/main/webapp/setup/addentity.jsp
new file mode 100644
index 0000000..1ed576f
--- /dev/null
+++ b/src/main/webapp/setup/addentity.jsp
@@ -0,0 +1,204 @@
+<%--
+ Document : index
+ Created on : May 28, 2013, 11:20:32 AM
+ Author : sernadela
+--%>
+
+<%@include file="/layout/taglib.jsp" %>
+
+ COEUS Setup
+
+ ">
+ ">
+ ">
+
+
+
+
+
+
+
+
Entity URI - coeus:
+
+
+
New Entity:
+
+
+
+
+ Title
+
+
+
+ Label
+
+
+
coeus:isIncludedIn
+
+
+
+
+ Add
+
+
+ Cancel
+
+
+
+
+
+
+
+
+
modal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/webapp/setup/html.jsp b/src/main/webapp/setup/html.jsp
index b2cb90a..79dddd8 100644
--- a/src/main/webapp/setup/html.jsp
+++ b/src/main/webapp/setup/html.jsp
@@ -25,14 +25,14 @@
- ">Home
+ ">Home
">Seed
Setup