ontology.rb revision 13afaf97a3dc4419d05bde698d8f6ba2465b55fb
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # Ontohub Library Includes
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # Ontology Model Includes
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # Multiple Class Features
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen has_many :source_links, class_name: 'Link', foreign_key: 'source_id', dependent: :destroy
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen has_many :target_links, class_name: 'Link', foreign_key: 'target_id', dependent: :destroy
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen attr_accessible :iri, :name, :description, :logic_id, :category_ids, :documentation, :acronym, :file_extension, :projects
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen validates_uniqueness_of :iri, :if => :iri_changed?
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen validates_format_of :iri, :with => URI::regexp(Settings.allowed_iri_schemes)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen format: { with: URI::regexp(Settings.allowed_iri_schemes) }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen scope :search, ->(query) { where "ontologies.iri #{connection.ilike_operator} :term OR name #{connection.ilike_operator} :term", :term => "%" << query << "%" }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen scope :list, includes(:logic).order('ontologies.state asc, ontologies.entities_count desc')
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen name? ? name : iri
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # title for links
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen name? ? iri : nil
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen def symbols_count
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen entities_count
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen "#{basepath}#{file_extension}"
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen def is?(logic_name)
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen self.logic ? (self.logic.name == logic_name) : false