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
.caryophyllales
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
17 import eu
.etaxonomy
.cdm
.app
.berlinModelImport
.SourceBase
;
18 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
19 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
20 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
21 import eu
.etaxonomy
.cdm
.io
.caryo
.CaryoImportConfigurator
;
22 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
23 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
24 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
25 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
26 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
34 public class CaryoActivator
extends SourceBase
{
35 private static final Logger logger
= Logger
.getLogger(CaryoActivator
.class);
37 //database validation status (create, update, validate ...)
38 static final DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
39 static final Source source
= caryo_len61();
42 static final ICdmDataSource cdmDestination
= CdmDestinations
.localH2();
43 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
44 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_postgres_CdmTest();
46 static final String classificationName
= "Caryophyllales";
49 static final UUID classificationUuid
= UUID
.fromString("9edc58b5-de3b-43aa-9f31-1ede7c009c2b");
52 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
55 static final boolean doTaxa
= true;
56 static final boolean doDeduplicate
= true;
59 private void doImport(ICdmDataSource cdmDestination
){
62 CaryoImportConfigurator config
= CaryoImportConfigurator
.NewInstance(source
, cdmDestination
);
63 config
.setClassificationUuid(classificationUuid
);
64 config
.setCheck(check
);
65 config
.setDoTaxa(doTaxa
);
66 config
.setDbSchemaValidation(hbm2dll
);
67 config
.setSourceReferenceTitle("NCU - Caryophyllales, v0.4");
68 config
.setClassificationName(classificationName
);
70 CdmDefaultImport
<CaryoImportConfigurator
> myImport
= new CdmDefaultImport
<CaryoImportConfigurator
>();
75 System
.out
.println("Start import from ("+ source
.toString() + ") ...");
76 config
.setSourceReference(getSourceReference(config
.getSourceReferenceTitle()));
77 myImport
.invoke(config
);
78 System
.out
.println("End import from ("+ source
.toString() + ")...");
85 ICdmApplicationConfiguration app
= myImport
.getCdmAppController();
86 int count
= app
.getAgentService().deduplicate(Person
.class, null, null);
87 logger
.warn("Deduplicated " + count
+ " persons.");
88 // count = app.getAgentService().deduplicate(Team.class, null, null);
89 // logger.warn("Deduplicated " + count + " teams.");
90 count
= app
.getReferenceService().deduplicate(Reference
.class, null, null);
91 logger
.warn("Deduplicated " + count
+ " references.");
96 private Reference
<?
> getSourceReference(String string
) {
97 Reference
<?
> result
= ReferenceFactory
.newGeneric();
98 result
.setTitleCache(string
);
103 public static Source
caryo_len61(){
104 // Cyryophyllales source
105 String dbms
= Source
.SQL_SERVER_2008
;
106 String strServer
= "Lenovo-T61";
107 String strDB
= "caryo";
109 String userName
= "WebUser";
110 return makeSource(dbms
, strServer
, strDB
, port
, userName
, null);
118 public static void main(String
[] args
) {
119 CaryoActivator me
= new CaryoActivator();
120 me
.doImport(cdmDestination
);