Class: YOWL::IndividualAssociation

Inherits:
LabelledDocObject show all
Defined in:
lib/yowl/individual_association.rb

Instance Attribute Summary collapse

Attributes inherited from DocObject

#resource, #schema

Instance Method Summary collapse

Methods inherited from LabelledDocObject

#<=>, #comment, #commentOrLabel, #definition, #editorialNotes, #hasComment?, #hasDefinition?, #hasDifferentLabel?, #hasEditorialNotes?, #see_alsos, #status

Methods inherited from DocObject

#escaped_short_name, #escaped_uri, #get_literal, #hasOtherNamespace?, #hasUri?, #ns, #ontology, #repository, #short_name, #to_s, #uri

Constructor Details

#initialize(resource, schema, domainIndividual, rangeIndividual) ⇒ IndividualAssociation

Returns a new instance of IndividualAssociation.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/yowl/individual_association.rb', line 10

def initialize(resource, schema, domainIndividual, rangeIndividual)
  
  if resource.nil?
    raise "Problem"
  end
  super(resource, schema)
  
  @domainIndividual = domainIndividual
  @rangeIndividual = rangeIndividual

  @key = "#{@domainIndividual.uri},#{@rangeIndividual.uri},#{label}".hash
  
  #puts "Created IndividualAssociation #{@domainIndividual.uri},#{@rangeIndividual.uri}, #{uri}"
end

Instance Attribute Details

#domainIndividualObject (readonly)

Returns the value of attribute domainIndividual.



5
6
7
# File 'lib/yowl/individual_association.rb', line 5

def domainIndividual
  @domainIndividual
end

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/yowl/individual_association.rb', line 8

def key
  @key
end

#propertyObject (readonly)

Returns the value of attribute property.



7
8
9
# File 'lib/yowl/individual_association.rb', line 7

def property
  @property
end

#rangeIndividualObject (readonly)

Returns the value of attribute rangeIndividual.



6
7
8
# File 'lib/yowl/individual_association.rb', line 6

def rangeIndividual
  @rangeIndividual
end

Instance Method Details

#addAsGraphVizEdge(graph_, nodes_, edges_, level_) ⇒ Object

Add the current IndividualAssociation as an edge to the given GraphViz graph, but check whether the IndividualAssociation refers to a Domain and Range class in the current schema and whether the IndividualAssociation has already been added to the graph (by checking the given edges collection).



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/yowl/individual_association.rb', line 43

def addAsGraphVizEdge(graph_, nodes_, edges_, level_)
  
  if level_ < 1
    return nodes_, edges_
  end

  nodes_, edges_ = @domainIndividual.addAsGraphvizNode(graph_, nodes_, edges_, level_)
  nodes_, edges_ = @rangeIndividual.addAsGraphvizNode(graph_, nodes_, edges_, level_)
  
  if edges_.has_key?(@key)
    return nodes_, edges_
  end
  
  domainIndividualNode = nodes_[@domainIndividual.uri]
  rangeIndividualNode = nodes_[@rangeIndividual.uri]
  
  #
  # As the level_ parameter for the two calls to addAsGraphvizNode might have caused
  # that one or both of these nodes are not generated, we have to check for this here.
  #
  if domainIndividualNode.nil? or rangeIndividualNode.nil?
    return nodes_, edges_
  end
  
  options = {
    :label => label.sub(/.*:/, ''),
    :tooltip => uri.to_s, 
    :arrowhead => :open, 
    :arrowsize => 0.5,
    :penwidth => 0.5
  }
  
  edges_[@key] = graph_.add_edges(domainIndividualNode, rangeIndividualNode, options)
  
  return nodes_, edges_
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/yowl/individual_association.rb', line 33

def eql?(other)
  @key.eql? other.key
end

#hashObject



29
30
31
# File 'lib/yowl/individual_association.rb', line 29

def hash
  return key
end

#labelObject



25
26
27
# File 'lib/yowl/individual_association.rb', line 25

def label
  return short_name
end