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
.util
.UUID
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
18 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
19 import eu
.etaxonomy
.cdm
.app
.images
.ImageImportConfigurator
;
20 import eu
.etaxonomy
.cdm
.app
.tcs
.TcsSources
;
21 import eu
.etaxonomy
.cdm
.app
.wp6
.palmae
.config
.PalmaeProtologueImportConfigurator
;
22 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
23 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
24 import eu
.etaxonomy
.cdm
.io
.PalmaeImageImport
;
25 import eu
.etaxonomy
.cdm
.io
.PalmaeProtologueImport
;
26 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
27 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
28 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
29 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.DO_REFERENCES
;
30 import eu
.etaxonomy
.cdm
.io
.tcsrdf
.TcsRdfImportConfigurator
;
31 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
32 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
33 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
40 public class PalmaeActivator
{
41 private static final Logger logger
= Logger
.getLogger(PalmaeActivator
.class);
43 //database validation status (create, update, validate ...)
44 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
45 static final String tcsSource
= TcsSources
.arecaceae_local();
46 static final ICdmDataSource cdmDestination
= CdmDestinations
.localH2Palmae();
48 public static final UUID featureTreeUuid
= UUID
.fromString("72ccce05-7cc8-4dab-8e47-bf3f5fd848a0");
50 static final UUID treeUuid
= UUID
.fromString("1adb71d4-cce6-45e1-b578-e668778d9ec6");
51 static final UUID secUuid
= UUID
.fromString("5f32b8af-0c97-48ac-8d33-6099ed68c625");
52 static final String sourceSecId
= "palm_pub_ed_999999";
53 static final boolean pubishReferencesInBibliography
= false;
55 //should the other imports run as well?
56 static final boolean includeTaxonX
= true;
57 static final boolean includeImages
= true;
58 static final boolean includeExcelProtologue
= true;
59 static final boolean includeMediaProtologue
= true;
60 static final boolean updateFeatureTree
= true;
63 static final CHECK check
= CHECK
.CHECK_AND_IMPORT
;
65 static boolean useTaxonomicTree
= true;
68 static final boolean doAuthors
= true;
70 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
72 static final boolean doTaxonNames
= true;
73 static final boolean doRelNames
= true;
76 static final boolean doTaxa
= true;
77 static final boolean doRelTaxa
= true;
78 static final boolean doFacts
= true;
81 private boolean doImport(){
82 boolean success
= true;
83 System
.out
.println("Start import from Tcs("+ tcsSource
.toString() + ") ...");
85 //make BerlinModel Source
86 String source
= tcsSource
;
87 ICdmDataSource destination
= cdmDestination
;
89 TcsRdfImportConfigurator tcsImportConfigurator
= TcsRdfImportConfigurator
.NewInstance(source
, destination
);
91 tcsImportConfigurator
.setTreeUuid(treeUuid
);
92 tcsImportConfigurator
.setSecUuid(secUuid
);
93 tcsImportConfigurator
.setSourceSecId(sourceSecId
);
95 tcsImportConfigurator
.setDoAuthors(doAuthors
);
96 tcsImportConfigurator
.setDoReferences(doReferences
);
97 tcsImportConfigurator
.setDoTaxonNames(doTaxonNames
);
98 tcsImportConfigurator
.setDoRelNames(doRelNames
);
100 tcsImportConfigurator
.setDoTaxa(doTaxa
);
101 tcsImportConfigurator
.setDoRelTaxa(doRelTaxa
);
102 tcsImportConfigurator
.setDoFacts(doFacts
);
103 tcsImportConfigurator
.setUseTaxonomicTree(useTaxonomicTree
);
104 tcsImportConfigurator
.setPublishReferences(pubishReferencesInBibliography
);
106 tcsImportConfigurator
.setCheck(check
);
107 tcsImportConfigurator
.setDbSchemaValidation(hbm2dll
);
110 CdmDefaultImport
<TcsRdfImportConfigurator
> tcsImport
= new CdmDefaultImport
<TcsRdfImportConfigurator
>();
111 //new Test().invoke(tcsImportConfigurator);
112 success
&= tcsImport
.invoke(tcsImportConfigurator
);
115 logger
.info("Make feature tree");
116 CdmApplicationController app
= tcsImport
.getCdmAppController();
118 FeatureTree tree
= getFeatureTree();
119 app
.getDescriptionService().saveFeatureTree(tree
);
120 System
.out
.println("End import from TCS ("+ source
.toString() + ")...");
126 private FeatureTree
getFeatureTree(){
128 FeatureTree result
= FeatureTree
.NewInstance(featureTreeUuid
);
129 FeatureNode root
= result
.getRoot();
132 newNode
= FeatureNode
.NewInstance(Feature
.INTRODUCTION());
133 root
.addChild(newNode
);
134 newNode
= FeatureNode
.NewInstance(Feature
.DISTRIBUTION());
135 root
.addChild(newNode
);
136 newNode
= FeatureNode
.NewInstance(Feature
.BIOLOGY_ECOLOGY());
137 root
.addChild(newNode
);
138 newNode
= FeatureNode
.NewInstance(Feature
.CONSERVATION());
139 root
.addChild(newNode
);
140 newNode
= FeatureNode
.NewInstance(Feature
.COMMON_NAME());
141 root
.addChild(newNode
);
142 newNode
= FeatureNode
.NewInstance(Feature
.ETYMOLOGY());
143 root
.addChild(newNode
);
144 newNode
= FeatureNode
.NewInstance(Feature
.USES());
145 root
.addChild(newNode
);
146 newNode
= FeatureNode
.NewInstance(Feature
.CULTIVATION());
147 root
.addChild(newNode
);
148 // "anatomy", "fossil record" "relationships"
150 newNode
= FeatureNode
.NewInstance(Feature
.DISCUSSION());
151 root
.addChild(newNode
);
152 newNode
= FeatureNode
.NewInstance(Feature
.DIAGNOSIS());
153 root
.addChild(newNode
);
154 newNode
= FeatureNode
.NewInstance(Feature
.DESCRIPTION());
155 root
.addChild(newNode
);
156 newNode
= FeatureNode
.NewInstance(Feature
.MATERIALS_EXAMINED());
157 root
.addChild(newNode
);
158 newNode
= FeatureNode
.NewInstance(Feature
.ANATOMY());
159 root
.addChild(newNode
);
168 public static void main(String
[] args
) {
169 boolean success
= true;
171 logger
.debug("start");
173 PalmaeActivator me
= new PalmaeActivator();
177 System
.out
.println("Start importing images ...");
178 CdmDefaultImport
<IImportConfigurator
> imageImporter
= new CdmDefaultImport
<IImportConfigurator
>();
179 ImageImportConfigurator imageConfigurator
= ImageImportConfigurator
.NewInstance(
180 PalmaeImageActivator
.sourceFolder
, cdmDestination
, PalmaeImageImport
.class);
181 imageConfigurator
.setSecUuid(secUuid
);
182 success
&= imageImporter
.invoke(imageConfigurator
);
183 System
.out
.println("End importing images ...");
186 if (includeExcelProtologue
){
187 System
.out
.println("Start importing protologues ...");
188 ImageImportConfigurator imageConfigurator
= ImageImportConfigurator
.NewInstance(
189 PalmaeExcelProtologueActivator
.sourceFile
, cdmDestination
, PalmaeProtologueImport
.class);
190 imageConfigurator
.setSecUuid(secUuid
);
192 CdmDefaultImport
<IImportConfigurator
> imageImporter
= new CdmDefaultImport
<IImportConfigurator
>();
193 imageImporter
.invoke(imageConfigurator
);
194 System
.out
.println("End importing protologues ...");
196 if (includeMediaProtologue
){
197 System
.out
.println("Start importing protologues from \\\\media...");
198 String protologueSource
= "\\\\media\\EditWP6\\palmae\\protologe";
199 String urlString
= "http://wp5.e-taxonomy.eu/media/palmae/protologe/";
200 File source
= new File (protologueSource
);
202 PalmaeProtologueImportConfigurator protologConfig
= PalmaeProtologueImportConfigurator
.NewInstance(protologueSource
, cdmDestination
, urlString
);
203 CdmDefaultImport
<IImportConfigurator
> cdmImport
= new CdmDefaultImport
<IImportConfigurator
>();
205 //protologConfig.setDoFacts(doDescriptions);
206 protologConfig
.setCheck(check
);
207 protologConfig
.setDbSchemaValidation(DbSchemaValidation
.UPDATE
);
209 protologConfig
.setSource(source
);
210 success
&= cdmImport
.invoke(protologConfig
);
212 System
.out
.println("End importing protologues ...");
216 System
.out
.println("Start importing taxonX ...");
217 PalmaeTaxonXImportActivator taxonXimporter
= new PalmaeTaxonXImportActivator();
218 PalmaeTaxonXImportActivator
.cdmDestination
= cdmDestination
;
219 success
&= taxonXimporter
.runImport();
220 System
.out
.println("End importing taxonX ...");
223 PalmaeFeatureTreeUpdater updater
= new PalmaeFeatureTreeUpdater();
224 if (updateFeatureTree
){
225 updater
.updateMissingFeatures(cdmDestination
);
228 String strSuccess
= "";
229 if (success
== false){
232 System
.out
.println("Import " + strSuccess
+ "successful");