lib/qooxview/entity.rb in qooxview-1.9.10 vs lib/qooxview/entity.rb in qooxview-1.9.11
- old
+ new
@@ -41,10 +41,11 @@
@save_after_create = false
@changed = false
@null_allowed = false
@loading = false
@is_loaded = false
+ @dont_migrate = false
if @data_class != 'Entity'
@@all[@data_class] = self
dputs(4) { "Initializing #{self.class.name} with data_class = #{@data_class}" }
@@ -82,10 +83,15 @@
}
dputs(4) { "Block is now: #{@blocks.inspect}" }
end
end
+ # Overwrites ActiveSupport load, which is not needed
+ def self.load(has_static = true)
+ Entities.method_missing(self.name).load(has_static)
+ end
+
# Here comes the definition of the data used in that Entity. If the
# return-value is true, the data is loaded automatically
def setup_data
return false
end
@@ -165,13 +171,13 @@
# Makes for a small proxy, in that only the needed classes are
# instantiated - useful for stuff like long LDAP-lists...
def get_data_instance(k)
return nil if !k
- if k.class != Fixnum
+ if k.class != Integer
dputs(0) { 'This is very bad' }
- dputs(0) { "value k is #{k.inspect}" }
+ dputs(0) { "value k is #{k.inspect} - #{k.class}" }
dputs(0) { "caller-stack is #{caller}" }
raise 'WrongIndex'
end
return nil if not k or not @data[k.to_i]
if !@data_instances[k.to_i]
@@ -244,16 +250,16 @@
dputs(0) { caller.inspect }
super cmd, *args
end
end
- def respond_to?(cmd)
+ def respond_to?(cmd, all = false)
dputs(5) { cmd.inspect }
if cmd =~ /^(match_by_|search_by_|list_|listp_|value_)/
return true
end
- super cmd
+ super cmd, all
end
def whoami
dputs(0) { "I'm !*2@#" }
end
@@ -342,11 +348,11 @@
def self.delete_all_data(local_only = false)
@@all.each_pair { |k, v|
dputs(2) { "Erasing data of #{k}" }
v.delete_all(local_only)
}
- ConfigBases.init
+ ConfigBases.init_load
end
def self.save_all()
#dputs_func
dputs(3) { 'Saving everything' }
@@ -374,10 +380,12 @@
end
def self.reload
Entities.save_all
Entities.delete_all_data(true)
+ SQLite.dbs_close_all
+ SQLite.dbs_open_load_migrate
Entities.load_all
end
def self.is_setup?(e)
ret = false
@@ -443,21 +451,21 @@
def setup_instance
end
alias_method :old_respond_to?, :respond_to?
- def respond_to?(cmd)
+ def respond_to?(cmd, all = false)
field = cmd.to_s
if field == 'to_ary'
dputs(4) { 'not responding to_ary' }
return false
end
case field
when /=$/
return true
else
- return (@proxy.get_value(cmd) or super)
+ return (@proxy.get_value(cmd) or super(cmd, all))
end
end
def method_missing(cmd, *args)
#cmd == :owner ? dputs_func : dputs_unfunc
@@ -572,11 +580,11 @@
dputs(5) { "e is #{e.inspect} from #{@proxy.data.inspect}" }
if not raw and e
v = @proxy.get_value(f)
- if e.class == Fixnum and v and v.dtype == 'entity'
+ if e.class == Integer and v and v.dtype == 'entity'
dputs(5) { "Getting instance for #{v.inspect}" }
dputs(5) { "Getting instance with #{e.class} - #{e.inspect}" }
dputs(5) { "Field = #{field}; id = #{@id}" }
if e > 0 or @proxy.null_allowed
e = v.eclass.get_data_instance([e].flatten.first)
@@ -600,22 +608,9 @@
def data_set(field_orig, value)
field = field_orig.to_s
(direct = field =~ /^_/) and field.sub!(/^_/, '')
dputs(4) { "Direct is #{direct.inspect} for field #{field_orig.inspect}" }
-=begin
- v = if value.is_a? Entity
- dputs( 3 ){ "Converting #{value} to #{value.id}" }
- value.id
- elsif value.is_a? Array
- dputs(3){"Storing an array #{value.inspect}"}
- dp value.collect{|val|
- val.is_a?( Entity ) ? val.id : val
- }
- else
- value
- end
-=end
v = value
dputs(4) { "Self is #{self.public_methods.sort.inspect}" }
if (self.public_methods.index("#{field}=".to_sym)) && (not direct)
dputs(3) { "Setting #{field} through local method" }
send("#{field}=".to_sym, v)