Module: Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList

Includes:
DSL, Converter, Output
Included in:
TreeDiff
Defined in:
lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/output.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/input.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/discarded.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/node_attr_maps.rb

Overview

Note:

it can have multiple usages

  1. Live locations tree structure into a nodes list file (nodeId, parendId, name,...)
  2. A locations tree built from an input csv into a nodes list hash
  3. Change the keys of the hash nodes
  4. Parse the values
Note:

this use case can be inherited from to provision parsed input to other use cases.

Note:

it allows to define custom_node_parser and custom_node_parser_after methods (param: node_hash), to allow custom parsing.

  • It has a generic parser that validates the classifications

Service to transform (CONVERT or PARSE) an input locations structure into a list of hash nodes. As this format allows to easily compare what has changed in the locations structure.

Examples:

class Custom::UseCase::TagtreeToList < Eco::API::UseCases::GraphQL::Samples::Location
  name 'tagtree-to-list'
  type :other

  include Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList

end

Defined Under Namespace

Modules: Converter, Output

Constant Summary

Constants included from Converter::Discarded

Converter::Discarded::DISCARDED_NODES

Constants included from Converter::NodeAttrMaps

Converter::NodeAttrMaps::NODE_ATTR_MAPS

Constants included from Helpers::Location::Base::TreeTracking

Helpers::Location::Base::TreeTracking::TAGTREE_BACKUP

Constants included from Output

Output::OUT_FILENAME, Output::OUT_FOLDER, Output::OUT_HEADER, Output::OUT_TIME_FORMAT

Instance Attribute Summary

Attributes included from Helpers::Base::ErrorHandling

#exception, #exiting

Attributes included from Language::AuxiliarLogger

#logger

Attributes included from Helpers::Location::Base::TreeTracking

#current_tree, #previous_tree

Instance Method Summary collapse

Methods included from Helpers::Location::Base

#live_tree, #session_live_tree, #tagtree_id, #target_structure_id, #target_structure_id_const

Methods included from Language::AuxiliarLogger

#log

Methods included from Helpers::Location::Base::TreeTracking

#backup_tree, #track_current_tree, #track_current_tree?

Instance Method Details

#processObject



33
34
35
36
37
38
39
40
41
# File 'lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb', line 33

def process
  with_error_handling do
    as_nodes_json(input_tagtree).tap do |list|
      next generate_live_nodes_file(list) unless list.empty?

      log(:error) { "There are no location nodes!" }
    end
  end
end