thinkmap.client
Class SourceEntity

java.lang.Object
  extended by thinkmap.client.Entity
      extended by thinkmap.client.SourceEntity

public class SourceEntity
extends Entity

Source Entities are created by the SourceManager and generally represent the root of the Entity chain. One source entity is created (on demand) for each entity in the datasource. SourceEntities have an EntityId, which is used to uniquely identify them to the datasource. They also have a set of relations which describes their relationship to other related Entities.

Source entities fetch their relations from the datasource lazily.

Source Entities can be serialized to a DataSource via the writeTo() method.

Version:
$Revision: 1.40 $

Nested Class Summary
 class SourceEntity.Relation
          A Relation defines a relationship between two entities in the source manager.
 
Field Summary
protected  long createdOnRevision
           
protected  boolean dataFetched
          Whether the actual data of the SourceEntity has been fetched.
static String ENTITY_ID
           
protected  boolean hasRelations
           
protected  Hashtable providedProperties
           
static String RELATED_ENTITIES
           
protected  long relatedFetchedOnRevision
           
protected  byte relatedFlag
           
 
Fields inherited from class thinkmap.client.Entity
phDeferred
 
Constructor Summary
SourceEntity()
           
 
Method Summary
 void addProperty(Property pp)
          Adds a property that was configured via xml.
 void addRelation(SourceEntity.Relation re)
          Add a relation to this SourceEntity.
 void clearRelatedEntities()
          Remove all the related entities from this entity, and mark the relations as needing to be loaded from the datasource.
 Property createProperty()
          Create a new property for xml configuration that will eventually be added via the addProperty() method.
 SourceEntity.Relation createRelation()
          Create a relation that will be added via the addRelation() method.
 Object getAttribute(String name)
          Get an attribute from the SourceEntity
 EntityId getEntityId()
          Get the entity id of this entity
 Object getPropertyAttribute(String propertyName, String attributeName)
          Get an attribute of a provided property
 Property[] getProvidedProperties()
           
 byte getRelatedFlags()
           
 SourceEntity.Relation getRelation(int i)
          Get a relation at a particular index.
 int getRelationCount()
          Get the number of relations that this entity has.
 void invalidateRelations()
          Mark the relations as needing to be (re)fetched from the datasource.
 void setAttribute(String name, Object value)
          Set an attribute on the SourceEntity
 void setAttributes(Hashtable cache)
          Set many attributes at once
 void setEntityId(EntityId id)
          Set the entity id of this entity.
 void setEntityId(String[] s)
          Set the id of the entity, which uniquely identifies the entity.
 void setEntityType(String s)
          Set the type of the entity.
 void setHasRelations(boolean val)
           
 void setRelatedFlags(byte i)
           
 String toString()
           
 void writeTo(IEntityHandler handler, boolean writeRelations)
           
 
Methods inherited from class thinkmap.client.Entity
getProperty, getPropertyNames, removeProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENTITY_ID

public static final String ENTITY_ID
See Also:
Constant Field Values

RELATED_ENTITIES

public static final String RELATED_ENTITIES
See Also:
Constant Field Values

providedProperties

protected Hashtable providedProperties

relatedFlag

protected byte relatedFlag

hasRelations

protected boolean hasRelations

relatedFetchedOnRevision

protected long relatedFetchedOnRevision

createdOnRevision

protected long createdOnRevision

dataFetched

protected boolean dataFetched
Whether the actual data of the SourceEntity has been fetched. If it hasn't, this is just a dummy entity (probably a dummy node), and it should be fetched from the datasource.

Constructor Detail

SourceEntity

public SourceEntity()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

createProperty

public Property createProperty()
Create a new property for xml configuration that will eventually be added via the addProperty() method.

Returns:
a new property for xml configuration

addProperty

public void addProperty(Property pp)
                 throws Exception
Adds a property that was configured via xml.

Parameters:
pp - a property that was configured via xml.
Throws:
Exception

setEntityId

public void setEntityId(String[] s)
Set the id of the entity, which uniquely identifies the entity. In XML, this may be a comma-separated list.

Parameters:
s - the entity's ID

setEntityType

public void setEntityType(String s)
Set the type of the entity.

Parameters:
s - the entity's type

setEntityId

public void setEntityId(EntityId id)
Set the entity id of this entity.

Parameters:
id -

getEntityId

public EntityId getEntityId()
Get the entity id of this entity

Returns:
the entity id of this entity

clearRelatedEntities

public void clearRelatedEntities()
Remove all the related entities from this entity, and mark the relations as needing to be loaded from the datasource.


getRelationCount

public int getRelationCount()
Get the number of relations that this entity has.

Returns:
the number of relations that this entity has.

getRelation

public SourceEntity.Relation getRelation(int i)
Get a relation at a particular index.

Parameters:
i - the index of the relation to retrieve
Returns:
the relattion at that index

createRelation

public SourceEntity.Relation createRelation()
Create a relation that will be added via the addRelation() method.

Returns:
a new relation

addRelation

public void addRelation(SourceEntity.Relation re)
Add a relation to this SourceEntity.

Parameters:
re - the relation to add

invalidateRelations

public void invalidateRelations()
Mark the relations as needing to be (re)fetched from the datasource.


writeTo

public void writeTo(IEntityHandler handler,
                    boolean writeRelations)

getRelatedFlags

public byte getRelatedFlags()

setRelatedFlags

public void setRelatedFlags(byte i)

setHasRelations

public void setHasRelations(boolean val)

getProvidedProperties

public Property[] getProvidedProperties()

getPropertyAttribute

public Object getPropertyAttribute(String propertyName,
                                   String attributeName)
Get an attribute of a provided property


setAttribute

public void setAttribute(String name,
                         Object value)
Set an attribute on the SourceEntity


setAttributes

public void setAttributes(Hashtable cache)
Set many attributes at once


getAttribute

public Object getAttribute(String name)
Get an attribute from the SourceEntity



Copyright © 2013 Thinkmap, Inc. All Rights Reserved.