Skip to content

Package: ReferencedListPropertyStrategy

ReferencedListPropertyStrategy

nameinstructionbranchcomplexitylinemethod
ReferencedListPropertyStrategy(EntityType, ListAttributeImpl, Descriptor, EntityMappingHelper)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addValueFromAxiom(Axiom)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
createListDescriptor(Axiom)
M: 0 C: 46
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
createListValueDescriptor(Object)
M: 0 C: 53
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 11
100%
M: 0 C: 1
100%
extractListValues(List, Object, AxiomValueGatherer)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
lambda$addValueFromAxiom$0(Axiom)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$addValueFromAxiom$1(Axiom)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$extractListValues$2(ReferencedListValueDescriptor, List, Object)
M: 0 C: 7
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.jopa.oom;
16:
17: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
18: import cz.cvut.kbss.jopa.model.metamodel.EntityType;
19: import cz.cvut.kbss.jopa.model.metamodel.ListAttributeImpl;
20: import cz.cvut.kbss.jopa.utils.EntityPropertiesUtils;
21: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListDescriptor;
22: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListDescriptorImpl;
23: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListValueDescriptor;
24: import cz.cvut.kbss.ontodriver.model.Assertion;
25: import cz.cvut.kbss.ontodriver.model.Axiom;
26: import cz.cvut.kbss.ontodriver.model.NamedResource;
27:
28: import java.net.URI;
29: import java.util.Collection;
30: import java.util.List;
31:
32: class ReferencedListPropertyStrategy<X> extends
33: ListPropertyStrategy<ReferencedListDescriptor, ReferencedListValueDescriptor, X> {
34:
35: ReferencedListPropertyStrategy(EntityType<X> et, ListAttributeImpl<? super X, ?> att, Descriptor descriptor,
36: EntityMappingHelper mapper) {
37: super(et, att, descriptor, mapper);
38: }
39:
40: @Override
41: void addValueFromAxiom(Axiom<?> ax) {
42: final ReferencedListDescriptor listDescriptor = createListDescriptor(ax);
43: final Collection<Axiom<NamedResource>> sequence = mapper.loadReferencedList(listDescriptor);
44: sequence.stream()
45: .filter(a -> a.getAssertion().getIdentifier().equals(attribute.getOWLPropertyHasContentsIRI().toURI()))
46: .forEach(super::addValueFromAxiom);
47: }
48:
49: @Override
50: ReferencedListDescriptor createListDescriptor(Axiom<?> ax) {
51: final NamedResource owner = ax.getSubject();
52:
53: final boolean inferred = attribute.isInferred();
54: final Assertion listProperty = Assertion.createObjectPropertyAssertion(attribute.getIRI().toURI(), inferred);
55: final Assertion nextNodeProperty = Assertion
56: .createObjectPropertyAssertion(attribute.getOWLObjectPropertyHasNextIRI().toURI(), inferred);
57: final Assertion nodeContentProperty = Assertion
58: .createObjectPropertyAssertion(attribute.getOWLPropertyHasContentsIRI().toURI(), inferred);
59: final ReferencedListDescriptor listDescriptor = new ReferencedListDescriptorImpl(owner, listProperty,
60: nextNodeProperty, nodeContentProperty);
61: listDescriptor.setContext(getAttributeContext());
62: return listDescriptor;
63: }
64:
65: @Override
66: <K> void extractListValues(List<K> list, X instance, AxiomValueGatherer valueBuilder) {
67: final ReferencedListValueDescriptor listDescriptor = createListValueDescriptor(instance);
68: final List<K> pendingItems = resolveUnpersistedItems(list);
69:• if (!pendingItems.isEmpty()) {
70: pendingItems.forEach(item -> referenceSavingResolver.registerPendingReference(item, listDescriptor, list));
71: return;
72: }
73: addListElementsToListValueDescriptor(listDescriptor, list);
74: valueBuilder.addReferencedListValues(listDescriptor);
75: }
76:
77: @Override
78: ReferencedListValueDescriptor createListValueDescriptor(X instance) {
79: final URI owner = EntityPropertiesUtils.getIdentifier(instance, et);
80: final Assertion hasList = Assertion
81: .createObjectPropertyAssertion(attribute.getIRI().toURI(), attribute.isInferred());
82: final Assertion hasNext = Assertion.createObjectPropertyAssertion(attribute
83: .getOWLObjectPropertyHasNextIRI().toURI(), attribute.isInferred());
84: final Assertion hasContent = Assertion.createObjectPropertyAssertion(attribute
85: .getOWLPropertyHasContentsIRI().toURI(), attribute.isInferred());
86: final ReferencedListValueDescriptor descriptor = new ReferencedListValueDescriptor(
87: NamedResource.create(owner), hasList, hasNext, hasContent);
88: descriptor.setContext(getAttributeContext());
89: return descriptor;
90: }
91: }