Skip to content

Package: SimpleListPropertyStrategy

SimpleListPropertyStrategy

nameinstructionbranchcomplexitylinemethod
SimpleListPropertyStrategy(EntityType, ListAttribute, 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: 34
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
createListValueDescriptor(Object)
M: 0 C: 38
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: 46
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 11
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%

Coverage

1: /**
2: * Copyright (C) 2016 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 java.net.URI;
18: import java.util.Collection;
19: import java.util.List;
20:
21: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
22: import cz.cvut.kbss.jopa.model.metamodel.EntityType;
23: import cz.cvut.kbss.jopa.model.metamodel.ListAttribute;
24: import cz.cvut.kbss.ontodriver.descriptor.SimpleListDescriptor;
25: import cz.cvut.kbss.ontodriver.descriptor.SimpleListDescriptorImpl;
26: import cz.cvut.kbss.ontodriver.descriptor.SimpleListValueDescriptor;
27: import cz.cvut.kbss.ontodriver.model.Assertion;
28: import cz.cvut.kbss.ontodriver.model.Axiom;
29: import cz.cvut.kbss.ontodriver.model.NamedResource;
30:
31: class SimpleListPropertyStrategy<X> extends
32: ListPropertyStrategy<SimpleListDescriptor, SimpleListValueDescriptor, X> {
33:
34: public SimpleListPropertyStrategy(EntityType<X> et, ListAttribute<? super X, ?> att,
35: Descriptor descriptor, EntityMappingHelper mapper) {
36: super(et, att, descriptor, mapper);
37: }
38:
39: @Override
40: void addValueFromAxiom(Axiom<?> ax) {
41: final SimpleListDescriptor listDescriptor = createListDescriptor(ax);
42: final Collection<Axiom<NamedResource>> sequence = mapper.loadSimpleList(listDescriptor);
43: sequence.forEach(super::addValueFromAxiom);
44: }
45:
46: @Override
47: SimpleListDescriptor createListDescriptor(Axiom<?> ax) {
48: final NamedResource owner = ax.getSubject();
49: final Assertion listProperty = Assertion.createObjectPropertyAssertion(listAttribute
50: .getIRI().toURI(), listAttribute.isInferred());
51: final Assertion nextNodeProperty = Assertion.createObjectPropertyAssertion(listAttribute
52: .getOWLObjectPropertyHasNextIRI().toURI(), listAttribute.isInferred());
53: final SimpleListDescriptor listDescriptor = new SimpleListDescriptorImpl(owner,
54: listProperty, nextNodeProperty);
55: listDescriptor.setContext(getAttributeContext());
56: return listDescriptor;
57: }
58:
59: @Override
60: <K> void extractListValues(List<K> list, X instance, AxiomValueGatherer valueBuilder) {
61: final SimpleListValueDescriptor listDescriptor = createListValueDescriptor(instance);
62: final Class<K> elemType = (Class<K>) listAttribute.getBindableJavaType();
63: final EntityType<K> valueType = mapper.getEntityType(elemType);
64:• if (list != null) {
65:• for (K item : list) {
66: final URI id = resolveValueIdentifier(item, valueType);
67: cascadeResolver.resolveFieldCascading(listAttribute, item, getAttributeContext());
68: listDescriptor.addValue(NamedResource.create(id));
69: }
70: }
71: valueBuilder.addSimpleListValues(listDescriptor);
72: }
73:
74: @Override
75: SimpleListValueDescriptor createListValueDescriptor(X instance) {
76: final NamedResource owner = NamedResource.create(resolveValueIdentifier(instance, et));
77: final Assertion listProperty = Assertion
78: .createObjectPropertyAssertion(listAttribute.getIRI().toURI(), listAttribute.isInferred());
79: final Assertion nextNodeProperty = Assertion.createObjectPropertyAssertion(listAttribute
80: .getOWLObjectPropertyHasNextIRI().toURI(), listAttribute.isInferred());
81: final SimpleListValueDescriptor listDescriptor = new SimpleListValueDescriptor(owner,
82: listProperty, nextNodeProperty);
83: listDescriptor.setContext(getAttributeContext());
84: return listDescriptor;
85: }
86: }