Class: Labimotion::SegmentEntity
- Inherits:
-
ApplicationEntity
- Object
- Grape::Entity
- ApplicationEntity
- Labimotion::SegmentEntity
- Defined in:
- lib/labimotion/entities/segment_entity.rb
Overview
Segment entity
Constant Summary
Constants inherited from ApplicationEntity
ApplicationEntity::CUSTOM_ENTITY_OPTIONS
Instance Method Summary collapse
- #klass_label ⇒ Object
-
#properties ⇒ Object
rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength.
Methods inherited from ApplicationEntity
Instance Method Details
#klass_label ⇒ Object
9 10 11 |
# File 'lib/labimotion/entities/segment_entity.rb', line 9 def klass_label object.segment_klass.label end |
#properties ⇒ Object
rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
13 14 15 16 17 18 19 20 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 |
# File 'lib/labimotion/entities/segment_entity.rb', line 13 def properties # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength return unless object.respond_to?(:properties) return if object&.properties.dig('layers').blank? object&.properties['layers'].each_key do |key| # rubocop:disable Metrics/BlockLength next if object&.properties.dig('layers', key, 'fields').blank? field_sample_molecules = object&.properties['layers'][key]['fields'].select { |ss| ss['type'] == 'drag_molecule' } field_sample_molecules.each do |field| idx = object&.properties['layers'][key]['fields'].index(field) sid = field.dig('value', 'el_id') next if sid.blank? el = Molecule.find_by(id: sid) next if el.blank? next if object&.properties.dig('layers', key, 'fields', idx, 'value').blank? object&.properties['layers'][key]['fields'][idx]['value']['el_svg'] = File.join('/images', 'molecules', el.molecule_svg_file) end field_tables = object.properties['layers'][key]['fields'].select { |ss| ss['type'] == 'table' } field_tables.each do |field| next unless field['sub_values'].present? && field['sub_fields'].present? field_table_molecules = field['sub_fields'].select { |ss| ss['type'] == 'drag_molecule' } next if field_table_molecules.blank? col_ids = field_table_molecules.map { |x| x.values[0] } col_ids.each do |col_id| field['sub_values'].each do |sub_value| next unless sub_value[col_id].present? && sub_value[col_id]['value'].present? && sub_value[col_id]['value']['el_id'].present? find_mol = Molecule.find_by(id: sub_value[col_id]['value']['el_id']) next if find_mol.blank? sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_mol.molecule_svg_file) sub_value[col_id]['value']['el_inchikey'] = find_mol.inchikey sub_value[col_id]['value']['el_smiles'] = find_mol.cano_smiles sub_value[col_id]['value']['el_iupac'] = find_mol.iupac_name sub_value[col_id]['value']['el_molecular_weight'] = find_mol.molecular_weight end end end end object&.properties end |