Constructor and Description |
---|
AndroidDBSession(android.content.Context context) |
AndroidDBSession(android.content.Context context,
String instanceId) |
Modifier and Type | Method and Description |
---|---|
void |
addAndSwitchInstance(String instanceId,
String path)
Adds a new instance with the given path to the DB.
|
void |
addInstance(String instanceId,
String path)
Adds a new instance with the given path to the DB.
|
void |
closeSession()
Closes the session and removes used resources
|
EntityBag |
createOrGetBag(String bagName)
Creates a bag or gets an existing one if it already existed for the connected instance.
|
EntityBag |
createOrGetBag(String instanceId,
String bagName)
Creates a bag or gets an existing one if it already existed for the specified instance.
|
Instance |
deleteInstance(String instanceId)
This deletes an instance all its related bags and entities permanently.
|
EntityBag |
getBag(String bagName)
Retrieves an existing bag if this exists on the connected instance, in case the bag does not
exist the method will return null
|
EntityBag |
getBag(String instanceId,
String bagName)
Retrieves an existing bag if this exists on the specified instance, in case the bag does not
exist the method will return null
|
List<EntityBag> |
getBags()
Gets a list of all existing bags in the default database instance
|
List<EntityBag> |
getBags(String instanceId)
Gets a list of all existing bags in the specified database instance
|
EntityManager |
getEntityManager()
Gets the entity manager that can be used for entity persistence
|
DBInstance |
getInstance(String instanceId)
Gets the metadata of a specific instance
|
String |
getInstanceId()
Gets the instance id of the currently connected instance
|
List<Instance> |
getInstances()
Gets a list of all available instances
|
UserAdministration |
getUserAdministration() |
void |
removeBag(String bagName)
Removes a bag from the current instance if it exists and is not in use
|
void |
removeBag(String instanceId,
String bagName)
Removes a bag from the specified instance if it exists and is not in use
|
void |
switchInstance(String instanceId)
Switches the current session to a new instance
|
public AndroidDBSession(android.content.Context context) throws JasDBStorageException
JasDBStorageException
public AndroidDBSession(android.content.Context context, String instanceId) throws JasDBStorageException
JasDBStorageException
public UserAdministration getUserAdministration() throws JasDBStorageException
getUserAdministration
in interface DBSession
JasDBStorageException
public List<Instance> getInstances() throws JasDBStorageException
DBSession
getInstances
in interface DBSession
JasDBStorageException
- If unable to load the list of available instancespublic void addInstance(String instanceId, String path) throws JasDBStorageException
DBSession
addInstance
in interface DBSession
instanceId
- The id of the instance, should not exist alreadypath
- The path where to store the instance and bag dataJasDBStorageException
- If unable to to add an instancepublic void addAndSwitchInstance(String instanceId, String path) throws JasDBStorageException
DBSession
addAndSwitchInstance
in interface DBSession
instanceId
- The id of the instance, should not exist alreadypath
- The path where to store the instance and bag dataJasDBStorageException
- If unable to to add an instancepublic void switchInstance(String instanceId) throws JasDBStorageException
DBSession
switchInstance
in interface DBSession
instanceId
- The id of the instanceJasDBStorageException
- If unable to switch to instancepublic Instance deleteInstance(String instanceId) throws JasDBStorageException
DBSession
deleteInstance
in interface DBSession
instanceId
- The instanceId of the instance and related resources (bags, entities) to deleteJasDBStorageException
- If unable to delete the instance and related resources (bags, entities)public EntityManager getEntityManager()
DBSession
getEntityManager
in interface DBSession
public String getInstanceId() throws JasDBStorageException
DBSession
getInstanceId
in interface DBSession
JasDBStorageException
- If unable to get the id of the current connected instancepublic EntityBag createOrGetBag(String bagName) throws JasDBStorageException
DBSession
createOrGetBag
in interface DBSession
bagName
- The name of the bagJasDBStorageException
- If unable to create or get the bagpublic EntityBag createOrGetBag(String instanceId, String bagName) throws JasDBStorageException
DBSession
createOrGetBag
in interface DBSession
instanceId
- The id of the instancebagName
- The name of the bagJasDBStorageException
- If unable to create or get the bagpublic EntityBag getBag(String bagName) throws JasDBStorageException
DBSession
getBag
in interface DBSession
bagName
- The name of the bagJasDBStorageException
- If unable to retrieve the bagpublic EntityBag getBag(String instanceId, String bagName) throws JasDBStorageException
DBSession
getBag
in interface DBSession
instanceId
- The id of the instancebagName
- The name of the bagJasDBStorageException
- If unable to retrieve the bagpublic DBInstance getInstance(String instanceId) throws JasDBStorageException
DBSession
getInstance
in interface DBSession
JasDBStorageException
- If unable to load the metadata of the instancepublic List<EntityBag> getBags() throws JasDBStorageException
DBSession
getBags
in interface DBSession
JasDBStorageException
- If unable to retrieve the list of entity bagspublic List<EntityBag> getBags(String instanceId) throws JasDBStorageException
DBSession
getBags
in interface DBSession
instanceId
- The id of the instanceJasDBStorageException
- If unable to retrieve the list of entity bagspublic void removeBag(String bagName) throws JasDBStorageException
DBSession
removeBag
in interface DBSession
bagName
- The name of the bagJasDBStorageException
- If unable to remove the bag when it does not exist or the bag is in usepublic void removeBag(String instanceId, String bagName) throws JasDBStorageException
DBSession
removeBag
in interface DBSession
instanceId
- The id of the instancebagName
- The name of the bagJasDBStorageException
- If unable to remove the bag when it does not exist or the bag is in usepublic void closeSession() throws JasDBStorageException
DBSession
closeSession
in interface DBSession
JasDBStorageException
- if unable to cleanly close the sessionCopyright © 2015. All rights reserved.