require 'scrivito/basic_obj' module Scrivito class BasicObj # Type computer computes with global Obj by default # which in legacy mode belongs to fiona_connector # Therefore we limit the scope of the search to Scrivito::Obj def self.type_computer @_type_computer ||= TypeComputer.new(Scrivito::BasicObj, Obj) end # optimized away def outdated? false end # optimized away def transfer_modifications_to(target_workspace) return unless modification raise TransferModificationsModifiedError, "Already modified in workspace #{target_workspace.id}" end def copy_binaries(attributes) # TODO: what to do? attributes end # Originally this method checks for conflicts # which are impossible here, hence the method is stubbed out def publishable? # TODO: implement CM validations here # FIXME: this can be solved much faster in PublishChecker self.id && Fiona7::EditedObj.find(self.id).permission.release? end # Original implentation reads file extension from name # but since dots are not allowed in the names # it has to be worked around. def file_extension if (blob = find_blob) File.extname(blob.filename)[1..-1] else "" end end def fiona_obj @fiona_obj ||= ::RailsConnector::BasicObj.find(self.id) end # Patch to allow reverting in rtc workspace def assert_revertable if workspace.id != 'rtc' raise ScrivitoError, "cannot revert changes, since obj is not from valid revertable workspace." end if modification == Modification::NEW || modification == Modification::DELETED raise ScrivitoError, "cannot revert changes, since obj is #{modification}." end end # Originally this method refers to the global Obj via ::Obj # and does not support shadow classes def self.where(field, operator, value, boost = nil) assert_not_basic_obj('.where') if self == ::Obj || self == Obj Workspace.current.objs.where(field, operator, value, boost) else Workspace.current.objs.where(:_obj_class, :equals, name) .and(field, operator, value, boost) end end # Originally this method refers to the global Obj via ::Obj # and does not support shadow classes def self.all assert_not_basic_obj('.all') if self == ::Obj || self == Obj Workspace.current.objs.all else find_all_by_obj_class(name) end end class << self def inherited(subclass,*args) super if subclass.name == 'Obj' && !::RailsConnector.const_defined?('Obj', false) ::RailsConnector.const_set('Obj', ::RailsConnector::AbstractObj) end ensure if subclass.name.present? subclass.register_attribute_definitions(subclass.to_s) end end end end end