Skip to contentPackage: Connector
Connector
Coverage
1: /**
2: * Copyright (C) 2016 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.sesame.connector;
16:
17: import cz.cvut.kbss.ontodriver.Closeable;
18: import cz.cvut.kbss.ontodriver.Wrapper;
19: import cz.cvut.kbss.ontodriver.sesame.exceptions.SesameDriverException;
20: import org.eclipse.rdf4j.model.*;
21:
22: import java.util.Collection;
23: import java.util.List;
24:
25: public interface Connector extends Closeable, StatementExecutor, Wrapper {
26:
27: /**
28: * Explicitly starts a transaction.
29: *
30: * @throws SesameDriverException If unable to start transaction
31: */
32: void begin() throws SesameDriverException;
33:
34: /**
35: * Commits the changes made since transaction beginning.
36: *
37: * @throws SesameDriverException If an error occurs during commit
38: * @see #begin()
39: */
40: void commit() throws SesameDriverException;
41:
42: /**
43: * Rolls back changes made since transaction beginning.
44: *
45: * @throws SesameDriverException If an error occurs when rolling back
46: * @see #begin()
47: */
48: void rollback() throws SesameDriverException;
49:
50: /**
51: * Gets resources representing currently existing contexts in the repository.
52: *
53: * @return List of resources
54: * @throws SesameDriverException If repository access error occurs
55: */
56: List<Resource> getContexts() throws SesameDriverException;
57:
58: /**
59: * Gets Sesame value factory.
60: *
61: * @return {@link ValueFactory}
62: */
63: ValueFactory getValueFactory();
64:
65: /**
66: * Finds statements corresponding to the specified criteria.
67: * <p>
68: * Note that some of the parameters are optional.
69: * <p>
70: * This version searches the default context.
71: *
72: * @param subject Statement subject, optional
73: * @param property Statement property, optional
74: * @param value Statement value, optional
75: * @param includeInferred Whether to include inferred statements as well
76: * @return Collection of matching statements
77: * @throws SesameDriverException If a repository access error occurs
78: * @see #findStatements(Resource, IRI, Value, boolean, IRI)
79: */
80: Collection<Statement> findStatements(Resource subject, IRI property, Value value, boolean includeInferred)
81: throws SesameDriverException;
82:
83: /**
84: * Finds statements corresponding to the specified criteria.
85: * <p>
86: * Note that some of the parameters are optional
87: *
88: * @param subject Statement subject, optional
89: * @param property Statement property, optional
90: * @param value Statement value, optional
91: * @param includeInferred Whether to include inferred statements as well
92: * @param context Optionally specify context in which the search should be performed. If not specified, the
93: * default one is used
94: * @return Collection of matching statements
95: * @throws SesameDriverException If a repository access error occurs
96: */
97: Collection<Statement> findStatements(Resource subject, IRI property, Value value,
98: boolean includeInferred, IRI context) throws SesameDriverException;
99:
100: /**
101: * Checks whether the repository contains any statements matching the specified criteria.
102: * <p>
103: * This version searches the default context.
104: *
105: * @param subject Statement subject, optional
106: * @param property Statement property, optional
107: * @param value Statement value, optional
108: * @param includeInferred Whether to include inferred statements as well
109: * @return Boolean indicating whether the statement exists
110: * @throws SesameDriverException If a repository access error occurs
111: * @see #containsStatement(Resource, IRI, Value, boolean, IRI)
112: */
113: boolean containsStatement(Resource subject, IRI property, Value value, boolean includeInferred)
114: throws SesameDriverException;
115:
116: /**
117: * Checks whether the repository contains any statements matching the specified criteria.
118: *
119: * @param subject Statement subject, optional
120: * @param property Statement property, optional
121: * @param value Statement value, optional
122: * @param includeInferred Whether to include inferred statements as well
123: * @param context Optionally specify context in which the search should be performed. If not specified, the
124: * default one is used
125: * @return Boolean indicating whether the statement exists
126: * @throws SesameDriverException If a repository access error occurs
127: */
128: boolean containsStatement(Resource subject, IRI property, Value value, boolean includeInferred, IRI context)
129: throws SesameDriverException;
130:
131: /**
132: * Adds the specified statements to the underlying repository.
133: * <p>
134: * Note that this operation is transactional and the changes are required to
135: * be persistent only after successful {@link #commit()}.
136: *
137: * @param statements The statements to add
138: * @throws IllegalStateException If transaction is not active
139: * @throws SesameDriverException If a repository access error occurs
140: */
141: void addStatements(Collection<Statement> statements) throws SesameDriverException;
142:
143: /**
144: * Removes the specified statements from the underlying repository.
145: * <p>
146: * Note that this operation is transactional and the changes are required to
147: * be persistent only after successful {@link #commit()}.
148: *
149: * @param statements The statements to remove
150: * @throws IllegalStateException If transaction is not active
151: * @throws SesameDriverException If a repository access error occurs
152: */
153: void removeStatements(Collection<Statement> statements) throws SesameDriverException;
154: }