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

import java.net.URISyntaxException;
import java.util.ArrayList;
import nl.mpi.arbil.util.ArbilBugCatcher;
import nl.mpi.kinnate.gedcomimport.ImportException;
import nl.mpi.kinnate.kindata.DataTypes;
import nl.mpi.kinnate.uniqueidentifiers.UniqueIdentifier;
import nl.mpi.kinnate.svg.GraphPanel;
import org.w3c.dom.Document;

/**
 *  Document   : RelationLinker
 *  Created on : Apr 12, 2011, 1:45:01 PM
 *  Author     : <NAME>
 */
public class RelationLinker extends DocumentLoader {

    private void removeMatchingRelations(Document entityDocument, UniqueIdentifier[] selectedIdentifiers) {
        // todo: complete the relation removal code
        // todo: this should use the EntityData object to remove the relaitons and then save via jaxb as is done in linkEntities other wise if a user removes a sibling relation and the common parent relation persists then the data will be in a broken state
//        ArrayList<String> identifierList = new ArrayList<String>();
//        for (UniqueIdentifier uniqueIdentifier : selectedIdentifiers) {
//            identifierList.add(uniqueIdentifier.getQueryIdentifier());
//        }
//        Element roodNode = entityDocument.getDocumentElement();
//        NodeList entityNodeList = roodNode.getElementsByTagNameNS("http://mpi.nl/tla/kin", "Entity");
//        Element entityNode = ((Element) entityNodeList.item(0));
//        NodeList relationsNodeList = entityNode.getElementsByTagNameNS("http://mpi.nl/tla/kin", "Relations");
//        Node relationsGroupNode = relationsNodeList.item(0);
//        if (relationsGroupNode != null) {
//            for (Node relationNode = relationsGroupNode.getFirstChild(); relationNode != null; relationNode = relationNode.getNextSibling()) {
//                if ("Relation".equals(relationNode.getLocalName())) {
//                    if (identifierList.contains(relationNode.getFirstChild().getNodeValue())) {
//                        // remove the matching relations
//                        relationsGroupNode.removeChild(relationNode);
//                    }
//                }
//            }
//        }
//        try {
//            NodeList relationIdentifierNodeList = org.apache.xpath.XPathAPI.selectNodeList(entityDocument, "/Kinnate/kin:Entity/kin:Relations/kin:Relation/kin:Identifier", roodNode);
//            for (int nodeCounter = 0; nodeCounter < relationIdentifierNodeList.getLength(); nodeCounter++) {
//                Node identifierNode = relationIdentifierNodeList.item(nodeCounter);
//                if (identifierNode != null) {
//                    System.out.println(identifierNode.getLocalName() + " : " + identifierNode.getTextContent());<commit_msg>Refactored to match recent changes to Arbil so that singletons are not static but are injected via the constructor.<commit_after>package nl.mpi.kinnate.kindocument;

import java.net.URISyntaxException;
import java.util.ArrayList;
import nl.mpi.arbil.userstorage.SessionStorage;
import nl.mpi.arbil.util.ArbilBugCatcher;
import nl.mpi.arbil.util.MessageDialogHandler;
import nl.mpi.kinnate.entityindexer.EntityCollection;
import nl.mpi.kinnate.gedcomimport.ImportException;
import nl.mpi.kinnate.kindata.DataTypes;
import nl.mpi.kinnate.uniqueidentifiers.UniqueIdentifier;
import nl.mpi.kinnate.svg.GraphPanel;
import org.w3c.dom.Document;

/**
 *  Document   : RelationLinker
 *  Created on : Apr 12, 2011, 1:45:01 PM
 *  Author     : <NAME>
 */
public class RelationLinker extends DocumentLoader {

    public RelationLinker(SessionStorage sessionStorage, MessageDialogHandler dialogHandler, EntityCollection entityCollection) {
        super(sessionStorage, dialogHandler, entityCollection);
    }

    private void removeMatchingRelations(Document entityDocument, UniqueIdentifier[] selectedIdentifiers) {
        // todo: complete the relation removal code
        // todo: this should use the EntityData object to remove the relaitons and then save via jaxb as is done in linkEntities other wise if a user removes a sibling relation and the common parent relation persists then the data will be in a broken state
//        ArrayList<String> identifierList = new ArrayList<String>();
//        for (UniqueIdentifier uniqueIdentifier : selectedIdentifiers) {
//            identifierList.add(uniqueIdentifier.getQueryIdentifier());
//        }
//        Element roodNode = entityDocument.getDocumentElement();
//        NodeList entityNodeList = roodNode.getElementsByTagNameNS("http://mpi.nl/tla/kin", "Entity");
//        Element entityNode = ((Element) entityNodeList.item(0));
//        NodeList relationsNodeList = entityNode.getElementsByTagNameNS("http://mpi.nl/tla/kin", "Relations");
//        Node relationsGroupNode = relationsNodeList.item(0);
//        if (relationsGroupNode != null) {
//            for (Node relationNode = relationsGroupNode.getFirstChild(); relationNode != null; relationNode = relationNode.getNextSibling()) {
//                if ("Relation".equals(relationNode.getLocalName())) {
//                    if (identifierList.contains(relationNode.getFirstChild().getNodeValue())) {
//                        // remove the matching relations
//                        relationsGroupNode.removeChild(relationNode);
//                    }
//                }
//            }
//        }
//        try {
//            NodeList relationIdentifierNodeList = org.apache.xpath.XPathAPI.selectNodeList(entityDocument, "/Kinnate/kin:Entity/kin:Relations/kin:Relation/kin:Identifier", roodNode);
//            for (int nodeCounter = 0; nodeCounter < relationIdentifierNodeList.getLength(); nodeCounter++) {
//                Node identifierNode = relationIdentifierNodeList.item(nodeCounter);
//                if (identifierNode != null) {
//                    System.out.println(identifierNode.getLocalName() + " : " + identifierNode.getTextContent());
{'fraction_non_alphanumeric': 0.1081218274111675, 'fraction_numerical': 0.005076142131979695, 'mean_word_length': 3.0906574394463666, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '16820', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1531, 'n_words': 351}