<commit_before>module Ecore
  module DocumentHierarchy

    # returns the full path of this document in the repository
    # including it's id
    def absolute_path
      "#{@path}/#{@id}"
    end

    # prepares statement to receive
    # children of current document
    #
    # if :type option is given, only documents of this type will be fetched
    #
    # example:
    #   mydocument.children(:type => Folder)
    #   # => [<Child1>,<Child2>]
    #
    # example:
    #   mydocument.children(:exec => false).where(:name => 'test').receive(:all)
    #
    def children(options={:type => nil, :get_dataset => false, :recursive => false, :reload => false, :preconditions => {:hidden => false}})
      return @children_cache if @children_cache and !options[:get_dataset] and !options[:reload]
      klass = Ecore::db[:documents]
      if options[:type]
        raise(TypeError, ":type must be an Ecore::DocumentResource") unless options[:type].respond_to?(:table_name)
        klass = Ecore::db[:"#{options[:type].table_name}"]
      end
      query = klass.store_preconditions((@group_ids || @user_id),self.class.get_type_if_has_superclass,self,nil,(options[:preconditions] || {:hidden => false}))
      query = ( options[:recursive] ? query.where(:path.like("#{absolute_path}%")) : query.where(:path => absolute_path) )
      return query if options[:get_dataset]
      @children_cache = query.order(:position,:name).receive(:all)
    end

    # extracts last id from path (which should be parent_id)
    def parent_id
      @path.split('/').last
    end

    # Sets the parent_id (and calculates the full path of parent, so it can
    # be set without any further effort.
    def parent_id=(p_id)
      return if p_id.empty? || p_id == parent_id
      user_id = @user_id
      if @group_ids
        user_id = @group_ids
      else
        if u = Ecore::User.first(@user_id)
          user_id = u.id_and_group_ids
        end
      end
      @parent_cache = Ecore::Document.find(user_id, :hidden => true).filter(:id => p_id).receive
      @old_path = self.path
      self.path = @parent_cache.absolute_path
      @path_changed = self.path<commit_msg>return if parent_id == nil<commit_after>module Ecore
  module DocumentHierarchy

    # returns the full path of this document in the repository
    # including it's id
    def absolute_path
      "#{@path}/#{@id}"
    end

    # prepares statement to receive
    # children of current document
    #
    # if :type option is given, only documents of this type will be fetched
    #
    # example:
    #   mydocument.children(:type => Folder)
    #   # => [<Child1>,<Child2>]
    #
    # example:
    #   mydocument.children(:exec => false).where(:name => 'test').receive(:all)
    #
    def children(options={:type => nil, :get_dataset => false, :recursive => false, :reload => false, :preconditions => {:hidden => false}})
      return @children_cache if @children_cache and !options[:get_dataset] and !options[:reload]
      klass = Ecore::db[:documents]
      if options[:type]
        raise(TypeError, ":type must be an Ecore::DocumentResource") unless options[:type].respond_to?(:table_name)
        klass = Ecore::db[:"#{options[:type].table_name}"]
      end
      query = klass.store_preconditions((@group_ids || @user_id),self.class.get_type_if_has_superclass,self,nil,(options[:preconditions] || {:hidden => false}))
      query = ( options[:recursive] ? query.where(:path.like("#{absolute_path}%")) : query.where(:path => absolute_path) )
      return query if options[:get_dataset]
      @children_cache = query.order(:position,:name).receive(:all)
    end

    # extracts last id from path (which should be parent_id)
    def parent_id
      @path.split('/').last
    end

    # Sets the parent_id (and calculates the full path of parent, so it can
    # be set without any further effort.
    def parent_id=(p_id)
      return if p_id.nil? || p_id.empty? || p_id == parent_id
      user_id = @user_id
      if @group_ids
        user_id = @group_ids
      else
        if u = Ecore::User.first(@user_id)
          user_id = u.id_and_group_ids
        end
      end
      @parent_cache = Ecore::Document.find(user_id, :hidden => true).filter(:id => p_id).receive
      @old_path = self.path
      self.path = @parent_cache.absolute_path
      @path_changed = self.path
{'fraction_non_alphanumeric': 0.13191881918819187, 'fraction_numerical': 0.0009225092250922509, 'mean_word_length': 3.1462715105162524, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 35, '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': '1532546', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1327, 'n_words': 335}