cz.cvut.kbss.ontodriver.sesame.SesameProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontodriver-sesame Show documentation
Show all versions of ontodriver-sesame Show documentation
Sesame implementation of the OntoDriver API
/**
* Copyright (C) 2020 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package cz.cvut.kbss.ontodriver.sesame;
import cz.cvut.kbss.ontodriver.Properties;
import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
import cz.cvut.kbss.ontodriver.model.Assertion;
import cz.cvut.kbss.ontodriver.model.Axiom;
import cz.cvut.kbss.ontodriver.model.NamedResource;
import cz.cvut.kbss.ontodriver.model.Value;
import cz.cvut.kbss.ontodriver.sesame.config.RuntimeConfiguration;
import cz.cvut.kbss.ontodriver.sesame.connector.Connector;
import cz.cvut.kbss.ontodriver.sesame.exceptions.SesameDriverException;
import org.eclipse.rdf4j.model.ValueFactory;
import java.net.URI;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
class SesameProperties implements Properties {
private final Connector connector;
private final ValueFactory valueFactory;
private final RuntimeConfiguration config;
private final Procedure beforeCallback;
private final Procedure afterChangeCallback;
public SesameProperties(SesameAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
this.connector = adapter.getConnector();
this.valueFactory = adapter.getValueFactory();
this.config = adapter.getConfig();
this.beforeCallback = beforeCallback;
this.afterChangeCallback = afterChangeCallback;
}
@Override
public Collection> getProperties(NamedResource individual, URI context, boolean includeInferred)
throws SesameDriverException {
beforeCallback.execute();
return new AxiomLoader(connector, valueFactory, config).loadAxioms(individual, includeInferred, context);
}
@Override
public void addProperties(NamedResource individual, URI context, Map>> properties)
throws OntoDriverException {
beforeCallback.execute();
new AxiomSaver(connector, valueFactory).persistAxioms(individual, properties, context);
afterChangeCallback.execute();
}
@Override
public void removeProperties(NamedResource individual, URI context, Map>> properties)
throws OntoDriverException {
new EpistemicAxiomRemover(connector, valueFactory).remove(individual, properties, context);
afterChangeCallback.execute();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy