Skip to contentPackage: StorageConnector
StorageConnector
Coverage
1: /**
2: * Copyright (C) 2023 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.jena.connector;
16:
17: import cz.cvut.kbss.ontodriver.Closeable;
18: import cz.cvut.kbss.ontodriver.Wrapper;
19: import cz.cvut.kbss.ontodriver.jena.exception.JenaDriverException;
20: import org.apache.jena.rdf.model.Property;
21: import org.apache.jena.rdf.model.RDFNode;
22: import org.apache.jena.rdf.model.Resource;
23: import org.apache.jena.rdf.model.Statement;
24:
25: import java.util.Collection;
26: import java.util.List;
27:
28: public interface StorageConnector extends Closeable, Wrapper, StatementExecutor {
29:
30: /**
31: * Begins a transaction.
32: */
33: void begin();
34:
35: /**
36: * Commits the current transaction.
37: *
38: * @throws JenaDriverException If commit fails
39: */
40: void commit() throws JenaDriverException;
41:
42: /**
43: * Rolls back the current transaction.
44: */
45: void rollback();
46:
47: /**
48: * Retrieves statements corresponding to the specified criteria from the specified named graph.
49: * <p>
50: * The first three parameters are optional, their absence signifies that any value in that position is acceptable.
51: * <p>
52: * {@code contexts} are also optional, their absence means that the default graph should be used.
53: *
54: * @param subject Statement subject, optional
55: * @param property Property, optional
56: * @param value Value, optional
57: * @param contexts Named graph IRIs, optional. If empty, the default graph will be used
58: * @return Collection of matching statements
59: */
60: Collection<Statement> find(Resource subject, Property property, RDFNode value, Collection<String> contexts);
61:
62: /**
63: * Checks whether the specified context (named graph) contains any statements matching the specified criteria.
64: * <p>
65: * The first three parameters are optional, their absence signifies that any value in that position is acceptable.
66: * <p>
67: * {@code context} is also optional, its absence means that the default graph should be used.
68: *
69: * @param subject Subject, optional
70: * @param property Property, optional
71: * @param value Value, optional
72: * @param contexts Named graph IRIs, optional. If empty, the default graph will be used
73: * @return {@code true} if at least one statement matches the criteria, {@code false} otherwise
74: */
75: boolean contains(Resource subject, Property property, RDFNode value, Collection<String> contexts);
76:
77: /**
78: * Lists all contexts (named graph) in the repository (including the transactional ones).
79: *
80: * @return List of named graph URIs
81: */
82: List<String> getContexts();
83:
84: /**
85: * Adds the specified statements to the specified context in the storage.
86: * <p>
87: * Requires an active transaction.
88: * <p>
89: * {@code context} is optional, its absence means that the statements will be added into the the default graph.
90: *
91: * @param statements Statements to add
92: * @param context Target context, optional
93: */
94: void add(List<Statement> statements, String context);
95:
96: /**
97: * Removes the specified statements from the specified context in the storage.
98: * <p>
99: * Requires an active transaction.
100: * <p>
101: * {@code context} is optional, its absence means that the statements will be removed from the the default graph.
102: *
103: * @param statements Statements to remove
104: * @param context Target context, optional
105: */
106: void remove(List<Statement> statements, String context);
107:
108: /**
109: * Removes statements matching the specified pattern from the specified storage context.
110: * <p>
111: * {@code context} is optional, its absence means that the statements will be removed from the the default graph.
112: *
113: * @param subject Statement subject, optional
114: * @param property Statement property, optional
115: * @param object Statement object, optional
116: * @param context Repository context IRI, optional
117: */
118: void remove(Resource subject, Property property, RDFNode object, String context);
119:
120: @Override
121: void close() throws JenaDriverException;
122: }