Revision 2b5f8b56
Added by Andreas Müller over 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/caryophyllales/CaryophyllalesCacheUpdater.java | ||
---|---|---|
1 |
package eu.etaxonomy.cdm.app.caryophyllales; |
|
2 |
import java.util.Arrays; |
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
|
8 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
9 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
10 |
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator; |
|
11 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
12 |
import eu.etaxonomy.cdm.io.common.ImportResult; |
|
13 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
14 |
|
|
15 |
public class CaryophyllalesCacheUpdater { |
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
private static final Logger logger = Logger.getLogger(CaryophyllalesCacheUpdater.class); |
|
22 |
|
|
23 |
//database validation status (create, update, validate ...) |
|
24 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
|
25 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo(); |
|
26 |
|
|
27 |
static final List<String> classListStrings = Arrays.asList(new String[]{ |
|
28 |
//IdentifiableEntity.class.getName(), |
|
29 |
// IdentifiableEntity.class.getName(), |
|
30 |
//AgentBase.class.getName(), |
|
31 |
//Reference.class.getName(), |
|
32 |
//TaxonNameBase.class.getName(), |
|
33 |
TaxonBase.class.getName() |
|
34 |
|
|
35 |
|
|
36 |
}); |
|
37 |
//new ArrayList<Class<? extends IdentifiableEntity>>(); |
|
38 |
|
|
39 |
// **************** ALL ********************* |
|
40 |
|
|
41 |
// //DescriptionBase |
|
42 |
// static final boolean doTaxonDescription = true; |
|
43 |
// static final boolean doSpecimenDescription = true; |
|
44 |
// static final boolean doNameDescription = true; |
|
45 |
// |
|
46 |
// //AgentBase |
|
47 |
// static final boolean doPerson = true; |
|
48 |
// static final boolean doTeam = true; |
|
49 |
// static final boolean doInstitution = true; |
|
50 |
// |
|
51 |
// //MediaEntities |
|
52 |
// static final boolean doCollection = true; |
|
53 |
// static final boolean doReferenceBase = true; |
|
54 |
// |
|
55 |
// //SpecimenOrObservationBase |
|
56 |
// static final boolean doFieldObservation = true; |
|
57 |
// static final boolean doDeriveUnit = true; |
|
58 |
// static final boolean doLivingBeing = true; |
|
59 |
// static final boolean doObservation = true; |
|
60 |
// static final boolean doSpecimen = true; |
|
61 |
// |
|
62 |
// //Media |
|
63 |
// static final boolean doMedia = true; |
|
64 |
// static final boolean doMediaKey = true; |
|
65 |
// static final boolean doFigure = true; |
|
66 |
// static final boolean doPhylogenticTree = true; |
|
67 |
// |
|
68 |
// |
|
69 |
// //TaxonBase |
|
70 |
// static final boolean doTaxon = true; |
|
71 |
// static final boolean doSynonym = true; |
|
72 |
// |
|
73 |
// static final boolean doSequence = true; |
|
74 |
// |
|
75 |
// //Names |
|
76 |
// static final boolean doViralName = true; |
|
77 |
// static final boolean doNonViralName = true; |
|
78 |
// static final boolean doBotanicalName = true; |
|
79 |
// static final boolean doZoologicalName = true; |
|
80 |
// static final boolean doCultivarPlantName = true; |
|
81 |
// |
|
82 |
// static final boolean doClassification = true; |
|
83 |
// |
|
84 |
// //TermBase |
|
85 |
// static final boolean doFeatureTree = true; |
|
86 |
// static final boolean doPolytomousKey = true; |
|
87 |
// |
|
88 |
// static final boolean doTermVocabulary = true; |
|
89 |
// static final boolean doDefinedTermBase = true; |
|
90 |
// |
|
91 |
|
|
92 |
|
|
93 |
private ImportResult doInvoke(ICdmDataSource destination){ |
|
94 |
ImportResult result = new ImportResult(); |
|
95 |
|
|
96 |
CacheUpdaterConfigurator config; |
|
97 |
try { |
|
98 |
config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings, true); |
|
99 |
|
|
100 |
// invoke import |
|
101 |
CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<CacheUpdaterConfigurator>(); |
|
102 |
result=myImport.invoke(config); |
|
103 |
//String successString = success ? "successful" : " with errors "; |
|
104 |
//System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString); |
|
105 |
return result; |
|
106 |
} catch (ClassNotFoundException e) { |
|
107 |
logger.error(e); |
|
108 |
result.setSuccess(false); |
|
109 |
return result; |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* @param args |
|
115 |
*/ |
|
116 |
public static void main(String[] args) { |
|
117 |
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination; |
|
118 |
|
|
119 |
System.out.println("Start updating caches for "+ destination.getDatabase() + "..."); |
|
120 |
CaryophyllalesCacheUpdater me = new CaryophyllalesCacheUpdater(); |
|
121 |
me.doInvoke(destination); |
|
122 |
|
|
123 |
} |
|
124 |
|
|
125 |
} |
|
126 |
|
|
127 |
|
|
1 |
package eu.etaxonomy.cdm.app.caryophyllales; |
|
2 |
import java.util.Arrays; |
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
|
8 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
9 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
10 |
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator; |
|
11 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
12 |
import eu.etaxonomy.cdm.io.common.ImportResult; |
|
13 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
14 |
|
|
15 |
public class CaryophyllalesCacheUpdater { |
|
16 |
|
|
17 |
private static final Logger logger = Logger.getLogger(CaryophyllalesCacheUpdater.class); |
|
18 |
|
|
19 |
//database validation status (create, update, validate ...) |
|
20 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
|
21 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo(); |
|
22 |
|
|
23 |
static final List<String> classListStrings = Arrays.asList(new String[]{ |
|
24 |
//IdentifiableEntity.class.getName(), |
|
25 |
// IdentifiableEntity.class.getName(), |
|
26 |
//AgentBase.class.getName(), |
|
27 |
//Reference.class.getName(), |
|
28 |
//TaxonNameBase.class.getName(), |
|
29 |
TaxonBase.class.getName() |
|
30 |
|
|
31 |
|
|
32 |
}); |
|
33 |
//new ArrayList<Class<? extends IdentifiableEntity>>(); |
|
34 |
|
|
35 |
// **************** ALL ********************* |
|
36 |
|
|
37 |
// //DescriptionBase |
|
38 |
// static final boolean doTaxonDescription = true; |
|
39 |
// static final boolean doSpecimenDescription = true; |
|
40 |
// static final boolean doNameDescription = true; |
|
41 |
// |
|
42 |
// //AgentBase |
|
43 |
// static final boolean doPerson = true; |
|
44 |
// static final boolean doTeam = true; |
|
45 |
// static final boolean doInstitution = true; |
|
46 |
// |
|
47 |
// //MediaEntities |
|
48 |
// static final boolean doCollection = true; |
|
49 |
// static final boolean doReferenceBase = true; |
|
50 |
// |
|
51 |
// //SpecimenOrObservationBase |
|
52 |
// static final boolean doFieldObservation = true; |
|
53 |
// static final boolean doDeriveUnit = true; |
|
54 |
// static final boolean doLivingBeing = true; |
|
55 |
// static final boolean doObservation = true; |
|
56 |
// static final boolean doSpecimen = true; |
|
57 |
// |
|
58 |
// //Media |
|
59 |
// static final boolean doMedia = true; |
|
60 |
// static final boolean doMediaKey = true; |
|
61 |
// static final boolean doFigure = true; |
|
62 |
// static final boolean doPhylogenticTree = true; |
|
63 |
// |
|
64 |
// |
|
65 |
// //TaxonBase |
|
66 |
// static final boolean doTaxon = true; |
|
67 |
// static final boolean doSynonym = true; |
|
68 |
// |
|
69 |
// static final boolean doSequence = true; |
|
70 |
// |
|
71 |
// //Names |
|
72 |
// static final boolean doViralName = true; |
|
73 |
// static final boolean doNonViralName = true; |
|
74 |
// static final boolean doBotanicalName = true; |
|
75 |
// static final boolean doZoologicalName = true; |
|
76 |
// static final boolean doCultivarPlantName = true; |
|
77 |
// |
|
78 |
// static final boolean doClassification = true; |
|
79 |
// |
|
80 |
// //TermBase |
|
81 |
// static final boolean doFeatureTree = true; |
|
82 |
// static final boolean doPolytomousKey = true; |
|
83 |
// |
|
84 |
// static final boolean doTermVocabulary = true; |
|
85 |
// static final boolean doDefinedTermBase = true; |
|
86 |
// |
|
87 |
|
|
88 |
|
|
89 |
private ImportResult doInvoke(ICdmDataSource destination){ |
|
90 |
ImportResult result = new ImportResult(); |
|
91 |
|
|
92 |
CacheUpdaterConfigurator config; |
|
93 |
try { |
|
94 |
config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings, true); |
|
95 |
|
|
96 |
// invoke import |
|
97 |
CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<CacheUpdaterConfigurator>(); |
|
98 |
result=myImport.invoke(config); |
|
99 |
//String successString = success ? "successful" : " with errors "; |
|
100 |
//System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString); |
|
101 |
return result; |
|
102 |
} catch (ClassNotFoundException e) { |
|
103 |
logger.error(e); |
|
104 |
result.setSuccess(false); |
|
105 |
return result; |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* @param args |
|
111 |
*/ |
|
112 |
public static void main(String[] args) { |
|
113 |
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination; |
|
114 |
|
|
115 |
System.out.println("Start updating caches for "+ destination.getDatabase() + "..."); |
|
116 |
CaryophyllalesCacheUpdater me = new CaryophyllalesCacheUpdater(); |
|
117 |
me.doInvoke(destination); |
|
118 |
|
|
119 |
} |
|
120 |
|
|
121 |
} |
|
122 |
|
|
123 |
|
Also available in: Unified diff
Add first version of Edaphobase importer and some clean up