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