Skip to content

Package: StorageConnector

StorageConnector

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.ontodriver.jena.connector;
14:
15: import cz.cvut.kbss.ontodriver.Closeable;
16: import cz.cvut.kbss.ontodriver.Wrapper;
17: import cz.cvut.kbss.ontodriver.jena.exception.JenaDriverException;
18: import org.apache.jena.rdf.model.Property;
19: import org.apache.jena.rdf.model.RDFNode;
20: import org.apache.jena.rdf.model.Resource;
21: import org.apache.jena.rdf.model.Statement;
22:
23: import java.util.Collection;
24: import java.util.List;
25:
26: public interface StorageConnector extends Closeable, Wrapper, StatementExecutor {
27:
28: /**
29: * Begins a transaction.
30: */
31: void begin();
32:
33: /**
34: * Commits the current transaction.
35: */
36: void commit() throws JenaDriverException;
37:
38: /**
39: * Rolls back the current transaction.
40: */
41: void rollback();
42:
43: /**
44: * Retrieves statements corresponding to the specified criteria from the specified named graph.
45: * <p>
46: * The first three parameters are optional, their absence signifies that any value in that position is acceptable.
47: * <p>
48: * {@code contexts} are also optional, their absence means that the default graph should be used.
49: *
50: * @param subject Statement subject, optional
51: * @param property Property, optional
52: * @param value Value, optional
53: * @param contexts Named graph IRIs, optional. If empty, the default graph will be used
54: * @return Collection of matching statements
55: */
56: Collection<Statement> find(Resource subject, Property property, RDFNode value, Collection<String> contexts);
57:
58: /**
59: * Checks whether the specified context (named graph) contains any statements matching the specified criteria.
60: * <p>
61: * The first three parameters are optional, their absence signifies that any value in that position is acceptable.
62: * <p>
63: * {@code context} is also optional, its absence means that the default graph should be used.
64: *
65: * @param subject Subject, optional
66: * @param property Property, optional
67: * @param value Value, optional
68: * @param contexts Named graph IRIs, optional. If empty, the default graph will be used
69: * @return {@code true} if at least one statement matches the criteria, {@code false} otherwise
70: */
71: boolean contains(Resource subject, Property property, RDFNode value, Collection<String> contexts);
72:
73: /**
74: * Lists all contexts (named graph) in the repository (including the transactional ones).
75: *
76: * @return List of named graph URIs
77: */
78: List<String> getContexts();
79:
80: /**
81: * Adds the specified statements to the specified context in the storage.
82: * <p>
83: * Requires an active transaction.
84: * <p>
85: * {@code context} is optional, its absence means that the statements will be added into the the default graph.
86: *
87: * @param statements Statements to add
88: * @param context Target context, optional
89: */
90: void add(List<Statement> statements, String context);
91:
92: /**
93: * Removes the specified statements from the specified context in the storage.
94: * <p>
95: * Requires an active transaction.
96: * <p>
97: * {@code context} is optional, its absence means that the statements will be removed from the the default graph.
98: *
99: * @param statements Statements to remove
100: * @param context Target context, optional
101: */
102: void remove(List<Statement> statements, String context);
103:
104: /**
105: * Removes statements matching the specified pattern from the specified storage context.
106: * <p>
107: * {@code context} is optional, its absence means that the statements will be removed from the the default graph.
108: *
109: * @param subject Statement subject, optional
110: * @param property Statement property, optional
111: * @param object Statement object, optional
112: * @param context Repository context IRI, optional
113: */
114: void remove(Resource subject, Property property, RDFNode object, String context);
115:
116: @Override
117: void close() throws JenaDriverException;
118: }