Revision 4e785924
Added by Andreas Müller over 2 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/caryophyllales/DeleteNonReferencedReferences.java | ||
---|---|---|
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 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/app/caryophyllales/NonReferencedObjectsDeleteActivator.java | ||
---|---|---|
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.NonReferencedObjectsDeleterConfigurator; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author k.luther |
|
22 |
* @since 2015 |
|
23 |
*/ |
|
24 |
public class NonReferencedObjectsDeleteActivator { |
|
25 |
|
|
26 |
@SuppressWarnings("unused") |
|
27 |
private static final Logger logger = Logger.getLogger(NonReferencedObjectsDeleteActivator.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 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp(); |
|
33 |
|
|
34 |
boolean doAuthors = true; |
|
35 |
boolean doReferences = true; |
|
36 |
|
|
37 |
private ImportResult doInvoke(ICdmDataSource destination){ |
|
38 |
ImportResult result = new ImportResult(); |
|
39 |
|
|
40 |
NonReferencedObjectsDeleterConfigurator config = NonReferencedObjectsDeleterConfigurator.NewInstance(destination); |
|
41 |
config.setDbSchemaValidation(hbm2dll); |
|
42 |
config.setDoReferences(doReferences); |
|
43 |
config.setDoAuthors(doAuthors); |
|
44 |
|
|
45 |
// invoke import |
|
46 |
CdmDefaultImport<NonReferencedObjectsDeleterConfigurator> myImport = new CdmDefaultImport<>(); |
|
47 |
result = myImport.invoke(config); |
|
48 |
System.out.println(result.getReports()); |
|
49 |
return result; |
|
50 |
} |
|
51 |
|
|
52 |
public static void main(String[] args) { |
|
53 |
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination; |
|
54 |
|
|
55 |
System.out.println("Start deleting non referenced objects for "+ destination.getDatabase() + "..."); |
|
56 |
NonReferencedObjectsDeleteActivator me = new NonReferencedObjectsDeleteActivator(); |
|
57 |
me.doInvoke(destination); |
|
58 |
System.exit(0); |
|
59 |
} |
|
60 |
} |
Also available in: Unified diff
Rename and update NonReferencedObjectsDeleteActivator