Skip to content

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