Revision c9b75310
Added by Andreas Müller over 3 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/merge/ConvertMergeStrategy.java | ||
---|---|---|
17 | 17 |
/** |
18 | 18 |
* @author k.luther |
19 | 19 |
* @since 27.08.2015 |
20 |
* |
|
21 | 20 |
*/ |
22 | 21 |
public class ConvertMergeStrategy extends DefaultMergeStrategy { |
23 | 22 |
|
24 | 23 |
private static final long serialVersionUID = -1046274562281576696L; |
25 | 24 |
|
26 | 25 |
private boolean deleteSecondObject = false; |
27 |
/** |
|
28 |
* @param mergeClazz |
|
29 |
*/ |
|
26 |
|
|
30 | 27 |
protected ConvertMergeStrategy(Class<? extends CdmBase> mergeClazz) { |
31 | 28 |
super(mergeClazz); |
32 |
|
|
33 | 29 |
} |
34 | 30 |
|
35 | 31 |
public static ConvertMergeStrategy NewInstance(Class<? extends CdmBase> mergeClazz){ |
... | ... | |
48 | 44 |
protected <T extends IMergable> void mergeCollectionFieldNoFirst(T mergeFirst, T mergeSecond, Field field, MergeMode mergeMode, Set<ICdmBase> deleteSet, Set<ICdmBase> clonedObjects) throws Exception{ |
49 | 45 |
super.mergeCollectionFieldNoFirst(mergeFirst, mergeSecond, field, mergeMode, deleteSet, clonedObjects); |
50 | 46 |
} |
51 |
|
|
52 | 47 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ICdmEntityDao.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
public interface ICdmEntityDao<T extends CdmBase> { |
36 | 36 |
|
37 |
/** |
|
38 |
* @param transientObject |
|
39 |
* @return |
|
40 |
* @throws DataAccessException |
|
41 |
*/ |
|
42 | 37 |
public UUID saveOrUpdate(T transientObject) throws DataAccessException; |
43 | 38 |
|
44 | 39 |
/** |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmEntityDaoBase.java | ||
---|---|---|
77 | 77 |
* with @Repository? |
78 | 78 |
*/ |
79 | 79 |
@Repository |
80 |
public abstract class CdmEntityDaoBase<T extends CdmBase> extends DaoBase implements ICdmEntityDao<T> { |
|
80 |
public abstract class CdmEntityDaoBase<T extends CdmBase> |
|
81 |
extends DaoBase |
|
82 |
implements ICdmEntityDao<T> { |
|
81 | 83 |
|
82 | 84 |
private static final Logger logger = Logger.getLogger(CdmEntityDaoBase.class); |
83 | 85 |
|
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmGenericDaoImpl.java | ||
---|---|---|
826 | 826 |
getSession().saveOrUpdate(cdmMetaData); |
827 | 827 |
} |
828 | 828 |
|
829 |
|
|
830 | 829 |
@Override |
831 | 830 |
public List<CdmMetaData> getMetaData() { |
832 | 831 |
Session session = getSession(); |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/AgentServiceImpl.java | ||
---|---|---|
226 | 226 |
strategy.setDefaultCollectionMergeMode(MergeMode.SECOND); |
227 | 227 |
strategy.setDeleteSecondObject(true); |
228 | 228 |
|
229 |
|
|
230 | 229 |
if (! genericDao.isMergeable(team, person, strategy)){ |
231 | 230 |
throw new MergeException("Person can not be transformed into team."); |
232 | 231 |
} |
233 | 232 |
try { |
234 |
//this.save(team); |
|
235 | 233 |
team.setProtectedNomenclaturalTitleCache(false); |
236 | 234 |
team.setProtectedTitleCache(true); |
237 | 235 |
team.setTitleCache(person.getTitleCache(), true); |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/AgentServiceImplTest.java | ||
---|---|---|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.api.service; |
11 | 10 |
|
12 | 11 |
import static org.junit.Assert.assertEquals; |
... | ... | |
45 | 44 |
*/ |
46 | 45 |
public class AgentServiceImplTest extends CdmTransactionalIntegrationTest{ |
47 | 46 |
|
48 |
/** |
|
49 |
* |
|
50 |
*/ |
|
51 | 47 |
private static final UUID UUID_EHRENBERG = UUID.fromString("6363ae88-ec57-4b23-8235-6c86fbe59446"); |
52 | 48 |
|
53 | 49 |
@SuppressWarnings("unused") |
... | ... | |
59 | 55 |
@SpringBeanByType |
60 | 56 |
private INameService nameSerivce; |
61 | 57 |
|
62 |
|
|
63 | 58 |
@Test |
64 | 59 |
@DataSets({ |
65 | 60 |
@DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"), |
66 | 61 |
@DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml") |
67 | 62 |
}) |
68 | 63 |
public void testConvertPerson2Team(){ |
69 |
String fullAuthor = "Original author"; |
|
64 |
|
|
65 |
//create data |
|
66 |
String fullAuthor = "Original author"; |
|
70 | 67 |
String nomTitle = "Abrev. aut."; |
71 | 68 |
Person person = Person.NewTitledInstance(fullAuthor); |
72 | 69 |
person.setNomenclaturalTitle(nomTitle); |
... | ... | |
79 | 76 |
service.save(person); |
80 | 77 |
nameSerivce.save(name); |
81 | 78 |
|
79 |
|
|
82 | 80 |
Team team = null; |
83 | 81 |
UpdateResult result = null; |
84 | 82 |
try { |
... | ... | |
93 | 91 |
Assert.assertEquals("Annotations should be moved", 1, team.getAnnotations().size()); |
94 | 92 |
Assert.assertNotNull("Contact must be copied too", team.getContact()); |
95 | 93 |
Assert.assertEquals("Team must be combination author now", team, name.getCombinationAuthorship()); |
96 |
|
|
97 | 94 |
} |
98 | 95 |
|
99 | 96 |
private Contact getContact(){ |
Also available in: Unified diff
cleanup