Vordel SDK

com.vordel.es
Class EntityStoreDelegate

java.lang.Object
  extended by com.vordel.es.EntityStoreDelegate

public class EntityStoreDelegate
extends java.lang.Object

Holding area for extended ES functionality which may be candidates for inclusion into the EntityStore interface proper in the future. Contains various convenience classes for higher-level manipulation of Entities.


Nested Class Summary
static class EntityStoreDelegate.TypedFieldEntity
          Store an Entity which has a field(s)of the specified type and a list of the names of those fields.
 
Constructor Summary
EntityStoreDelegate()
           
 
Method Summary
static Entity create(EntityStore es, ESPK parentPK, java.lang.String type, java.lang.Object[][] vals)
           
static Entity create(EntityStore es, java.lang.String shk)
           
static Entity createDefaultedEntity(EntityStore es, EntityType type)
          Utility to create a new Entity instance with all the default values already set
static Entity createDefaultedEntity(EntityStore es, java.lang.String type)
           
static byte[] exportStore(EntityStore es, boolean closure, boolean normalized, boolean types)
          Deprecated. Use the EntityStore.exportContents(java.io.OutputStream, java.util.Collection, int) method instead
static EntityStoreDelegate.TypedFieldEntity[] findEntitiesWithTypedFields(EntityStore es, java.lang.String fieldType, java.util.Set<ESPK> selectedKeys)
           
static Entity[] findEntity(EntityStore es, ESPK start, java.lang.String fieldName, java.lang.String value, EntityType type)
          Method used to find an entity of a type which contains a field with a certain value Note, use this method carefully as it will recursively get all entities from the entitystore!
static Entity[] findEntity(EntityStore es, java.lang.String fieldName, java.lang.String value, EntityType type)
          Method used to find an entity of a type which contains a field with a certain value Note, use this method carefully as it will recursively get all entities from the entitystore!
static java.util.Collection<ESPK> findNamedChildren(EntityStore es, ESPK parent, EntityType type, java.lang.String fieldName, java.lang.String value)
           
static java.util.Collection<EntityFieldReferences> findSoftReferencesToBranch(EntityStore es, ESPK rootPK)
           
static java.util.Set<ESPK> getDescendantPKs(EntityStore es, ESPK pk, java.lang.String typeName)
          Convenience method to retrieve a set of descendant ESPKs per type
static Entity getEntity(EntityStore es, ESPK pk)
           
static Entity getEntity(EntityStore es, ESPK currPK, java.lang.String shorthandKey)
           
static Entity getEntity(EntityStore es, java.lang.String shorthandKey)
          Method for getting an Entity for a 'shorthand' key.
static ESPK getEntityForKey(EntityStore es, ESPK epk)
          Locate the entity as specified by the key, in the EntityStore.
static java.util.SortedSet<Entity> getSortedChildEntities(EntityStore es, ESPK parentPK, EntityType type)
          Intended as a replacement for the SQL 'ORDER BY' construct.
static java.util.SortedSet<Entity> getSortedChildEntities(EntityStore es, ESPK parentPK, EntityType type, java.lang.String[] sortByFields)
          Intended as a replacement for the SQL 'ORDER BY' construct.
static java.util.SortedSet<Entity> getSortedChildEntities(EntityStore es, ESPK parentPK, EntityType type, java.lang.String[] sortByFields, int order)
           
static boolean hasType(EntityStore store, java.lang.String typeName)
          Method to determine whether an entity store has a particular type.
static boolean isFederated(java.io.InputStream is)
           
static java.lang.String pkToPath(EntityStore es, ESPK pk)
          Convenience method to return the normalized version of the ESPK as an XML fragment.
static void setDefaults(EntityStore es, Entity entity)
          Set any unset fields to have the defaults as set in their type definition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityStoreDelegate

public EntityStoreDelegate()
Method Detail

findNamedChildren

public static java.util.Collection<ESPK> findNamedChildren(EntityStore es,
                                                           ESPK parent,
                                                           EntityType type,
                                                           java.lang.String fieldName,
                                                           java.lang.String value)
                                                    throws EntityStoreException
Throws:
EntityStoreException

getSortedChildEntities

public static java.util.SortedSet<Entity> getSortedChildEntities(EntityStore es,
                                                                 ESPK parentPK,
                                                                 EntityType type)
                                                          throws EntityStoreException
Intended as a replacement for the SQL 'ORDER BY' construct. This method will choose the key fields of the specified EntityType to sort on.

Using an iterator on the resulting SortedSet, you're guaranteed that the ordering will be correct.

The ordering rules are that the sequence specified in the key fields array defines the precedence of the fields to sort, so if the keyField[N] matches for one or more entities, then the ordering goes to keyField[N+1] to determine order and so on. If all fields match, then the ESPK of the Entity is used to define order.

In the case of an Entity which has inherited some key field(s) from a superType, the precedence of the keys is:
superType.key1,..,superType.keyN,subtype.key1,...,subtype.keyN

For an example of this at work, see the test case com.vordel.es.TestEntityComparator

Parameters:
es - The EntityStore to call
parentPK - The parent node under which to search for Entities
type - The type of Entities to search for
Returns:
A SortedSet of Entities. Use iterator to access in order
Throws:
EntityStoreException

getSortedChildEntities

public static java.util.SortedSet<Entity> getSortedChildEntities(EntityStore es,
                                                                 ESPK parentPK,
                                                                 EntityType type,
                                                                 java.lang.String[] sortByFields)
                                                          throws EntityStoreException
Intended as a replacement for the SQL 'ORDER BY' construct. This method allows the caller to sort on arbitrary fields.

Using an iterator on the resulting SortedSet, you're guaranteed that the ordering will be correct.

The ordering rules are that the sequence specified in the sortByFields array defines the precedence of the fields to sort, so if the sortByFields[N] match for one or more entities, then the ordering goes to sortByFields[N+1] to determine order and so on. If all fields match, then the ESPK of the Entity is used to define order.

In the case of an Entity which has inherited some key field(s) from a superType, the precedence of the keys is:
superType.key1,....,superType.keyN,subtype.key1,...,subtype.keyN

For an example of this at work, see the test case com.vordel.es.TestEntityComparator

Parameters:
es - The EntityStore to call
parentPK - The parent node under which to search for Entities
type - The type of Entities to search for
sortByFields - The fields on which to sort the result set
Returns:
A SortedSet of Entities. Use iterator to access in order
Throws:
EntityStoreException
java.lang.IllegalArgumentException - If the specified fields don't match the specified type definition.

getSortedChildEntities

public static java.util.SortedSet<Entity> getSortedChildEntities(EntityStore es,
                                                                 ESPK parentPK,
                                                                 EntityType type,
                                                                 java.lang.String[] sortByFields,
                                                                 int order)
                                                          throws EntityStoreException
Throws:
EntityStoreException

getDescendantPKs

public static final java.util.Set<ESPK> getDescendantPKs(EntityStore es,
                                                         ESPK pk,
                                                         java.lang.String typeName)
                                                  throws EntityStoreException
Convenience method to retrieve a set of descendant ESPKs per type

Throws:
EntityStoreException

pkToPath

public static final java.lang.String pkToPath(EntityStore es,
                                              ESPK pk)
Convenience method to return the normalized version of the ESPK as an XML fragment.

Parameters:
es - The EntityStore containing the Entity specified
pk - The ESPK of the Entity whose location is to be described. Must be non-null and not the NULL_ESPK.
Returns:
A String representation of the normalized ESPK, or an empty string if there was a problem in generating the string.

createDefaultedEntity

public static Entity createDefaultedEntity(EntityStore es,
                                           EntityType type)
                                    throws EntityStoreException
Utility to create a new Entity instance with all the default values already set

Parameters:
es - The EntityStore to connect to to resolve defaulted links
type - The type of the entity to create
Returns:
A new entity with all the defaults set
Throws:
EntityStoreException - If there's a problem connecting to the entity store.

createDefaultedEntity

public static Entity createDefaultedEntity(EntityStore es,
                                           java.lang.String type)
                                    throws EntityStoreException
Throws:
EntityStoreException

setDefaults

public static void setDefaults(EntityStore es,
                               Entity entity)
                        throws EntityStoreException
Set any unset fields to have the defaults as set in their type definition

Parameters:
es -
entity -
Throws:
EntityStoreException

getEntityForKey

public static ESPK getEntityForKey(EntityStore es,
                                   ESPK epk)
Locate the entity as specified by the key, in the EntityStore. If the key is of type PortableESPK (the cross-ES form of the key) then it will be translated to the actual key for the underlying store's implementation. If the entity specified by the key does not exist, then null is returned.

Parameters:
es -
epk -
Returns:
The entity specified by the key, or null if it doesn't exist.
Throws:
EntityStoreException

getEntity

public static Entity getEntity(EntityStore es,
                               ESPK pk)

findEntitiesWithTypedFields

public static final EntityStoreDelegate.TypedFieldEntity[] findEntitiesWithTypedFields(EntityStore es,
                                                                                       java.lang.String fieldType,
                                                                                       java.util.Set<ESPK> selectedKeys)
                                                                                throws EntityStoreException
Throws:
EntityStoreException

findEntity

public static Entity[] findEntity(EntityStore es,
                                  java.lang.String fieldName,
                                  java.lang.String value,
                                  EntityType type)
                           throws EntityStoreException
Method used to find an entity of a type which contains a field with a certain value Note, use this method carefully as it will recursively get all entities from the entitystore!

Parameters:
es - - the entitystore to search
fieldName - - the field to be tested
value - - the value of fieldName (if null then the value of fieldName will not be tested)
type - - the type that is being search for (if null then any type that matches the fieldName value will be returned)
Returns:
an array of corresponding entities
Throws:
EntityStoreException

findEntity

public static Entity[] findEntity(EntityStore es,
                                  ESPK start,
                                  java.lang.String fieldName,
                                  java.lang.String value,
                                  EntityType type)
                           throws EntityStoreException
Method used to find an entity of a type which contains a field with a certain value Note, use this method carefully as it will recursively get all entities from the entitystore!

Parameters:
es - - the entitystore to search
start - - where to start the search
fieldName - - the field to be tested
value - - the value of fieldName (if null then the value of fieldName will not be tested)
type - - the type that is being search for (if null then any type that matches the fieldName value will be returned)
Returns:
an array of corresponding entities
Throws:
EntityStoreException

hasType

public static boolean hasType(EntityStore store,
                              java.lang.String typeName)
Method to determine whether an entity store has a particular type.

Parameters:
store -
typeName -
Returns:
true if the type exists, false otherwise

getEntity

public static Entity getEntity(EntityStore es,
                               java.lang.String shorthandKey)
                        throws EntityStoreException
Method for getting an Entity for a 'shorthand' key.

Parameters:
es - The EntityStore to search.
shorthandKey - A path referencing an Entity in the specified store.
Returns:
The first Entity referenced by the shorthand key, or null if a matching Entity can't be found.
Throws:
EntityStoreException
See Also:
ShorthandKeyFinder

getEntity

public static Entity getEntity(EntityStore es,
                               ESPK currPK,
                               java.lang.String shorthandKey)
                        throws EntityStoreException
Throws:
EntityStoreException

create

public static Entity create(EntityStore es,
                            ESPK parentPK,
                            java.lang.String type,
                            java.lang.Object[][] vals)
                     throws EntityStoreException
Throws:
EntityStoreException

create

public static Entity create(EntityStore es,
                            java.lang.String shk)
                     throws EntityStoreException
Throws:
EntityStoreException

exportStore

public static byte[] exportStore(EntityStore es,
                                 boolean closure,
                                 boolean normalized,
                                 boolean types)
                          throws EntityStoreException
Deprecated. Use the EntityStore.exportContents(java.io.OutputStream, java.util.Collection, int) method instead

Parameters:
es -
closure -
normalized -
types -
Returns:
A byte array containing the EntityStore's contents
Throws:
EntityStoreException

isFederated

public static boolean isFederated(java.io.InputStream is)

findSoftReferencesToBranch

public static java.util.Collection<EntityFieldReferences> findSoftReferencesToBranch(EntityStore es,
                                                                                     ESPK rootPK)
                                                                              throws EntityStoreException
Throws:
EntityStoreException

Vordel SDK


This documentation and all its contents and graphics, copyright © 1999 - 2011 Vordel