Skip to content

Package: Connector

Connector

Coverage

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