<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.daef.repositories;

import com.daef.models.Post;
import com.mongodb.WriteResult;
import java.util.List;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
/**
 *
 * @author Frederik
 */
public class PostRepositoryImpl implements PostInterface {

    @Autowired
    MongoTemplate mongoTemplate;
    
    @Override
    public void getAllPostByParentID(int id) {
        Query query = new Query(Criteria.where("PostParent").is(id));
        
        List<Post> list = mongoTemplate.find(query, Post.class);
        
        System.out.println("size: " + list.size());
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i).PostTitle);
        }
        System.out.println("done");
    }
    
}<commit_msg>done with this branch<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.daef.repositories;

import com.daef.models.Post;
import com.mongodb.WriteResult;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
/**
 *
 * @author Frederik
 */
public class PostRepositoryImpl implements PostInterface {

    @Autowired
    MongoTemplate mongoTemplate;
    
    @Override
    public void getAllPostByParentID(int id) {
        //the query to use
        Query query = new Query(Criteria.where("PostParent").is(id));
        
        //the end result. adds to this object, then returns it.
        List<Post> result = new ArrayList();
        
        //the first level of comments. the original comments on the post
        //NOT any comments on comments. yet.
        List<Post> list = mongoTemplate.find(query, Post.class);
        
        //a stack to easily add and remove from.
        Stack<Post> stack = new Stack();
        stack.addAll(list);
        
        //loop until the stack is empty
        while(!stack.isEmpty()){
            Post p = stack.pop();
            result.add(p);
            query = new Query(Criteria.where("PostParent").is(p.HanesstID));
            List<Post> tmpList = mongoTemplate.find(query, Post.class);
            stack.addAll(tmpList);
            
        }
        
        
    }
    
}
{'fraction_non_alphanumeric': 0.1069204152249135, 'fraction_numerical': 0.00034602076124567473, 'mean_word_length': 2.7594278283485045, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, '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': '2140558', 'n_tokens_mistral': 813, 'n_tokens_neox': 806, 'n_words': 217}