Project

General

Profile

« Previous | Next » 

Revision 0456d12d

Added by Andreas Müller over 6 years ago

move CacheUpdater

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/common/CacheUpdater.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

  
10
package eu.etaxonomy.cdm.app.common;
11

  
12
import java.util.Arrays;
13
import java.util.List;
14

  
15
import org.apache.log4j.Logger;
16

  
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
19
import eu.etaxonomy.cdm.io.common.ImportResult;
20
import eu.etaxonomy.cdm.io.operation.config.CacheUpdaterConfigurator;
21
import eu.etaxonomy.cdm.model.name.TaxonName;
22
import eu.etaxonomy.cdm.model.reference.Reference;
23
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
24

  
25

  
26
/**
27
 * TODO add the following to a wiki page:
28
 * HINT: If you are about to import into a mysql data base running under windows and if you wish to dump and restore the resulting data base under another operation systen
29
 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
30
 *
31
 *
32
 * @author a.mueller
33
 *
34
 */
35
public class CacheUpdater {
36
	private static final Logger logger = Logger.getLogger(CacheUpdater.class);
37

  
38
	//database validation status (create, update, validate ...)
39
//	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
40
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview_direct();
41
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_cichorieae();
42
//	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
43
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_euromed3();
44
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_flora_deutschland();
45
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales();
46

  
47

  
48
	static final List<String> classListStrings =  Arrays.asList(new String[]{
49
			//IdentifiableEntity.class.getName(),
50
//			IdentifiableEntity.class.getName(),
51
//			AgentBase.class.getName(),
52
			Reference.class.getName(),
53
			TaxonName.class.getName(),
54
			TaxonBase.class.getName()
55
	});
56
	//new ArrayList<Class<? extends IdentifiableEntity>>();
57

  
58

  
59

  
60
	private ImportResult doInvoke(ICdmDataSource destination){
61
		ImportResult result = new ImportResult();
62

  
63
		CacheUpdaterConfigurator config;
64
		try {
65
			config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings);
66

  
67
			// invoke import
68
			CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<>();
69
			result = myImport.invoke(config);
70
			//String successString = success ? "successful" : " with errors ";
71
			//System.out.println("End updating caches for "+ destination.getDatabase() + "..." +  successString);
72
			return result;
73
		} catch (ClassNotFoundException e) {
74
			logger.error(e);
75
			result.addException(e);
76
			return result;
77
		}
78
	}
79

  
80
	/**
81
	 * @param args
82
	 */
83
	public static void main(String[] args) {
84
		ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
85

  
86
		System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
87
		CacheUpdater me = new CacheUpdater();
88
		me.doInvoke(destination);
89

  
90
	}
91

  
92
	// **************** ALL *********************
93

  
94
//	//DescriptionBase
95
//	static final boolean doTaxonDescription = true;
96
//	static final boolean doSpecimenDescription = true;
97
//	static final boolean doNameDescription = true;
98
//
99
//	//AgentBase
100
//	static final boolean doPerson = true;
101
//	static final boolean doTeam = true;
102
//	static final boolean doInstitution = true;
103
//
104
//	//MediaEntities
105
//	static final boolean doCollection = true;
106
//	static final boolean doReferenceBase = true;
107
//
108
//	//SpecimenOrObservationBase
109
//	static final boolean doFieldObservation = true;
110
//	static final boolean doDeriveUnit = true;
111
//	static final boolean doLivingBeing = true;
112
//	static final boolean doObservation = true;
113
//	static final boolean doSpecimen = true;
114
//
115
//	//Media
116
//	static final boolean doMedia = true;
117
//	static final boolean doMediaKey = true;
118
//	static final boolean doFigure = true;
119
//	static final boolean doPhylogenticTree = true;
120
//
121
//
122
//	//TaxonBase
123
//	static final boolean doTaxon = true;
124
//	static final boolean doSynonym = true;
125
//
126
//	static final boolean doSequence = true;
127
//
128
//	//Names
129
//	static final boolean doTaxonName = true;
130
//
131
//	static final boolean doClassification = true;
132
//
133
//	//TermBase
134
//	static final boolean doFeatureTree = true;
135
//	static final boolean doPolytomousKey = true;
136
//
137
//	static final boolean doTermVocabulary = true;
138
//	static final boolean doDefinedTermBase = true;
139
//
140

  
141

  
142
}
app-import/src/main/java/eu/etaxonomy/cdm/app/common/tasks/CacheUpdater.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

  
10
package eu.etaxonomy.cdm.app.common.tasks;
11

  
12
import java.util.Arrays;
13
import java.util.List;
14

  
15
import org.apache.log4j.Logger;
16

  
17
import eu.etaxonomy.cdm.app.common.CdmDestinations;
18
import eu.etaxonomy.cdm.database.ICdmDataSource;
19
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
20
import eu.etaxonomy.cdm.io.common.ImportResult;
21
import eu.etaxonomy.cdm.io.operation.config.CacheUpdaterConfigurator;
22
import eu.etaxonomy.cdm.model.name.TaxonName;
23
import eu.etaxonomy.cdm.model.reference.Reference;
24
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
25

  
26

  
27
/**
28
 * TODO add the following to a wiki page:
29
 * HINT: If you are about to import into a mysql data base running under windows and if you wish to dump and restore the resulting data base under another operation systen
30
 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
31
 *
32
 *
33
 * @author a.mueller
34
 *
35
 */
36
public class CacheUpdater {
37
	private static final Logger logger = Logger.getLogger(CacheUpdater.class);
38

  
39
	//database validation status (create, update, validate ...)
40
//	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
41
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview_direct();
42
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_cichorieae();
43
//	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
44
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_euromed3();
45
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_flora_deutschland();
46
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales();
47

  
48

  
49
	static final List<String> classListStrings =  Arrays.asList(new String[]{
50
			//IdentifiableEntity.class.getName(),
51
//			IdentifiableEntity.class.getName(),
52
//			AgentBase.class.getName(),
53
			Reference.class.getName(),
54
			TaxonName.class.getName(),
55
			TaxonBase.class.getName()
56
	});
57
	//new ArrayList<Class<? extends IdentifiableEntity>>();
58

  
59

  
60

  
61
	private ImportResult doInvoke(ICdmDataSource destination){
62
		ImportResult result = new ImportResult();
63

  
64
		CacheUpdaterConfigurator config;
65
		try {
66
			config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings);
67

  
68
			// invoke import
69
			CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<>();
70
			result = myImport.invoke(config);
71
			//String successString = success ? "successful" : " with errors ";
72
			//System.out.println("End updating caches for "+ destination.getDatabase() + "..." +  successString);
73
			return result;
74
		} catch (ClassNotFoundException e) {
75
			logger.error(e);
76
			result.addException(e);
77
			return result;
78
		}
79
	}
80

  
81
	/**
82
	 * @param args
83
	 */
84
	public static void main(String[] args) {
85
		ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
86

  
87
		System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
88
		CacheUpdater me = new CacheUpdater();
89
		me.doInvoke(destination);
90

  
91
	}
92

  
93
	// **************** ALL *********************
94

  
95
//	//DescriptionBase
96
//	static final boolean doTaxonDescription = true;
97
//	static final boolean doSpecimenDescription = true;
98
//	static final boolean doNameDescription = true;
99
//
100
//	//AgentBase
101
//	static final boolean doPerson = true;
102
//	static final boolean doTeam = true;
103
//	static final boolean doInstitution = true;
104
//
105
//	//MediaEntities
106
//	static final boolean doCollection = true;
107
//	static final boolean doReferenceBase = true;
108
//
109
//	//SpecimenOrObservationBase
110
//	static final boolean doFieldObservation = true;
111
//	static final boolean doDeriveUnit = true;
112
//	static final boolean doLivingBeing = true;
113
//	static final boolean doObservation = true;
114
//	static final boolean doSpecimen = true;
115
//
116
//	//Media
117
//	static final boolean doMedia = true;
118
//	static final boolean doMediaKey = true;
119
//	static final boolean doFigure = true;
120
//	static final boolean doPhylogenticTree = true;
121
//
122
//
123
//	//TaxonBase
124
//	static final boolean doTaxon = true;
125
//	static final boolean doSynonym = true;
126
//
127
//	static final boolean doSequence = true;
128
//
129
//	//Names
130
//	static final boolean doTaxonName = true;
131
//
132
//	static final boolean doClassification = true;
133
//
134
//	//TermBase
135
//	static final boolean doFeatureTree = true;
136
//	static final boolean doPolytomousKey = true;
137
//
138
//	static final boolean doTermVocabulary = true;
139
//	static final boolean doDefinedTermBase = true;
140
//
141

  
142

  
143
}

Also available in: Unified diff