ontology_version.rb revision ab2be9b1453256821fb11be230149c49963a7b69
0075dcb5aeeee4864fe9f64db82c8a8202bbe6d6henning muellerclass OntologyVersion < ActiveRecord::Base
39f4456a75fd3e8b00e5eaa1158086c5cbf0774cTim Reddehase include CodeReferencable
6d4349ab76204cc56e3c5745f4b0d047ff082a03Eugen Kuksa include Numbering
39f4456a75fd3e8b00e5eaa1158086c5cbf0774cTim Reddehase
aead985e48027c9df1ef553b17df29dd378757aaJulian Kornberger include OntologyVersion::Files
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger include OntologyVersion::States
9c9b4f0d0199c3b1dbff564b87435b6693b7e692Julian Kornberger include OntologyVersion::Parsing
7aad606a237a0b6145ad1d020429fcbe20dd448bEugen Kuksa include OntologyVersion::Proving
dda6f544eb58d850394073e34ae6127498869a77Christian Clausen include OntologyVersion::OopsRequests
1926bd12c68c7c499d4251daf6341519193ca8c4Tim Reddehase include IRIUrlBuilder::Includeable
ab2be9b1453256821fb11be230149c49963a7b69Eugen Kuksa include ::AccessScopesForRepositoryAssociations
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller include Rails.application.routes.url_helpers
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller include ActionDispatch::Routing::UrlFor
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
6d4349ab76204cc56e3c5745f4b0d047ff082a03Eugen Kuksa numbering_parent_column 'ontology_id'
6d4349ab76204cc56e3c5745f4b0d047ff082a03Eugen Kuksa
0075dcb5aeeee4864fe9f64db82c8a8202bbe6d6henning mueller belongs_to :user
cbb18f95cb8354f0c3fb44ba5134dadc7ad6b2ecJulian Kornberger belongs_to :ontology, :counter_cache => :versions_count
0582d7384e787d483b2b37cc2b37fd59b02ce422Eugen Kuksa has_one :repository, through: :ontology
0582d7384e787d483b2b37cc2b37fd59b02ce422Eugen Kuksa has_many :theorems, through: :ontology
aca8ebc07736136a816f0a71534730ec65472df3Tim Reddehase belongs_to :commit
bb67f9b02f679071ac08d174531a03f325bc5327Eugen Kuksa has_one :repository, through: :ontology
bb67f9b02f679071ac08d174531a03f325bc5327Eugen Kuksa has_many :theorems, through: :ontology
940c9c3e36eaf2a919ea2f89e7ecde3f6ebc3450Eugen Kuksa
940c9c3e36eaf2a919ea2f89e7ecde3f6ebc3450Eugen Kuksa # Provers that can be used for proving goals in this ontology.
d07e32bfd3fe6571e81ce5122714f75ea74a3407Eugen Kuksa has_and_belongs_to_many :provers
3cd45197413df1ff1401697720f1ac9ccef8f8eehenning mueller
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller# before_validation :set_checksum
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller# validate :raw_file_size_maximum
ecf32c9d659a1f42c730d61eaa93583c095a4fddhenning mueller
bceeb5195a8524674b37f6abd92ccaba357e536bSascha Graef# validates_presence_of :basepath
0772cf7b22adf46dbab68e829d6a2cd8e8d1bc2ahenning mueller
432ee743a5f1c5688c73446b5977b06ed97fb67cJulian Kornberger scope :latest, order('id DESC')
b9f99a06294e593ce8fb34b015e83003229db058Julian Kornberger scope :done, state('done')
b3b159fb3284b66d0f8189a6a145c8163ccdae68henning mueller scope :failed, state('failed')
7ea9649883e1bbe8f2582db1a3c66af8b7206056henning mueller
6c8d349bce5a8aa4c5af757a84d9432153024e8fTim Reddehase acts_as_tree
6c8d349bce5a8aa4c5af757a84d9432153024e8fTim Reddehase
631f43db46ad7d375010c3169c81764eb27270a3Julian Kornberger # updated_at of the latest version
631f43db46ad7d375010c3169c81764eb27270a3Julian Kornberger def self.last_updated_at
631f43db46ad7d375010c3169c81764eb27270a3Julian Kornberger latest.first.try(:updated_at)
631f43db46ad7d375010c3169c81764eb27270a3Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
ae2ba7aeef036808e81fb6449e98ce9abb0fb234Daniel Couto Vale def to_param
7dc318cbd9f8c97406b48051005f23953e9e8a25Daniel Vale self.number
ae2ba7aeef036808e81fb6449e98ce9abb0fb234Daniel Couto Vale end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
543c1be79aecb1d19f3bd50d8581da5c1cd0893bEugen Kuksa def to_s
543c1be79aecb1d19f3bd50d8581da5c1cd0893bEugen Kuksa "#{ontology.name} (version #{number})"
543c1be79aecb1d19f3bd50d8581da5c1cd0893bEugen Kuksa end
543c1be79aecb1d19f3bd50d8581da5c1cd0893bEugen Kuksa
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller # Public URL to this version
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller #
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller # TODO: This returns a path without the commit id and filename for now,
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller # because the FilesController or the routes were not supporting it.
43a0f914166a28a9d7f75ab10673dce129cb38a9Julian Kornberger def url(params={})
4c1d51e9760c808027ec7f559e80067744c78541Eugen Kuksa #Rails.application.routes.url_helpers.repository_ref_path(repository, commit_oid, ontology.path, params.reverse_merge(host: Ontohub::Application.config.fqdn, port: Ontohub::Application.config.port, only_path: false))
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller url_for [repository, ontology, self]
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller end
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller def default_url_options
4c1d51e9760c808027ec7f559e80067744c78541Eugen Kuksa {host: Ontohub::Application.config.fqdn,
4c1d51e9760c808027ec7f559e80067744c78541Eugen Kuksa port: Ontohub::Application.config.port}
43a0f914166a28a9d7f75ab10673dce129cb38a9Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
823b204d13c129df1ae3b49ff62ee1da0c8f6b63Eugen Kuksa def path
823b204d13c129df1ae3b49ff62ee1da0c8f6b63Eugen Kuksa "#{basepath}#{file_extension}"
823b204d13c129df1ae3b49ff62ee1da0c8f6b63Eugen Kuksa end
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller
2ae84818de6541409f6c8f2b417b868325aed315Tim Reddehase def file_in_repository
36775360692520baa2625045372081b2cbc9959dTim Reddehase ontology.repository.get_file(path, commit_oid)
2ae84818de6541409f6c8f2b417b868325aed315Tim Reddehase end
2ae84818de6541409f6c8f2b417b868325aed315Tim Reddehase
33d42e7c36aef2d703ed3e35536dca4cd4290470Tim Reddehase def locid
33d42e7c36aef2d703ed3e35536dca4cd4290470Tim Reddehase "/ref/#{number}#{ontology.locid}"
33d42e7c36aef2d703ed3e35536dca4cd4290470Tim Reddehase end
33d42e7c36aef2d703ed3e35536dca4cd4290470Tim Reddehase
33d42e7c36aef2d703ed3e35536dca4cd4290470Tim Reddehase alias_method :versioned_locid, :locid
33d42e7c36aef2d703ed3e35536dca4cd4290470Tim Reddehase
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller protected
8d4d8ac34f199d5c7d26694fabbfe2ab6bc0f9d9henning mueller
ecf32c9d659a1f42c730d61eaa93583c095a4fddhenning mueller def raw_file_size_maximum
ecf32c9d659a1f42c730d61eaa93583c095a4fddhenning mueller if raw_file.size > 10.megabytes.to_i
ecf32c9d659a1f42c730d61eaa93583c095a4fddhenning mueller errors.add :raw_file, 'The maximum file size is 10M.'
ecf32c9d659a1f42c730d61eaa93583c095a4fddhenning mueller end
ecf32c9d659a1f42c730d61eaa93583c095a4fddhenning mueller end
1b6021653a43264993b21ebb20e0119aa2fd6741henning mueller
0eae0f423c62bcc939e76f37ce7a7a9913b58422Julian Kornberger def refresh_checksum!
0eae0f423c62bcc939e76f37ce7a7a9913b58422Julian Kornberger self.checksum = Digest::SHA1.file(raw_path!).hexdigest
0eae0f423c62bcc939e76f37ce7a7a9913b58422Julian Kornberger save! if checksum_changed?
1b6021653a43264993b21ebb20e0119aa2fd6741henning mueller end
b0ad67a7b41855a9148f346eb5b5d2b9276796ddhenning mueller
0075dcb5aeeee4864fe9f64db82c8a8202bbe6d6henning muellerend