Class: YOWL::Individual
- Inherits:
-
LabelledDocObject
- Object
- DocObject
- LabelledDocObject
- YOWL::Individual
- Defined in:
- lib/yowl/individual.rb
Overview
Represents an Individual defined in the schema
Instance Attribute Summary
Attributes inherited from DocObject
Class Method Summary collapse
Instance Method Summary collapse
-
#addAsGraphvizNode(graph_, nodes_, edges_, level_, maxLevel_ = 0) ⇒ Object
Add the current Individual as a GraphViz node to the given collection of nodes and to the given graph.
-
#associatedIndividuals ⇒ Object
Return a collection of Associations representing ObjectProperties where the current class is one of the Domain classes.
-
#asSvg ⇒ Object
Generate a diagram for each Individual.
- #classes ⇒ Object
- #isSkosConcept? ⇒ Boolean
- #isSkosConceptInScheme?(conceptScheme_) ⇒ Boolean
- #isSkosConceptScheme? ⇒ Boolean
-
#label ⇒ Object
This label is a bit different than the one in the base class as this one gets its prefix stripped, if there is one.
-
#prefix ⇒ Object
The prefix to be used for the URI of this Individual, if defined, nil if it isn’t.
- #types ⇒ Object
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
Class Method Details
.withUri(resource, schema) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/yowl/individual.rb', line 16 def Individual.withUri(resource, schema) if resource.anonymous? warn "WARNING: Ignoring Individual with uri #{resource.to_s}" return end individual = schema.individuals[resource.to_s] if individual return individual end individual = Individual.new(resource, schema) schema.individuals[resource.to_s] = individual return individual end |
Instance Method Details
#addAsGraphvizNode(graph_, nodes_, edges_, level_, maxLevel_ = 0) ⇒ Object
Add the current Individual as a GraphViz node to the given collection of nodes and to the given graph. Return the collection of nodes.
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/yowl/individual.rb', line 322 def addAsGraphvizNode (graph_, nodes_, edges_, level_, maxLevel_ = 0) if level_ < 1 return nodes_, edges_ end if @schema..verbose puts "- Processing Individual #{label}" end # # No need to add a node twice # if nodes_.has_key?(uri) return nodes_, edges_ end = { :shape => :record, :style => "rounded,filled", :label => labelAsGraphvizRecord, :tooltip => uri, :peripheries => 1, :margin => "0.21,0.055", :fontcolor => :black, :fontsize => 8, :penwidth => 0.5, :color => :black, :fillcolor => "#FCFCFC", :href => "#individual_#{short_name}" } if level_ == maxLevel_ [:color] = "red" [:penwidth] = 1 end node = graph_.add_nodes(escaped_uri, ) nodes_[uri] = node node.URL = "#individual_#{short_name}" #if hasComment? # node.tooltip = comment #end #classes.each do |klass| # nodes_, edges_ = klass.addAsGraphvizNode(graph_, nodes_, edges_) # Class.newGraphVizEdge(graph_, node, nodes_[klass.uri], false) #end inboundAssociations.each do |association| nodes_, edges_ = association.addAsGraphVizEdge(graph_, nodes_, edges_, level_ - 1) end outboundAssociations.each do |association| nodes_, edges_ = association.addAsGraphVizEdge(graph_, nodes_, edges_, level_ - 1) end return nodes_, edges_ end |
#associatedIndividuals ⇒ Object
Return a collection of Associations representing ObjectProperties where the current class is one of the Domain classes.
170 171 172 173 174 175 |
# File 'lib/yowl/individual.rb', line 170 def associatedIndividuals if not defined?(@associatedIndividuals) init_associatedIndividuals end return @associatedIndividuals end |
#asSvg ⇒ Object
Generate a diagram for each Individual
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
# File 'lib/yowl/individual.rb', line 381 def asSvg if @schema..verbose puts "Generating SVG for Individual #{short_name}" end g = GraphvizUtility.setDefaults(GraphViz.new(:G, :type => :digraph)) g[:rankdir] = "LR" g.node[:fixedsize] = false nodes = Hash.new edges = Hash.new nodes, edges = addAsGraphvizNode(g, nodes, edges, 5, 5) return GraphvizUtility.(g) end |
#classes ⇒ Object
106 107 108 109 110 111 |
# File 'lib/yowl/individual.rb', line 106 def classes if not defined?(@classes) init_classes end return @classes end |
#isSkosConcept? ⇒ Boolean
142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/yowl/individual.rb', line 142 def isSkosConcept? puts "isSkosConcept #{@resource}" inScheme = get_literal(YOWL::Namespaces::SKOS.inScheme) if not inScheme.nil? return true end topConceptOf = get_literal(YOWL::Namespaces::SKOS.topConceptOf) if not topConceptOf.nil? return true end return false end |
#isSkosConceptInScheme?(conceptScheme_) ⇒ Boolean
156 157 158 159 160 161 162 163 |
# File 'lib/yowl/individual.rb', line 156 def isSkosConceptInScheme?(conceptScheme_) inScheme = get_literal(YOWL::Namespaces::SKOS.inScheme) if inScheme and inScheme.uri == conceptScheme_.uri puts "isSkosConceptInScheme #{@resource}: #{inScheme.uri}" return true end return false end |
#isSkosConceptScheme? ⇒ Boolean
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/yowl/individual.rb', line 130 def isSkosConceptScheme? conceptSchemeClassURI = YOWL::Namespaces::SKOS.ConceptScheme.to_s types.each do |type| #puts "isSkosConceptScheme #{type.to_s} #{conceptSchemeClassURI}" if type.to_s == conceptSchemeClassURI return true end end return false end |
#label ⇒ Object
This label is a bit different than the one in the base class as this one gets its prefix stripped, if there is one.
35 36 37 |
# File 'lib/yowl/individual.rb', line 35 def label @label ||= init_label end |
#prefix ⇒ Object
The prefix to be used for the URI of this Individual, if defined, nil if it isn’t
71 72 73 |
# File 'lib/yowl/individual.rb', line 71 def prefix @prefix ||= init_prefix end |
#types ⇒ Object
82 83 84 85 86 87 |
# File 'lib/yowl/individual.rb', line 82 def types if not defined?(@types) init_types end return @types end |