19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/labimotion/models/concerns/datasetable.rb', line 19
def save_dataset(**args)
return if not_dataset?
klass = Labimotion::DatasetKlass.find_by(id: args[:dataset_klass_id])
uuid = SecureRandom.uuid
props = args[:properties]
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
props['identifier'] = klass.identifier if klass.identifier.present?
props['uuid'] = uuid
props['klass'] = 'Dataset'
ds = Labimotion::Dataset.find_by(element_type: self.class.name, element_id: id)
if ds.present? && (ds.klass_uuid != props['klass_uuid'] || ds.properties != props)
ds.update!(properties_release: klass.properties_release, uuid: uuid, dataset_klass_id: args[:dataset_klass_id], properties: props, klass_uuid: props['klass_uuid'])
end
return if ds.present?
props['klass_uuid'] = klass.uuid
Labimotion::Dataset.create!(properties_release: klass.properties_release, uuid: uuid, dataset_klass_id: args[:dataset_klass_id], element_type: self.class.name, element_id: id, properties: props, klass_uuid: klass.uuid)
end
|