cz.cvut.kbss.ontodriver.owlapi.OwlapiProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontodriver-owlapi Show documentation
Show all versions of ontodriver-owlapi Show documentation
OWLAPI-based implementation of the OntoDriver API
The newest version!
/*
* JOPA
* Copyright (C) 2024 Czech Technical University in Prague
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package cz.cvut.kbss.ontodriver.owlapi;
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.owlapi.exception.OwlapiDriverException;
import cz.cvut.kbss.ontodriver.owlapi.util.Procedure;
import java.net.URI;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import static cz.cvut.kbss.ontodriver.util.ErrorUtils.getNPXMessageSupplier;
public class OwlapiProperties implements Properties {
private final OwlapiAdapter adapter;
private final Procedure beforeCallback;
private final Procedure afterChangeCallback;
public OwlapiProperties(OwlapiAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
this.afterChangeCallback = afterChangeCallback;
this.beforeCallback = beforeCallback;
this.adapter = adapter;
}
@Override
public Collection> getProperties(NamedResource individual, URI context, boolean includeInferred)
throws OntoDriverException {
Objects.requireNonNull(individual, getNPXMessageSupplier("individual"));
beforeCallback.execute();
return adapter.getPropertiesHandler().getProperties(individual, includeInferred);
}
@Override
public void addProperties(NamedResource individual, URI context, Map>> properties)
throws OntoDriverException {
ensureValidity(individual, properties);
if (!properties.isEmpty()) {
adapter.getPropertiesHandler().addProperties(individual, properties);
}
afterChangeCallback.execute();
}
private void ensureValidity(NamedResource individual, Map>> properties)
throws OwlapiDriverException {
Objects.requireNonNull(individual, getNPXMessageSupplier("individual"));
Objects.requireNonNull(properties, getNPXMessageSupplier("properties"));
beforeCallback.execute();
}
@Override
public void removeProperties(NamedResource individual, URI context, Map>> properties)
throws OntoDriverException {
ensureValidity(individual, properties);
if (!properties.isEmpty()) {
adapter.getPropertiesHandler().removeProperties(individual, properties);
}
afterChangeCallback.execute();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy