<commit_before>require_relative 'network_system_registry.rb'

class SystemRegistry < ErrorsApi

  def initialize(core_api)
    @network_registry = NetworkSystemRegistry.new(core_api)
    p :NEW_SYSTEM_REG
  end

  def api_shutdown
    @network_registry.api_shutdown
  end
  
  def test_result(request_result_hash)
    clear_error
    if request_result_hash.nil? || !request_result_hash
      @last_error = @network_registry.last_error
      return request_result_hash
    end
    if request_result_hash[:result] == 'OK'
      # p request_result_hash[:object].class.name
      return request_result_hash[:object]
    end
    @last_error = request_result_hash[:error].to_s + ':' + @network_registry.last_error.to_s
    return request_result_hash[:object] if request_result_hash.key?(:object)
    return false
  end

  #
  #  def  find_engine_services(params)
  #    test_result(send_request('find_engine_services',params))
  #  end
  def remove_from_managed_engines_registry(params)
    p :remove_from_managed_engines_registry
    p params
    test_result(send_request('remove_from_managed_engines_registry', params))
  end

  def find_engine_service_hash(params)
    test_result(send_request('find_engine_service_hash', params))
  end

  def find_engine_services_hashes(params)
    test_result(send_request('find_engine_services_hashes', params))
  end

  def get_engine_nonpersistant_services(params)
    test_result(send_request('get_engine_nonpersistant_services', params))
  end

  def get_engine_persistant_services(params)
    test_result(send_request('get_engine_persistant_services', params))
  end

  def add_to_managed_engines_registry(service_hash)
    test_result(send_request('add_to_managed_engines_registry', service_hash))
  end

  def save_as_orphan(params)
    p :save_as_orphan
    p params
    test_result(send_request('save_as_orphan', params))
  end

  def release_orphan(params)
    p :release_orphan
    p params
    test_result(send_request('release_orphan', params))
  end

  def all_engines_registered_to(service_type)
    test_result(send_request('all_engines_registered_to', service_type))
  end 
  
  def reparent_orphan(params)
    p :reparent_orphan
    p params
    test_result(send_request('reparent_orphan', params))
  end

  def rebirth_orphan(params)
    p :reparent_orphan
    p params
    test_result(send_request('rebirth_orphan', params))
  end

  def retrieve_orphan(params)
    p :retrieve_orphan
    p params
    test_result(send_request('retrieve_orphan', params))
  end

  def get_orphaned_services(params)
    p :get_orphaned_services
    p params
    test_result(send_request('get_orphaned_services', params))
  end

  def find_orphan_consumers(params)
    p :get_orphaned_services
    p params
    test_result(send_request('find_orphan_consumers', params))
  end

  def orphanate_service(service_query_hash)
    p :get_orphaned_services
    p service_query_hash
    test_result(send_request('orphanate_service', service_query_hash))
  end

  def find_service_consumers(service_query_hash)
    test_result(send_request('find_service_consumers', service_query_hash))
  end

  def update_attached_service(service_hash)
    test_result(send_request('update_attached_service', service_hash))
  end

  def add_to_services_registry(service_hash)
    test_result(send_request('add_to_services_registry', service_hash))
  end
<commit_msg>hie jun code<commit_after>require_relative 'network_system_registry.rb'

class SystemRegistry < ErrorsApi

  def initialize(core_api)
    @network_registry = NetworkSystemRegistry.new(core_api)
    p :NEW_SYSTEM_REG
  end

  def api_shutdown
    @network_registry.api_shutdown
  end
  
  def test_result(request_result_hash)
    clear_error
    if request_result_hash.nil? || !request_result_hash
      @last_error = @network_registry.last_error
      return request_result_hash
    end
    if request_result_hash[:result] == 'OK'
      # p request_result_hash[:object].class.name
      return request_result_hash[:object]
    end
    @last_error = request_result_hash[:error].to_s + ':' + @network_registry.last_error.to_s
    return request_result_hash[:object] if request_result_hash.key?(:object)
    return false
  end

  #
  #  def  find_engine_services(params)
  #    test_result(send_request('find_engine_services',params))
  #  end
  def remove_from_managed_engines_registry(params)
    p :remove_from_managed_engines_registry
    p params
    test_result(send_request('remove_from_managed_engines_registry', params))
  end

  def find_engine_service_hash(params)
    test_result(send_request('find_engine_service_hash', params))
  end

  def find_engine_services_hashes(params)
    test_result(send_request('find_engine_services_hashes', params))
  end

  def get_engine_nonpersistant_services(params)
    test_result(send_request('get_engine_nonpersistant_services', params))
  end

  def get_engine_persistant_services(params)
    test_result(send_request('get_engine_persistant_services', params))
  end

  def add_to_managed_engines_registry(service_hash)
    test_result(send_request('add_to_managed_engines_registry', service_hash))
  end

  def save_as_orphan(params)
    p :save_as_orphan
    p params
    test_result(send_request('save_as_orphan', params))
  end

  def release_orphan(params)
    p :release_orphan
    p params
    test_result(send_request('release_orphan', params))
  end

  def all_engines_registered_to(service_type)
    test_result(send_request('all_engines_registered_to', service_type))
  end 
  
  def reparent_orphan(params)
    p :reparent_orphan
    p params
    test_result(send_request('reparent_orphan', params))
  end

  def rebirth_orphan(params)
    p :reparent_orphan
    p params
    test_result(send_request('rebirth_orphan', params))
  end

  def retrieve_orphan(params)
    p :retrieve_orphan
    p params
    test_result(send_request('retrieve_orphan', params))
  end

  def get_orphaned_services(params)
    p :get_orphaned_services
    p params
    test_result(send_request('get_orphaned_services', params))
  end

#  def find_orphan_consumers(params)
#    p :get_orphaned_services
#    p params
#    test_result(send_request('find_orphan_consumers', params))
#  end

  def orphanate_service(service_query_hash)
    p :get_orphaned_services
    p service_query_hash
    test_result(send_request('orphanate_service', service_query_hash))
  end

  def find_service_consumers(service_query_hash)
    test_result(send_request('find_service_consumers', service_query_hash))
  end

  def update_attached_service(service_hash)
    test_result(send_request('update_attached_service', service_hash))
  end

  def add_to_services_registry(service_hash)
    test_result(send_request('add_to_services_registry', service_hash))
  end

{'fraction_non_alphanumeric': 0.07472625036993193, 'fraction_numerical': 0.0, 'mean_word_length': 5.275766016713092, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7578724', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2217, 'n_words': 352}