Merge branch 'release/5.45.0'
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / strategy / merge / IMergeStrategy.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.cdm.strategy.merge;
10
11 import java.util.Set;
12
13 import eu.etaxonomy.cdm.model.common.ICdmBase;
14
15 /**
16 * @author a.mueller
17 * @since 31.07.2009
18 */
19 public interface IMergeStrategy {
20
21 public MergeMode getMergeMode(String propertyName);
22
23 /**
24 * Sets the merge mode for property propertyName
25 * @param propertyName
26 * @param mergeMode
27 * @throws MergeException
28 */
29 public void setMergeMode(String propertyName, MergeMode mergeMode) throws MergeException;
30
31 /**
32 * Sets the default merge mode for all properties.
33 * The default merge mode is used if no more specific merge mode is defined for a certain property.
34 * @param mergeMode
35 */
36 public void setDefaultMergeMode(MergeMode defaultMergeMode);
37
38 /**
39 * Sets the default merge mode for all collection properties.
40 * The default collection merge mode is used if no specific merge mode is defined for a certain collection property.
41 * @param mergeMode
42 */
43 public void setDefaultCollectionMergeMode(MergeMode defaultCollectionMergeMode);
44
45
46 /**
47 * Merges mergeSecond into mergeFirst.
48 * Returns a set of CdmBases that became orphant during the merge process and
49 * therefore must be deleted from a persistent context.
50 * @param <T>
51 * @param mergeFirst
52 * @param mergeSecond
53 * @throws MergeException
54 */
55 public <T extends IMergable> Set<ICdmBase> invoke(T mergeFirst, T mergeSecond) throws MergeException;
56
57 /**
58 * Merges mergeSecond into mergeFirst.
59 * Returns a set of CdmBases that became orphant during the merge process and
60 * therefore must be deleted from a persistent context.
61 * @param <T>
62 * @param mergeFirst
63 * @param mergeSecond
64 * @param clonedObjects a set of objects that needed to be cloned during merge.
65 * This set will be filled during merge and should preferably be empty at the beginning
66 * @throws MergeException
67 */
68 public <T extends IMergable> Set<ICdmBase> invoke(T mergeFirst, T mergeSecond, Set<ICdmBase> clonedObjects) throws MergeException;
69
70 /**
71 * If set to true the merge will only reallocate all references that point
72 * to the second entity to the first entity. All data attached to the
73 * second entity will be completely lost. All data attached to the first
74 * entity will be saved as it is. All other {@link MergeMode} information will
75 * be neglected.<BR>
76 * The second entity will finally be deleted.
77 *
78 * #see {@link #setOnlyReallocateLinks(boolean)}
79 */
80 public boolean isOnlyReallocateReferences();
81
82 // Removed as this is not yet implemented in underlying classes
83 // /**
84 // * Sets the onlyReallocateReferences parameter. See {@link #isOnlyReallocateReferences()}
85 // * for the parameters semantics.
86 // * @see #isOnlyReallocateReferences()
87 // * @param onlyReallocateReferences
88 // */
89 // public void setOnlyReallocateLinks(boolean onlyReallocateReferences);
90
91 }