Skip to content

Package: InferredAxiomLoader

InferredAxiomLoader

nameinstructionbranchcomplexitylinemethod
InferredAxiomLoader(InferredStorageConnector)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
contains(Resource, Property, RDFNode, URI)
M: 0 C: 13
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
find(AxiomDescriptor, Map)
M: 0 C: 44
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
findStatements(Resource, Property, URI)
M: 0 C: 13
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$find$1(Assertion, List, AxiomDescriptor, Statement)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
lambda$null$0(List, AxiomDescriptor, Assertion, Value)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 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.jena;
16:
17: import cz.cvut.kbss.ontodriver.descriptor.AxiomDescriptor;
18: import cz.cvut.kbss.ontodriver.jena.connector.InferredStorageConnector;
19: import cz.cvut.kbss.ontodriver.model.Assertion;
20: import cz.cvut.kbss.ontodriver.model.Axiom;
21: import cz.cvut.kbss.ontodriver.model.AxiomImpl;
22: import cz.cvut.kbss.ontodriver.model.Value;
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.net.URI;
29: import java.util.*;
30:
31: import static org.apache.jena.rdf.model.ResourceFactory.createProperty;
32: import static org.apache.jena.rdf.model.ResourceFactory.createResource;
33:
34: class InferredAxiomLoader extends AbstractAxiomLoader {
35:
36: private final InferredStorageConnector connector;
37:
38: InferredAxiomLoader(InferredStorageConnector connector) {
39: this.connector = connector;
40: this.inferred = true;
41: }
42:
43: @Override
44: boolean contains(Resource subject, Property property, RDFNode object, URI context) {
45:• return connector.containsWithInference(subject, property, object, context != null ? context.toString() : null);
46: }
47:
48: @Override
49: List<Axiom<?>> find(AxiomDescriptor descriptor, Map<String, Assertion> assertions) {
50: final List<Axiom<?>> result = new ArrayList<>();
51: final Resource subject = createResource(descriptor.getSubject().getIdentifier().toString());
52:• for (Assertion a : assertions.values()) {
53: final Property property = createProperty(a.getIdentifier().toString());
54: final Collection<Statement> statements =
55: findStatements(subject, property, descriptor.getAssertionContext(a));
56: statements.forEach(s -> {
57: final Optional<Value<?>> value = resolveValue(a, s.getObject());
58: value.ifPresent(v -> result.add(new AxiomImpl<>(descriptor.getSubject(), a, v)));
59: });
60: }
61: return result;
62: }
63:
64: @Override
65: Collection<Statement> findStatements(Resource subject, Property property, URI context) {
66:• return connector.findWithInference(subject, property, null, context != null ? context.toString() : null);
67: }
68: }