Skip to content

Package: Connector

Connector

Coverage

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