2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.app
.pesi
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
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
.CdmDefaultImport
;
21 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
22 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.DO_REFERENCES
;
23 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
24 import eu
.etaxonomy
.cdm
.io
.pesi
.erms
.ErmsImportConfigurator
;
25 import eu
.etaxonomy
.cdm
.io
.pesi
.out
.PesiTransformer
;
26 import eu
.etaxonomy
.cdm
.model
.common
.ISourceable
;
27 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
28 import eu
.etaxonomy
.cdm
.model
.name
.ZoologicalName
;
32 * TODO add the following to a wiki page:
33 * 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
34 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
40 public class ErmsActivator
{
41 private static final Logger logger
= Logger
.getLogger(ErmsActivator
.class);
43 //database validation status (create, update, validate ...)
44 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
45 static final Source ermsSource
= PesiSources
.PESI_ERMS();
46 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_pesi_erms();
47 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_test_local_mysql_test();
48 static final UUID treeUuid
= UUID
.fromString("8bd27d84-fd4f-4bfa-bde0-3e6b7311b334");
49 static final UUID featureTreeUuid
= UUID
.fromString("33cbf7a8-0c47-4d47-bd11-b7d77a38d0f6");
50 //static final Object[] featureKeyList = new Integer[]{1,4,5,10,11,12,13,14, 249, 250, 251, 252, 253};
53 static final CHECK check
= CHECK
.CHECK_AND_IMPORT
;
55 static final int partitionSize
= 5000;
59 static final NomenclaturalCode nomenclaturalCode
= NomenclaturalCode
.ICZN
;
62 static final boolean ignoreNull
= true;
64 // ***************** ALL ************************************************//
67 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
70 static final boolean doTaxa
= true;
71 static final boolean doRelTaxa
= true;
72 static final boolean doLinks
= true;
73 static final boolean doOccurences
= true;
74 static final boolean doImages
= true;
77 //******************** NONE ***************************************//
81 // static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
84 // static final boolean doTaxa = false;
85 // static final boolean doRelTaxa = false;
86 // static final boolean doLinks = false;
87 // static final boolean doOccurences = false;
94 public static void main(String
[] args
) {
95 System
.out
.println("Start import from ("+ ermsSource
.getDatabase() + ") ...");
98 Source source
= ermsSource
;
99 ICdmDataSource destination
= CdmDestinations
.chooseDestination(args
) != null ? CdmDestinations
.chooseDestination(args
) : cdmDestination
;
101 ErmsImportConfigurator ermsImportConfigurator
= ErmsImportConfigurator
.NewInstance(source
, destination
);
103 ermsImportConfigurator
.setClassificationUuid(treeUuid
);
104 ermsImportConfigurator
.setNomenclaturalCode(nomenclaturalCode
);
106 ermsImportConfigurator
.setIgnoreNull(ignoreNull
);
107 ermsImportConfigurator
.setDoReferences(doReferences
);
109 ermsImportConfigurator
.setDoTaxa(doTaxa
);
110 ermsImportConfigurator
.setDoRelTaxa(doRelTaxa
);
111 ermsImportConfigurator
.setDoLinks(doLinks
);
112 ermsImportConfigurator
.setDoOccurrence(doOccurences
);
113 ermsImportConfigurator
.setDbSchemaValidation(hbm2dll
);
115 ermsImportConfigurator
.setCheck(check
);
116 ermsImportConfigurator
.setRecordsPerTransaction(partitionSize
);
117 ermsImportConfigurator
.setSourceRefUuid(PesiTransformer
.uuidSourceRefErms
);
120 CdmDefaultImport
<ErmsImportConfigurator
> ermsImport
= new CdmDefaultImport
<ErmsImportConfigurator
>();
121 ermsImport
.invoke(ermsImportConfigurator
);
123 if (ermsImportConfigurator
.getCheck().equals(CHECK
.CHECK_AND_IMPORT
) || ermsImportConfigurator
.getCheck().equals(CHECK
.IMPORT_WITHOUT_CHECK
) ){
124 ICdmApplicationConfiguration app
= ermsImport
.getCdmAppController();
125 ISourceable obj
= app
.getCommonService().getSourcedObjectByIdInSource(ZoologicalName
.class, "1000027", null);
128 // //make feature tree
129 // FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList);
130 // app = ermsImport.getCdmAppController();
131 // app.getFeatureTreeService().saveOrUpdate(tree);
133 System
.out
.println("End import from ("+ source
.getDatabase() + ")...");