Class: LD4L::OreRDF::AggregationResource

Inherits:
ActiveTriples::Resource
  • Object
show all
Defined in:
lib/ld4l/ore_rdf/models/aggregation_resource.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.localname_prefixObject (readonly)

Returns the value of attribute localname_prefix.



5
6
7
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 5

def localname_prefix
  @localname_prefix
end

Class Method Details

.item_proxies_solr_nameObject



160
161
162
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 160

def self.item_proxies_solr_name
  :item_proxies_ssm
end

Instance Method Details

#destroy_item_at(position) ⇒ Object

Destroy the item at specified position and remove content from the aggregation



125
126
127
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 125

def destroy_item_at(position)
  # TODO Stubbed - Requires definition and implementation
end

#destroy_item_with_content(content) ⇒ Object

Destroy the item with the content and remove content from the aggregation



120
121
122
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 120

def destroy_item_with_content(content)
  # TODO Stubbed - Requires definition and implementation
end

#find_item_with_content(content) ⇒ Object

Get the persisted LD4L::OreRDF::ProxyResource instance that holds the content NOTE: Not implemented.



95
96
97
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 95

def find_item_with_content(content)
  # TODO Stubbed - Requires definition and implementation
end

#first_proxyObject



51
52
53
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 51

def first_proxy
  OreRDF::Aggregation.get_first_value self, first_proxy_
end

#first_proxy=(value) ⇒ Object



46
47
48
49
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 46

def first_proxy= value
  value = [] if value.nil?
  self.first_proxy_ = value
end

#first_proxy_subjectObject



55
56
57
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 55

def first_proxy_subject
  OreRDF::Aggregation.get_first_value self, first_proxy_, true
end

#generate_solr_document(all_proxies = []) ⇒ Object

Generate the solr document hash specific to a aggregation resource.

NOTE: If all_proxies is [], then will try to query from triple store which means that if the proxies have not

yet been persisted, then they will not be found.

NOTE: This method should not be called directory. Use LD4L::OreRDF::Aggregation.generate_solr_documents instead.

Parameters:



145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 145

def generate_solr_document( all_proxies=[] )
   solr_doc = ActiveTriples::Solrizer::IndexingService.new(self).generate_solr_document do |solr_doc|
     # TODO add owner_name and owner sort field
     # solr_doc.merge!(:owner_name_ti => owner.name)   # TODO add name to FOAF Gem
     # solr_doc.merge!(:owner_name_sort_ss => owner.name)

     # add all item_proxies
     all_proxies = get_items if all_proxies.empty?  # NOTE: get_items depends on aggregation_resource being persisted prior to this call
     proxy_ids = all_proxies.collect { |item| item.id }
     solr_doc.merge!(self.class.item_proxies_solr_name => proxy_ids)
     solr_doc
   end
   solr_doc
end

#get_item_at(position) ⇒ Object

Return the LD4L::OreRDF::ProxyResource instance for the item at the specified position in an ordered collection



105
106
107
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 105

def get_item_at(position)
  # TODO Stubbed - Required definition and implementation
end

#get_item_content_at(position) ⇒ Object

Return the content at the specified position in an ordered collection



100
101
102
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 100

def get_item_content_at(position)
  # TODO Stubbed - Required definition and implementation
end

#get_items(start = nil, limit = nil) ⇒ Object

Returns an array of persisted LD4L::OreRDF::ProxyResource instances for the items in the“ aggregation.



89
90
91
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 89

def get_items(start=nil,limit=nil)
  LD4L::OreRDF::ProxyResource.get_range(self, start, limit)
end

#get_items_content(start = nil, limit = nil) ⇒ Object

Returns an array the items in the aggregation. TODO: How to begin at start and limit to number of returned items, effectively handling ranges of data.



83
84
85
86
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 83

def get_items_content(start=nil,limit=nil)
  # TODO: Stubbed to return all items.
  get_values('aggregates')
end

#has_item_at?(position) ⇒ Boolean

Determine if an item exists at the specified position in the ordered aggregation

Returns:

  • (Boolean)


115
116
117
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 115

def has_item_at?(position)
  # TODO Stubbed - Requires definition and implementation
end

#has_item_content?(content) ⇒ Boolean

Determine if the content is already in the aggregation

Returns:

  • (Boolean)


110
111
112
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 110

def has_item_content?(content)
  # TODO Stubbed - Requires definition and implementation
end

#is_ordered?Boolean

Determine if the aggregation holds an ordered list of items

Returns:

  • (Boolean)


130
131
132
133
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 130

def is_ordered?
  # TODO Stubbed to always return false until ordered lists are implemented
  return false
end

#last_proxyObject



64
65
66
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 64

def last_proxy
  OreRDF::Aggregation.get_first_value self, last_proxy_
end

#last_proxy=(value) ⇒ Object



59
60
61
62
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 59

def last_proxy= value
  value = [] if value.nil?
  self.last_proxy_ = value
end

#last_proxy_subjectObject



68
69
70
# File 'lib/ld4l/ore_rdf/models/aggregation_resource.rb', line 68

def last_proxy_subject
  OreRDF::Aggregation.get_first_value self, last_proxy_, true
end