org.pandora.knowledge.database
Class DatabaseMemory

java.lang.Object
  extended by org.pandora.knowledge.BasicMemory
      extended by org.pandora.knowledge.database.DatabaseMemory
All Implemented Interfaces:
Memory

public class DatabaseMemory
extends BasicMemory

Uses JPA to store the memory to a Derby database.


Field Summary
static java.lang.String CACHE_SIZE
           
static java.lang.String DATABASE_DRIVER
           
static java.lang.String DATABASE_PASSWORD
           
static java.lang.String DATABASE_TEST_URL
           
static java.lang.String DATABASE_URL
           
static java.lang.String DATABASE_USER
           
static java.lang.String IMPORT_URL
           
static boolean RECREATE_DATABASE
           
static boolean TEST
           
 
Constructor Summary
DatabaseMemory()
           
 
Method Summary
 void abort()
          Clear the memory.
 void createMemory(java.lang.String database)
          Create the database.
 void deleteMemory()
          Delete all content from the database.
 void destroyMemory(java.lang.String database)
          Drop the database.
 javax.persistence.EntityManager getEntityManager()
           
 javax.persistence.EntityManagerFactory getFactory()
           
 java.lang.String getMemoryName()
          Return the current connected database name.
 void importMemory(java.lang.String database)
          Import the database into this instance.
 void initialize(java.util.Map<java.lang.String,java.lang.Object> properties)
          Initialize any configurable settings from the properties.
 Network newMemory()
          Return an isolated transactional memory.
 void restore()
          This implementation does not support persistence.
 void restore(java.lang.String database)
          Connect and create the EntityManager.
 void save()
          Commit short-term memory to the database.
 void setEntityManager(javax.persistence.EntityManager entityManager)
           
 void setFactory(javax.persistence.EntityManagerFactory factory)
           
 void shutdown()
          Shutdown the database.
 void switchMemory(java.lang.String database)
          Switch to a different database.
 
Methods inherited from class org.pandora.knowledge.BasicMemory
addActiveMemory, addListener, getActiveMemory, getListeners, getLongTermMemory, getPandora, getShortTermMemory, setActiveMemory, setLongTermMemory, setPandora, setShortTermMemory, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATABASE_USER

public static java.lang.String DATABASE_USER

DATABASE_PASSWORD

public static java.lang.String DATABASE_PASSWORD

IMPORT_URL

public static java.lang.String IMPORT_URL

DATABASE_URL

public static java.lang.String DATABASE_URL

DATABASE_TEST_URL

public static java.lang.String DATABASE_TEST_URL

DATABASE_DRIVER

public static java.lang.String DATABASE_DRIVER

CACHE_SIZE

public static java.lang.String CACHE_SIZE

TEST

public static boolean TEST

RECREATE_DATABASE

public static boolean RECREATE_DATABASE
Constructor Detail

DatabaseMemory

public DatabaseMemory()
Method Detail

initialize

public void initialize(java.util.Map<java.lang.String,java.lang.Object> properties)
Initialize any configurable settings from the properties.

Specified by:
initialize in interface Memory
Overrides:
initialize in class BasicMemory

getFactory

public javax.persistence.EntityManagerFactory getFactory()

setFactory

public void setFactory(javax.persistence.EntityManagerFactory factory)

getEntityManager

public javax.persistence.EntityManager getEntityManager()

setEntityManager

public void setEntityManager(javax.persistence.EntityManager entityManager)

save

public void save()
Commit short-term memory to the database.

Specified by:
save in interface Memory
Overrides:
save in class BasicMemory

shutdown

public void shutdown()
Shutdown the database.

Specified by:
shutdown in interface Memory
Overrides:
shutdown in class BasicMemory

restore

public void restore()
This implementation does not support persistence.

Specified by:
restore in interface Memory
Overrides:
restore in class BasicMemory

restore

public void restore(java.lang.String database)
Connect and create the EntityManager.

Specified by:
restore in interface Memory
Overrides:
restore in class BasicMemory

newMemory

public Network newMemory()
Return an isolated transactional memory. Can be used by senses or sub-conscious thought for concurrent processing.

Specified by:
newMemory in interface Memory
Overrides:
newMemory in class BasicMemory

getMemoryName

public java.lang.String getMemoryName()
Return the current connected database name.

Specified by:
getMemoryName in interface Memory
Overrides:
getMemoryName in class BasicMemory

createMemory

public void createMemory(java.lang.String database)
Create the database.

Specified by:
createMemory in interface Memory
Overrides:
createMemory in class BasicMemory

destroyMemory

public void destroyMemory(java.lang.String database)
Drop the database.

Specified by:
destroyMemory in interface Memory
Overrides:
destroyMemory in class BasicMemory

deleteMemory

public void deleteMemory()
Delete all content from the database.

Specified by:
deleteMemory in interface Memory
Overrides:
deleteMemory in class BasicMemory

switchMemory

public void switchMemory(java.lang.String database)
Switch to a different database.

Specified by:
switchMemory in interface Memory
Overrides:
switchMemory in class BasicMemory

importMemory

public void importMemory(java.lang.String database)
Import the database into this instance.

Specified by:
importMemory in interface Memory
Overrides:
importMemory in class BasicMemory

abort

public void abort()
Clear the memory.

Specified by:
abort in interface Memory
Overrides:
abort in class BasicMemory