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
.eflora
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
17 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
18 import eu
.etaxonomy
.cdm
.app
.common
.CdmImportSources
;
19 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
20 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
21 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
22 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
23 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
24 import eu
.etaxonomy
.cdm
.io
.eflora
.centralAfrica
.ferns
.CentralAfricaFernsImportConfigurator
;
25 import eu
.etaxonomy
.cdm
.io
.eflora
.floraMalesiana
.FloraMalesianaTransformer
;
26 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
27 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
28 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
29 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
30 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
37 public class CentralAfricaFernsActivator
{
38 @SuppressWarnings("unused")
39 private static final Logger logger
= Logger
.getLogger(CentralAfricaFernsActivator
.class);
41 //database validation status (create, update, validate ...)
42 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
43 static final Source mySource
= CdmImportSources
.AFRICA_FERNS_ACCESS();
45 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_test_andreasM2();
46 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_preview();
47 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production();
48 // static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
51 public static final UUID featureTreeUuid
= UUID
.fromString("62d930cb-aabb-461c-ad16-0fdbd2bae592");
53 public static final String sourceReference
= "Flora of Central Africa";
55 public static final String classificationName
= "Flora of Central Africa - Ferns";
58 static final UUID classificationUuid
= UUID
.fromString("a90fa160-8f33-4a19-9c5a-ab05a1553017");
61 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
63 // static boolean doPrintKeys = false;
66 static final boolean doTaxa
= true;
68 // private boolean includeSapindaceae1 = true;
72 private void doImport(ICdmDataSource cdmDestination
){
76 Source source
= mySource
;
78 // mySource.getResultSet("SELECT * FROM tmp");
79 CentralAfricaFernsImportConfigurator config
= CentralAfricaFernsImportConfigurator
.NewInstance(source
, cdmDestination
);
80 config
.setClassificationUuid(classificationUuid
);
81 config
.setClassificationName(classificationName
);
82 config
.setDoTaxa(doTaxa
);
83 config
.setCheck(check
);
84 // configsetDoPrintKeys(doPrintKeys);
85 config
.setDbSchemaValidation(hbm2dll
);
87 CdmDefaultImport
<CentralAfricaFernsImportConfigurator
> myImport
= new CdmDefaultImport
<CentralAfricaFernsImportConfigurator
>();
90 // if (includeSapindaceae1){
91 System
.out
.println("Start import from ("+ source
.toString() + ") ...");
92 config
.setSourceReference(getSourceReference(sourceReference
));
93 myImport
.invoke(config
);
94 System
.out
.println("End import from ("+ source
.toString() + ")...");
99 FeatureTree tree
= makeFeatureNode(myImport
.getCdmAppController().getTermService());
100 myImport
.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree
);
104 // TransactionStatus tx = myImport.getCdmAppController().startTransaction();
105 // List<FeatureTree> keys = myImport.getCdmAppController().getFeatureTreeService().list(PolytomousKey.class, null, null, null, null);
106 // for(FeatureTree key : keys){
107 // ((PolytomousKey)key).print(System.out);
108 // System.out.println();
110 // myImport.getCdmAppController().commitTransaction(tx);
115 private Reference
getSourceReference(String string
) {
116 Reference result
= ReferenceFactory
.newGeneric();
117 result
.setTitleCache(string
);
121 private FeatureTree
makeFeatureNode(ITermService service
){
122 FloraMalesianaTransformer transformer
= new FloraMalesianaTransformer();
124 FeatureTree result
= FeatureTree
.NewInstance(featureTreeUuid
);
125 result
.setTitleCache("Flora Malesiana Presentation Feature Tree");
126 FeatureNode root
= result
.getRoot();
129 newNode
= FeatureNode
.NewInstance(Feature
.CITATION());
130 root
.addChild(newNode
);
132 newNode
= FeatureNode
.NewInstance(Feature
.DESCRIPTION());
133 root
.addChild(newNode
);
143 public static void main(String
[] args
) {
144 CentralAfricaFernsActivator me
= new CentralAfricaFernsActivator();
145 me
.doImport(cdmDestination
);