<commit_before># encoding: utf-8
module FruitToLime
    # The root model for Go import. This class is the container for everything else.
    class RootModel
        # the import_coworker is a special coworker that is set as
        # responsible for objects that requires a coworker, eg a note.
        attr_accessor :import_coworker

        attr_accessor :settings, :organizations, :coworkers, :deals, :notes
        def serialize_variables
            [
             {:id => :settings, :type => :settings},
             {:id => :coworkers, :type => :coworkers},
             {:id => :organizations, :type => :organizations},
             {:id => :deals, :type => :deals},
             {:id => :notes, :type => :notes},
            ]
        end

        def serialize_name
            "GoImport"
        end

        include SerializeHelper

        def initialize()
            @settings = Settings.new
            @organizations = []
            @coworkers = []
            @import_coworker = Coworker.new
            @import_coworker.integration_id = "import"
            @import_coworker.first_name = "Import"
            @coworkers.push @import_coworker
            @deals = []
            @notes = []
        end

        # Adds the specifed coworker object to the model.
        # @example Add a coworker from a hash
        #    rootmodel.add_coworker({
        #        :integration_id=>"123",
        #        :first_name=>"Kalle",
        #        :last_name=>"Anka",
        #        :email=>"<EMAIL>"
        #    })
        #
        # @example Add a coworker from a new coworker
        #    coworker = FruitToLime::Coworker.new
        #    coworker.integration_id = "123"
        #    coworker.first_name="Kalle"
        #    coworker.last_name="Anka"
        #    coworker.email = "<EMAIL>"
        #    rootmodel.add_coworker(coworker)
        #
        # @example If you want to keep adding coworkers and dont care about duplicates not being added
        #    begin
        #       rootmodel.add_coworker(coworker)
        #    rescue FruitToLime::AlreadyAddedError
        #       puts "Warning: already added coworker"
        #    end
        # @see Coworker
        def add_coworker(coworker)
            @coworkers = [] if @coworkers == nil

            if coworker == nil
                raise "Missing coworker to add!"
            end

            coworker = Coworker.new(coworker) if !coworker.is_a?(Coworker)

            if find_coworker_by_integration_id(coworker.integration_id) != nil
                raise AlreadyAddedError, "Already added a coworker with integration_id #{coworker.integration_id}"
            end

            @coworkers.push(coworker)

            return coworker
        end

        # Adds the specifed organization object to the model.
        # @example Add an organization from a hash
        #    rootmodel.add_organization({
        #        :integration_id => "123",
        #        :name => "<NAME>",
        #    })
        #
        # @example Add an organization from a new organization
        #    organization = FruitToLime::Organization.new
        #    organization.integration_id = "123"
        #    organization.name = "<NAME>"
        #    rootmodel.add_organization(organization)
        #
        # @example If you want to keep adding organizations and dont
        # care about duplicates not being added. Your model might not
        # be saved due to duplicate integration_ids.
        #    begin
        #       rootmodel.add_organization(organization)
        #    rescue FruitToLime::AlreadyAddedError
        #       puts "Warning: already added organization"
        #    end
        # @see Coworker
        def add_organization(organization)
            @organizations = [] if @organizations.nil?

            if organization.nil?
                raise "Missing organization to add"
            end

            organization = Organization.new(organization) if !organization.is_a?(Organization)

            if find_organization_by_integration_id(organization.integration_id) != nil
                raise AlreadyAddedError, "Already added an organization with integration_id #(organization.integration_id)"
            end

            @organizations.push(organization)

            return organization
        end

        # Adds the specifed deal object to the model.
        # @example Add an deal from a hash
        #    rootmodel.add_deal({
        #        :integration_id => "123",
        #        :name => "Big deal",
        #    })
        #
        # @example Add a deal from a new deal
        #    deal = FruitToLime::Deal.new
        #    deal.integration_id = "123"
        #    deal.name = "Big deal"
        #    rootmodel.add_deal(deal)
        #
        # @example If you want to keep adding deals and dont
        # care about duplicates not being added. Your model might not
        # be saved due to duplicate integration_ids.
        #    begin
        #       rootmodel.add_deal(deal)
        #    rescue FruitToLime::AlreadyAddedError
        #       puts "Warning: already added deal"
        #    end
        # @see Coworker
        def add_deal(deal)
            @deals = [] if @deals.nil?

            if deal.nil?
                raise "Missing deal to add"
            end

            deal = Deal.new(deal) if !deal.is_a?(Deal)

            if find_deal_by_integration_id(deal.integration_id) != nil
                raise AlreadyAddedError, "Already added a deal with integration_id #{deal.integration_id}"
            end

            @deals.push(deal)

            return deal
        end

        # Adds the specifed note object to the model.
        # @example Add an deal from a hash
        #    rootmodel.add_note({
        #        :integration_id => "123",
        #        :text => "This is a note",
        #    })<commit_msg>Set import coworker as deal's responsible if no coworker is specifed<commit_after># encoding: utf-8
module FruitToLime
    # The root model for Go import. This class is the container for everything else.
    class RootModel
        # the import_coworker is a special coworker that is set as
        # responsible for objects that requires a coworker, eg a note.
        attr_accessor :import_coworker

        attr_accessor :settings, :organizations, :coworkers, :deals, :notes
        def serialize_variables
            [
             {:id => :settings, :type => :settings},
             {:id => :coworkers, :type => :coworkers},
             {:id => :organizations, :type => :organizations},
             {:id => :deals, :type => :deals},
             {:id => :notes, :type => :notes},
            ]
        end

        def serialize_name
            "GoImport"
        end

        include SerializeHelper

        def initialize()
            @settings = Settings.new
            @organizations = []
            @coworkers = []
            @import_coworker = Coworker.new
            @import_coworker.integration_id = "import"
            @import_coworker.first_name = "Import"
            @coworkers.push @import_coworker
            @deals = []
            @notes = []
        end

        # Adds the specifed coworker object to the model.
        # @example Add a coworker from a hash
        #    rootmodel.add_coworker({
        #        :integration_id=>"123",
        #        :first_name=>"Kalle",
        #        :last_name=>"Anka",
        #        :email=>"<EMAIL>"
        #    })
        #
        # @example Add a coworker from a new coworker
        #    coworker = FruitToLime::Coworker.new
        #    coworker.integration_id = "123"
        #    coworker.first_name="Kalle"
        #    coworker.last_name="Anka"
        #    coworker.email = "<EMAIL>"
        #    rootmodel.add_coworker(coworker)
        #
        # @example If you want to keep adding coworkers and dont care about duplicates not being added
        #    begin
        #       rootmodel.add_coworker(coworker)
        #    rescue FruitToLime::AlreadyAddedError
        #       puts "Warning: already added coworker"
        #    end
        # @see Coworker
        def add_coworker(coworker)
            @coworkers = [] if @coworkers == nil

            if coworker == nil
                raise "Missing coworker to add!"
            end

            coworker = Coworker.new(coworker) if !coworker.is_a?(Coworker)

            if find_coworker_by_integration_id(coworker.integration_id) != nil
                raise AlreadyAddedError, "Already added a coworker with integration_id #{coworker.integration_id}"
            end

            @coworkers.push(coworker)

            return coworker
        end

        # Adds the specifed organization object to the model.
        # @example Add an organization from a hash
        #    rootmodel.add_organization({
        #        :integration_id => "123",
        #        :name => "<NAME>",
        #    })
        #
        # @example Add an organization from a new organization
        #    organization = FruitToLime::Organization.new
        #    organization.integration_id = "123"
        #    organization.name = "<NAME>"
        #    rootmodel.add_organization(organization)
        #
        # @example If you want to keep adding organizations and dont
        # care about duplicates not being added. Your model might not
        # be saved due to duplicate integration_ids.
        #    begin
        #       rootmodel.add_organization(organization)
        #    rescue FruitToLime::AlreadyAddedError
        #       puts "Warning: already added organization"
        #    end
        # @see Coworker
        def add_organization(organization)
            @organizations = [] if @organizations.nil?

            if organization.nil?
                raise "Missing organization to add"
            end

            organization = Organization.new(organization) if !organization.is_a?(Organization)

            if find_organization_by_integration_id(organization.integration_id) != nil
                raise AlreadyAddedError, "Already added an organization with integration_id #(organization.integration_id)"
            end

            @organizations.push(organization)

            return organization
        end

        # Adds the specifed deal object to the model.
        # @example Add an deal from a hash
        #    rootmodel.add_deal({
        #        :integration_id => "123",
        #        :name => "<NAME>",
        #    })
        #
        # @example Add a deal from a new deal
        #    deal = FruitToLime::Deal.new
        #    deal.integration_id = "123"
        #    deal.name = "<NAME>"
        #    rootmodel.add_deal(deal)
        #
        # @example If you want to keep adding deals and dont
        # care about duplicates not being added. Your model might not
        # be saved due to duplicate integration_ids.
        #    begin
        #       rootmodel.add_deal(deal)
        #    rescue FruitToLime::AlreadyAddedError
        #       puts "Warning: already added deal"
        #    end
        # @see Coworker
        def add_deal(deal)
            @deals = [] if @deals.nil?

            if deal.nil?
                raise "Missing deal to add"
            end

            deal = Deal.new(deal) if !deal.is_a?(Deal)

            if find_deal_by_integration_id(deal.integration_id) != nil
                raise AlreadyAddedError, "Already added a deal with integration_id #{deal.integration_id}"
            end

            if deal.responsible_coworker.nil?
                deal.responsible_coworker = @import_coworker
            end

            @deals.push(deal)

            return deal
        end

        # Adds the specifed note object to the model.
        # @example Add an deal from a hash
        #    rootmodel.add_note({
        #        :integration_id => "123",
        #        :text => "This is a note",
        #    })
{'fraction_non_alphanumeric': 0.08462896041684174, 'fraction_numerical': 0.003697789730229431, 'mean_word_length': 1.697800952165042, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 53, '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': '5984210', 'n_tokens_mistral': 3433, 'n_tokens_neox': 3270, 'n_words': 883}