thinkmap.datasource.database
Class EntityResultMapping

java.lang.Object
  extended by thinkmap.datasource.database.EntityResultMapping
All Implemented Interfaces:
Serializable, IEntityResultMapping

public class EntityResultMapping
extends Object
implements IEntityResultMapping, Serializable

Simple class that stores mapping from table columns to entities.

For edge mappings this stores information about both the edge and the related node, thus allowing a single query to return both the edge and the related node.

Version:
$Revision: 1.4 $
See Also:
Serialized Form

Field Summary
protected  boolean cache
           
protected  Byte cacheFlag
           
protected  Binding entityTypeBinding
           
protected  Binding[] ids
           
protected  Binding[] props
           
protected  EntityRelation[] relations
           
 
Constructor Summary
EntityResultMapping()
          Creates a new EntityResultMapping object.
EntityResultMapping(Binding entityType, Binding[] ids, Binding[] props)
          Creates a new EntityResultMapping object.
EntityResultMapping(Binding entityType, Binding[] ids, Binding[] props, Binding relatedEntityType, Binding[] relatedIds, boolean isReciprocal, String relation)
          Creates a new EntityResultMapping object.
EntityResultMapping(Binding entityType, Binding[] ids, Binding[] props, EntityRelation[] relations)
          Creates a new EntityResultMapping object.
 
Method Summary
 boolean getCache()
          Determine if this mapping can cache its elements
 Binding getEntityType()
          Get the entity type of mapped entities.
 Binding[] getIdBindings()
          Get the id column index array.
 boolean getIsReciprocal()
          Deprecated.  
 Binding[] getPropertyBindings()
          Get the property column index array.
 Binding getRelatedEntityType()
          Deprecated.  
 Binding[] getRelatedIdBindings()
          Deprecated.  
 String getRelation()
          Deprecated.  
 EntityRelation[] getRelations()
          Get the Relations for this entity.
 void outputEntity(IEntityHandler callback, Message message, SourceEntity entity, EntityId id, Object context)
          Output entities to an IEntityHandler
 void setCache(boolean b)
          Set to true if this mapping can cache its elements
 void setEntityType(Binding entityType)
          Set the entity type of mapped entities.
 void setIdBindings(Binding[] ids)
          Set the id column index array.
 void setIsReciprocal(boolean isReciprocal)
          Deprecated.  
 void setPropertyBindings(Binding[] props)
          Set the property column index array.
 void setRelatedEntityType(Binding relatedEntityType)
          Deprecated.  
 void setRelatedIdBindings(Binding[] relatedIds)
          Deprecated.  
 void setRelation(String relation)
          Deprecated.  
 void setRelations(EntityRelation[] relations)
          Set the Relations for this entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheFlag

protected Byte cacheFlag

cache

protected boolean cache

entityTypeBinding

protected Binding entityTypeBinding

ids

protected Binding[] ids

props

protected Binding[] props

relations

protected EntityRelation[] relations
Constructor Detail

EntityResultMapping

public EntityResultMapping()
Creates a new EntityResultMapping object.


EntityResultMapping

public EntityResultMapping(Binding entityType,
                           Binding[] ids,
                           Binding[] props)
Creates a new EntityResultMapping object. This constructor is suited to node mappings, as it provides only information about id keys and properties.

Parameters:
entityType - entity type of mapped entities
ids - array of id column indices
props - array of property column indices

EntityResultMapping

public EntityResultMapping(Binding entityType,
                           Binding[] ids,
                           Binding[] props,
                           Binding relatedEntityType,
                           Binding[] relatedIds,
                           boolean isReciprocal,
                           String relation)
Creates a new EntityResultMapping object. This constructor is suited to edge mappings, as it provides the information needed to construct entities relations.

Parameters:
entityType - entity type of mapped entities
ids - array of id column indices
props - array of property column indices
relatedEntityType - entity type of related entity
relatedIds - array of related id column indices
isReciprocal - true if the relation is reciprocal

EntityResultMapping

public EntityResultMapping(Binding entityType,
                           Binding[] ids,
                           Binding[] props,
                           EntityRelation[] relations)
Creates a new EntityResultMapping object. This constructor is suited to edge mappings, as it provides the information needed to construct entities relations.

Parameters:
entityType - entity type of mapped entities
ids - array of id column indices
props - array of property column indices
relatedEntityType - entity type of related entity
relatedIds - array of related id column indices
isReciprocal - true if the relation is reciprocal
Method Detail

setEntityType

public void setEntityType(Binding entityType)
Set the entity type of mapped entities.

Parameters:
entityType - entity type

getEntityType

public Binding getEntityType()
Get the entity type of mapped entities.

Returns:
entity type

setIdBindings

public void setIdBindings(Binding[] ids)
Set the id column index array.

Parameters:
ids - column indices

getIdBindings

public Binding[] getIdBindings()
Get the id column index array.

Returns:
id column indices

setRelations

public void setRelations(EntityRelation[] relations)
Set the Relations for this entity.

Parameters:
relations - The relations

getRelations

public EntityRelation[] getRelations()
Get the Relations for this entity.

Returns:
the relations

setPropertyBindings

public void setPropertyBindings(Binding[] props)
Set the property column index array.

Parameters:
props - property column indices

getPropertyBindings

public Binding[] getPropertyBindings()
Get the property column index array.

Returns:
property column indices

setRelatedEntityType

public void setRelatedEntityType(Binding relatedEntityType)
Deprecated. 

Set the entity type of related entities.

Parameters:
relatedEntityType - related entity type

getRelatedEntityType

public Binding getRelatedEntityType()
Deprecated. 

Get the entity type of related entities.

Returns:
related entity type

setRelatedIdBindings

public void setRelatedIdBindings(Binding[] relatedIds)
Deprecated. 

Set the related id column index array.

Parameters:
relatedIds - related id column indices

getRelatedIdBindings

public Binding[] getRelatedIdBindings()
Deprecated. 

Get the related id column index array.

Returns:
related id column indices

setIsReciprocal

public void setIsReciprocal(boolean isReciprocal)
Deprecated. 

Set whether or not the relation specified in this mapping is reciprocal.

Parameters:
isReciprocal - true if the relation is reciprocal

getIsReciprocal

public boolean getIsReciprocal()
Deprecated. 

Determine if the relation specified in this mapping is reciprocal.

Returns:
true if the relation is reciprocal

setCache

public void setCache(boolean b)
Set to true if this mapping can cache its elements

Parameters:
b - true if this mapping can cahce its elements

getCache

public boolean getCache()
Determine if this mapping can cache its elements

Returns:
true if this mapping can cache its element

getRelation

public String getRelation()
Deprecated. 

Get the name of the relation that connects this entity and the related entity.

Returns:
the name of the relation that connects this entity and the related entity

setRelation

public void setRelation(String relation)
Deprecated. 

Sets the name of the relation that connects this entity and the related entity.


outputEntity

public void outputEntity(IEntityHandler callback,
                         Message message,
                         SourceEntity entity,
                         EntityId id,
                         Object context)
                  throws BindingException
Description copied from interface: IEntityResultMapping
Output entities to an IEntityHandler

Specified by:
outputEntity in interface IEntityResultMapping
Parameters:
callback - the IEntityHandler that will receive entities
message - the incoming message
entity - the entity being bound (may be null)
id - the id of the entity being bound
context - context object; datasource-specific
Throws:
BindingException


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.