Skip to content

Package: Connector

Connector

Coverage

1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.ontodriver.owlapi.connector;
16:
17: import org.semanticweb.owlapi.model.OWLOntologyChange;
18:
19: import java.net.URI;
20: import java.util.List;
21: import java.util.function.Consumer;
22: import java.util.function.Function;
23:
24: /**
25: * Storage connector interface.
26: * <p>
27: * This interface declares the methods accessible from the driver.
28: */
29: public interface Connector {
30:
31: /**
32: * Gets logical URI of the ontology loaded by this connector.
33: *
34: * @return Ontology URI
35: */
36: URI getOntologyUri();
37:
38: /**
39: * Gets snapshot of the underlying ontology.
40: * <p>
41: * The snapshot is completely independent of the live ontology, so any changes to either are not visible to the
42: * other.
43: *
44: * @return Value object with the ontology snapshot
45: */
46: OntologySnapshot getOntologySnapshot();
47:
48: /**
49: * Executes read-only operation on the live ontology.
50: *
51: * @param function The function to execute
52: * @param <R> Result type
53: * @return Read result
54: */
55: <R> R executeRead(Function<OntologySnapshot, R> function);
56:
57: /**
58: * Executes a write operation on the live ontology.
59: *
60: * @param function The function to execute
61: */
62: void executeWrite(Consumer<OntologySnapshot> function);
63:
64: /**
65: * Applies the specified changes to the underlying ontology.
66: * <p>
67: * Note that this operation is atomic - the changes are applied as a whole and no other operation can be performed
68: * on the underlying ontology while the changes are being applied.
69: *
70: * @param changes The changes to apply
71: */
72: void applyChanges(List<OWLOntologyChange> changes);
73:
74: /**
75: * Closes the specified transactional snapshot.
76: * <p>
77: * This in particular means destroying the transactional ontology.
78: *
79: * @param snapshot The snapshot to close
80: */
81: void closeSnapshot(OntologySnapshot snapshot);
82: }