Alignment API and Server 4.5 (1846M)

fr.inrialpes.exmo.align.service
Class CacheImpl

java.lang.Object
  extended by fr.inrialpes.exmo.align.service.CacheImpl

public class CacheImpl
extends Object

This class caches the content of the alignment database. I.e., It loads the metadata in the hash table It stores the alignment when requested It


Field Summary
private static String ALID
           
(package private)  Hashtable<String,Alignment> alignmentTable
           
private static String CACHED
           
(package private)  Connection conn
           
(package private)  int CONNECTION_ERROR
           
(package private)  String host
           
(package private)  String idprefix
           
(package private)  int INIT_ERROR
           
(package private) static org.slf4j.Logger logger
           
(package private)  Hashtable<URI,Set<Alignment>> ontologyTable
           
private static String OURI1
           
private static String OURI2
           
(package private)  String port
           
(package private)  int rights
           
(package private)  DBService service
           
private static String STORED
           
(package private)  int SUCCESS
           
private static String SVCNS
           
(package private)  int VERSION
           
 
Constructor Summary
CacheImpl(DBService serv)
           
 
Method Summary
protected  Collection<Alignment> alignments()
           
protected  Collection<Alignment> alignments(URI u1, URI u2)
           
 void changeColumnType(Statement st, String tableName, String columnName, String newType)
           
 void cleanUpCache()
           
 void close()
           
 Statement createStatement()
           
 void eraseAlignment(String uri, boolean eraseFromDB)
          Non publicised class
protected  void flushAlignment(Alignment alignment)
          unload the cells of an alignment...
protected  void flushCache()
           
 String generateAlignmentUri()
           
private  String generateCellId()
           
private  String generateId()
           
 Alignment getAlignment(String uri)
          retrieve full alignment from id (and cache it)
 Set<Alignment> getAlignments(URI uri)
           
 Set<Alignment> getAlignments(URI uri1, URI uri2)
          returns the alignments between two ontologies if one of the ontologies is null, then return them all
 Alignment getMetadata(String uri)
          retrieve alignment metadata from id This is more difficult because we return the alignment we have disreagarding if it is complete o only metadata
 void init(Properties p, String prefix)
          loads the alignment descriptions from the database and put them in the alignmentTable hashtable
 void initDatabase()
           
 boolean isAlignmentStored(Alignment alignment)
           
protected  Enumeration<Alignment> listAlignments()
           
private  void loadAlignments(boolean force)
          loads the alignment descriptions from the database and put them in the alignmentTable hashtable index them under the ontology URIs
protected  Collection<URI> ontologies()
           
 String quote(String s)
          quote: Prepare a string to be used in SQL queries by preceeding occurences of "'", """, and "\" by a "\".
private  int randomNum()
           
 String recordAlignment(String uri, Alignment alignment, boolean force)
          records alignment identified by id
 String recordNewAlignment(Alignment alignment, boolean force)
          records newly created alignment
 String recordNewAlignment(String uri, Alignment al, boolean force)
          records alignment identified by id
 void recordOntology(Statement st, String id, boolean source, URI uri, URI file, Ontology onto)
           
 String recoverAlignmentUri(String id)
           
private  void registerServer(String host, String port, Boolean writeable, String prefix)
           
 void renameColumn(Statement st, String tableName, String oldName, String newName, String newType)
           
 void reset()
           
 void resetCacheStamp(Alignment result)
           
 void resetDatabase(boolean force)
           
protected  Alignment retrieveAlignment(String uri, Alignment alignment)
          loads the full alignment from the database and put it in the alignmentTable hastable should be invoked when: ( result.getExtension(CACHED) == "" && result.getExtension(STORED) != "") {
protected  Alignment retrieveDescription(String id)
          loads the description of alignments from the database and set them in an alignment object
 void storeAlignment(String uri)
           
 String stripAlignmentUri(String alid)
           
 void unRecordAlignment(Alignment alignment)
          suppresses the record for an alignment
 void unstoreAlignment(String uri)
          Non publicised class
 void unstoreAlignment(String uri, Alignment alignment)
           
 void updateDatabase()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static final org.slf4j.Logger logger

alignmentTable

Hashtable<String,Alignment> alignmentTable

ontologyTable

Hashtable<URI,Set<Alignment>> ontologyTable

host

String host

port

String port

rights

int rights

idprefix

String idprefix

VERSION

final int VERSION
See Also:
Constant Field Values

service

DBService service

conn

Connection conn

CONNECTION_ERROR

final int CONNECTION_ERROR
See Also:
Constant Field Values

SUCCESS

final int SUCCESS
See Also:
Constant Field Values

INIT_ERROR

final int INIT_ERROR
See Also:
Constant Field Values

SVCNS

private static final String SVCNS

CACHED

private static final String CACHED
See Also:
Constant Field Values

STORED

private static final String STORED
See Also:
Constant Field Values

ALID

private static final String ALID
See Also:
Constant Field Values

OURI1

private static final String OURI1
See Also:
Constant Field Values

OURI2

private static final String OURI2
See Also:
Constant Field Values
Constructor Detail

CacheImpl

public CacheImpl(DBService serv)
Method Detail

reset

public void reset()
           throws SQLException
Throws:
SQLException

init

public void init(Properties p,
                 String prefix)
          throws SQLException,
                 AlignmentException
loads the alignment descriptions from the database and put them in the alignmentTable hashtable

Throws:
SQLException
AlignmentException

close

public void close()
           throws SQLException
Throws:
SQLException

createStatement

public Statement createStatement()
                          throws SQLException
Throws:
SQLException

loadAlignments

private void loadAlignments(boolean force)
                     throws SQLException
loads the alignment descriptions from the database and put them in the alignmentTable hashtable index them under the ontology URIs

Throws:
SQLException

listAlignments

protected Enumeration<Alignment> listAlignments()

alignments

protected Collection<Alignment> alignments()

ontologies

protected Collection<URI> ontologies()

alignments

protected Collection<Alignment> alignments(URI u1,
                                           URI u2)

flushCache

protected void flushCache()

retrieveDescription

protected Alignment retrieveDescription(String id)
loads the description of alignments from the database and set them in an alignment object


retrieveAlignment

protected Alignment retrieveAlignment(String uri,
                                      Alignment alignment)
                               throws SQLException,
                                      AlignmentException,
                                      URISyntaxException
loads the full alignment from the database and put it in the alignmentTable hastable should be invoked when: ( result.getExtension(CACHED) == "" && result.getExtension(STORED) != "") {

Throws:
SQLException
AlignmentException
URISyntaxException

flushAlignment

protected void flushAlignment(Alignment alignment)
unload the cells of an alignment... This should help retrieving some space should be invoked when: ( result.getExtension(CACHED) != "" && obviously result.getExtension(STORED) != ""


generateAlignmentUri

public String generateAlignmentUri()

recoverAlignmentUri

public String recoverAlignmentUri(String id)

stripAlignmentUri

public String stripAlignmentUri(String alid)

generateCellId

private String generateCellId()

generateId

private String generateId()

randomNum

private int randomNum()

getMetadata

public Alignment getMetadata(String uri)
                      throws AlignmentException
retrieve alignment metadata from id This is more difficult because we return the alignment we have disreagarding if it is complete o only metadata

Throws:
AlignmentException

getAlignment

public Alignment getAlignment(String uri)
                       throws AlignmentException,
                              SQLException
retrieve full alignment from id (and cache it)

Throws:
AlignmentException
SQLException

getAlignments

public Set<Alignment> getAlignments(URI uri)

getAlignments

public Set<Alignment> getAlignments(URI uri1,
                                    URI uri2)
returns the alignments between two ontologies if one of the ontologies is null, then return them all


recordNewAlignment

public String recordNewAlignment(Alignment alignment,
                                 boolean force)
records newly created alignment


recordNewAlignment

public String recordNewAlignment(String uri,
                                 Alignment al,
                                 boolean force)
                          throws AlignmentException
records alignment identified by id

Throws:
AlignmentException

recordAlignment

public String recordAlignment(String uri,
                              Alignment alignment,
                              boolean force)
records alignment identified by id


unRecordAlignment

public void unRecordAlignment(Alignment alignment)
suppresses the record for an alignment


quote

public String quote(String s)
quote: Prepare a string to be used in SQL queries by preceeding occurences of "'", """, and "\" by a "\". This should be implemented at a lower level within Java itself (or the sql package). This function is used here for protecting everything to be entered in the database


isAlignmentStored

public boolean isAlignmentStored(Alignment alignment)

eraseAlignment

public void eraseAlignment(String uri,
                           boolean eraseFromDB)
                    throws SQLException,
                           AlignmentException
Non publicised class

Throws:
SQLException
AlignmentException

unstoreAlignment

public void unstoreAlignment(String uri)
                      throws SQLException,
                             AlignmentException
Non publicised class

Throws:
SQLException
AlignmentException

unstoreAlignment

public void unstoreAlignment(String uri,
                             Alignment alignment)
                      throws SQLException,
                             AlignmentException
Throws:
SQLException
AlignmentException

storeAlignment

public void storeAlignment(String uri)
                    throws AlignmentException,
                           SQLException
Throws:
AlignmentException
SQLException

recordOntology

public void recordOntology(Statement st,
                           String id,
                           boolean source,
                           URI uri,
                           URI file,
                           Ontology onto)
                    throws SQLException
Throws:
SQLException

resetCacheStamp

public void resetCacheStamp(Alignment result)

cleanUpCache

public void cleanUpCache()

initDatabase

public void initDatabase()
                  throws SQLException
Throws:
SQLException

resetDatabase

public void resetDatabase(boolean force)
                   throws SQLException,
                          AlignmentException
Throws:
SQLException
AlignmentException

registerServer

private void registerServer(String host,
                            String port,
                            Boolean writeable,
                            String prefix)
                     throws SQLException
Throws:
SQLException

renameColumn

public void renameColumn(Statement st,
                         String tableName,
                         String oldName,
                         String newName,
                         String newType)
                  throws SQLException
Throws:
SQLException

changeColumnType

public void changeColumnType(Statement st,
                             String tableName,
                             String columnName,
                             String newType)
                      throws SQLException
Throws:
SQLException

updateDatabase

public void updateDatabase()
                    throws SQLException,
                           AlignmentException
Throws:
SQLException
AlignmentException

Alignment API and Server 4.5 (1846M)

(C) INRIA & friends, 2003-2013