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
.vibrant
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
17 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
18 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
19 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
20 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
21 import eu
.etaxonomy
.cdm
.io
.common
.events
.LoggingIoObserver
;
22 import eu
.etaxonomy
.cdm
.io
.dwca
.in
.DwcaImportConfigurator
;
23 import eu
.etaxonomy
.cdm
.io
.dwca
.in
.DwcaImportConfigurator
.DatasetUse
;
24 import eu
.etaxonomy
.cdm
.io
.dwca
.in
.IImportMapping
.MappingType
;
25 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
26 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
34 public class DwcaScratchpadImportActivator
{
35 @SuppressWarnings("unused")
36 private static final Logger logger
= Logger
.getLogger(DwcaScratchpadImportActivator
.class);
38 //database validation status (create, update, validate ...)
39 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
40 static final URI source
= dwca_test_scratch_test();
43 // static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
44 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_test_local_mysql_dwca();
45 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
48 //default nom code is ICZN as it allows adding publication year
49 static final NomenclaturalCode defaultNomCode
= NomenclaturalCode
.ICZN
;
53 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
56 static DatasetUse datasetUse
= DatasetUse
.CLASSIFICATION
;
59 static boolean validateRankConsistency
= true;
63 static final boolean doTaxa
= true;
67 static final MappingType mappingType
= MappingType
.InMemoryMapping
;
69 private void doImport(ICdmDataSource cdmDestination
){
72 DwcaImportConfigurator config
= DwcaImportConfigurator
.NewInstance(source
, cdmDestination
);
73 config
.addObserver(new LoggingIoObserver());
74 config
.setCheck(check
);
75 config
.setDbSchemaValidation(hbm2dll
);
76 config
.setMappingType(mappingType
);
77 config
.setValidateRankConsistency(validateRankConsistency
);
78 config
.setNomenclaturalCode(defaultNomCode
);
80 CdmDefaultImport myImport
= new CdmDefaultImport();
85 System
.out
.println("Start import from ("+ source
.toString() + ") ...");
86 config
.setSourceReference(getSourceReference(config
.getSourceReferenceTitle()));
87 myImport
.invoke(config
);
88 System
.out
.println("End import from ("+ source
.toString() + ")...");
94 private Reference
<?
> getSourceReference(String string
) {
95 Reference
<?
> result
= ReferenceFactory
.newGeneric();
96 result
.setTitleCache(string
);
102 public static URI
dwca_test_scratch_test() {
103 URI sourceUrl
= URI
.create("file:////PESIIMPORT3/vibrant/dwca/dwca_export_scratchpads_test.zip");
111 public static void main(String
[] args
) {
112 DwcaScratchpadImportActivator me
= new DwcaScratchpadImportActivator();
113 me
.doImport(cdmDestination
);