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.caryophyllales;
|
10
|
|
11
|
import org.apache.log4j.Logger;
|
12
|
|
13
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
14
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
15
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
16
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
17
|
import eu.etaxonomy.cdm.io.common.ImportResult;
|
18
|
import eu.etaxonomy.cdm.io.operation.config.DeleteNonReferencedReferencesConfigurator;
|
19
|
|
20
|
/**
|
21
|
* @author k.luther
|
22
|
* @since 2015
|
23
|
*/
|
24
|
public class DeleteNonReferencedReferences {
|
25
|
|
26
|
@SuppressWarnings("unused")
|
27
|
private static final Logger logger = Logger.getLogger(DeleteNonReferencedReferences.class);
|
28
|
|
29
|
//database validation status (create, update, validate ...)
|
30
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
31
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo();
|
32
|
|
33
|
private ImportResult doInvoke(ICdmDataSource destination){
|
34
|
ImportResult result = new ImportResult();
|
35
|
|
36
|
DeleteNonReferencedReferencesConfigurator config;
|
37
|
config = DeleteNonReferencedReferencesConfigurator.NewInstance(destination);
|
38
|
|
39
|
// invoke import
|
40
|
CdmDefaultImport<DeleteNonReferencedReferencesConfigurator> myImport = new CdmDefaultImport<>();
|
41
|
result = myImport.invoke(config);
|
42
|
//String successString = success ? "successful" : " with errors ";
|
43
|
//System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString);
|
44
|
return result;
|
45
|
}
|
46
|
|
47
|
public static void main(String[] args) {
|
48
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
49
|
|
50
|
System.out.println("Start deleting non referenced objects for "+ destination.getDatabase() + "...");
|
51
|
DeleteNonReferencedReferences me = new DeleteNonReferencedReferences();
|
52
|
me.doInvoke(destination);
|
53
|
System.exit(0);
|
54
|
}
|
55
|
}
|