lib/eco/api/session.rb in eco-helpers-1.5.0 vs lib/eco/api/session.rb in eco-helpers-1.5.1

- old
+ new

@@ -84,23 +84,21 @@ # If `schema` is `nil` or not provided it uses the currently associated to the `session` def entry_factory(schema: nil) schema = to_schema(schema) || self.schema return @entry_factories[schema&.id] if @entry_factories.key?(schema&.id) - # TODO: check PersonEntry#to_internal and #to_external in init_attr_trackers - # => when attr_map is avoided, it doesn't work as it should mappings = [] if map_file = config.people.fields_mapper mappings = map_file ? file_manager.load_json(map_file) : [] end - @entry_factories[schema&.id] = Eco::API::Common::People::EntryFactory.new({ + @entry_factories[schema&.id] = Eco::API::Common::People::EntryFactory.new( + enviro, schema: schema, person_parser: config.people.parser, - attr_map: Eco::Data::Mapper.new(mappings), - logger: logger - }) + attr_map: Eco::Data::Mapper.new(mappings) + ) end # Helper to obtain a PersonFactory # @param schema [String, Ecoportal::API::V1::PersonSchema] `schema` to which associate the PersonFactory, # where `String` can be the _name_ or the _id_ of the schema. @@ -193,9 +191,14 @@ when job_groups.exists?(name) job_groups[name] else job_groups.new(name, order: order) end + end + + # shortcut to create a job of certain type within a group + def new_job(group, name, type, usecase, sets = [:core, :details, :account]) + job_group(group).new(name, usecase: usecase, type: type, sets: sets) end def jobs_launch(simulate: false) job_groups.launch(simulate: simulate) end