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
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
17 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
18 import eu
.etaxonomy
.cdm
.app
.images
.ImageImportConfigurator
;
19 import eu
.etaxonomy
.cdm
.app
.tcs
.TcsSources
;
20 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
21 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
22 import eu
.etaxonomy
.cdm
.io
.PalmaeImageImport
;
23 import eu
.etaxonomy
.cdm
.io
.PalmaeProtologueImport
;
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
.common
.IImportConfigurator
.DO_REFERENCES
;
28 import eu
.etaxonomy
.cdm
.io
.tcsrdf
.TcsRdfImportConfigurator
;
29 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
30 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
31 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
38 public class PalmaeActivator
{
39 private static final Logger logger
= Logger
.getLogger(PalmaeActivator
.class);
41 //database validation status (create, update, validate ...)
42 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
43 static final String tcsSource
= TcsSources
.arecaceae_local();
44 static final ICdmDataSource cdmDestination
= CdmDestinations
.localH2Palmae();
46 static final UUID featureTreeUuid
= UUID
.fromString("72ccce05-7cc8-4dab-8e47-bf3f5fd848a0");
48 static final UUID secUuid
= UUID
.fromString("5f32b8af-0c97-48ac-8d33-6099ed68c625");
49 static final String sourceSecId
= "palm_pub_ed_999999";
51 //should the taxonX import run as well?
52 static final boolean includeTaxonX
= true;
53 static final boolean includeImages
= true;
54 static final boolean includeProtologue
= true;
57 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
60 static final boolean doAuthors
= true;
62 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
64 static final boolean doTaxonNames
= true;
65 static final boolean doRelNames
= true;
68 static final boolean doTaxa
= true;
69 static final boolean doRelTaxa
= true;
70 static final boolean doFacts
= true;
74 private boolean doImport(){
75 boolean success
= true;
76 System
.out
.println("Start import from Tcs("+ tcsSource
.toString() + ") ...");
78 //make BerlinModel Source
79 String source
= tcsSource
;
80 ICdmDataSource destination
= cdmDestination
;
82 TcsRdfImportConfigurator tcsImportConfigurator
= TcsRdfImportConfigurator
.NewInstance(source
, destination
);
84 tcsImportConfigurator
.setSecUuid(secUuid
);
85 tcsImportConfigurator
.setSourceSecId(sourceSecId
);
87 tcsImportConfigurator
.setDoAuthors(doAuthors
);
88 tcsImportConfigurator
.setDoReferences(doReferences
);
89 tcsImportConfigurator
.setDoTaxonNames(doTaxonNames
);
90 tcsImportConfigurator
.setDoRelNames(doRelNames
);
92 tcsImportConfigurator
.setDoTaxa(doTaxa
);
93 tcsImportConfigurator
.setDoRelTaxa(doRelTaxa
);
94 tcsImportConfigurator
.setDoFacts(doFacts
);
96 tcsImportConfigurator
.setCheck(check
);
97 tcsImportConfigurator
.setDbSchemaValidation(hbm2dll
);
100 CdmDefaultImport
<TcsRdfImportConfigurator
> tcsImport
= new CdmDefaultImport
<TcsRdfImportConfigurator
>();
101 //new Test().invoke(tcsImportConfigurator);
102 success
&= tcsImport
.invoke(tcsImportConfigurator
);
105 logger
.info("Make feature tree");
106 CdmApplicationController app
= tcsImport
.getCdmApp();
108 FeatureTree tree
= getFeatureTree();
109 app
.getDescriptionService().saveFeatureTree(tree
);
110 System
.out
.println("End import from TCS ("+ source
.toString() + ")...");
116 private FeatureTree
getFeatureTree(){
118 FeatureTree result
= FeatureTree
.NewInstance(featureTreeUuid
);
119 FeatureNode root
= result
.getRoot();
122 newNode
= FeatureNode
.NewInstance(Feature
.INTRODUCTION());
123 root
.addChild(newNode
);
124 newNode
= FeatureNode
.NewInstance(Feature
.DISTRIBUTION());
125 root
.addChild(newNode
);
126 newNode
= FeatureNode
.NewInstance(Feature
.BIOLOGY_ECOLOGY());
127 root
.addChild(newNode
);
128 newNode
= FeatureNode
.NewInstance(Feature
.CONSERVATION());
129 root
.addChild(newNode
);
130 newNode
= FeatureNode
.NewInstance(Feature
.COMMON_NAME());
131 root
.addChild(newNode
);
132 newNode
= FeatureNode
.NewInstance(Feature
.ETYMOLOGY());
133 root
.addChild(newNode
);
134 newNode
= FeatureNode
.NewInstance(Feature
.USES());
135 root
.addChild(newNode
);
136 newNode
= FeatureNode
.NewInstance(Feature
.CULTIVATION());
137 root
.addChild(newNode
);
138 // "anatomy", "fossil record" "relationships"
140 newNode
= FeatureNode
.NewInstance(Feature
.DISCUSSION());
141 root
.addChild(newNode
);
142 newNode
= FeatureNode
.NewInstance(Feature
.DIAGNOSIS());
143 root
.addChild(newNode
);
144 newNode
= FeatureNode
.NewInstance(Feature
.DESCRIPTION());
145 root
.addChild(newNode
);
146 newNode
= FeatureNode
.NewInstance(Feature
.MATERIALS_EXAMINED());
147 root
.addChild(newNode
);
157 public static void main(String
[] args
) {
158 boolean success
= true;
160 logger
.debug("start");
161 PalmaeActivator me
= new PalmaeActivator();
165 System
.out
.println("Start importing images ...");
166 CdmDefaultImport
<IImportConfigurator
> imageImporter
= new CdmDefaultImport
<IImportConfigurator
>();
167 ImageImportConfigurator imageConfigurator
= ImageImportConfigurator
.NewInstance(
168 PalmaeImageActivator
.sourceFolder
, cdmDestination
, PalmaeImageImport
.class);
169 imageConfigurator
.setSecUuid(secUuid
);
170 success
&= imageImporter
.invoke(imageConfigurator
);
171 System
.out
.println("End importing images ...");
174 if (includeProtologue
){
175 System
.out
.println("Start importing protologues ...");
176 ImageImportConfigurator imageConfigurator
= ImageImportConfigurator
.NewInstance(
177 PalmaeProtologueActivator
.sourceFile
, cdmDestination
, PalmaeProtologueImport
.class);
178 imageConfigurator
.setSecUuid(secUuid
);
180 CdmDefaultImport
<IImportConfigurator
> imageImporter
= new CdmDefaultImport
<IImportConfigurator
>();
181 imageImporter
.invoke(imageConfigurator
);
182 System
.out
.println("End importing protologues ...");
186 System
.out
.println("Start importing taxonX ...");
187 PalmaeTaxonXImportActivator taxonXimporter
= new PalmaeTaxonXImportActivator();
188 PalmaeTaxonXImportActivator
.cdmDestination
= cdmDestination
;
189 PalmaeTaxonXImportActivator
.secUuid
= secUuid
;
190 success
&= taxonXimporter
.runImport();
191 System
.out
.println("End importing taxonX ...");
194 String strSuccess
= "";
195 if (success
== false){
198 System
.out
.println("Import " + strSuccess
+ "successful");