Class: Labimotion::DatasetEntity

Inherits:
PropertiesEntity show all
Defined in:
lib/labimotion/entities/dataset_entity.rb

Overview

Dataset entity

Constant Summary

Constants inherited from ApplicationEntity

ApplicationEntity::CUSTOM_ENTITY_OPTIONS

Instance Method Summary collapse

Methods inherited from PropertiesEntity

#set_table

Methods inherited from ApplicationEntity

expose!, expose_timestamps

Instance Method Details

#klass_labelObject



12
13
14
# File 'lib/labimotion/entities/dataset_entity.rb', line 12

def klass_label
  object&.dataset_klass&.label
end

#klass_olsObject



8
9
10
# File 'lib/labimotion/entities/dataset_entity.rb', line 8

def klass_ols
  object&.dataset_klass&.ols_term_id
end

#propertiesObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/labimotion/entities/dataset_entity.rb', line 21

def properties
  properties = object&.properties || {}
  properties[Labimotion::Prop::LAYERS].keys.each do |key|
    layer = properties[Labimotion::Prop::LAYERS][key] || {}
    return properties if layer.empty? || layer[Labimotion::Prop::FIELDS].nil?

    field_vocs = layer[Labimotion::Prop::FIELDS].select { |ss| ss['is_voc'] == true }
    field_vocs.each do |field|
      idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
      next if idx.nil?

      case field['source']
        when Labimotion::Prop::ELEMENT
          if field['identifier'] == 'element.name'
            byebug
            properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = root_element&.name
          #  dic[field.identifier] = currentElement.name

          end
        when Labimotion::Prop::SEGMENT
          segs = root_element&.segments&.select { |ss| field['source_id'] == ss.segment_klass&.identifier }
          next if segs.empty? || field['layer_id'].blank? || field['field_id'].blank?

          seg = segs&.first
          seg_fields = seg.properties.dig(Labimotion::Prop::LAYERS, field['layer_id'], Labimotion::Prop::FIELDS).select { |ff| ff['field'] == field['field_id'] }
          seg_field = seg_fields&.first
          properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = seg_field['value']
        when Labimotion::Prop::DATASET
          byebug
        end
    end

    # layer[Labimotion::Prop::FIELDS].each do |field|
    # end
  end

  # byebug
  # layers = properties['layers']

  # properties['vocabularies'].each_with_object({}) do |v, h|
  #   h[v['name']] = v['value']
  # end
  properties
end

#root_elementObject



17
18
19
# File 'lib/labimotion/entities/dataset_entity.rb', line 17

def root_element
  object&.element&.root_element
end