<commit_before>package nl.mpi.kinnate.kindocument;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import nl.mpi.arbil.userstorage.SessionStorage;
import nl.mpi.arbil.util.BugCatcher;
import nl.mpi.arbil.util.MessageDialogHandler;
import nl.mpi.kinnate.entityindexer.EntityCollection;
import nl.mpi.kinnate.gedcomimport.ImportException;
import nl.mpi.kinnate.kindata.EntityRelation;
import nl.mpi.kinnate.uniqueidentifiers.UniqueIdentifier;

/**
 *  Document   : DocumentLoader
 *  Created on : Sep 28, 2011, 2:21:15 PM
 *  Author     : <NAME>
 */
public class DocumentLoader {

    protected SessionStorage sessionStorage;
    private MessageDialogHandler dialogHandler;
    protected HashMap<UniqueIdentifier, EntityDocument> entityMap = new HashMap<UniqueIdentifier, EntityDocument>();
    private EntityCollection entityCollection;
    protected BugCatcher bugCatcher;

    public DocumentLoader(SessionStorage sessionStorage, MessageDialogHandler dialogHandler, EntityCollection entityCollection, BugCatcher bugCatcher) {
        this.sessionStorage = sessionStorage;
        this.dialogHandler = dialogHandler;
        this.entityCollection = entityCollection;
        this.bugCatcher = bugCatcher;
    }

    protected EntityDocument getEntityDocument(UniqueIdentifier selectedIdentifier) throws ImportException, URISyntaxException {
        EntityDocument entityDocument = new EntityDocument(new URI(new EntityCollection(sessionStorage, dialogHandler, bugCatcher).getEntityPath(selectedIdentifier)), new ImportTranslator(true), sessionStorage);
//        System.out.println("Loaded 1: " + entityDocument.entityData.getUniqueIdentifier().getAttributeIdentifier());
        entityMap.put(entityDocument.entityData.getUniqueIdentifier(), entityDocument);
        for (EntityRelation entityRelation : entityDocument.entityData.getAllRelations()) {
            EntityDocument relatedDocument = entityMap.get(entityRelation.alterUniqueIdentifier);
            if (relatedDocument == null) {
                // get the path from the database
                final URI entityUri = new URI(new EntityCollection(sessionStorage, dialogHandler, bugCatcher).getEntityPath(entityRelation.alterUniqueIdentifier));
                relatedDocument = new EntityDocument(entityUri, new ImportTranslator(true), sessionStorage);
//                System.out.println("Loaded 2: " + entityRelation.alterUniqueIdentifier.getAttributeIdentifier());
                entityMap.put(entityRelation.alterUniqueIdentifier, relatedDocument);
            }
        }
        linkLoadedEntities();
        return entityDocument;
    }

    protected EntityDocument getEntityDocuments(UniqueIdentifier[] selectedIdentifiers, ArrayList<EntityDocument> entityDocumentList) throws ImportException, URISyntaxException {
        EntityDocument leadEntityDocument = null;
        for (UniqueIdentifier uniqueIdentifier : selectedIdentifiers) {
            EntityDocument entityDocument = getEntityDocument(uniqueIdentifier);
            if (leadEntityDocument == null) {
                leadEntityDocument = entityDocument;
            } else {
                entityDocumentList.add(entityDocument);
            }<commit_msg>Updated to the latest Arbil version and made the changes required for the bug catcher modifications.<commit_after>package nl.mpi.kinnate.kindocument;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import nl.mpi.arbil.userstorage.SessionStorage;
import nl.mpi.arbil.util.BugCatcher;
import nl.mpi.arbil.util.MessageDialogHandler;
import nl.mpi.kinnate.entityindexer.EntityCollection;
import nl.mpi.kinnate.gedcomimport.ImportException;
import nl.mpi.kinnate.kindata.EntityRelation;
import nl.mpi.kinnate.uniqueidentifiers.UniqueIdentifier;

/**
 *  Document   : DocumentLoader
 *  Created on : Sep 28, 2011, 2:21:15 PM
 *  Author     : <NAME>
 */
public class DocumentLoader {

    protected SessionStorage sessionStorage;
    private MessageDialogHandler dialogHandler;
    protected HashMap<UniqueIdentifier, EntityDocument> entityMap = new HashMap<UniqueIdentifier, EntityDocument>();
    private EntityCollection entityCollection;

    public DocumentLoader(SessionStorage sessionStorage, MessageDialogHandler dialogHandler, EntityCollection entityCollection) {
        this.sessionStorage = sessionStorage;
        this.dialogHandler = dialogHandler;
        this.entityCollection = entityCollection;
    }

    protected EntityDocument getEntityDocument(UniqueIdentifier selectedIdentifier) throws ImportException, URISyntaxException {
        EntityDocument entityDocument = new EntityDocument(new URI(new EntityCollection(sessionStorage, dialogHandler).getEntityPath(selectedIdentifier)), new ImportTranslator(true), sessionStorage);
//        System.out.println("Loaded 1: " + entityDocument.entityData.getUniqueIdentifier().getAttributeIdentifier());
        entityMap.put(entityDocument.entityData.getUniqueIdentifier(), entityDocument);
        for (EntityRelation entityRelation : entityDocument.entityData.getAllRelations()) {
            EntityDocument relatedDocument = entityMap.get(entityRelation.alterUniqueIdentifier);
            if (relatedDocument == null) {
                // get the path from the database
                final URI entityUri = new URI(new EntityCollection(sessionStorage, dialogHandler).getEntityPath(entityRelation.alterUniqueIdentifier));
                relatedDocument = new EntityDocument(entityUri, new ImportTranslator(true), sessionStorage);
//                System.out.println("Loaded 2: " + entityRelation.alterUniqueIdentifier.getAttributeIdentifier());
                entityMap.put(entityRelation.alterUniqueIdentifier, relatedDocument);
            }
        }
        linkLoadedEntities();
        return entityDocument;
    }

    protected EntityDocument getEntityDocuments(UniqueIdentifier[] selectedIdentifiers, ArrayList<EntityDocument> entityDocumentList) throws ImportException, URISyntaxException {
        EntityDocument leadEntityDocument = null;
        for (UniqueIdentifier uniqueIdentifier : selectedIdentifiers) {
            EntityDocument entityDocument = getEntityDocument(uniqueIdentifier);
            if (leadEntityDocument == null) {
                leadEntityDocument = entityDocument;
            } else {
                entityDocumentList.add(entityDocument);
            }
{'fraction_non_alphanumeric': 0.07778978237382313, 'fraction_numerical': 0.004012964963728971, 'mean_word_length': 4.118483412322274, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2561837', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1525, 'n_words': 328}