Skip to content

Package: StorageConnector

StorageConnector

Coverage

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