public class P3MDatabase extends Object implements IP3MDatabase
IP3MDatabase
based on Hibernate.
Created: August 17, 2008Constructor and Description |
---|
P3MDatabase()
Constructor using the default configuration file.
|
P3MDatabase(String configurationFile)
Constructor for custom configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the database.
|
void |
clearCache(Object o)
Clears the given object from cache.
|
void |
close()
Closes the database connection.
|
protected void |
dbChanged()
DB-write hook for switching flushing on or off.
|
void |
delete(Object o)
Deletes an object with hibernate.
|
void |
deleteAllResults(ProjectionModel projection,
IProgressObserver observer)
Delete all results of the projection.
|
boolean |
deleteMatrix(Matrix matrix)
Deletes given matrix from the database.
|
boolean |
deleteParameter(Parameter parameter)
Deletes given parameter from database.
|
boolean |
deleteParameterAssignment(ParameterAssignment assignment)
Deletes given parameter assignment.
|
boolean |
deleteParameterInstance(ParameterInstance instance)
Deletes given parameter instances from the data base.
|
boolean |
deleteProjection(ProjectionModel projection,
IProgressObserver observer)
Delete projection from database.
|
void |
deleteResult(ResultsOfTrial resultOfTrial)
Deletes a result.
|
boolean |
deleteSet(Set set)
Deletes given set from database.
|
boolean |
deleteSeType(SetType setType)
Delete
SetType from database. |
List<ParameterAssignment> |
getAllParameterAssignments(ParameterInstance param)
Retrieves all
ParameterAssignment entities for a certain
ParameterInstance . |
List<ParameterInstance> |
getAllParameterInstances()
Retrieves list with all parameter instances.
|
List<Parameter> |
getAllParameters()
Retrieves list with all parameters.
|
List<ProjectionModel> |
getAllProjections()
Retrieves list of all projections from the database.
|
List<ResultsOfTrial> |
getAllResults(ProjectionModel projection)
Retrieves all results for the given projection.
|
List<Set> |
getAllSets()
Retrieves all sets from database.
|
List<SetType> |
getAllSetTypes()
Retrieve all Settypes from data base.
|
org.hibernate.cfg.Configuration |
getConfig() |
static String |
getHibernateConfigFile()
Gets the hibernate configuration file.
|
Parameter |
getParameter(String name)
Retrieves a parameter with the given name from the database.
|
ParameterInstance |
getParameterInstance(Parameter param,
int generation)
Retrieves a parameter instance from the database.
|
ProjectionModel |
getProjectionByID(int id)
Retrieves projection by id.
|
IProjectionResultsIterator |
getResultIterator(ProjectionModel projection)
Gets the result iterator.
|
void |
init(org.jamesii.core.data.DBConnectionData dbConn,
P3JConfigFile configFile)
Initialize database connection.
|
Matrix |
newMatrix(Matrix2D value)
Creates a new matrix if a matrix with the same values is not already
existing in the system.
|
Parameter |
newParameter(String name,
int sortIndex,
boolean genDep,
MatrixDimension height,
MatrixDimension width,
Population population)
Creates a new parameter (if not already existent) and returns it.
|
ParameterAssignment |
newParameterAssignment(ParameterInstance paramInstance,
String name,
String description,
double probability,
double deviation,
Matrix2D value)
Creates a new parameter assignment.
|
ParameterInstance |
newParameterInstance(int comparisonIndex,
Parameter param,
int generation)
Creates new parameter instance.
|
void |
newProjection(ProjectionModel projection)
Adds new projection to database, automatically adds any
Parameter
or ParameterInstance entities that have not yet been created. |
Set |
newSet(List<ParameterInstance> defParams,
String name,
String desc,
double prob)
Creates a new set.
|
SetType |
newSetType(String name,
String description)
Create new Settype.
|
void |
open()
Establishes database connection.
|
void |
save(Object o)
Saves an object with hibernate.
|
void |
saveParameterAssignment(ParameterAssignment assignment)
Saves given parameter assignment.
|
void |
saveProjection(ProjectionModel projection)
Saves projection.
|
void |
saveSet(Set set)
Updates the set.
|
void |
saveSetType(SetType setType)
Updates the Settype.
|
void |
saveTrialResults(ResultsOfTrial resultOfTrial)
Saves results of a single trial.
|
static void |
setHibernateConfigFile(String hibernateConfigFile)
Sets the hibernate configuration file.
|
static Exception |
testConnection(org.jamesii.core.data.DBConnectionData dbConnData)
Test connection to database.
|
static Exception |
testConnection(String dbURL,
String dbUserName,
String dbPassword)
Test connection to database.
|
public P3MDatabase()
public P3MDatabase(String configurationFile)
configurationFile
- the name of the configuration filepublic void init(org.jamesii.core.data.DBConnectionData dbConn, P3JConfigFile configFile)
IP3MDatabase
init
in interface IP3MDatabase
dbConn
- the connection detailsconfigFile
- the config file with additional informationpublic void open()
IP3MDatabase
open
in interface IP3MDatabase
public void clear()
IP3MDatabase
clear
in interface IP3MDatabase
public void close()
IP3MDatabase
close
in interface IP3MDatabase
protected void dbChanged()
public void save(Object o)
o
- the object to be savedpublic void delete(Object o)
o
- the object to be deletedpublic Parameter newParameter(String name, int sortIndex, boolean genDep, MatrixDimension height, MatrixDimension width, Population population)
IP3MDatabase
newParameter
in interface IP3MDatabase
name
- name of the parametersortIndex
- the sorting indexgenDep
- flag to determine generation dependencyheight
- height of parameter valueswidth
- width of parameter valuespopulation
- the population to which this parameter referspublic Parameter getParameter(String name)
IP3MDatabase
getParameter
in interface IP3MDatabase
name
- the name of the parameter to be retrievedpublic List<Parameter> getAllParameters()
IP3MDatabase
getAllParameters
in interface IP3MDatabase
Parameter
instances stored in the databasepublic boolean deleteParameter(Parameter parameter)
IP3MDatabase
deleteParameter
in interface IP3MDatabase
parameter
- the parameter to be deletedpublic ParameterInstance newParameterInstance(int comparisonIndex, Parameter param, int generation)
IP3MDatabase
newParameterInstance
in interface IP3MDatabase
comparisonIndex
- comparison index of the instanceparam
- the associated parametergeneration
- the generation of the instancepublic ParameterInstance getParameterInstance(Parameter param, int generation)
IP3MDatabase
getParameterInstance
in interface IP3MDatabase
param
- the associated parametergeneration
- the generation for which the parameter shall be instantiatedpublic List<ParameterInstance> getAllParameterInstances()
IP3MDatabase
getAllParameterInstances
in interface IP3MDatabase
public boolean deleteParameterInstance(ParameterInstance instance)
IP3MDatabase
deleteParameterInstance
in interface IP3MDatabase
instance
- the instance to be deletedpublic Matrix newMatrix(Matrix2D value)
IP3MDatabase
newMatrix
in interface IP3MDatabase
value
- the value of the matrixpublic boolean deleteMatrix(Matrix matrix)
IP3MDatabase
deleteMatrix
in interface IP3MDatabase
matrix
- the matrix to be deletedpublic ParameterAssignment newParameterAssignment(ParameterInstance paramInstance, String name, String description, double probability, double deviation, Matrix2D value)
IP3MDatabase
newParameterAssignment
in interface IP3MDatabase
paramInstance
- the associated parameter instancename
- the name of the assignmentdescription
- the description of the assignmentprobability
- the probability of the assignmentdeviation
- the assumption-inherent deviation, i.e. the noisevalue
- the assigned valuepublic List<ParameterAssignment> getAllParameterAssignments(ParameterInstance param)
IP3MDatabase
ParameterAssignment
entities for a certain
ParameterInstance
.getAllParameterAssignments
in interface IP3MDatabase
param
- the parameter instancepublic boolean deleteParameterAssignment(ParameterAssignment assignment)
IP3MDatabase
deleteParameterAssignment
in interface IP3MDatabase
assignment
- the assignment to be deletedpublic void saveParameterAssignment(ParameterAssignment assignment)
IP3MDatabase
saveParameterAssignment
in interface IP3MDatabase
assignment
- the parameter assignmentpublic Set newSet(List<ParameterInstance> defParams, String name, String desc, double prob)
IP3MDatabase
newSet
in interface IP3MDatabase
defParams
- parameter instance for which assignments can be definedname
- name of the setdesc
- description of the setprob
- probability of the setpublic void saveSet(Set set)
IP3MDatabase
ParameterAssignmentSet
instances as well.saveSet
in interface IP3MDatabase
set
- the set to be updatedpublic List<Set> getAllSets()
IP3MDatabase
getAllSets
in interface IP3MDatabase
public boolean deleteSet(Set set)
IP3MDatabase
deleteSet
in interface IP3MDatabase
set
- the set to be deletedpublic SetType newSetType(String name, String description)
IP3MDatabase
newSetType
in interface IP3MDatabase
name
- name of the Settype to be createddescription
- description of the Settype to be createdpublic List<SetType> getAllSetTypes()
IP3MDatabase
getAllSetTypes
in interface IP3MDatabase
public void saveSetType(SetType setType)
IP3MDatabase
Set
instances as well.saveSetType
in interface IP3MDatabase
setType
- the Settype to be updatedpublic boolean deleteSeType(SetType setType)
IP3MDatabase
SetType
from database.deleteSeType
in interface IP3MDatabase
setType
- the Settype to be deletedpublic void newProjection(ProjectionModel projection)
IP3MDatabase
Parameter
or ParameterInstance
entities that have not yet been created.newProjection
in interface IP3MDatabase
projection
- the new projectionpublic boolean deleteProjection(ProjectionModel projection, IProgressObserver observer)
IP3MDatabase
deleteProjection
in interface IP3MDatabase
projection
- the projection to be deletedobserver
- the progress observer (may be null)public List<ProjectionModel> getAllProjections()
IP3MDatabase
getAllProjections
in interface IP3MDatabase
public ProjectionModel getProjectionByID(int id)
IP3MDatabase
getProjectionByID
in interface IP3MDatabase
id
- the id of the projectionpublic void saveProjection(ProjectionModel projection)
IP3MDatabase
saveProjection
in interface IP3MDatabase
projection
- the projection to be saved/updatedpublic static Exception testConnection(org.jamesii.core.data.DBConnectionData dbConnData)
dbConnData
- the database connection datapublic static Exception testConnection(String dbURL, String dbUserName, String dbPassword)
dbURL
- the URL of the databasedbUserName
- the DB user namedbPassword
- the DB passwordpublic void saveTrialResults(ResultsOfTrial resultOfTrial)
IP3MDatabase
saveTrialResults
in interface IP3MDatabase
resultOfTrial
- the result of the trialpublic List<ResultsOfTrial> getAllResults(ProjectionModel projection)
IP3MDatabase
getAllResults
in interface IP3MDatabase
projection
- the projectionpublic void deleteResult(ResultsOfTrial resultOfTrial)
IP3MDatabase
deleteResult
in interface IP3MDatabase
resultOfTrial
- the result of trialpublic void deleteAllResults(ProjectionModel projection, IProgressObserver observer)
IP3MDatabase
deleteAllResults
in interface IP3MDatabase
projection
- the projectionobserver
- the progress observer (may be null)public IProjectionResultsIterator getResultIterator(ProjectionModel projection)
IP3MDatabase
getResultIterator
in interface IP3MDatabase
projection
- the projection for which the results shall be gatheredpublic void clearCache(Object o)
IP3MDatabase
clearCache
in interface IP3MDatabase
o
- the object to be cleared from cachepublic static String getHibernateConfigFile()
public static void setHibernateConfigFile(String hibernateConfigFile)
hibernateConfigFile
- the new hibernate configuration filepublic org.hibernate.cfg.Configuration getConfig()
Copyright © 2013. All Rights Reserved.