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
.tcs
.TcsSources
;
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
.IImportConfigurator
.CHECK
;
23 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.DO_REFERENCES
;
24 import eu
.etaxonomy
.cdm
.io
.tcsrdf
.TcsRdfImportConfigurator
;
25 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
26 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
27 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
34 public class PalmaeActivator
{
35 private static Logger logger
= Logger
.getLogger(PalmaeActivator
.class);
37 //database validation status (create, update, validate ...)
38 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
39 static final String tcsSource
= TcsSources
.arecaceae_local();
40 static final ICdmDataSource cdmDestination
= CdmDestinations
.localH2();
41 // static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
43 static final UUID featureTreeUuid
= UUID
.fromString("72ccce05-7cc8-4dab-8e47-bf3f5fd848a0");
45 static final UUID secUuid
= UUID
.fromString("5f32b8af-0c97-48ac-8d33-6099ed68c625");
46 static final String sourceSecId
= "palm_pub_ed_999999";
47 //should the taxonX import run as well?
48 static final boolean includeTaxonX
= false;
51 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
54 static final boolean doAuthors
= true;
56 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
58 static final boolean doTaxonNames
= true;
59 static final boolean doRelNames
= true;
61 //static final boolean doTypes = true;
62 //static final boolean doNameFacts = true;
65 static final boolean doTaxa
= true;
66 static final boolean doRelTaxa
= true;
67 static final boolean doFacts
= true;
71 private boolean doImport(){
72 boolean success
= true;
73 System
.out
.println("Start import from Tcs("+ tcsSource
.toString() + ") ...");
75 //make BerlinModel Source
76 String source
= tcsSource
;
77 ICdmDataSource destination
= cdmDestination
;
79 TcsRdfImportConfigurator tcsImportConfigurator
= TcsRdfImportConfigurator
.NewInstance(source
, destination
);
81 tcsImportConfigurator
.setSecUuid(secUuid
);
82 tcsImportConfigurator
.setSourceSecId(sourceSecId
);
84 tcsImportConfigurator
.setDoAuthors(doAuthors
);
85 tcsImportConfigurator
.setDoReferences(doReferences
);
86 tcsImportConfigurator
.setDoTaxonNames(doTaxonNames
);
87 tcsImportConfigurator
.setDoRelNames(doRelNames
);
88 //tcsImportConfigurator.setDoNameStatus(doNameStatus);
89 //tcsImportConfigurator.setDoTypes(doTypes);
90 //tcsImportConfigurator.setDoNameFacts(doNameFacts);
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
);
106 logger
.info("Make feature tree");
107 CdmApplicationController app
= tcsImport
.getCdmApp();
111 FeatureTree tree
= getFeatureTree();
112 app
.getDescriptionService().saveFeatureTree(tree
);
113 System
.out
.println("End import from TCS ("+ source
.toString() + ")...");
119 private FeatureTree
getFeatureTree(){
121 FeatureTree result
= FeatureTree
.NewInstance(featureTreeUuid
);
122 FeatureNode root
= result
.getRoot();
125 newNode
= FeatureNode
.NewInstance(Feature
.INTRODUCTION());
126 root
.addChild(newNode
);
127 newNode
= FeatureNode
.NewInstance(Feature
.DISTRIBUTION());
128 root
.addChild(newNode
);
129 newNode
= FeatureNode
.NewInstance(Feature
.BIOLOGY_ECOLOGY());
130 root
.addChild(newNode
);
131 newNode
= FeatureNode
.NewInstance(Feature
.CONSERVATION());
132 root
.addChild(newNode
);
133 newNode
= FeatureNode
.NewInstance(Feature
.COMMON_NAME());
134 root
.addChild(newNode
);
135 newNode
= FeatureNode
.NewInstance(Feature
.ETYMOLOGY());
136 root
.addChild(newNode
);
137 newNode
= FeatureNode
.NewInstance(Feature
.USES());
138 root
.addChild(newNode
);
139 newNode
= FeatureNode
.NewInstance(Feature
.CULTIVATION());
140 root
.addChild(newNode
);
141 // "anatomy", "fossil record" "relationships"
143 newNode
= FeatureNode
.NewInstance(Feature
.DISCUSSION());
144 root
.addChild(newNode
);
145 newNode
= FeatureNode
.NewInstance(Feature
.DIAGNOSIS());
146 root
.addChild(newNode
);
147 newNode
= FeatureNode
.NewInstance(Feature
.DESCRIPTION());
148 root
.addChild(newNode
);
149 newNode
= FeatureNode
.NewInstance(Feature
.MATERIALS_EXAMINED());
150 root
.addChild(newNode
);
160 public static void main(String
[] args
) {
161 boolean success
= true;
163 logger
.debug("start");
164 PalmaeActivator me
= new PalmaeActivator();
168 PalmaeTaxonXImportActivator taxonXimporter
= new PalmaeTaxonXImportActivator();
169 PalmaeTaxonXImportActivator
.cdmDestination
= cdmDestination
;
170 PalmaeTaxonXImportActivator
.secUuid
= secUuid
;
171 success
&= taxonXimporter
.runImport();
174 String strSuccess
= "";
175 if (success
== false){
178 System
.out
.println("Import " + strSuccess
+ "successful");