it.unimi.dico.islab.idbs2.cloud
Class CloudNode

java.lang.Object
  extended by it.unimi.dico.islab.idbs2.cloud.CloudNode

public class CloudNode
extends Object

Representation of a node of the cloud providing methods for content's management. A node N is composed by a set of resources (class Resource), a prominence value and e set of edges (class CloudNode pointing other nodes. This class also contains the representation of the essential.
An essential is formally a couple <K,T> where K is a set of keywords (related to this node) associated with a relevance value and T is a set of types (associated with this node) associated with a relevance value.

In addiction it contains Hibernate information for cloud database synchronization.

Author:
Vegeziel
See Also:
Cloud, Resource, CloudEdge, EsTerm, EsType

Field Summary
 double DEFAULT_RESOURCE_RELEVANCE
           
 
Method Summary
protected  CloudEdge addEdge(CloudNode node, double weight)
          Adds an edge to the current node.
 EsTerm addEsTerm(Integer termId, String termValue, Double relevance)
          Add a keyword (represented by the class EsTerm) to this node.
 EsType addEsType(String classId, Double relevance)
          Add a type (represented by the class EsType) to this node.
 Resource addResource(String resId, Double relevance)
          Create and add a resource (instance of the Resource class) to this node.
 Set<Resource> addResources(List<String> resources, List<Double> relevances)
          Creates and add a list of resources (instances of the Resource class) to this node.
 Cloud getCloud()
          Get the owner cloud (Cloud object) of this node.
 CloudEdge getEdge(CloudNode target)
          Get the edge having this node as a source node and the given node as target if such an edge exists.
 Set<CloudEdge> getEdges()
          Get the set of edges having this node as a source node.
 Integer getId()
          Get the id of the corresponding database persisted object.
 SortedSet<EsTerm> getKeywords()
          Get the set of all keywords associated to this node.
 double getProminence()
          Getter for the prominence value of this node
 Set<Resource> getResources()
          Get the set of all resources connected to this node.
 SortedSet<EsType> getTypes()
          Get the set of all types associated to this node.
protected  void setCloud(Cloud cl)
          Set the owner cloud (Cloud object) of this node.
protected  void setEdges(Set<CloudEdge> edges)
          Set the edges having this node as a source node.
 void setKeywords(SortedSet<EsTerm> keywords)
          Set the keywords connected to this node.
 void setProminence(double prominence)
          Setter for the prominence value of this node
protected  void setResources(Set<Resource> resources)
          Set the resources connected to this node.
protected  void setTypes(SortedSet<EsType> types)
          Set the types connected to this node.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_RESOURCE_RELEVANCE

public final double DEFAULT_RESOURCE_RELEVANCE
See Also:
Constant Field Values
Method Detail

addEdge

protected CloudEdge addEdge(CloudNode node,
                            double weight)

Adds an edge to the current node. Direct use of this method is discouraged. use the Cloud.addEdge method instead.

Parameters:
node - the CloudNode to which the edge is directed (the source node is the current node).
weight - the edge weight.
Returns:
returns the generated edge (an instance of CloudEdge).
See Also:
Cloud.addEdge(CloudNode, CloudNode, double)

addResource

public Resource addResource(String resId,
                            Double relevance)

Create and add a resource (instance of the Resource class) to this node. Recalling the fact that a CloudNode is a collection of resources (resulting from a clustering operation), this method is used to put in the node its belonging resources.

Parameters:
resId - the string representing the knowledge chunk identifier of the inserted resource.
relevance - the relevance value of the inserted resource
Returns:
the generated Resource instance.
See Also:
Resource

addResources

public Set<Resource> addResources(List<String> resources,
                                  List<Double> relevances)

Creates and add a list of resources (instances of the Resource class) to this node.

Parameters:
resources - a list of resource ids to be included in this node.
relevances - a list of relevances values to be associated (respecting the order of the list) to the ids in resources. This parameter could be null: in this case the DEFAULT_RESOURCE_RELEVANCE default value will be used for all resources.
Returns:
the set of created resources already added to this CloudNode
See Also:
addResource(String, Double)

getEdge

public CloudEdge getEdge(CloudNode target)

Get the edge having this node as a source node and the given node as target if such an edge exists.

Parameters:
target - connected node.
Returns:
The required CloudEdge object or null if not found.

addEsType

public EsType addEsType(String classId,
                        Double relevance)

Add a type (represented by the class EsType) to this node.

Parameters:
classId - the identifier of the added type (RDF class).
relevance - the relevance of the added type for this node.
Returns:
the generated type (instance of the EsType class)
See Also:
EsType

addEsTerm

public EsTerm addEsTerm(Integer termId,
                        String termValue,
                        Double relevance)

Add a keyword (represented by the class EsTerm) to this node.

Parameters:
termId - the identifier of the added Term in the correlated KC database.
termValue - the string representation of the added term.
Returns:
the generated keyword (instance of the EsTerm class)
See Also:
EsTerm

getResources

public Set<Resource> getResources()

Get the set of all resources connected to this node.

Returns:
a set of all resources connected to this node.

setResources

protected void setResources(Set<Resource> resources)

Set the resources connected to this node.

Parameters:
resources - a set of the resources to be inserted in this node.

getProminence

public double getProminence()

Getter for the prominence value of this node

Returns:
the prominence value of this node.

setProminence

public void setProminence(double prominence)

Setter for the prominence value of this node

Parameters:
prominence - the prominence value to be set.

getCloud

public Cloud getCloud()
Get the owner cloud (Cloud object) of this node.

Returns:
the owner cloud of this node.

setCloud

protected void setCloud(Cloud cl)
Set the owner cloud (Cloud object) of this node.

Parameters:
cl - the owner cloud of this node.

getId

public Integer getId()

Get the id of the corresponding database persisted object.

Returns:
the identifier (primary key) of the corresponding row on the relational Hibernate-mapped relational database.

getEdges

public Set<CloudEdge> getEdges()

Get the set of edges having this node as a source node.

Returns:
a set of all edges starting from this node.

setEdges

protected void setEdges(Set<CloudEdge> edges)

Set the edges having this node as a source node.

Parameters:
edges - a set of all edges starting from this node.

getTypes

public SortedSet<EsType> getTypes()

Get the set of all types associated to this node.

Returns:
a set of all types (object of EsType class) associated with this node.

setTypes

protected void setTypes(SortedSet<EsType> types)
Set the types connected to this node.

Parameters:
types - the set of all types connected with this node.

getKeywords

public SortedSet<EsTerm> getKeywords()

Get the set of all keywords associated to this node.

Returns:
a set of all keywords (object of EsKeyword class) associated with this node.

setKeywords

public void setKeywords(SortedSet<EsTerm> keywords)
Set the keywords connected to this node.

Parameters:
keywords - the set of all types connected with this node.

toString

public String toString()
Overrides:
toString in class Object