Skip to content

Package: OneLevelCascadeExplorer

OneLevelCascadeExplorer

nameinstructionbranchcomplexitylinemethod
OneLevelCascadeExplorer()
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)
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%
exploreNonCascaded(Attribute, Object)
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
start(AbstractEntityManager, Object, CascadeType)
M: 6 C: 45
88%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 2 C: 10
83%
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.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: public abstract class OneLevelCascadeExplorer {
26:
27: protected CascadeType ct;
28:
29: public void start(final AbstractEntityManager pc, final Object o, CascadeType ct) {
30: this.ct = ct;
31:
32: final EntityType<?> a = pc.getMetamodel().entity(o.getClass());
33:• for (final Attribute<?, ?> at : a.getAttributes()) {
34:
35: final List<CascadeType> cTypes = Arrays.asList(at.getCascadeTypes());
36:
37: try {
38:• if (!cTypes.contains(CascadeType.ALL) && !cTypes.contains(this.ct)) {
39: exploreNonCascaded(at, o);
40: } else {
41: exploreCascaded(at, o);
42: }
43: } catch (Exception e) {
44: throw new OWLPersistenceException(e);
45: }
46: }
47: }
48:
49: protected void exploreCascaded(final Attribute<?, ?> at, final Object o) {
50: // empty body
51: }
52:
53: protected void exploreNonCascaded(final Attribute<?, ?> at, final Object o) throws IllegalAccessException {
54: // empty body
55: }
56: }