pl.edu.agh.cast.data.model.general
Interface IManyToManyRelation

All Superinterfaces:
Identifiable, IDisposable, IDomainElement, IElement, IGeneralElement, IPropertyContainer, IReplicable, IValidatable, Observer, Serializable
All Known Subinterfaces:
IOneToOneRelation, ITimedManyToManyRelation, ITimedOneToOneRelation
All Known Implementing Classes:
ManyToManyRelation, OneToOneRelation, TimedManyToManyRelation, TimedOneToOneRelation

public interface IManyToManyRelation
extends IGeneralElement

An interface of many-to-many relations which may have multiple source and target entities. The relation may be directed or bi-directional. In the former case the direction is from source entities to target entities.

Each relation has to satisfy the following condition:

Both source and target entities are properties of type PropertyType.REFERENCE_LIST. The names of the properties are: IManyToManyRelation.Properties.SOURCE_ENTITIES, IManyToManyRelation.Properties.TARGET_ENTITIES and IManyToManyRelation.Properties.DIRECTED

Author:
AGH CAST Team
See Also:
IGeneralDataSet, IEntity

Nested Class Summary
static class IManyToManyRelation.Properties
          Enumeration of property name constants.
 
Field Summary
static Type TYPE
          The type of many-to-many relation elements.
 
Method Summary
 void addSourceEntitiy(IEntity entity)
          Adds a source entity associated with the relation.
 void addTargetEntitiy(IEntity entity)
          Adds a target entity associated with the relation.
 List<? extends IEntity> getSourceEntities()
          Returns source entities associated with the relation.
 IEntity getSourceEntitiy(int index)
          Gets source entity associated with the relation with given index in the list.
 List<? extends IEntity> getTargetEntities()
          Returns target entities associated with the relation.
 IEntity getTargetEntitiy(int index)
          Gets target entity associated with the relation with given index in the list.
 Boolean isDirected()
          Checks if given relation is directed (from source to target entities) or not (in that case it is bi-directional).
 boolean removeSourceEntitiy(IEntity entity)
          Removes the specified source entity associated with the relation.
 boolean removeTargetEntitiy(IEntity entity)
          Removes the specified target entity associated with the relation.
 void setDirected(Boolean directed)
          Sets the directed flag.
 void setSourceEntities(List<? extends IEntity> entities)
          Sets source entities associated with the relation.
 void setTargetEntities(List<? extends IEntity> entities)
          Sets target entities associated with the relation.
 
Methods inherited from interface pl.edu.agh.cast.data.model.IElement
getDataSet
 
Methods inherited from interface pl.edu.agh.cast.data.model.Identifiable
getId, getType
 
Methods inherited from interface pl.edu.agh.cast.data.model.property.IPropertyContainer
addProperty, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, matches, removeProperty, setProperty
 
Methods inherited from interface java.util.Observer
update
 
Methods inherited from interface pl.edu.agh.cast.common.IValidatable
isValid
 
Methods inherited from interface pl.edu.agh.cast.common.IDisposable
dispose
 
Methods inherited from interface pl.edu.agh.cast.common.IReplicable
replicate, replicateTo
 

Field Detail

TYPE

static final Type TYPE
The type of many-to-many relation elements.

Method Detail

getSourceEntities

@PropertyGetter(name="SOURCE_ENTITIES",
                type=REFERENCE_LIST,
                matchable=true)
List<? extends IEntity> getSourceEntities()
Returns source entities associated with the relation. Result must contain at least one entity.

Returns:
list of source entities

setSourceEntities

@PropertySetter(name="SOURCE_ENTITIES")
void setSourceEntities(List<? extends IEntity> entities)
Sets source entities associated with the relation.

Parameters:
entities - collection containing at least one entity
Throws:
IllegalArgumentException - when entity list is null or empty

getSourceEntitiy

IEntity getSourceEntitiy(int index)
Gets source entity associated with the relation with given index in the list.

Parameters:
index - index of entity in the source entities list
Returns:
entity from given index or null if not present

addSourceEntitiy

void addSourceEntitiy(IEntity entity)
                      throws ModelException
Adds a source entity associated with the relation.

Parameters:
entity - entity to add
Throws:
IllegalArgumentException - when entity is null
ModelException - when entity is already the relation's source entity

removeSourceEntitiy

boolean removeSourceEntitiy(IEntity entity)
Removes the specified source entity associated with the relation.

Parameters:
entity - entity to remove
Returns:
true if the source entity was present and successfully removed
Throws:
IllegalArgumentException - when entity is null

getTargetEntities

@PropertyGetter(name="TARGET_ENTITIES",
                type=REFERENCE_LIST,
                matchable=true)
List<? extends IEntity> getTargetEntities()
Returns target entities associated with the relation. Result must contain at least one entity.

Returns:
list of target entities

setTargetEntities

@PropertySetter(name="TARGET_ENTITIES")
void setTargetEntities(List<? extends IEntity> entities)
Sets target entities associated with the relation.

Parameters:
entities - collection containing at least one entity
Throws:
IllegalArgumentException - when entity list is null or empty

getTargetEntitiy

IEntity getTargetEntitiy(int index)
Gets target entity associated with the relation with given index in the list.

Parameters:
index - index of entity in the target entities list
Returns:
entity from given index or null if not present

addTargetEntitiy

void addTargetEntitiy(IEntity entity)
                      throws ModelException
Adds a target entity associated with the relation.

Parameters:
entity - entity to add
Throws:
IllegalArgumentException - when entity is null
ModelException - when entity is already the relation's target entity

removeTargetEntitiy

boolean removeTargetEntitiy(IEntity entity)
Removes the specified target entity associated with the relation.

Parameters:
entity - entity to remove
Returns:
true if the target entity was present and successfully removed
Throws:
IllegalArgumentException - when entity is null

isDirected

@PropertyGetter(name="DIRECTED",
                type=BOOLEAN,
                matchable=true)
Boolean isDirected()
Checks if given relation is directed (from source to target entities) or not (in that case it is bi-directional).

Returns:
true if this relation is directed, false if it is bi-directional

setDirected

@PropertySetter(name="DIRECTED")
void setDirected(Boolean directed)
Sets the directed flag.

Parameters:
directed - the flag


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.