Class: SakaiInfo::DeletedContentResource

Inherits:
ContentResource show all
Defined in:
lib/sakai-info/content.rb

Instance Attribute Summary collapse

Attributes inherited from Content

#parent_id

Attributes inherited from SakaiObject

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ContentResource

#detailed_summary_serialization, find_by_uuid, #size_on_disk, #summary_serialization

Methods inherited from Content

all_serializations, #binary_entity, #child_summary_serialization, #effective_realm, #mod_details_serialization, #mod_serialization, #original_mod_details_serialization, #original_mod_serialization, #parent, #properties_serialization, #realm, #realm_serialization, #size_on_disk, #summary_serialization

Methods included from ModProps

included

Methods inherited from SakaiObject

all_serializations, #dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #summary_serialization, #to_csv, #to_json, #to_yaml

Constructor Details

#initialize(dbrow) ⇒ DeletedContentResource

Returns a new instance of DeletedContentResource.



266
267
268
269
270
# File 'lib/sakai-info/content.rb', line 266

def initialize(dbrow)
  super(dbrow)
  @table_name = "content_resource_delete"
  @deleted_at = @dbrow[:delete_date].strftime("%Y-%m-%d %H:%M:%S")
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



259
260
261
# File 'lib/sakai-info/content.rb', line 259

def context
  @context
end

#dbrowObject (readonly)

Returns the value of attribute dbrow.



259
260
261
# File 'lib/sakai-info/content.rb', line 259

def dbrow
  @dbrow
end

#deleted_atObject (readonly)

Returns the value of attribute deleted_at.



259
260
261
# File 'lib/sakai-info/content.rb', line 259

def deleted_at
  @deleted_at
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



259
260
261
# File 'lib/sakai-info/content.rb', line 259

def file_path
  @file_path
end

#resource_type_idObject (readonly)

Returns the value of attribute resource_type_id.



259
260
261
# File 'lib/sakai-info/content.rb', line 259

def resource_type_id
  @resource_type_id
end

#uuidObject (readonly)

Returns the value of attribute uuid.



259
260
261
# File 'lib/sakai-info/content.rb', line 259

def uuid
  @uuid
end

Class Method Details

.clear_cacheObject



261
262
263
# File 'lib/sakai-info/content.rb', line 261

def self.clear_cache
  @@cache = {}
end

.count_by_parent(parent_id) ⇒ Object



309
310
311
# File 'lib/sakai-info/content.rb', line 309

def self.count_by_parent(parent_id)
  DeletedContentResource.query_by_parent(parent_id).count
end

.find(id) ⇒ Object



272
273
274
275
276
277
278
279
280
281
# File 'lib/sakai-info/content.rb', line 272

def self.find(id)
  if @@cache[id].nil?
    row = DB.connect[:content_resource_delete].where(:resource_id => id).first
    if row.nil?
      raise ObjectNotFoundException.new(DeletedContentResource, id)
    end
    @@cache[id] = DeletedContentResource.new(row)
  end
  @@cache[id]
end

.find_by_delete_userid(user_id) ⇒ Object



287
288
289
290
291
292
293
294
# File 'lib/sakai-info/content.rb', line 287

def self.find_by_delete_userid(user_id)
  resources = []
  DB.connect[:content_resource_delete].where(:delete_userid => user_id).all.each do |row|
    @@cache[row[:resource_id]] = DeletedContentResource.new(row)
    resources << @@cache[row[:resource_id]]
  end
  resources
end

.find_by_parent(parent_id) ⇒ Object



300
301
302
303
304
305
306
307
# File 'lib/sakai-info/content.rb', line 300

def self.find_by_parent(parent_id)
  resources = []
  DeletedContentResource.query_by_parent(parent_id).all.each do |row|
    @@cache[row[:resource_id]] = DeletedContentResource.new(row)
    resources << @@cache[row[:resource_id]]
  end
  resources
end

.query_by_parent(parent_id) ⇒ Object



296
297
298
# File 'lib/sakai-info/content.rb', line 296

def self.query_by_parent(parent_id)
  DB.connect[:content_resource_delete].where(:in_collection => parent_id)
end

Instance Method Details

#default_serializationObject



313
314
315
316
317
318
# File 'lib/sakai-info/content.rb', line 313

def default_serialization
  result = super
  result["deleted_at"] = self.deleted_at
  result["deleted_by"] = self.deleted_by.serialize(:summary)
  result
end

#deleted_byObject



283
284
285
# File 'lib/sakai-info/content.rb', line 283

def deleted_by
  @deleted_by ||= User.find(@dbrow[:delete_userid])
end