Package: DefaultContextInferenceStatementLoader
DefaultContextInferenceStatementLoader
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DefaultContextInferenceStatementLoader(RepoConnection, Resource, AxiomBuilder) |
|
|
|
|
|
||||||||||||||||||||
contextMatches(Set, Statement, Assertion) |
|
|
|
|
|
||||||||||||||||||||
loadAxioms(Set) |
|
|
|
|
|
||||||||||||||||||||
resolveContexts(AxiomDescriptor, Assertion) |
|
|
|
|
|
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2023 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.rdf4j.loader;
19:
20: import cz.cvut.kbss.ontodriver.descriptor.AxiomDescriptor;
21: import cz.cvut.kbss.ontodriver.model.Assertion;
22: import cz.cvut.kbss.ontodriver.model.Axiom;
23: import cz.cvut.kbss.ontodriver.rdf4j.connector.RepoConnection;
24: import cz.cvut.kbss.ontodriver.rdf4j.exception.Rdf4jDriverException;
25: import cz.cvut.kbss.ontodriver.rdf4j.util.AxiomBuilder;
26: import org.eclipse.rdf4j.model.Resource;
27: import org.eclipse.rdf4j.model.Statement;
28: import cz.cvut.kbss.ontodriver.rdf4j.config.Rdf4jOntoDriverProperties;
29:
30: import java.net.URI;
31: import java.util.Collection;
32: import java.util.Collections;
33: import java.util.Set;
34:
35: /**
36: * Implements loading of inferred statements from the default repository context.
37: *
38: * @see Rdf4jOntoDriverProperties#INFERENCE_IN_DEFAULT_CONTEXT
39: */
40: public class DefaultContextInferenceStatementLoader extends StatementLoader {
41:
42: public DefaultContextInferenceStatementLoader(RepoConnection connector, Resource subject, AxiomBuilder axiomBuilder) {
43: super(connector, subject, axiomBuilder);
44: }
45:
46: @Override
47: protected Set<URI> resolveContexts(AxiomDescriptor descriptor, Assertion a) {
48:• return includeInferred && a.isInferred() ? Collections.emptySet() : super.resolveContexts(descriptor, a);
49: }
50:
51: @Override
52: protected boolean contextMatches(Set<URI> assertionCtx, Statement s, Assertion a) {
53:• if (includeInferred && a.isInferred()) {
54: return true;
55: }
56: return super.contextMatches(assertionCtx, s, a);
57: }
58:
59: @Override
60: public Collection<Axiom<?>> loadAxioms(Set<URI> contexts) throws Rdf4jDriverException {
61:• return super.loadAxioms(includeInferred ? Collections.emptySet() : contexts);
62: }
63: }