Class: Rhoconnect::BulkData
- Inherits:
-
Model
- Object
- Model
- Rhoconnect::BulkData
show all
- Defined in:
- lib/rhoconnect/bulk_data/bulk_data.rb
Instance Attribute Summary
Attributes inherited from Model
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Model
_field_key, _prefix, class_prefix, #decrement!, field, #field_key, fields, #increment!, #initialize, is_exist?, list, load, marshal_class_name, #next_id, populate_attributes, #redis, redis, set, #to_array, validates_presence_of
Class Method Details
.create(fields = {}) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 64
def create(fields={})
fields[:id] = fields[:name]
fields[:state] ||= :inprogress
fields[:sources] ||= []
fields[:partition_sources] ||= []
super(fields)
end
|
.enqueue(params = {}) ⇒ Object
72
73
74
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 72
def enqueue(params={})
Resque.enqueue(BulkDataJob,params)
end
|
.get_name(partition, user_id) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 76
def get_name(partition,user_id)
if partition == :user
File.join(APP_NAME,user_id,user_id)
else
File.join(APP_NAME,APP_NAME)
end
end
|
.index_file ⇒ Object
88
89
90
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 88
def index_file
File.join(File.dirname(__FILE__),'syncdb.index.schema')
end
|
.schema_file ⇒ Object
84
85
86
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 84
def schema_file
File.join(File.dirname(__FILE__),'syncdb.schema')
end
|
Instance Method Details
#completed? ⇒ Boolean
16
17
18
19
20
21
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 16
def completed?
if state.to_sym == :completed
return true
end
false
end
|
#dbfiles_exist? ⇒ Boolean
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 46
def dbfiles_exist?
files = [dbfile,dbfile+'.rzip']
if Rhoconnect.blackberry_bulk_sync
files << dbfile+'.hsqldb.data'
files << dbfile+'.hsqldb.script'
files << dbfile+'.hsqldb.properties'
end
files.each do |file|
return false unless File.exist?(file)
end
true
end
|
#delete ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 23
def delete
sources[0, -1].each do |source|
s = Source.load(source,{:app_id => app_id, :user_id => user_id})
Store.flash_data(s.docname(:md_copy)) if s
end
super
end
|
#delete_files ⇒ Object
59
60
61
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 59
def delete_files
FileUtils.rm Dir.glob(File.join(Rhoconnect.base_directory, "#{self.url}*"))
end
|
#process_sources ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 31
def process_sources
sources[0, -1].each do |source|
s = Source.load(source,{:app_id => app_id, :user_id => user_id})
if s
SourceSync.new(s).process_query(nil)
s.clone(:md,:md_copy) unless s.sync_type.to_sym == :bulk_sync_only
end
end
end
|
#url ⇒ Object
41
42
43
44
|
# File 'lib/rhoconnect/bulk_data/bulk_data.rb', line 41
def url
zippath = dbfile.gsub(Regexp.compile(Regexp.escape(Rhoconnect.data_directory)), "")
URI.escape(File.join('/data',zippath))
end
|