org.norther.tammi.root.db
Interface BeanRepositoryClient

All Superinterfaces:
MultiRepositoryClient, RepositoryClient
All Known Subinterfaces:
BeanRepositoryFilter
All Known Implementing Classes:
DefaultBeanRepositoryClient, DefaultBeanRepositoryFilter

public interface BeanRepositoryClient
extends MultiRepositoryClient

Extends MultiRepositoryClient by supporting variable based repositories.

Author:
Ilkka Priha

Field Summary
static Object NULL_PK
          The null pk.
static Object ROOT_PK
          The root pk.
 
Method Summary
 boolean add1NForeignReferences(Object node, String className, String fkField, Object[] fks, Persister persister)
          Adds foreign references to 1:n relations in a tree.
 boolean add1NNullReferences(String className, String fkField, Object[] fks, Persister persister)
          Adds null references to 1:n relations in a tree.
 boolean add1NObjectReferences(Object node, String relField, String fkField, Object[] fks, Persister persister)
          Adds object references to 1:n relations in a tree formed by nodes of the same class.
 boolean addAttributeValues(Object node, String field, Persister persister, List result)
          Adds nested attribute values in a tree to a list.
 boolean addTo1NRelationMap(Object node, String fkField, DBCriteria criteria, Persister persister, ConcurrentMap map)
          Adds referenced objects fulfilling the specified criteria in a 1:n tree to a map.
 boolean addTo1NRelationMap(Object node, String relField, String fkField, DBCriteria criteria, Persister persister, ConcurrentMap map)
          Adds referenced objects fulfilling the specified criteria in a 1:n tree to a map.
 boolean addToAttributeChain(Object node, String relField, String valueField, Persister persister, List list)
          Adds attribute values of a chain of referenced objects in a tree into a list, the attribute of the end object at the lowest index.
 boolean addToAttributeMap(Object node, String relField, String valueField, Persister persister, ConcurrentMap map)
          Adds attribute values of referenced nodes in a tree into a map.
 boolean addToIdentityList(Collection vars, int index, String[] nameFields, Persister persister, OrderedSet list)
          Adds a collection of variables as enumerated identities to an ordered set.
 boolean addToIdentityList(Variable var, int index, String[] nameFields, Persister persister, OrderedSet list)
          Adds the specified variable as an enumerated identity to an ordered set.
 boolean addToIdentityTree(Collection roots, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds a collection of root variables to an ordered map.
 boolean addToIdentityTree(Collection vars, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the variable chains of the selected variables to an ordered map.
 boolean addToIdentityTree(Identity[] ids, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the variable chains of the selected identities to an ordered map.
 boolean addToIdentityTree(Identity id, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the variable chain of the selected identity to an ordered map.
 boolean addToIdentityTree(Variable root, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the specified root variable to an ordered map.
 boolean addToIdentityTree(Variable var, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the variable chain of the selected variable to an ordered map.
 boolean addToMNRelationMap(Object node, String indirection, String fkField1, String fkField2, DBCriteria criteria, Persister persister, ConcurrentMap map)
          Adds referenced objects fulfilling the specified criteria in a m:n tree to a map.
 boolean addToMNRelationMap(Object node, String relField, String indirection, String fkField1, String fkField2, DBCriteria criteria, Persister persister, ConcurrentMap map)
          Adds referenced objects fulfilling the specified criteria in a m:n tree to a map.
 boolean addToRelationChain(Object node, String relField, Persister persister, List list)
          Adds a chain of referenced objects in a tree to a list, the end variable at the lowest index.
 boolean addToRelationMap(Object node, String relField, Persister persister, ConcurrentMap map)
          Adds referenced objects in a tree to a map.
 boolean addToVariableChain(Variable var, String relField, Collection filter, Persister persister, List list)
          Adds a chain of referenced variables in a tree to a list, the end variable at the lowest index.
 void collapseInIdentityTree(Identity id, Persister persister, OrderedMap tree)
          Collapses the specified identity in the ordered map representing an identity tree.
 Introspector createIntrospector()
          Creates a variable introspector.
 Variable createVariable(Class clazz)
          Creates a new variable instance of the specified class.
 Variable createVariable(String type)
          Creates a new variable MBean instance of the specified type.
 void delete1NRelationTree(Object node, String relField, List predeps, List postdeps, Persister persister)
          Deletes the specified object and its subtree from a tree in 1:n relations.
 void deleteMNRelationTree(Object node, String relField, String indirection, String fkField1, String fkField2, List predeps, List postdeps, Persister persister)
          Deletes the specified object and its subtree from a tree in m:n relations.
 void deleteObject(Object node, List predeps, List postdeps, Persister persister)
          Deletes the specified object and its dependencies.
 void expandInIdentityTree(Identity id, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Expands the specified identity in the ordered map representing an identity tree.
 VariableAttributeInfo getAttributeInfo(Variable node, String field, Persister persister)
          Gets a nested attribute info in a tree.
 Object getAttributeValue(Object node, String field, Persister persister)
          Gets a nested attribute value in a tree.
 List getAttributeValues(Object node, String field, Persister persister)
          Gets a list of nested attribute values in a tree.
 Object getEndReference(Object node, String relField, Persister persister)
          Gets the end node in a tree.
 Object getKeyAttributeValue(Object node, Persister persister)
          Gets the primary key attribute value.
 Object[] getKeyAttributeValues(Object node, Persister persister)
          Gets an array of primary key attribute values.
 Object getNextReference(Object node, int index, String relField, Persister persister)
          Gets the indexed node in a tree.
 Object getNextReference(Object node, String relField, Persister persister)
          Gets the next referenced node in a tree.
 List getNextReferences(Object node, String relField, Persister persister)
          Gets a list of referenced nodes in a tree.
 int getReferenceDepth(Object node, String relField, Persister persister)
          Gets the depth of a node in a tree.
 Object getRootReference(Object node, String relField, Persister persister)
          Gets the root node in a tree.
 List getRootReferences(Object node, String relField, Persister persister)
          Gets a list of root nodes in a tree.
 ObjectName getVariableRegistryName()
          Gets the the variable registry to be applied by contexts of this filter.
 boolean isLocalizedBeans()
          Gets the localized beans flag.
 boolean isNullPK(Object pk)
          Checks whether the specified pk is a null key.
 boolean isRelatedTo(Object node, String relField, Object xpk, Persister persister)
          Checks whether the specified key is related to the specified node.
 boolean isRootPK(Object pk)
          Checks whether the specified pk is a root key.
 Collection queryAllObjects(String className, DBCriteria criteria, String[] sortFields, Persister persister)
          Queries all objects fulfilling the specified criteria, and may sort them by optional sort fields.
 Collection queryTreeObjects(String className, Object pk, String relField, DBCriteria criteria, String[] sortFields, Persister persister)
          Queries objects on the next level in a relation tree fulfilling the specified criteria, and may sort them by optional sort fields.
 boolean restoreIdentityTree(List enums, int depth, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Restores the specified enumerated identities to an ordered map.
 void setAttributeValue(Object node, String field, Object value, boolean forced, Persister persister)
          Sets a nested attribute value in a tree with a forced option.
 void setAttributeValue(Object node, String field, Object value, Persister persister)
          Sets a nested attribute value in a tree.
 void setKeyAttributeValue(Object node, Object value, Persister persister)
          Sets the primary key attribute value.
 void setKeyAttributeValues(Object node, Object[] values, Persister persister)
          Sets an array of primary key attribute values.
 void setLocalizedBeans(boolean flag)
          Sets the localized beans flag.
 Object[] setMNForeignReferences(Object node, String indirection, String fkField1, String fkField2, Object[] fks, Persister persister)
          Sets foreign references in m:n relations in a tree.
 Object[] setMNObjectReferences(Object node, String relField, String indirection, String fkField1, String fkField2, Object[] fks, Persister persister)
          Sets object references in m:n relations in a tree formed by nodes of the same class.
 void setVariableRegistryName(ObjectName registry)
          Sets the variable registry to be applied by contexts this filter.
 Collection sortObjects(Collection objects, String[] sortFields, Persister persister)
          Sorts a collection of objects with the specified fields.
 
Methods inherited from interface org.norther.tammi.root.db.MultiRepositoryClient
acquirePersister, acquirePersister, acquirePersister, clearConnections, connectionKeySet, containsConnection, getAuthenticatedPasswordKey, getAuthenticatedUsernameKey, getAuthenticationConnectionKey, getConnectionAlias, getConnectionUsername, getPersisterClassName, getResourceKey, isConnectionAuthenticated, removeConnection, setAuthenticationConnection, setConnectionAlias, setConnectionAuthenticated, setConnectionPassword, setConnectionUsername, setPersisterClassName, setResourceKey
 
Methods inherited from interface org.norther.tammi.root.db.RepositoryClient
acquirePersister, acquirePersister, acquirePersister, getAuthenticatedPasswordKey, getAuthenticatedUsernameKey, getAuthenticationConnectionKey, getConnectionKey, getConnectionUsername, getPersisterClassName, isConnectionAuthenticated, setAuthenticationConnection, setConnectionAuthenticated, setConnectionKey, setConnectionPassword, setConnectionUsername, setPersisterClassName
 

Field Detail

NULL_PK

static final Object NULL_PK
The null pk.


ROOT_PK

static final Object ROOT_PK
The root pk.

Method Detail

isNullPK

boolean isNullPK(Object pk)
Checks whether the specified pk is a null key.

Parameters:
pk - the pk to check.
Returns:
true for a null key, false otherwise.

isRootPK

boolean isRootPK(Object pk)
Checks whether the specified pk is a root key.

Parameters:
pk - the pk to check.
Returns:
true for a root key, false otherwise.

isLocalizedBeans

boolean isLocalizedBeans()
Gets the localized beans flag.

Returns:
the localized beans flag.

setLocalizedBeans

void setLocalizedBeans(boolean flag)
Sets the localized beans flag.

Parameters:
flag - the localized beans flag.

createIntrospector

Introspector createIntrospector()
Creates a variable introspector.

Returns:
the introspector.

getVariableRegistryName

ObjectName getVariableRegistryName()
Gets the the variable registry to be applied by contexts of this filter.

Returns:
the object name of the variable registry or a query.

setVariableRegistryName

void setVariableRegistryName(ObjectName registry)
Sets the variable registry to be applied by contexts this filter. If it is not set, the default one will be used.

Parameters:
registry - the object name of the variable registry or a query.

createVariable

Variable createVariable(String type)
                        throws ConstructionException
Creates a new variable MBean instance of the specified type.

Parameters:
type - the type of the variable.
Returns:
the variable MBean instance.
Throws:
ConstructionException - if construction fails.

createVariable

Variable createVariable(Class clazz)
                        throws ConstructionException
Creates a new variable instance of the specified class.

Parameters:
clazz - the class of the variable.
Returns:
the variable MBean instance.
Throws:
ConstructionException - if construction fails.

getKeyAttributeValue

Object getKeyAttributeValue(Object node,
                            Persister persister)
                            throws AttributeNotFoundException
Gets the primary key attribute value.

Parameters:
node - the node object.
persister - the persister.
Returns:
the primary key attribute value or null.
Throws:
AttributeNotFoundException - for a missing field.

setKeyAttributeValue

void setKeyAttributeValue(Object node,
                          Object value,
                          Persister persister)
                          throws AttributeNotFoundException,
                                 InvalidAttributeValueException
Sets the primary key attribute value.

Parameters:
node - the node object.
persister - the persister.
value - the primary key attribute value.
Throws:
InvalidAttributeValueException - if the value is invalid.
AttributeNotFoundException - for a missing field.

getKeyAttributeValues

Object[] getKeyAttributeValues(Object node,
                               Persister persister)
                               throws AttributeNotFoundException
Gets an array of primary key attribute values.

Parameters:
node - the node object.
persister - the persister.
Returns:
an array of primary key attribute values or null.
Throws:
AttributeNotFoundException - for a missing field.

setKeyAttributeValues

void setKeyAttributeValues(Object node,
                           Object[] values,
                           Persister persister)
                           throws InvalidAttributeValueException,
                                  AttributeNotFoundException
Sets an array of primary key attribute values.

Parameters:
node - the node object.
persister - the persister.
values - an array of primary key values.
Throws:
InvalidAttributeValueException - if the value is invalid.
AttributeNotFoundException - for a missing field.

getAttributeInfo

VariableAttributeInfo getAttributeInfo(Variable node,
                                       String field,
                                       Persister persister)
                                       throws AttributeNotFoundException
Gets a nested attribute info in a tree.

Parameters:
node - the node variable.
field - the attribute field(s).
persister - the persister.
Returns:
the attribute info or null.
Throws:
AttributeNotFoundException - for a missing field.

getAttributeValue

Object getAttributeValue(Object node,
                         String field,
                         Persister persister)
                         throws AttributeNotFoundException
Gets a nested attribute value in a tree.

Parameters:
node - the node object.
field - the attribute field(s).
persister - the persister.
Returns:
the attribute value or null.
Throws:
AttributeNotFoundException - for a missing field.

setAttributeValue

void setAttributeValue(Object node,
                       String field,
                       Object value,
                       Persister persister)
                       throws AttributeNotFoundException,
                              InvalidAttributeValueException
Sets a nested attribute value in a tree.

Parameters:
node - the node object.
field - the attribute field(s).
value - the attribute value.
persister - the persister.
Throws:
AttributeNotFoundException - for a missing field.
InvalidAttributeValueException - if the value is invalid.

setAttributeValue

void setAttributeValue(Object node,
                       String field,
                       Object value,
                       boolean forced,
                       Persister persister)
                       throws AttributeNotFoundException,
                              InvalidAttributeValueException
Sets a nested attribute value in a tree with a forced option.

Parameters:
node - the node object.
field - the attribute field(s).
value - the attribute value.
forced - if true, forces the setting.
persister - the persister.
Throws:
AttributeNotFoundException - for a missing field.
InvalidAttributeValueException - if the value is invalid.

getAttributeValues

List getAttributeValues(Object node,
                        String field,
                        Persister persister)
                        throws AttributeNotFoundException
Gets a list of nested attribute values in a tree.

Parameters:
node - the node object.
field - the attribute field(s).
persister - the persister.
Returns:
a list of attribute values.
Throws:
AttributeNotFoundException - for a missing field.

addAttributeValues

boolean addAttributeValues(Object node,
                           String field,
                           Persister persister,
                           List result)
                           throws AttributeNotFoundException
Adds nested attribute values in a tree to a list.

Parameters:
node - the node object.
field - the attribute field(s).
persister - the persister.
result - a list of attribute values.
Returns:
true if added, false otherwise.
Throws:
AttributeNotFoundException - for a missing field.

getReferenceDepth

int getReferenceDepth(Object node,
                      String relField,
                      Persister persister)
                      throws AttributeNotFoundException
Gets the depth of a node in a tree.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
Returns:
the depth.
Throws:
AttributeNotFoundException - for a missing field.

getEndReference

Object getEndReference(Object node,
                       String relField,
                       Persister persister)
                       throws AttributeNotFoundException
Gets the end node in a tree. The first one is applied at each level in 1:n relations.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
Returns:
the end node or null.
Throws:
AttributeNotFoundException - for a missing field.

getRootReference

Object getRootReference(Object node,
                        String relField,
                        Persister persister)
                        throws AttributeNotFoundException
Gets the root node in a tree. The root level is one level below the end level. The first one is applied at each level in 1:n relations.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
Returns:
the root node or null.
Throws:
AttributeNotFoundException - for a missing field.

getRootReferences

List getRootReferences(Object node,
                       String relField,
                       Persister persister)
                       throws AttributeNotFoundException
Gets a list of root nodes in a tree. The root level is one level below the end level.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
Returns:
a list of referenced nodes.
Throws:
AttributeNotFoundException - for a missing field.

getNextReference

Object getNextReference(Object node,
                        String relField,
                        Persister persister)
                        throws AttributeNotFoundException
Gets the next referenced node in a tree. The first one is applied in 1:n relations.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
Returns:
the referenced node or null.
Throws:
AttributeNotFoundException - for a missing field.

getNextReference

Object getNextReference(Object node,
                        int index,
                        String relField,
                        Persister persister)
                        throws AttributeNotFoundException
Gets the indexed node in a tree. The first one is applied at each level in 1:n relations.

Parameters:
node - the node object.
index - the node index.
relField - the relation field.
persister - the persister.
Returns:
the indexed node or null.
Throws:
AttributeNotFoundException - for a missing field.

getNextReferences

List getNextReferences(Object node,
                       String relField,
                       Persister persister)
                       throws AttributeNotFoundException
Gets a list of referenced nodes in a tree.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
Returns:
a read-only list of referenced nodes.
Throws:
AttributeNotFoundException - for a missing field.

isRelatedTo

boolean isRelatedTo(Object node,
                    String relField,
                    Object xpk,
                    Persister persister)
                    throws AttributeNotFoundException
Checks whether the specified key is related to the specified node.

Parameters:
node - the node object.
relField - the relation field.
xpk - the primary key to check.
persister - the persister.
Returns:
true if referenced, false otherwise.
Throws:
AttributeNotFoundException - for a missing field.

addToRelationChain

boolean addToRelationChain(Object node,
                           String relField,
                           Persister persister,
                           List list)
                           throws AttributeNotFoundException,
                                  PersisterException
Adds a chain of referenced objects in a tree to a list, the end variable at the lowest index. The first one is applied at each level in 1:n and m:n relations.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
list - the result list.
Returns:
true if added, false otherwise.
Throws:
AttributeNotFoundException - for a missing field.
PersisterException - if a persister operation fails.

addToRelationMap

boolean addToRelationMap(Object node,
                         String relField,
                         Persister persister,
                         ConcurrentMap map)
                         throws AttributeNotFoundException,
                                PersisterException
Adds referenced objects in a tree to a map. All objects at all levels are included. Objects are mapped by their primary keys.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
map - the result map.
Returns:
true if added, false otherwise.
Throws:
AttributeNotFoundException - for a missing field.
PersisterException - if a persister operation fails.

addTo1NRelationMap

boolean addTo1NRelationMap(Object node,
                           String fkField,
                           DBCriteria criteria,
                           Persister persister,
                           ConcurrentMap map)
                           throws AttributeNotFoundException,
                                  PersisterException
Adds referenced objects fulfilling the specified criteria in a 1:n tree to a map. Only the next level is included. Objects are mapped by their primary keys.

Parameters:
node - the node object.
fkField - the foreign key field.
criteria - the selection criteria.
persister - the persister.
map - the result map.
Returns:
true if added, false otherwise.
Throws:
AttributeNotFoundException - for a missing field.
PersisterException - if a persister operation fails.

addTo1NRelationMap

boolean addTo1NRelationMap(Object node,
                           String relField,
                           String fkField,
                           DBCriteria criteria,
                           Persister persister,
                           ConcurrentMap map)
                           throws AttributeNotFoundException,
                                  PersisterException
Adds referenced objects fulfilling the specified criteria in a 1:n tree to a map. All objects at all levels are included. Objects are mapped by their primary keys.

Parameters:
node - the node object.
relField - the relation field.
fkField - the foreign key field.
criteria - the selection criteria.
persister - the persister.
map - the result map.
Returns:
true if added, false otherwise.
Throws:
AttributeNotFoundException - for a missing field.
PersisterException - if a persister operation fails.

addToMNRelationMap

boolean addToMNRelationMap(Object node,
                           String indirection,
                           String fkField1,
                           String fkField2,
                           DBCriteria criteria,
                           Persister persister,
                           ConcurrentMap map)
                           throws AttributeNotFoundException,
                                  PersisterException
Adds referenced objects fulfilling the specified criteria in a m:n tree to a map. Only the next level is included. Objects are mapped by their primary keys.

Parameters:
node - the node object.
indirection - the indirection class name.
fkField1 - the foreign key field to the node.
fkField2 - the foreign key field to the reference.
criteria - the selection criteria.
persister - the persister.
map - the result map.
Returns:
true if added, false otherwise.
Throws:
AttributeNotFoundException - for a missing field.
PersisterException - if a persister operation fails.

addToMNRelationMap

boolean addToMNRelationMap(Object node,
                           String relField,
                           String indirection,
                           String