pl.edu.agh.cast.model.mapper
Class Link

java.lang.Object
  extended by pl.edu.agh.cast.model.mapper.Link

public class Link
extends Object

The link represents the raw connection between nodes in the base model.

Author:
AGH CAST Team

Constructor Summary
Link(long srcId, long dstId, String name, int priority)
          Lazy binding constructor.
Link(Map args)
          Creates the link from key : value pairs.
Link(Node src, Node dst, String name, int priority)
          Creates the link from given set of attributes.
Link(Node src, Node dst, String name, Priority priority)
           
Link(Node src, Node dst, String name, Priority priority, String srcAccessor, String dstAccessor)
           
Link(Node src, Node dst, String name, Priority priority, String srcAcc, String dstAcc, int srcPosition, int dstPosition)
           
 
Method Summary
 boolean equals(Object other)
          
static Link find(Link link)
          Find link which is equal to given link.
static Link find(long linkId)
          Find link with given id of null if not present.
static List<Link> findWithDst(long nodeId)
          Find all link whose destination is a node with given id.
static List<Link> findWithSrc(long nodeId)
          Find all link whose source is a node with given id.
 Node getDst()
          Destination node getter.
 String getDstAccessor()
          Returns the name of the destination node accessor method.
 long getDstId()
          The destination id getter.
 int getDstPosition()
          The position of destination node among other nodes at the destination side of the relationship (set of links).
 long getId()
          DB indentifier reader.
 String getName()
          Name getter.
 int getPriority()
          Priority reader.
 Node getSrc()
          Source node getter.
 String getSrcAccessor()
          Returns the name of the source node accessor method.
 long getSrcId()
          The source id getter.
 int getSrcPosition()
          The position of source node among other nodes at the source side of the relationship (set of links).
 int hashCode()
          The hash code.
 boolean save()
          Save given metamodel link in the DB.
 void setDst(Node dst)
          Destination setter.
 void setDstAccessor(String accessor)
          Target accessor setter.
 void setDstPosition(int position)
          The target position setter.
 void setId(long newId)
          Id setter.
 void setPriority(int newPriority)
          Priority setter.
 void setPriority(Object priority)
          Priority setter (tries to translate given object to priority).
 void setSaved(boolean newSaved)
          Saved flag setter.
 void setSrc(Node srcNode)
          Source setter.
 void setSrcAccessor(String accessor)
          Source accessor setter.
 void setSrcPosition(int position)
           
static void stats()
          Print out the stats of the link cache.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Link

public Link(Map args)
Creates the link from key : value pairs.

Parameters:
args - the map of key : value pairs.

Link

public Link(Node src,
            Node dst,
            String name,
            int priority)
Creates the link from given set of attributes.

Parameters:
src - The source of the link
dst - The target of the link
name - The name of the link
priority - The priority of the link

Link

public Link(long srcId,
            long dstId,
            String name,
            int priority)
Lazy binding constructor.

Parameters:
srcId - The id of the source node
dstId - The id of the destination node
name - The name of the link
priority - The priority of the link

Link

public Link(Node src,
            Node dst,
            String name,
            Priority priority,
            String srcAccessor,
            String dstAccessor)

Link

public Link(Node src,
            Node dst,
            String name,
            Priority priority)

Link

public Link(Node src,
            Node dst,
            String name,
            Priority priority,
            String srcAcc,
            String dstAcc,
            int srcPosition,
            int dstPosition)
Method Detail

save

public boolean save()
Save given metamodel link in the DB.

The saving process is recursive. Source and destination nodes are saved first and then the link is saved.

Returns:
True if the save was successful (or link has been saved earlier).

getPriority

public int getPriority()
Priority reader.

Returns:
Priority value

setPriority

public void setPriority(int newPriority)
Priority setter.

Parameters:
newPriority - priority value

setPriority

public void setPriority(Object priority)
Priority setter (tries to translate given object to priority).

Parameters:
priority - priority value

getDst

public Node getDst()
Destination node getter. Due to DB load optimization, must be used internally as well.

Returns:
Destination metamodel node

getDstId

public long getDstId()
The destination id getter.

Returns:
The destination id.

getSrc

public Node getSrc()
Source node getter. Due to DB load optimization, must be used internally as well.

Returns:
Source metamodel node

getSrcId

public long getSrcId()
The source id getter.

Returns:
The source id.

getId

public long getId()
DB indentifier reader.

Returns:
DB identifier

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

getName

public String getName()
Name getter.

Returns:
Name of the link

setSrc

public void setSrc(Node srcNode)
Source setter.

Parameters:
srcNode - Node to be set as source of the link

setDst

public void setDst(Node dst)
Destination setter.

Parameters:
dst - Node to be set as desitintion of the link

equals

public boolean equals(Object other)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

find

public static Link find(long linkId)
Find link with given id of null if not present.

Parameters:
linkId - The id of the link
Returns:
Link with given id or null

setSrcPosition

public void setSrcPosition(int position)

getSrcPosition

public int getSrcPosition()
The position of source node among other nodes at the source side of the relationship (set of links).

Returns:
The position of the source node.

setDstPosition

public void setDstPosition(int position)
The target position setter.

Parameters:
position - The position to set.

getDstPosition

public int getDstPosition()
The position of destination node among other nodes at the destination side of the relationship (set of links).

Returns:
The position of the target node.

hashCode

public int hashCode()
The hash code.

Overrides:
hashCode in class Object
Returns:
hash code

getSrcAccessor

public String getSrcAccessor()
Returns the name of the source node accessor method.

Returns:
Source node getter

getDstAccessor

public String getDstAccessor()
Returns the name of the destination node accessor method.

Returns:
Destination node getter

setSaved

public void setSaved(boolean newSaved)
Saved flag setter.

Parameters:
newSaved - New saved value.

setId

public void setId(long newId)
Id setter.

Parameters:
newId - New id

setSrcAccessor

public void setSrcAccessor(String accessor)
Source accessor setter.

Parameters:
accessor - The source accessor.

setDstAccessor

public void setDstAccessor(String accessor)
Target accessor setter.

Parameters:
accessor - The target accessor.

find

public static Link find(Link link)
Find link which is equal to given link.

Parameters:
link - The link which is used as the query example.
Returns:
The link with the same id.

findWithSrc

public static List<Link> findWithSrc(long nodeId)
                              throws SQLException
Find all link whose source is a node with given id.

Parameters:
nodeId - The id of the source node
Returns:
List of links
Throws:
SQLException

findWithDst

public static List<Link> findWithDst(long nodeId)
                              throws SQLException
Find all link whose destination is a node with given id.

Parameters:
nodeId - The id of the destination node
Returns:
List of links
Throws:
SQLException

stats

public static void stats()
Print out the stats of the link cache.



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