1
|
/**
|
2
|
* Copyright (C) 2017 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.app.common.tasks;
|
10
|
|
11
|
import org.apache.log4j.Logger;
|
12
|
|
13
|
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
|
14
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
15
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
16
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
17
|
import eu.etaxonomy.cdm.model.agent.Person;
|
18
|
import eu.etaxonomy.cdm.model.agent.Team;
|
19
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
20
|
|
21
|
/**
|
22
|
* Deduplicates certain classes.
|
23
|
*
|
24
|
* CAUTION: Deduplicating teams does not yet work correctly. Team members are often duplicated.
|
25
|
*
|
26
|
* @author a.mueller
|
27
|
* @since 24.11.2017
|
28
|
*/
|
29
|
public class Deduplicator {
|
30
|
@SuppressWarnings("unused")
|
31
|
private static final Logger logger = Logger.getLogger(Deduplicator.class);
|
32
|
|
33
|
//database validation status (create, update, validate ...)
|
34
|
// static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
35
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_cichorieae();
|
36
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
37
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp();
|
38
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_flora_cuba();
|
39
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo_spp();
|
40
|
|
41
|
|
42
|
static boolean doPersons = true;
|
43
|
static boolean doTeams = false;
|
44
|
static boolean doReferences = false;
|
45
|
|
46
|
|
47
|
private void doInvoke(ICdmDataSource destination){
|
48
|
|
49
|
try {
|
50
|
CdmApplicationController app = CdmApplicationController.NewInstance(destination, DbSchemaValidation.VALIDATE);
|
51
|
|
52
|
if (doPersons){
|
53
|
app.getAgentService().deduplicate(Person.class, null, null);
|
54
|
}
|
55
|
if (doTeams){
|
56
|
app.getAgentService().deduplicate(Team.class, null, null);
|
57
|
}
|
58
|
if (doReferences){
|
59
|
app.getReferenceService().deduplicate(Reference.class, null, null);
|
60
|
}
|
61
|
} catch (Exception e) {
|
62
|
e.printStackTrace();
|
63
|
}
|
64
|
}
|
65
|
|
66
|
public static void main(String[] args) {
|
67
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
68
|
|
69
|
System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
|
70
|
Deduplicator me = new Deduplicator();
|
71
|
me.doInvoke(destination);
|
72
|
System.exit(0);
|
73
|
}
|
74
|
}
|