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
.wp6
.palmae
;
13 import java
.net
.MalformedURLException
;
15 import java
.util
.UUID
;
17 import org
.apache
.log4j
.Logger
;
18 import org
.springframework
.transaction
.TransactionStatus
;
20 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
21 import eu
.etaxonomy
.cdm
.app
.tcs
.TcsSources
;
22 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
23 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
24 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
25 import eu
.etaxonomy
.cdm
.io
.common
.ICdmImport
;
26 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
27 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
28 import eu
.etaxonomy
.cdm
.io
.taxonx
.TaxonXImportConfigurator
;
35 public class PalmaeTaxonXImportActivator
{
36 private static final Logger logger
= Logger
.getLogger(PalmaeTaxonXImportActivator
.class);
38 //database validation status (create, update, validate ...)
39 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.UPDATE
;
40 //static final String tcsSource = TcsSources.taxonX_local();
41 static File source
= TcsSources
.taxonX_localDir();
42 static ICdmDataSource cdmDestination
= CdmDestinations
.localH2();
44 static UUID secUuid
= UUID
.fromString("5f32b8af-0c97-48ac-8d33-6099ed68c625");
47 static CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
49 static boolean doDescriptions
= true;
51 public boolean runImport(){
52 boolean success
= true;
54 ICdmDataSource destination
= cdmDestination
;
56 TaxonXImportConfigurator taxonXImportConfigurator
= TaxonXImportConfigurator
.NewInstance("", destination
);
58 CdmDefaultImport
<IImportConfigurator
> cdmImport
= new CdmDefaultImport
<IImportConfigurator
>();
60 taxonXImportConfigurator
.setSecUuid(secUuid
);
62 taxonXImportConfigurator
.setDoFacts(doDescriptions
);
64 taxonXImportConfigurator
.setCheck(check
);
65 taxonXImportConfigurator
.setDbSchemaValidation(hbm2dll
);
67 cdmImport
.startController(taxonXImportConfigurator
, destination
);
68 TransactionStatus tx
= cdmImport
.getCdmApp().startTransaction();
70 //new Test().invoke(tcsImportConfigurator);
71 if (source
.isDirectory()){
73 for (File file
: source
.listFiles() ){
77 url
= file
.toURI().toURL();
78 taxonXImportConfigurator
.setSource(url
.toString());
79 String originalSourceId
= file
.getName();
80 originalSourceId
=originalSourceId
.replace(".xml", "");
81 taxonXImportConfigurator
.setOriginalSourceId(originalSourceId
);
82 success
&= cdmImport
.invoke(taxonXImportConfigurator
);
83 } catch (MalformedURLException e
) {
89 success
&= cdmImport
.invoke(taxonXImportConfigurator
);
91 cdmImport
.getCdmApp().commitTransaction(tx
);
99 public static void main(String
[] args
) {
100 System
.out
.println("Start import from Source("+ source
.toString() + ") ...");
102 PalmaeTaxonXImportActivator importer
= new PalmaeTaxonXImportActivator();
103 importer
.runImport();
106 System
.out
.println("End import from Source ("+ source
.toString() + ")...");