validate
[cdmlib-apps.git] / app-import / src / main / java / eu / etaxonomy / cdm / app / wp6 / cichorieae / CichorieaeCacheUpdater.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.wp6.cichorieae;
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.DbSchemaValidation;
19 import eu.etaxonomy.cdm.database.ICdmDataSource;
20 import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator;
21 import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
22 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
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 bas 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 CichorieaeCacheUpdater {
36 private static final Logger logger = Logger.getLogger(CichorieaeCacheUpdater.class);
37
38 //database validation status (create, update, validate ...)
39 static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
40 static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_cichorieae();
41
42 static final List<String> classListStrings = Arrays.asList(new String[]{
43 //IdentifiableEntity.class.getName(),
44 // IdentifiableEntity.class.getName(),
45 TaxonNameBase.class.getName(),
46 TaxonBase.class.getName()
47 });
48 //new ArrayList<Class<? extends IdentifiableEntity>>();
49
50 // **************** ALL *********************
51
52 // //DescriptionBase
53 // static final boolean doTaxonDescription = true;
54 // static final boolean doSpecimenDescription = true;
55 // static final boolean doNameDescription = true;
56 //
57 // //AgentBase
58 // static final boolean doPerson = true;
59 // static final boolean doTeam = true;
60 // static final boolean doInstitution = true;
61 //
62 // //MediaEntities
63 // static final boolean doCollection = true;
64 // static final boolean doReferenceBase = true;
65 //
66 // //SpecimenOrObservationBase
67 // static final boolean doFieldObservation = true;
68 // static final boolean doDeriveUnit = true;
69 // static final boolean doLivingBeing = true;
70 // static final boolean doObservation = true;
71 // static final boolean doSpecimen = true;
72 //
73 // //Media
74 // static final boolean doMedia = true;
75 // static final boolean doMediaKey = true;
76 // static final boolean doFigure = true;
77 // static final boolean doPhylogenticTree = true;
78 //
79 //
80 // //TaxonBase
81 // static final boolean doTaxon = true;
82 // static final boolean doSynonym = true;
83 //
84 // static final boolean doSequence = true;
85 //
86 // //Names
87 // static final boolean doViralName = true;
88 // static final boolean doNonViralName = true;
89 // static final boolean doBotanicalName = true;
90 // static final boolean doZoologicalName = true;
91 // static final boolean doCultivarPlantName = true;
92 //
93 // static final boolean doClassification = true;
94 //
95 // //TermBase
96 // static final boolean doFeatureTree = true;
97 // static final boolean doPolytomousKey = true;
98 //
99 // static final boolean doTermVocabulary = true;
100 // static final boolean doDefinedTermBase = true;
101 //
102
103
104 private boolean doInvoke(ICdmDataSource destination){
105 boolean success = true;
106
107 CacheUpdaterConfigurator config;
108 try {
109 config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings);
110
111 // invoke import
112 CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<CacheUpdaterConfigurator>();
113 success &= myImport.invoke(config);
114 String successString = success ? "successful" : " with errors ";
115 System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString);
116 return success;
117 } catch (ClassNotFoundException e) {
118 logger.error(e);
119 return false;
120 }
121 }
122
123 /**
124 * @param args
125 */
126 public static void main(String[] args) {
127 ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
128
129 System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
130 CichorieaeCacheUpdater me = new CichorieaeCacheUpdater();
131 me.doInvoke(destination);
132
133 }
134
135 }