<commit_before>package org.protempa.bp.commons.dsb.sqlgen;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.protempa.proposition.Proposition;
import org.protempa.proposition.UniqueIdentifier;

abstract class RefResultProcessor<P extends Proposition> extends
        AbstractResultProcessor {
    private ReferenceSpec referenceSpec;
    private ResultCache<P> cache;

    protected RefResultProcessor() {
    }

    @Override
    public final void process(ResultSet resultSet) throws SQLException {
        EntitySpec entitySpec = getEntitySpec();
        while (resultSet.next()) {
            int i = 1;
            String[] uniqueIds = new String[entitySpec.getUniqueIdSpecs().length];
            i = readUniqueIds(uniqueIds, resultSet, i);
            UniqueIdentifier uniqueIdentifier = generateUniqueIdentifier(
                    entitySpec.getName(), uniqueIds);
            String[] refUniqueIds = new String[this.referenceSpec
                    .getUniqueIdSpecs().length];
            i = readUniqueIds(refUniqueIds, resultSet, i);
            UniqueIdentifier refUniqueIdentifier = generateUniqueIdentifier(
                    this.referenceSpec.getEntityName(), refUniqueIds);
            addToReferences(uniqueIdentifier, refUniqueIdentifier);
        }
    }

    private final void addToReferences(UniqueIdentifier uniqueIdentifier,
            UniqueIdentifier refUniqueIdentifier) {
        P proposition = this.cache.getProposition(uniqueIdentifier);
        assert proposition != null : "No proposition for unique identifier "
                + uniqueIdentifier;
        addReferenceForProposition(this.referenceSpec.getReferenceName(),
                proposition, refUniqueIdentifier);
    }

    abstract void addReferenceForProposition(String referenceName,
            P proposition, UniqueIdentifier uid);

    final void setCache(ResultCache<P> cache) {
        this.cache = cache;
    }

    final ResultCache<P> getCache() {
        return this.cache;
    }

    final ReferenceSpec getReferenceSpec() {
        return this.referenceSpec;
    }

    final void setReferenceSpec(ReferenceSpec referenceSpec) {
        this.referenceSpec = referenceSpec;
    }
}<commit_msg>updated addToReferences() to make sure that the updated Proposition (with new reference added) is put back into the ResultCache object.<commit_after>package org.protempa.bp.commons.dsb.sqlgen;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.protempa.proposition.Proposition;
import org.protempa.proposition.UniqueIdentifier;

abstract class RefResultProcessor<P extends Proposition> extends
        AbstractResultProcessor {
    private ReferenceSpec referenceSpec;
    private ResultCache<P> cache;

    protected RefResultProcessor() {
    }

    @Override
    public final void process(ResultSet resultSet) throws SQLException {
        EntitySpec entitySpec = getEntitySpec();
        while (resultSet.next()) {
            int i = 1;
            String[] uniqueIds = new String[entitySpec.getUniqueIdSpecs().length];
            i = readUniqueIds(uniqueIds, resultSet, i);
            UniqueIdentifier uniqueIdentifier = generateUniqueIdentifier(
                    entitySpec.getName(), uniqueIds);
            String[] refUniqueIds = new String[this.referenceSpec
                    .getUniqueIdSpecs().length];
            i = readUniqueIds(refUniqueIds, resultSet, i);
            UniqueIdentifier refUniqueIdentifier = generateUniqueIdentifier(
                    this.referenceSpec.getEntityName(), refUniqueIds);
            addToReferences(uniqueIdentifier, refUniqueIdentifier);
        }
    }

    private final void addToReferences(UniqueIdentifier uniqueIdentifier,
            UniqueIdentifier refUniqueIdentifier) {
        P proposition = this.cache.getProposition(uniqueIdentifier);
        assert proposition != null : "No proposition for unique identifier "
                + uniqueIdentifier;
        addReferenceForProposition(this.referenceSpec.getReferenceName(),
                proposition, refUniqueIdentifier);
        this.cache.put(uniqueIdentifier, proposition);
    }

    abstract void addReferenceForProposition(String referenceName,
            P proposition, UniqueIdentifier uid);

    final void setCache(ResultCache<P> cache) {
        this.cache = cache;
    }

    final ResultCache<P> getCache() {
        return this.cache;
    }

    final ReferenceSpec getReferenceSpec() {
        return this.referenceSpec;
    }

    final void setReferenceSpec(ReferenceSpec referenceSpec) {
        this.referenceSpec = referenceSpec;
    }
}
{'fraction_non_alphanumeric': 0.07536169293889008, 'fraction_numerical': 0.0004318721658389117, 'mean_word_length': 2.955593509820666, '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': '835294', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1079, 'n_words': 265}