p3j.database
Interface IP3MDatabase

All Known Implementing Classes:
P3MDatabase

public interface IP3MDatabase

Database interface for P3J. It provides loading, saving, and look-up means for all parts of the PPPM that ought to be persistent (e.g., Parameter, ParameterInstance, Set, SetType). Created on January 11, 2007

Author:
Christina Bohk, Roland Ewald

Method Summary
 void clear()
          Clears the database.
 void clearCache(Object o)
          Clears the given object from cache.
 void close()
          Closes the database connection.
 void deleteAllResults(ProjectionModel projection)
          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)
          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<Matrix> getAllMatrices()
          Retrieves all input matrices from the database.
 List<ParameterAssignment> getAllParameterAssignments(ParameterInstance paramInstance)
          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.
 Matrix getMatrix(Matrix2D value)
          Get matrix with a certain value from database.
 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(james.core.data.DBConnectionData dbConn)
          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, 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> params, 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 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.
 

Method Detail

init

void init(james.core.data.DBConnectionData dbConn)
Initialize database connection.

Parameters:
dbConn - the connection details

open

void open()
Establishes database connection.


clear

void clear()
Clears the database. I.e., it removes *all* entries and re-initializes the (potentially changed) table structure.


close

void close()
Closes the database connection.


newParameter

Parameter newParameter(String name,
                       boolean genDep,
                       MatrixDimension height,
                       MatrixDimension width,
                       Population population)
Creates a new parameter (if not already existent) and returns it.

Parameters:
name - name of the parameter
genDep - flag to determine generation dependency
height - height of parameter values
width - width of parameter values
population - the population to which this parameter refers
Returns:
newly created parameter (or retrieved from DB)

getParameter

Parameter getParameter(String name)
Retrieves a parameter with the given name from the database.

Parameters:
name - the name of the parameter to be retrieved
Returns:
the parameter, or null if not exists

getAllParameters

List<Parameter> getAllParameters()
Retrieves list with all parameters.

Returns:
list of all Parameter instances stored in the database

deleteParameter

boolean deleteParameter(Parameter parameter)
Deletes given parameter from database.

Parameters:
parameter - the parameter to be deleted
Returns:
true if deletion was successful, otherwise false

newParameterInstance

ParameterInstance newParameterInstance(int comparisonIndex,
                                       Parameter param,
                                       int generation)
Creates new parameter instance.

Parameters:
comparisonIndex - comparison index of the instance
param - the associated parameter
generation - the generation of the instance
Returns:
a newly created instance, or instance with the same generation and parameter from the database

getParameterInstance

ParameterInstance getParameterInstance(Parameter param,
                                       int generation)
Retrieves a parameter instance from the database.

Parameters:
param - the associated parameter
generation - the generation for which the parameter shall be instantiated
Returns:
existing parameter from database, or null

getAllParameterInstances

List<ParameterInstance> getAllParameterInstances()
Retrieves list with all parameter instances.

Returns:
list of all parameter instances that are stored in the database

deleteParameterInstance

boolean deleteParameterInstance(ParameterInstance instance)
Deletes given parameter instances from the data base.

Parameters:
instance - the instance to be deleted
Returns:
true, if deletion was successful

newMatrix

Matrix newMatrix(Matrix2D value)
Creates a new matrix if a matrix with the same values is not already existing in the system.

Parameters:
value - the value of the matrix
Returns:
the newly created (or retrieved) matrix

getMatrix

Matrix getMatrix(Matrix2D value)
Get matrix with a certain value from database.

Parameters:
value - the value of the matrix
Returns:
the matrix, if could be found - otherwise null

getAllMatrices

List<Matrix> getAllMatrices()
Retrieves all input matrices from the database.

Returns:
list of all matrices

deleteMatrix

boolean deleteMatrix(Matrix matrix)
Deletes given matrix from the database.

Parameters:
matrix - the matrix to be deleted
Returns:
true if deletion was successful

newParameterAssignment

ParameterAssignment newParameterAssignment(ParameterInstance paramInstance,
                                           String name,
                                           String description,
                                           double probability,
                                           double deviation,
                                           Matrix2D value)
Creates a new parameter assignment.

Parameters:
paramInstance - the associated parameter instance
name - the name of the assignment
description - the description of the assignment
probability - the probability of the assignment
deviation - the assumption-inherent deviation, i.e. the noise
value - the assigned value
Returns:
the instantiated assignment

getAllParameterAssignments

List<ParameterAssignment> getAllParameterAssignments(ParameterInstance paramInstance)
Retrieves all ParameterAssignment entities for a certain ParameterInstance.

Parameters:
paramInstance - the parameter instance
Returns:
list containing all parameter assignments from database

deleteParameterAssignment

boolean deleteParameterAssignment(ParameterAssignment assignment)
Deletes given parameter assignment.

Parameters:
assignment - the assignment to be deleted
Returns:
true, if deletion was successful

saveParameterAssignment

void saveParameterAssignment(ParameterAssignment assignment)
Saves given parameter assignment.

Parameters:
assignment - the parameter assignment

newSet

Set newSet(List<ParameterInstance> params,
           String name,
           String desc,
           double prob)
Creates a new set.

Parameters:
params - parameter instance for which assignments can be defined
name - name of the set
desc - description of the set
prob - probability of the set
Returns:
newly created set

saveSet

void saveSet(Set set)
Updates the set. This stores all changed/added/removed ParameterAssignmentSet instances as well.

Parameters:
set - the set to be updated

deleteSet

boolean deleteSet(Set set)
Deletes given set from database.

Parameters:
set - the set to be deleted
Returns:
true, if deletion was successful

getAllSets

List<Set> getAllSets()
Retrieves all sets from database.

Returns:
list of all sets

newSetType

SetType newSetType(String name,
                   String description)
Create new Settype.

Parameters:
name - name of the Settype to be created
description - description of the Settype to be created
Returns:
newly created Settype

saveSetType

void saveSetType(SetType setType)
Updates the Settype. This stores all changed/added/removed Set instances as well.

Parameters:
setType - the Settype to be updated

getAllSetTypes

List<SetType> getAllSetTypes()
Retrieve all Settypes from data base.

Returns:
list with all Settypes in the database

deleteSeType

boolean deleteSeType(SetType setType)
Delete SetType from database.

Parameters:
setType - the Settype to be deleted
Returns:
true, if deletion was successful

newProjection

void newProjection(ProjectionModel projection)
Adds new projection to database, automatically adds any Parameter or ParameterInstance entities that have not yet been created.

Parameters:
projection - the new projection

getAllProjections

List<ProjectionModel> getAllProjections()
Retrieves list of all projections from the database.

Returns:
list of all projections from the database
Throws:
Exception - if lookup fails

getProjectionByID

ProjectionModel getProjectionByID(int id)
Retrieves projection by id.

Parameters:
id - the id of the projection
Returns:
the projection, null if none was found

deleteProjection

boolean deleteProjection(ProjectionModel projection)
Delete projection from database.

Parameters:
projection - the projection to be deleted
Returns:
true, if deletion was successful

saveProjection

void saveProjection(ProjectionModel projection)
Saves projection.

Parameters:
projection - the projection to be saved/updated

saveTrialResults

void saveTrialResults(ResultsOfTrial resultOfTrial)
Saves results of a single trial. They are reproducible, as they include the specific parameter assignments that were used.

Parameters:
resultOfTrial - the result of the trial

getAllResults

List<ResultsOfTrial> getAllResults(ProjectionModel projection)
Retrieves all results for the given projection. Take care:

Parameters:
projection - the projection
Returns:
the all results

deleteResult

void deleteResult(ResultsOfTrial resultOfTrial)
Deletes a result.

Parameters:
resultOfTrial - the result of trial

deleteAllResults

void deleteAllResults(ProjectionModel projection)
Delete all results of the projection.

Parameters:
projection - the projection

getResultIterator

IProjectionResultsIterator getResultIterator(ProjectionModel projection)
Gets the result iterator.

Parameters:
projection - the projection for which the results shall be gathered
Returns:
the result iterator

clearCache

void clearCache(Object o)
Clears the given object from cache. Use only if you know this object is not going to be needed again (e.g., during a result export).

Parameters:
o - the object to be cleared from cache


Copyright © 2012. All Rights Reserved.