Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 9df7be58 authored by Seungkeun Lee's avatar Seungkeun Lee
Browse files

No commit message

No commit message
parent e6d5df62
No related branches found
No related tags found
No related merge requests found
package fr.inrialpes.exmo.align.service;
import java.net.URI;
import java.util.Enumeration;
import org.semanticweb.owl.align.Alignment;
public interface Cache {
int put(long id, URI uri1, URI uri2, Alignment alignmnet);
Alignment get(long id);
Enumeration get(URI uri);
Enumeration get(URI uri1, URI uri2);
}
package fr.inrialpes.exmo.align.service;
import java.net.URI;
import java.sql.ResultSet;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.semanticweb.owl.align.Alignment;
public class CacheImpl implements Cache {
Hashtable alignmentTable = null;
public CacheImpl() {
}
private Hashtable loadAll(boolean force){
Hashtable result = null;
return result;
}
public int put(long id, URI uri1, URI uri2, Alignment alignmnet) {
return 0;
}
public Alignment get(long id) {
Alignment result = null;
return result;
}
public Enumeration get(URI uri) {
Enumeration result = null;
return result;
}
public Enumeration get(URI uri1, URI uri2) {
Enumeration result = null;
return result;
}
}
......@@ -19,13 +19,18 @@
*/
package fr.inrialpes.exmo.align.service;
import java.net.URI;
import java.util.Enumeration;
import org.semanticweb.owl.align.Alignment;
public interface DBService {
public long store(Alignment alignment);
public Alignment find(long id);
public int connect(String password); // password in database
// JE: to be added
//public int init(String IPAdress, String id, String password); // with userID, password in database
public int connect(String IPAdress, String id, String password); // with userID, password in database
public Alignment find(long id); // find alignment with alignmentID
public Enumeration find(URI uri); // find alignment list with an ontology uri
public Enumeration find(URI uri1, URI uri2); // find alignment list with two ontology uri
public int close();
}
/*
* $Id$
*
* Copyright (C) XX, 2006
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package fr.inrialpes.exmo.align.service;
import java.util.*;
import java.util.Vector;
import java.util.Enumeration;
import java.net.URI;
import java.sql.Connection;
import java.sql.DriverManager;
import com.mysql.jdbc.ResultSet;
import com.mysql.jdbc.Statement;
import java.sql.ResultSet;
import java.sql.Statement;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.Cell;
......@@ -40,8 +61,12 @@ public class DBServiceImpl implements DBService{
String s_uri2 = "";
String s_method = "";
String s_cell = "";
final int CONNECTION_ERROR = 1;
final int SUCCESS = 2;
final int INIT_ERROR = 3;
static Hashtable cache = null;
static Cache cache = null;
public DBServiceImpl() {
try{
......@@ -55,12 +80,30 @@ public class DBServiceImpl implements DBService{
try {
conn = DriverManager.getConnection(url, "root", password);
st = (Statement) conn.createStatement();
cache = loadAll(true);
} catch(Exception ex) {return -1;}
return 1;
} catch(Exception ex) {return CONNECTION_ERROR;}
if(init()) return SUCCESS;
else return INIT_ERROR;
}
public int connect(String IPAddress, String id, String password) {
try {
conn = DriverManager.getConnection("jdbc:mysql://"+IPAddress+":3306/DBService", id, password);
st = (Statement) conn.createStatement();
} catch(Exception ex) {return CONNECTION_ERROR;}
if(init()) return SUCCESS;
else return INIT_ERROR;
}
private boolean init() {
try {
cache = new CacheImpl();
return true;
} catch (Exception e) {return false;}
}
private Hashtable loadAll(boolean force){
Hashtable result = new Hashtable();
String query = null;
......@@ -187,6 +230,37 @@ public class DBServiceImpl implements DBService{
return result;
}
public Enumeration find(URI uri) {
Enumeration result = null;
Alignment temp = null;
String query = null;
try {
result = (Enumeration) cache.get(uri);
if (result == null) {
query = "select id " + "from alignment " + "where id = " + id;
rs = (ResultSet) st.executeQuery(query);
if(rs == null) return null;
else {
while (rs.next()) {
temp = retrieve(id);
loadOne(id, temp, true);
}
}
}
} catch (Exception e) {System.out.println("Alignment Finding Exception");}
return result;
} // find alignment list with an ontology uri
public Enumeration find(URI uri1, URI uri2) {
Enumeration result = null;
return result;
} // find alignment list with two ontology uri
protected Alignment retrieve(long id){
OWLOntology o1 = null;
OWLOntology o2 = null;
......@@ -278,6 +352,7 @@ public class DBServiceImpl implements DBService{
}
public int close(){
try {
conn.close();
st.close();
......@@ -287,6 +362,7 @@ public class DBServiceImpl implements DBService{
return -1;
}
}
public static OWLOntology loadOntology(URI uri) throws Exception {
OWLRDFParser parser = new OWLRDFParser();
parser.setConnection(OWLManager.getOWLConnection());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment