Class Tag::Asset
In: lib/tag/asset.rb
Parent: ActiveRecord::Base

Represents the table tagsasset

Methods

External Aliases

user -> owner
group -> community

Public Class methods

[Source]

    # File lib/tag/asset.rb, line 32
32:     def self.resource_types
33:       [
34:         BlogPost,
35:         Wiki::Page,
36: #         MB::Message,
37:         Journal::Article,
38:         DlFile,
39:         IG::Image,
40:         Bookmark::Entry,
41: #         Group,
42: #         DlFolder
43:       ]
44:     end

Public Instance methods

label (logic to fetch non-empty title)

[Source]

    # File lib/tag/asset.rb, line 73
73:     def label
74:       return self.title if self.title.any?
75: 
76:       # fallback to the name of the resource
77:       if self.resource.respond_to?(:name) && self.resource.name.any?
78:         return self.resource.name
79:       else
80:         STDERR.puts 'Asset %i has no title' % self.id
81:         return ''
82:       end
83:     end

com.liferay.portlet.tags.model.TagsAsset

[Source]

    # File lib/tag/asset.rb, line 8
 8:     def liferay_class
 9:       'com.liferay.portlet.tags.model.TagsAsset'
10:     end

Content can be of several different types. Finding Wiki::Page s and Journal::Article s is a bit tricky..

[Source]

    # File lib/tag/asset.rb, line 48
48:     def resource
49:       resource_id = self.classpk
50:       #logger.debug "Looking up resource #{resource_id}"
51: 
52:       _class = Classname.model(Classname.find(self.classnameid).value)
53:       if _class
54:         if _class==Wiki::Page
55:           Wiki::Page.find(:first,
56:             :conditions => "resourceprimkey=#{resource_id}", :order => "version DESC")
57: 
58:         elsif _class==Journal::Article
59:           Journal::Article.find(:first,
60:             :conditions => "resourceprimkey=#{resource_id}", :order => "version DESC")
61: 
62:         else
63:           _class.find resource_id
64:         end
65: 
66:       else
67:         logger.warn "Resource #{resource_id} of asset #{self.id} was left unresolved"
68:         return nil
69:       end
70:     end

[Validate]