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
.IImportConfigurator
;
26 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
27 import eu
.etaxonomy
.cdm
.io
.taxonx
.TaxonXImportConfigurator
;
34 public class PalmaeTaxonXImportActivator
{
35 private static final Logger logger
= Logger
.getLogger(PalmaeTaxonXImportActivator
.class);
37 //database validation status (create, update, validate ...)
38 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.UPDATE
;
39 //static final String tcsSource = TcsSources.taxonX_local();
40 static File source
= TcsSources
.taxonX_localDir();
41 static ICdmDataSource cdmDestination
= CdmDestinations
.localH2();
43 static UUID secUuid
= UUID
.fromString("5f32b8af-0c97-48ac-8d33-6099ed68c625");
46 static CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
48 static boolean doDescriptions
= true;
50 public boolean runImport(){
51 boolean success
= true;
53 ICdmDataSource destination
= cdmDestination
;
55 TaxonXImportConfigurator taxonXImportConfigurator
= TaxonXImportConfigurator
.NewInstance("", destination
);
57 CdmDefaultImport
<IImportConfigurator
> cdmImport
= new CdmDefaultImport
<IImportConfigurator
>();
59 taxonXImportConfigurator
.setSecUuid(secUuid
);
61 taxonXImportConfigurator
.setDoFacts(doDescriptions
);
63 taxonXImportConfigurator
.setCheck(check
);
64 taxonXImportConfigurator
.setDbSchemaValidation(hbm2dll
);
66 cdmImport
.startController(taxonXImportConfigurator
, destination
);
67 TransactionStatus tx
= cdmImport
.getCdmApp().startTransaction();
69 //new Test().invoke(tcsImportConfigurator);
70 if (source
.isDirectory()){
72 for (File file
: source
.listFiles() ){
76 url
= file
.toURI().toURL();
77 taxonXImportConfigurator
.setSource(url
.toString());
78 String originalSourceId
= file
.getName();
79 originalSourceId
=originalSourceId
.replace(".xml", "");
80 taxonXImportConfigurator
.setOriginalSourceId(originalSourceId
);
81 success
&= cdmImport
.invoke(taxonXImportConfigurator
);
82 } catch (MalformedURLException e
) {
88 success
&= cdmImport
.invoke(taxonXImportConfigurator
);
90 cdmImport
.getCdmApp().commitTransaction(tx
);
98 public static void main(String
[] args
) {
99 System
.out
.println("Start import from Source("+ source
.toString() + ") ...");
101 PalmaeTaxonXImportActivator importer
= new PalmaeTaxonXImportActivator();
102 importer
.runImport();
105 System
.out
.println("End import from Source ("+ source
.toString() + ")...");