ontology.rb revision cf778c11532841285b0b40421eaea8874eaa933a
1516N/Aclass Ontology < ActiveRecord::Base
26N/A
26N/A # Ontohub Library Includes
26N/A include Commentable
26N/A include Metadatable
26N/A
26N/A # Ontology Model Includes
26N/A include Ontology::Import
26N/A include Ontology::Scopes
26N/A include Ontology::States
26N/A include Ontology::Versions
26N/A include Ontology::Entities
26N/A include Ontology::Sentences
26N/A include Ontology::Links
26N/A include Ontology::Distributed
26N/A include Ontology::Categories
26N/A include Ontology::Oops
26N/A include Ontology::OntologyTypes
26N/A include Ontology::Projects
26N/A include Ontology::Tools
26N/A include Ontology::Tasks
26N/A include Ontology::LicenseModels
2466N/A include Ontology::FormalityLevels
2466N/A include Ontology::FileExtensions
2466N/A
26N/A # Multiple Class Features
2092N/A include Aggregatable
1431N/A
1218N/A belongs_to :repository
1431N/A belongs_to :language
1218N/A belongs_to :logic, counter_cache: true
576N/A has_many :source_links, class_name: 'Link', foreign_key: 'source_id', dependent: :destroy
576N/A has_many :target_links, class_name: 'Link', foreign_key: 'target_id', dependent: :destroy
1431N/A
1431N/A attr_accessible :iri, :name, :description, :logic_id, :category_ids, :documentation, :acronym, :file_extension, :projects, :present
1431N/A
1431N/A validates_uniqueness_of :iri, :if => :iri_changed?
1431N/A validates_format_of :iri, :with => URI::regexp(Settings.allowed_iri_schemes)
1431N/A
1431N/A validates :documentation,
1431N/A allow_blank: true,
2466N/A format: { with: URI::regexp(Settings.allowed_iri_schemes) }
2466N/A
2466N/A validates_presence_of :basepath
2466N/A
2466N/A delegate :permission?, to: :repository
2466N/A
2466N/A strip_attributes :only => [:name, :iri]
2466N/A
2466N/A scope :search, ->(query) { where "ontologies.iri #{connection.ilike_operator} :term OR name #{connection.ilike_operator} :term", :term => "%" << query << "%" }
576N/A scope :list, includes(:logic).order('ontologies.state asc, ontologies.entities_count desc')
576N/A
576N/A def to_s
576N/A name? ? name : iri
576N/A end
576N/A
1431N/A # title for links
1431N/A def title
1431N/A name? ? iri : nil
696N/A end
2092N/A
1448N/A def symbols
1448N/A entities
1448N/A end
1448N/A
1218N/A def symbols_count
1448N/A entities_count
1218N/A end
1448N/A
1448N/A def path
1218N/A "#{basepath}#{file_extension}"
1218N/A end
1218N/A
1218N/Aend
1448N/A