Skip to content

Package: OneLevelMergeCascadeExplorer

OneLevelMergeCascadeExplorer

nameinstructionbranchcomplexitylinemethod
OneLevelMergeCascadeExplorer()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
exploreCascaded(Attribute, Object, Object)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
start(AbstractEntityManager, Object, Object)
M: 6 C: 37
86%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 2 C: 8
80%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2022 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.model;
16:
17: import cz.cvut.kbss.jopa.exceptions.OWLPersistenceException;
18: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
19: import cz.cvut.kbss.jopa.model.metamodel.Attribute;
20: import cz.cvut.kbss.jopa.model.metamodel.EntityType;
21:
22: import java.util.Arrays;
23: import java.util.List;
24:
25: /**
26: * Merge cascade resolver.
27: * <p>
28: * Cascades the merge operation to attributes which support merge cascading.
29: */
30: class OneLevelMergeCascadeExplorer {
31:
32: void start(final AbstractEntityManager pc, final Object merged, final Object toMerge) {
33:
34: final EntityType<?> a = pc.getMetamodel().entity(toMerge.getClass());
35:• for (final Attribute<?, ?> at : a.getAttributes()) {
36:
37: final List<CascadeType> cTypes = Arrays.asList(at.getCascadeTypes());
38:
39: try {
40:• if (cTypes.contains(CascadeType.ALL) || cTypes.contains(CascadeType.MERGE)) {
41: exploreCascaded(at, merged, toMerge);
42: }
43: } catch (Exception e) {
44: throw new OWLPersistenceException(e);
45: }
46: }
47: }
48:
49: void exploreCascaded(final Attribute<?, ?> at, final Object merged, final Object toMerge) {
50: // empty body
51: }
52: }