Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
sernadela committed Oct 31, 2013
2 parents fe4de01 + 1a6639c commit 4822efe
Show file tree
Hide file tree
Showing 77 changed files with 9,062 additions and 1,215 deletions.
991 changes: 991 additions & 0 deletions src/main/java/pt/ua/bioinformatics/coeus/actions/ConfigActionBean.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
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.UrlBinding;

/**
*
* @author sernadela
*/
@UrlBinding("/manager/{$model}/{method}")
public class ManagerActionBean implements ActionBean {

private static final String INDEX_VIEW = "/setup/index.jsp";
private static final String SEEDS_VIEW = "/setup/seeds.jsp";
//private static final String SEEDS_ADD_VIEW = "/setup/addseed.jsp";
//private static final String ENTITY_ADD_VIEW = "/setup/addentity.jsp";
private static final String ENTITIES_VIEW = "/setup/entities.jsp";
//private static final String CONCEPT_ADD_VIEW = "/setup/addconcept.jsp";
private static final String CONCEPTS_VIEW = "/setup/concepts.jsp";
//private static final String RESOURCE_ADD_VIEW = "/setup/addresource.jsp";
private static final String RESOURCES_VIEW = "/setup/resources.jsp";
private static final String SELECTORS_VIEW = "/setup/selectors.jsp";
private static final String ENVIRONMENTS_VIEW = "/setup/environments.jsp";
private static final String ENVIRONMENTS_EDIT_VIEW = "/setup/editenvironment.jsp";
private static final String NOTFOUND_VIEW = "/setup/404.jsp";
private static final String GRAPH_VIEW = "/setup/graph.jsp";
private String method;
private String model;
private ActionBeanContext context;

@DefaultHandler
public Resolution handle() {
return new ForwardResolution(NOTFOUND_VIEW);
}

public Resolution config() {
return new ForwardResolution("/setup/config.jsp");
}

public Resolution graph() {
return new ForwardResolution(GRAPH_VIEW);
}

public Resolution environments() {
if (method != null && method.startsWith("edit")) {
return new ForwardResolution(ENVIRONMENTS_EDIT_VIEW);
} else {
return new ForwardResolution(ENVIRONMENTS_VIEW);
}
}

public Resolution seed() {
if (method == null) {
return new ForwardResolution(SEEDS_VIEW);
} else {
return new ForwardResolution(INDEX_VIEW);
}
}

public Resolution entity() {
return new ForwardResolution(ENTITIES_VIEW);
}

public Resolution concept() {
return new ForwardResolution(CONCEPTS_VIEW);
}

public Resolution resource() {
return new ForwardResolution(RESOURCES_VIEW);
}
public Resolution selector() {
return new ForwardResolution(SELECTORS_VIEW);
}

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public String getMethod() {
return method;
}

public void setMethod(String method) {
this.method = method;
}

@Override
public void setContext(ActionBeanContext actionBeanContext) {
this.context = actionBeanContext;
}

@Override
public ActionBeanContext getContext() {
return context;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public Resolution handle() {
if (sub.indexOf(":") > 1) {
try {
if (pred.indexOf(":") > 1) {

System.err.println(old_obj+" , "+new_obj);
// test old_obj
String xsd = "http://www.w3.org/2001/XMLSchema#";
Statement statToRemove = null;
Expand Down Expand Up @@ -142,8 +142,9 @@ public Resolution handle() {

if (Boot.getAPI().containsStatement(statToRemove)) {

Boot.getAPI().addStatement(statToAdd);
Boot.getAPI().removeStatement(statToRemove);
Boot.getAPI().addStatement(statToAdd);


result.put("status", 100);
result.put("message", "[COEUS][API][Update] Triples updated in the knowledge base.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public Resolution handle() {
//verify if is a xsd type
if (obj.startsWith("xsd:")) {
String[] old = obj.split(":", 3);
System.err.println(obj);
Literal l = Boot.getAPI().getModel().createTypedLiteral(old[2], xsd + old[1]);
statToAdd = Boot.getAPI().getModel().createLiteralStatement(Boot.getAPI().createResource(PrefixFactory.decode(sub)), Predicate.get(pred), l);
} else if (obj.indexOf(":") > 1) {
Expand Down
53 changes: 53 additions & 0 deletions src/main/java/pt/ua/bioinformatics/coeus/api/DB.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package pt.ua.bioinformatics.coeus.api;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
Expand Down Expand Up @@ -239,4 +243,53 @@ public ResultSet getData(String query) {
}

}

/**
* Create the DB and it table structure if not exists according to the giving parameters
*
* @param url
* @param user
* @param pass
* @throws ClassNotFoundException
* @throws SQLException
* @throws IOException
*/
public void createDB(String url, String user, String pass) throws ClassNotFoundException, SQLException, IOException {

Class.forName("com.mysql.jdbc.Driver");
url=url.replace("?autoReconnect=true","");
String[] urlSplited=url.split("/");
String db=urlSplited[urlSplited.length-1];
//System.out.println(db);
String jdbc=url.replace("/"+db, "") + "?allowMultiQueries=true&user=" + user + "&password=" + pass;
System.out.println(jdbc);
connection = DriverManager.getConnection(jdbc);
String script=readScript().replaceAll("coeusdb", db);
pStatement = connection.prepareStatement(script);
pStatement.execute();
pStatement.close();
connection.close();
}

/**
* Read the coeus.sql file and convert it to String
*
* @return
* @throws FileNotFoundException
* @throws IOException
*/
public String readScript() throws FileNotFoundException, IOException {
StringBuilder sb = new StringBuilder();

BufferedReader br = new BufferedReader(new FileReader(DB.class.getResource("/").getPath() + "coeus.sql"));
String line = br.readLine();

while (line != null) {
sb.append(line);
sb.append('\n');
line = br.readLine();
}
br.close();
return sb.toString();
}
}
Loading

0 comments on commit 4822efe

Please sign in to comment.