labimotion 2.3.2 → 2.4.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -22
- data/lib/labimotion/apis/element_variation_api.rb +3 -58
- data/lib/labimotion/apis/generic_element_api.rb +22 -0
- data/lib/labimotion/collection/import.rb +3 -36
- data/lib/labimotion/constants.rb +0 -6
- data/lib/labimotion/entities/application_entity.rb +1 -5
- data/lib/labimotion/entities/properties_entity.rb +28 -0
- data/lib/labimotion/helpers/element_helpers.rb +5 -27
- data/lib/labimotion/helpers/param_helpers.rb +1 -0
- data/lib/labimotion/libs/converter.rb +22 -99
- data/lib/labimotion/libs/linked_element.rb +193 -0
- data/lib/labimotion/libs/nmr_mapper.rb +4 -34
- data/lib/labimotion/models/concerns/attachment_converter.rb +0 -24
- data/lib/labimotion/models/concerns/datasetable.rb +5 -16
- data/lib/labimotion/models/concerns/element_fetchable.rb +2 -3
- data/lib/labimotion/models/concerns/segmentable.rb +5 -24
- data/lib/labimotion/models/element.rb +2 -3
- data/lib/labimotion/utils/mapper_utils.rb +5 -30
- data/lib/labimotion/utils/prop.rb +0 -1
- data/lib/labimotion/utils/units.rb +32 -67
- data/lib/labimotion/version.rb +1 -1
- data/lib/labimotion.rb +1 -11
- metadata +5 -24
- data/lib/labimotion/libs/element_variation_column_set.rb +0 -426
- data/lib/labimotion/libs/element_variation_header.rb +0 -119
- data/lib/labimotion/libs/export_element_variations.rb +0 -245
- data/lib/labimotion/libs/export_tpa_segments.rb +0 -53
- data/lib/labimotion/libs/import_element_variations.rb +0 -411
- data/lib/labimotion/libs/klass_version.rb +0 -66
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'active_support/core_ext/object/blank'
|
|
4
|
-
|
|
5
|
-
module Labimotion
|
|
6
|
-
# Resolves which release of a template a saved element, segment or dataset follows, as
|
|
7
|
-
# the pair [klass_uuid, properties_release]. The submitted properties carry the klass_uuid
|
|
8
|
-
# they were built on; it counts when it is the klass's current release or one of its
|
|
9
|
-
# revisions, so a copy of an older record keeps that release instead of being relabelled.
|
|
10
|
-
module KlassVersion
|
|
11
|
-
# A new record without a known release, such as a new empty one, follows the current release.
|
|
12
|
-
# A copy of a record from an instance with releases of its own names a klass_uuid this one
|
|
13
|
-
# cannot resolve; it keeps the release the client sent only when that release names the same uuid.
|
|
14
|
-
def self.for_create(klass, revisions, submitted_uuid, client_release: nil)
|
|
15
|
-
uuid = string_uuid(submitted_uuid)
|
|
16
|
-
release = release_of(klass, revisions, uuid)
|
|
17
|
-
return [uuid, release] if release
|
|
18
|
-
return [uuid, client_release] if uuid.present? && release_uuid(client_release) == uuid
|
|
19
|
-
|
|
20
|
-
[klass.uuid, klass.properties_release]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# An existing record keeps its stored klass_uuid when none is submitted, then the uuid its
|
|
24
|
-
# stored release names, and follows the current release only when it has neither. A klass_uuid
|
|
25
|
-
# this instance cannot resolve (a record imported from elsewhere) keeps the release stored with it.
|
|
26
|
-
def self.for_update(klass, revisions, submitted_uuid, record)
|
|
27
|
-
uuid = string_uuid(submitted_uuid).presence || record.klass_uuid.presence
|
|
28
|
-
if uuid.nil?
|
|
29
|
-
stored_uuid = release_uuid(record.properties_release)
|
|
30
|
-
return [stored_uuid, record.properties_release] if stored_uuid
|
|
31
|
-
|
|
32
|
-
return [klass.uuid, klass.properties_release]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
release = release_of(klass, revisions, uuid) || record.properties_release.presence
|
|
36
|
-
[uuid, release || klass.properties_release]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# for_update when the record exists, for_create when it is nil.
|
|
40
|
-
def self.for_record(klass, revisions, submitted_uuid, record, client_release: nil)
|
|
41
|
-
return for_create(klass, revisions, submitted_uuid, client_release: client_release) if record.nil?
|
|
42
|
-
|
|
43
|
-
for_update(klass, revisions, submitted_uuid, record)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Revisions are soft-deleted, and deleting one does not change which release the records
|
|
47
|
-
# built on it follow, so a deleted revision still answers here.
|
|
48
|
-
def self.release_of(klass, revisions, uuid)
|
|
49
|
-
return if uuid.blank?
|
|
50
|
-
return klass.properties_release if uuid == klass.uuid
|
|
51
|
-
|
|
52
|
-
revisions.with_deleted.where(uuid: uuid).order(id: :desc).pick(:properties_release)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Every release hash carries the uuid of the release it describes; nil when it names none.
|
|
56
|
-
def self.release_uuid(release)
|
|
57
|
-
release.is_a?(Hash) ? string_uuid(release['uuid']).presence : nil
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# properties is a free-form hash, so klass_uuid can arrive as an array or a number; either
|
|
61
|
-
# would turn the revision lookup into a query matching more than the record's own release.
|
|
62
|
-
def self.string_uuid(submitted_uuid)
|
|
63
|
-
submitted_uuid.is_a?(String) ? submitted_uuid : nil
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|