<commit_before>package org.eclipse.rdf4j.validation;


import org.eclipse.rdf4j.IsolationLevel;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.sail.NotifyingSailConnection;
import org.eclipse.rdf4j.sail.SailConnectionListener;
import org.eclipse.rdf4j.sail.SailException;
import org.eclipse.rdf4j.sail.helpers.NotifyingSailConnectionWrapper;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by heshanjayasinghe on 4/23/17.
 */
public class SHACLSailConnection extends NotifyingSailConnectionWrapper implements SailConnectionListener {

    private  SHACLSail sail;
    List<Statement> addedStatement = new ArrayList<Statement>();

    /**
     * Creates a new {@link org.eclipse.rdf4j.sail.helpers.NotifyingSailConnectionWrapper} object that wraps the supplied connection.
     *
     * @param wrappedCon
     */


    public SHACLSailConnection(NotifyingSailConnection wrappedCon) {
        super(wrappedCon);
    }

    public SHACLSailConnection(SHACLSail shaclSail) {
        super(null);
        this.sail = shaclSail;
    }

    @Override
    public void begin(IsolationLevel level) throws SailException {
        super.begin(level);
    }

    @Override
    public void statementAdded(Statement statement) {
        addedStatement.add(statement);
    }

    @Override
    public void statementRemoved(Statement st) {

    }

    @Override
    public void commit() throws SailException {
        super.commit();
        MoreDataCacheLayer getMoreDataCacheLayer = new MoreDataCacheLayer(this);
        sail.shapes.forEach(shape -> shape.validate(addedStatement, getMoreDataCacheLayer));
    }

    public void addShaclViolationListener(ShaclViolationListener shaclViolationListener) {

    }
}<commit_msg>add statement added and statement removed<commit_after>package org.eclipse.rdf4j.validation;

import org.eclipse.rdf4j.IsolationLevel;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.impl.TreeModel;
import org.eclipse.rdf4j.sail.NotifyingSailConnection;
import org.eclipse.rdf4j.sail.SailConnectionListener;
import org.eclipse.rdf4j.sail.SailException;
import org.eclipse.rdf4j.sail.helpers.NotifyingSailConnectionWrapper;

/**
 * Created by heshanjayasinghe on 4/23/17.
 */
public class SHACLSailConnection extends NotifyingSailConnectionWrapper
		implements SailConnectionListener {

	private SHACLSail sail;
	private boolean statementsRemoved;
	private Model newStatements;



	public SHACLSailConnection(SHACLSail shaclSail, NotifyingSailConnection connection) {
		super(connection);
		this.sail = shaclSail;

	}

	@Override
	public void begin(IsolationLevel level) throws SailException {
		super.begin(level);
	}

	@Override
	public void statementAdded(Statement statement) {
		if (statementsRemoved) {
			return;
		}

		if (newStatements == null) {
			newStatements = createModel();
		}
		newStatements.add(statement);
	}


	@Override
	public void statementRemoved(Statement statement) {
		boolean removed = (newStatements != null) ? newStatements.remove(statement) : false;
		if (!removed) {
			statementsRemoved = true;
			newStatements = null;
		}
	}



	@Override
	public void commit() throws SailException {
		super.commit();

	}

	protected Model createModel(){
		return new TreeModel();
	};


}
{'fraction_non_alphanumeric': 0.08948478457366676, 'fraction_numerical': 0.008134980415787888, 'mean_word_length': 4.32051282051282, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4826617', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1014, 'n_words': 201}