|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpl.edu.agh.cast.data.model.property.PropertyContainer
pl.edu.agh.cast.data.model.AbstractElement
pl.edu.agh.cast.data.model.general.ManyToManyRelation
public class ManyToManyRelation
Default implementation of IManyToManyRelation
interface.
All public constructors set the element type to IManyToManyRelation.TYPE
. Protected constructors should only
be used by direct subclasses to provide the concrete type to the super constructor.
IManyToManyRelation
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from interface pl.edu.agh.cast.data.model.general.IManyToManyRelation |
---|
IManyToManyRelation.Properties |
Field Summary |
---|
Fields inherited from interface pl.edu.agh.cast.data.model.general.IManyToManyRelation |
---|
TYPE |
Constructor Summary | |
---|---|
|
ManyToManyRelation()
Default constructor. |
|
ManyToManyRelation(IGeneralDataSet<? extends IGeneralElement> dataSet,
List<? extends IEntity> sources,
List<? extends IEntity> targets,
boolean directed)
Creates new many-to-many relation with given data set, source and target entities, direction and newly-generated ID. |
protected |
ManyToManyRelation(Type type)
Initializes element with type. |
protected |
ManyToManyRelation(Type type,
UUID id,
IGeneralDataSet<? extends IGeneralElement> dataSet,
List<? extends IEntity> sources,
List<? extends IEntity> targets,
boolean directed)
Initializes element with type, ID, data set, source and target entities lists and direction flag. |
protected |
ManyToManyRelation(Type type,
UUID id,
List<? extends IEntity> sources,
List<? extends IEntity> targets,
boolean directed)
Initializes element with type, ID, source and target entities lists and direction flag. |
|
ManyToManyRelation(UUID id,
IGeneralDataSet<? extends IGeneralElement> dataSet,
List<? extends IEntity> sources,
List<? extends IEntity> targets,
boolean directed)
Creates new many-to-many relation with given ID, data set, source and target entities and direction. |
|
ManyToManyRelation(UUID id,
List<? extends IEntity> sources,
List<? extends IEntity> targets,
boolean directed)
Creates new many-to-many relation with given ID, source and target entities and direction. |
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. |
protected String |
getDescString()
Returns a string with short description of element. |
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). |
protected boolean |
isEntityListValid(List<? extends IEntity> entities)
Checks if given list of entities is valid for the relation's source and target entities list. |
protected boolean |
isEntityValid(IEntity entity)
Checks if given entity is valid for the relation's source and target entities list. |
protected boolean |
isSourceEntitiesResolved()
Checks if the list of source entities is resolved (loaded). |
protected boolean |
isSourceEntityListValid(List<? extends IEntity> entities)
Checks if given list of entities is valid for the relation's source entities list. |
protected boolean |
isTargetEntitiesResolved()
Checks if the list of target entities is resolved (loaded). |
protected boolean |
isTargetEntityListValid(List<? extends IEntity> entities)
Checks if given list of entities is valid for the relations source and target entities list. |
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. |
ManyToManyRelation |
replicate()
Returns a replicated instance of this instance. |
ManyToManyRelation |
replicateTo(Object replica)
Replicates this instance state to given replica object. |
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 class pl.edu.agh.cast.data.model.AbstractElement |
---|
afterSetMetaPropertyManager, canReplicateTo, checkIfValid, equals, getDataSet, getId, getType, hashCode, isValid, setDataSet, setId, setType, toString |
Methods inherited from class pl.edu.agh.cast.data.model.property.PropertyContainer |
---|
addProperty, createProperty, dispose, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, initializeProperties, matches, removeProperty, setMetaPropertyManager, setProperty, update |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
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 |
Constructor Detail |
---|
public ManyToManyRelation()
Usage of this constructor is discouraged, since it does not provide any integrity control. If, however, this
constructor is used, the AbstractElement.isValid()
method should be called in order to check the integrity.
public ManyToManyRelation(UUID id, List<? extends IEntity> sources, List<? extends IEntity> targets, boolean directed)
If the sources
or targets
list is an instance of IReferenceList
then it is used
internally, otherwise all entities from this list are added to internal collection.
id
- ID of the elementsources
- list of source entities - must contain at least one referencetargets
- list of target entities - must contain at least one referencedirected
- the flag indicating whether the relation is directed or not (see
IManyToManyRelation.isDirected()
)public ManyToManyRelation(IGeneralDataSet<? extends IGeneralElement> dataSet, List<? extends IEntity> sources, List<? extends IEntity> targets, boolean directed)
If the sources
or targets
list is an instance of IReferenceList
then it is used
internally, otherwise all entities from this list are added to internal collection.
dataSet
- the general data set this relation is insources
- list of source entities - must contain at least one referencetargets
- list of target entities - must contain at least one referencedirected
- the flag indicating whether the relation is directed or not (see
IManyToManyRelation.isDirected()
)public ManyToManyRelation(UUID id, IGeneralDataSet<? extends IGeneralElement> dataSet, List<? extends IEntity> sources, List<? extends IEntity> targets, boolean directed)
If the sources
or targets
list is an instance of IReferenceList
then it is used
internally, otherwise all entities from this list are added to internal collection.
id
- ID of the elementdataSet
- the general data set this relation is insources
- list of source entities - must contain at least one referencetargets
- list of target entities - must contain at least one referencedirected
- the flag indicating whether the relation is directed or not (see
IManyToManyRelation.isDirected()
)protected ManyToManyRelation(Type type)
This constructor should be used only by extending classes to implement the default constructor. The incoming and outgoing relation lists are initialized with empty lists.
type
- type of the elementAbstractElement.AbstractElement(Type)
protected ManyToManyRelation(Type type, UUID id, List<? extends IEntity> sources, List<? extends IEntity> targets, boolean directed)
type
- type of element which extends this oneid
- ID of the elementsources
- list of source entities - must contain at least one referencetargets
- list of target entities - must contain at least one referencedirected
- the flag indicating whether the relation is directed or not (see
IManyToManyRelation.isDirected()
)protected ManyToManyRelation(Type type, UUID id, IGeneralDataSet<? extends IGeneralElement> dataSet, List<? extends IEntity> sources, List<? extends IEntity> targets, boolean directed)
type
- type of element which extends this oneid
- ID of the elementdataSet
- the general data set this relation is insources
- list of source entities - must contain at least one referencetargets
- list of target entities - must contain at least one referencedirected
- the flag indicating whether the relation is directed or not (see
IManyToManyRelation.isDirected()
)Method Detail |
---|
protected boolean isEntityListValid(List<? extends IEntity> entities) throws ModelException
This method is called by the setSourceEntities(List)
and {setTargetEntities(List)
methods. By
default it always returns true
, however it can be overridden in order to define new validation
rules. In such case the implementation from base class should be called inside the overridden method in order to
preserve data consistency.
entities
- the entities list to validate
true
if the entity list is valid, false
otherwise
ModelException
- if there is a severe validity violationprotected boolean isSourceEntityListValid(List<? extends IEntity> entities) throws ModelException
This method is called by the setSourceEntities(List)
method. By default it always returns
true
, however it can be overridden in order to define new validation rules. In such case the
implementation from base class should be called inside the overridden method in order to preserve data
consistency.
entities
- the entities list to validate
true
if the entity list is valid for source entities, false
otherwise
ModelException
- if there is a severe validity violationprotected boolean isTargetEntityListValid(List<? extends IEntity> entities) throws ModelException
This method is called by the {setTargetEntities(List)
method. By default it always returns
true
, however it can be overridden in order to define new validation rules. In such case the
implementation from base class should be called inside the overridden method in order to preserve data
consistency.
entities
- the entities list to validate
true
if the entity list is valid for target entities, false
otherwise
ModelException
- if there is a severe validity violationprotected boolean isEntityValid(IEntity entity) throws ModelException
This method is called by the {addSourceEntitiy(IEntity)
and addTargetEntitiy(IEntity)
methods.
By default it always returns true
, however it can be overridden in order to define new validation
rules. In such case the implementation from base class should be called inside the overridden method in order to
preserve data consistency.
entities
- the entity to validate
true
if the entity is valid, false
otherwise
ModelException
- if there is a severe validity violationpublic final List<? extends IEntity> getSourceEntities()
getSourceEntities
in interface IManyToManyRelation
IManyToManyRelation.getSourceEntities()
public final void setSourceEntities(List<? extends IEntity> entities)
setSourceEntities
in interface IManyToManyRelation
entities
- collection containing at least one entitypl.edu.agh.cast.data.model.general.IManyToManyRelation#setSourceEntities(java.lang.Iterable)
public final void addSourceEntitiy(IEntity entity) throws ModelException
addSourceEntitiy
in interface IManyToManyRelation
entity
- entity to add
ModelException
- when entity is already the relation's source entity#addSourceEntitiy(pl.edu.agh.cast.data.model.general.IEntity)
public final boolean removeSourceEntitiy(IEntity entity)
removeSourceEntitiy
in interface IManyToManyRelation
entity
- entity to remove
true
if the source entity was present and successfully removed#removeSourceEntitiy(pl.edu.agh.cast.data.model.general.IEntity)
public final IEntity getSourceEntitiy(int index)
getSourceEntitiy
in interface IManyToManyRelation
index
- index of entity in the source entities list
null
if not presentIManyToManyRelation.getSourceEntitiy(int)
protected final boolean isSourceEntitiesResolved()
true
if the source reference list is resolvedIReferenceList.isResolved()
public final List<? extends IEntity> getTargetEntities()
getTargetEntities
in interface IManyToManyRelation
IManyToManyRelation.getTargetEntities()
public final void setTargetEntities(List<? extends IEntity> entities)
setTargetEntities
in interface IManyToManyRelation
entities
- collection containing at least one entitypl.edu.agh.cast.data.model.general.IManyToManyRelation#setTargetEntities(java.lang.Iterable)
public final void addTargetEntitiy(IEntity entity) throws ModelException
addTargetEntitiy
in interface IManyToManyRelation
entity
- entity to add
ModelException
- when entity is already the relation's target entity#addTargetEntitiy(pl.edu.agh.cast.data.model.general.IEntity)
public final boolean removeTargetEntitiy(IEntity entity)
removeTargetEntitiy
in interface IManyToManyRelation
entity
- entity to remove
true
if the target entity was present and successfully removed#removeTargetEntitiy(pl.edu.agh.cast.data.model.general.IEntity)
public final IEntity getTargetEntitiy(int index)
getTargetEntitiy
in interface IManyToManyRelation
index
- index of entity in the target entities list
null
if not presentIManyToManyRelation.getTargetEntitiy(int)
protected final boolean isTargetEntitiesResolved()
true
if the target reference list is resolvedIReferenceList.isResolved()
public final Boolean isDirected()
isDirected
in interface IManyToManyRelation
true
if this relation is directed, false
if it is bi-directionalIManyToManyRelation.isDirected()
public final void setDirected(Boolean directed)
setDirected
in interface IManyToManyRelation
directed
- the flagIManyToManyRelation.setDirected(java.lang.Boolean)
protected String getDescString()
AbstractElement.toString()
and may be
overridden in order to customize its results.
getDescString
in class AbstractElement
AbstractElement.getDescString()
public ManyToManyRelation replicateTo(Object replica) throws IllegalArgumentException, ReplicationException
Replicates element type and ID.
Replicates relation direction, the lists of source and target entities are empty.
replicateTo
in interface IReplicable
replicateTo
in class AbstractElement
replica
- the object to replicate to
IllegalArgumentException
- if given object is null or of invalid type
ReplicationException
- if replication failsAbstractElement.replicateTo(java.lang.Object)
public ManyToManyRelation replicate() throws ReplicationException
replicate
in interface IReplicable
replicate
in class AbstractElement
ReplicationException
- if replication failsIReplicable.replicate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |