pl.edu.agh.cast.schema.model.presentation
Class SchemaConnection

java.lang.Object
  extended by pl.edu.agh.cast.data.model.property.PropertyContainer
      extended by pl.edu.agh.cast.data.model.AbstractElement
          extended by pl.edu.agh.cast.data.model.presentation.PresentationElement<IElement>
              extended by pl.edu.agh.cast.schema.model.presentation.SchemaConnection
All Implemented Interfaces:
Serializable, Observer, IDisposable, IReplicable, IValidatable, Identifiable, IElement, IPresentationElement<IElement>, IPropertyChangeProvider, IPropertyContainer, ISchemaConnection, ISchemaElement<IElement>

public class SchemaConnection
extends PresentationElement<IElement>
implements ISchemaConnection

Default implementation of ISchemaConnection.

Author:
AGH CAST Team
See Also:
ISchemaConnection, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface pl.edu.agh.cast.data.model.presentation.IPresentationElement
IPresentationElement.Properties, IPresentationElement.PropertyCategory
 
Field Summary
 
Fields inherited from interface pl.edu.agh.cast.schema.model.presentation.ISchemaConnection
TYPE
 
Fields inherited from interface pl.edu.agh.cast.data.model.presentation.IPresentationElement
ATTRIBUTE_CHANGE_EVENT
 
Constructor Summary
protected SchemaConnection()
          Default constructor.
  SchemaConnection(ISchemaDataSet dataSet, Type derivedType, boolean directed)
          Constructor for creating new schema connection without setting ends of it.
  SchemaConnection(ISchemaDataSet dataSet, Type derivedType, ISchemaNode source, ISchemaNode target)
          Constructor for creating new indirected schema connection associated with given schema nodes.
  SchemaConnection(ISchemaDataSet dataSet, Type derivedType, ISchemaNode source, ISchemaNode target, boolean directed)
          Constructor for creating new schema connection associated with given schema nodes.
  SchemaConnection(ISchemaDataSet dataSet, UUID id, ISchemaNode source, ISchemaNode target, boolean directed, Collection<? extends IElement> originalElements)
          The constructor for schema connections created manually.
protected SchemaConnection(Type type)
           
 
Method Summary
protected  boolean checkIfValid()
          Checks if the element is valid.
protected  IVisualSchemaConnection createVisualElement()
          Creates a new visual element to be associated with this presentation element.
protected  String getDescString()
          Returns a string with short description of element.
 ISchemaNode getSourceNode()
          Gets source node.
 ISchemaNode getTargetNode()
          Gets target node.
 Integer getWeight()
          A problem dependent weight.
 boolean isBetween(ISchemaNode node1, ISchemaNode node2)
          Checks if this connection is between two given nodes.
 Boolean isDirected()
          Indicates if a connections is directed or not.
 SchemaConnection replicate()
          Returns a replicated instance of this instance.
 SchemaConnection replicateTo(Object replica)
          Replicates this instance state to given replica object.
 void setDirected(Boolean directed)
           
 void setSourceNode(ISchemaNode node)
          Sets source node.
 void setTargetNode(ISchemaNode node)
          Sets target node.
 
Methods inherited from class pl.edu.agh.cast.data.model.presentation.PresentationElement
addPropertyChangeListener, firePropertyChange, getDerivedType, getLabel, getOriginalElements, getVisualElement, hasAssociatedVisualElement, removePropertyChangeListener, setDerivedType, setLabel, setOriginalElements, setSuppressAllEvents, setVisualElement
 
Methods inherited from class pl.edu.agh.cast.data.model.AbstractElement
afterSetMetaPropertyManager, canReplicateTo, 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.presentation.IPresentationElement
getDerivedType, getLabel, getOriginalElements, getVisualElement, hasAssociatedVisualElement, setDerivedType, setLabel, setOriginalElements, setSuppressAllEvents, setVisualElement
 
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.data.model.property.IPropertyChangeProvider
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

SchemaConnection

protected SchemaConnection()
Default constructor.

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.


SchemaConnection

protected SchemaConnection(Type type)

SchemaConnection

public SchemaConnection(ISchemaDataSet dataSet,
                        UUID id,
                        ISchemaNode source,
                        ISchemaNode target,
                        boolean directed,
                        Collection<? extends IElement> originalElements)
The constructor for schema connections created manually. The schema connection belongs to the schema data set given in the constructor. The given list of original elements is used. The ID is randomly generated.

Parameters:
dataSet - data set which a new connections belongs to
id - the ID of the element
source - source node
target - target node
directed - a flag which indicates if connection is directed
originalElements - a reference list to represented domain model elements - if null, then empty IReferenceList instance is acquired from ReferenceUtil

SchemaConnection

public SchemaConnection(ISchemaDataSet dataSet,
                        Type derivedType,
                        ISchemaNode source,
                        ISchemaNode target,
                        boolean directed)
Constructor for creating new schema connection associated with given schema nodes. This constructor should be used when adding new connection from palette.

Parameters:
dataSet - the data set this connection belongs to
derivedType - derived type
source - source node
target - target node
directed - flag which indicates if connections is directed or not

SchemaConnection

public SchemaConnection(ISchemaDataSet dataSet,
                        Type derivedType,
                        ISchemaNode source,
                        ISchemaNode target)
Constructor for creating new indirected schema connection associated with given schema nodes. This constructor should be used when adding new indirected connection from palette.

Parameters:
dataSet - the data set this connection belongs to
derivedType - derived type
source - source node
target - target node

SchemaConnection

public SchemaConnection(ISchemaDataSet dataSet,
                        Type derivedType,
                        boolean directed)
Constructor for creating new schema connection without setting ends of it. It demands from the user to set it manually using setters method.

Parameters:
dataSet - data set which a new connections belongs to
derivedType - derived type
directed - flag which indicates if connections is directed or not
Method Detail

checkIfValid

protected boolean checkIfValid()
Checks if the element is valid.

This method is called by the AbstractElement.isValid() 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.

Overrides:
checkIfValid in class PresentationElement<IElement>
Returns:
true if the element is valid, false otherwise
See Also:
AbstractElement.checkIfValid()

getSourceNode

public ISchemaNode getSourceNode()
Gets source node. If a connection is indirected this node is represented just as one of the connection's end.

Specified by:
getSourceNode in interface ISchemaConnection
Returns:
source node
See Also:
ISchemaConnection.getSourceNode()

getTargetNode

public ISchemaNode getTargetNode()
Gets target node. If a connection is indirected this node is represented just as one of the connection's end.

Specified by:
getTargetNode in interface ISchemaConnection
Returns:
target node
See Also:
ISchemaConnection.getTargetNode()

setSourceNode

public void setSourceNode(ISchemaNode node)
Sets source node. If a connection is indirected this node is represented just as one of the connection's end.

Specified by:
setSourceNode in interface ISchemaConnection
Parameters:
node - source node
See Also:
#setSourceNode(pl.edu.agh.cast.schema.model.presentation.ISchemaNode)

setTargetNode

public void setTargetNode(ISchemaNode node)
Sets target node. If a connection is indirected this node is represented just as one of the connection's end.

Specified by:
setTargetNode in interface ISchemaConnection
Parameters:
node - target node
See Also:
#setTargetNode(pl.edu.agh.cast.schema.model.presentation.ISchemaNode)

isDirected

public Boolean isDirected()
Indicates if a connections is directed or not.

Specified by:
isDirected in interface ISchemaConnection
Returns:
true if connection is directed, false otherwise
See Also:
ISchemaConnection.isDirected()

setDirected

public void setDirected(Boolean directed)

getWeight

public Integer getWeight()
A problem dependent weight.

Specified by:
getWeight in interface ISchemaConnection
Returns:
weight of the connection
See Also:
ISchemaConnection.getWeight()

getDescString

protected String getDescString()
Returns a string with short description of element. This method is used by AbstractElement.toString() and may be overridden in order to customize its results.

Overrides:
getDescString in class AbstractElement
Returns:
a description string
See Also:
AbstractElement.getDescString()

isBetween

public boolean isBetween(ISchemaNode node1,
                         ISchemaNode node2)
Checks if this connection is between two given nodes.

Specified by:
isBetween in interface ISchemaConnection
Parameters:
node1 - first node
node2 - second node
Returns:
true if this connection group is between two given nodes
See Also:
#isBetween(pl.edu.agh.cast.schema.model.presentation.ISchemaNode, pl.edu.agh.cast.schema.model.presentation.ISchemaNode)

createVisualElement

protected IVisualSchemaConnection createVisualElement()
Creates a new visual element to be associated with this presentation element.

This method should be implemented in each concrete subclass of PresentationElement.

Specified by:
createVisualElement in class PresentationElement<IElement>
Returns:
a new instance of visual element to be associated with this instance
See Also:
PresentationElement.createVisualElement()

replicateTo

public SchemaConnection replicateTo(Object replica)
                             throws IllegalArgumentException,
                                    ReplicationException
Replicates this instance state to given replica object. The replica should be an instance of replicated instance's class (same class or subclass).

Replicates element type and ID.

Replicates element derived type, label and original element list.

Replicates the direction flag, source and target nodes are null empty.

Specified by:
replicateTo in interface IReplicable
Overrides:
replicateTo in class PresentationElement<IElement>
Parameters:
replica - the object to replicate to
Returns:
the replica object (the same instance as given)
Throws:
IllegalArgumentException - if given object is null or of invalid type
ReplicationException - if replication fails
See Also:
PresentationElement.replicateTo(java.lang.Object)

replicate

public SchemaConnection replicate()
                           throws ReplicationException
Returns a replicated instance of this instance.

Specified by:
replicate in interface IReplicable
Overrides:
replicate in class AbstractElement
Returns:
replicated instance
Throws:
ReplicationException - if replication fails
See Also:
IReplicable.replicate()


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