Package: OneLevelMergeCascadeExplorer
OneLevelMergeCascadeExplorer
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
OneLevelMergeCascadeExplorer() |
|
|
|
|
|
||||||||||||||||||||
exploreCascaded(Attribute, Object, Object) |
|
|
|
|
|
||||||||||||||||||||
start(AbstractEntityManager, Object, Object) |
|
|
|
|
|
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model;
19:
20: import cz.cvut.kbss.jopa.exceptions.OWLPersistenceException;
21: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
22: import cz.cvut.kbss.jopa.model.metamodel.Attribute;
23: import cz.cvut.kbss.jopa.model.metamodel.EntityType;
24:
25: import java.util.Arrays;
26: import java.util.List;
27:
28: /**
29: * Merge cascade resolver.
30: * <p>
31: * Cascades the merge operation to attributes which support merge cascading.
32: */
33: class OneLevelMergeCascadeExplorer {
34:
35: void start(final AbstractEntityManager pc, final Object merged, final Object toMerge) {
36:
37: final EntityType<?> a = pc.getMetamodel().entity(toMerge.getClass());
38:• for (final Attribute<?, ?> at : a.getAttributes()) {
39:
40: final List<CascadeType> cTypes = Arrays.asList(at.getCascadeTypes());
41:
42: try {
43:• if (cTypes.contains(CascadeType.ALL) || cTypes.contains(CascadeType.MERGE)) {
44: exploreCascaded(at, merged, toMerge);
45: }
46: } catch (Exception e) {
47: throw new OWLPersistenceException(e);
48: }
49: }
50: }
51:
52: void exploreCascaded(final Attribute<?, ?> at, final Object merged, final Object toMerge) {
53: // empty body
54: }
55: }