Class: TaliaCore::SemanticRelation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TaliaCore::SemanticRelation
- Defined in:
- lib/talia_core/semantic_relation.rb
Class Method Summary collapse
-
.fat_record_select ⇒ Object
For selecting “fat” records on the semantic properties.
-
.find_fat_relations(source, predicate) ⇒ Object
Retrieve “fat” relations for the given source and property.
Instance Method Summary collapse
-
#matches?(predicate, value = nil) ⇒ Boolean
Returns true if the Relation matches the given predicate URI (and value, if given).
Class Method Details
.fat_record_select ⇒ Object
For selecting “fat” records on the semantic properties
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/talia_core/semantic_relation.rb', line 40 def fat_record_select @select ||= begin select = 'semantic_relations.id AS id, semantic_relations.created_at AS created_at, ' select << 'semantic_relations.updated_at AS updated_at, ' select << 'semantic_relations.rel_order AS rel_order,' select << 'object_id, object_type, subject_id, predicate_uri, ' select << 'obj_props.created_at AS property_created_at, ' select << 'obj_props.updated_at AS property_updated_at, ' select << 'obj_props.value AS property_value, ' select << 'obj_sources.created_at AS object_created_at, ' select << 'obj_sources.updated_at AS object_updated_at, obj_sources.type AS object_realtype, ' select << 'obj_sources.uri AS object_uri' select end end |
.find_fat_relations(source, predicate) ⇒ Object
Retrieve “fat” relations for the given source and property
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/talia_core/semantic_relation.rb', line 26 def find_fat_relations(source, predicate) joins = ActiveSource.sources_join joins << ActiveSource.props_join relations = SemanticRelation.find(:all, :conditions => { :subject_id => source.id, :predicate_uri => predicate }, :joins => joins, :select => fat_record_select ) relations end |
Instance Method Details
#matches?(predicate, value = nil) ⇒ Boolean
Returns true if the Relation matches the given predicate URI (and value, if given)
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/talia_core/semantic_relation.rb', line 10 def matches?(predicate, value = nil) if(value) if(value.is_a?(ActiveSource) || value.is_a?(SemanticProperty)) (predicate_uri == predicate.to_s) && (value == object) else return false unless(object.is_a?(SemanticProperty)) (predicate_uri == predicate.to_s) && (object.value == value) end else predicate_uri == predicate.to_s end end |