Skip to content

Package: SimpleListPropertyStrategy

SimpleListPropertyStrategy

nameinstructionbranchcomplexitylinemethod
SimpleListPropertyStrategy(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: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
createListDescriptor(Axiom)
M: 0 C: 38
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
createListValueDescriptor(Object)
M: 0 C: 42
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
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: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$extractListValues$1(SimpleListValueDescriptor, 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.ontodriver.descriptor.SimpleListDescriptor;
21: import cz.cvut.kbss.ontodriver.descriptor.SimpleListDescriptorImpl;
22: import cz.cvut.kbss.ontodriver.descriptor.SimpleListValueDescriptor;
23: import cz.cvut.kbss.ontodriver.model.Assertion;
24: import cz.cvut.kbss.ontodriver.model.Axiom;
25: import cz.cvut.kbss.ontodriver.model.NamedResource;
26:
27: import java.util.Collection;
28: import java.util.List;
29:
30: class SimpleListPropertyStrategy<X> extends
31: ListPropertyStrategy<SimpleListDescriptor, SimpleListValueDescriptor, X> {
32:
33: SimpleListPropertyStrategy(EntityType<X> et, ListAttributeImpl<? super X, ?> att, Descriptor descriptor,
34: EntityMappingHelper mapper) {
35: super(et, att, descriptor, mapper);
36: }
37:
38: @Override
39: void addValueFromAxiom(Axiom<?> ax) {
40: final SimpleListDescriptor listDescriptor = createListDescriptor(ax);
41: final Collection<Axiom<NamedResource>> sequence = mapper.loadSimpleList(listDescriptor);
42: sequence.forEach(super::addValueFromAxiom);
43: }
44:
45: @Override
46: SimpleListDescriptor createListDescriptor(Axiom<?> ax) {
47: final NamedResource owner = ax.getSubject();
48: final Assertion listProperty = Assertion
49: .createObjectPropertyAssertion(attribute.getIRI().toURI(), attribute.isInferred());
50: final Assertion nextNodeProperty = Assertion
51: .createObjectPropertyAssertion(attribute.getOWLObjectPropertyHasNextIRI().toURI(),
52: attribute.isInferred());
53: final SimpleListDescriptor listDescriptor = new SimpleListDescriptorImpl(owner, listProperty, nextNodeProperty);
54: listDescriptor.setContext(getAttributeContext());
55: return listDescriptor;
56: }
57:
58: @Override
59: <K> void extractListValues(List<K> list, X instance, AxiomValueGatherer valueBuilder) {
60: final SimpleListValueDescriptor listDescriptor = createListValueDescriptor(instance);
61: final List<K> pendingItems = resolveUnpersistedItems(list);
62:• if (!pendingItems.isEmpty()) {
63: pendingItems.forEach(item -> referenceSavingResolver.registerPendingReference(item, listDescriptor, list));
64: return;
65: }
66: addListElementsToListValueDescriptor(listDescriptor, list);
67: valueBuilder.addSimpleListValues(listDescriptor);
68: }
69:
70: @Override
71: SimpleListValueDescriptor createListValueDescriptor(X instance) {
72: final NamedResource owner = NamedResource.create(resolveValueIdentifier(instance, et));
73: final Assertion listProperty = Assertion
74: .createObjectPropertyAssertion(attribute.getIRI().toURI(), attribute.isInferred());
75: final Assertion nextNodeProperty = Assertion.createObjectPropertyAssertion(attribute
76: .getOWLObjectPropertyHasNextIRI().toURI(), attribute.isInferred());
77: final SimpleListValueDescriptor listDescriptor = new SimpleListValueDescriptor(owner, listProperty,
78: nextNodeProperty);
79: listDescriptor.setContext(getAttributeContext());
80: return listDescriptor;
81: }
82: }