Skip to content

Package: LocalModel

LocalModel

nameinstructionbranchcomplexitylinemethod
LocalModel()
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
addStatements(Collection)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
enhanceStatements(Collection, Resource, URI, Value, URI[])
M: 0 C: 32
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
getAddedStatements()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRemovedStatements()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
removeStatements(Collection)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

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 org.openrdf.model.*;
18: import org.openrdf.model.impl.LinkedHashModel;
19:
20: import java.util.Collection;
21:
22: /**
23: * Caches local transactional changes to the Sesame repository model.
24: *
25: * @author ledvima1
26: *
27: */
28: class LocalModel {
29:
30:         private final Model addedStatements;
31:         private final Model removedStatements;
32:
33:         LocalModel() {
34:                 this.addedStatements = new LinkedHashModel();
35:                 this.removedStatements = new LinkedHashModel();
36:         }
37:
38:         void enhanceStatements(Collection<Statement> statements, Resource subject, URI property,
39:                         Value object, URI... contexts) {
40:•                final URI[] ctxs = contexts != null ? contexts : new URI[0];
41:                 final Collection<Statement> added = addedStatements.filter(subject, property, object, ctxs);
42:                 statements.addAll(added);
43:                 final Collection<Statement> removed = removedStatements.filter(subject, property, object, ctxs);
44:                 statements.removeAll(removed);
45:         }
46:
47:         void addStatements(Collection<Statement> statements) {
48:                 removedStatements.removeAll(statements);
49:                 addedStatements.addAll(statements);
50:         }
51:
52:         void removeStatements(Collection<Statement> statements) {
53:                 addedStatements.removeAll(statements);
54:                 removedStatements.addAll(statements);
55:         }
56:
57:         Collection<Statement> getAddedStatements() {
58:                 return addedStatements;
59:         }
60:
61:         Collection<Statement> getRemovedStatements() {
62:                 return removedStatements;
63:         }
64: }