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
.common
;
12 import java
.util
.HashSet
;
13 import java
.util
.List
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.springframework
.core
.io
.ClassPathResource
;
19 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
20 import eu
.etaxonomy
.cdm
.api
.application
.CdmIoApplicationController
;
21 import eu
.etaxonomy
.cdm
.api
.service
.config
.ITaxonServiceConfigurator
;
22 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonServiceConfiguratorImpl
;
23 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
24 import eu
.etaxonomy
.cdm
.common
.DefaultProgressMonitor
;
25 import eu
.etaxonomy
.cdm
.common
.IProgressMonitor
;
26 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
27 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
28 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
29 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
30 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
31 import eu
.etaxonomy
.cdm
.model
.location
.TdwgArea
;
32 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
33 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
36 * @author a.babadshanjan
39 public class TestActivator
{
40 @SuppressWarnings("unused")
41 private static final Logger logger
= Logger
.getLogger(TestActivator
.class);
43 //static final Source faunaEuropaeaSource = FaunaEuropaeaSources.faunEu();
44 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview_B();
45 static final ICdmDataSource cdmDestination
= CdmDestinations
.localH2();
47 static final int limitSave
= 2000;
49 // static final CHECK check = CHECK.CHECK_AND_IMPORT;
50 static final CHECK check
= CHECK
.CHECK_ONLY
;
51 static DbSchemaValidation dbSchemaValidation
= DbSchemaValidation
.CREATE
;
52 // static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.UPDATE;
53 // static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
54 static final NomenclaturalCode nomenclaturalCode
= NomenclaturalCode
.ICBN
;
61 public static void main(String
[] args
) {
63 ICdmDataSource destination
= cdmDestination
;
65 CdmApplicationController app
;
67 // applicationEventMulticaster
68 // app = CdmIoApplicationController.NewInstance(destination, dbSchemaValidation);
70 IProgressMonitor progressMonitor
= DefaultProgressMonitor
.NewInstance();
71 String resourcePath
= "/eu/etaxonomy/cdm/appimportTestApplicationContext.xml";
72 ClassPathResource resource
= new ClassPathResource(resourcePath
);
73 // ApplicationListener<?> listener = new AppImportApplicationListener();
74 // List<ApplicationListener> listeners = new ArrayList<ApplicationListener>();
75 // listeners.add(listener);
76 // app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor, listeners);
77 app
= CdmApplicationController
.NewInstance(resource
, destination
, dbSchemaValidation
, false, progressMonitor
);
83 app
.changeDataSource(destination
);
84 ICdmDataSource cdmDestination
= CdmDestinations
.cdm_edit_cichorieae_preview_B();
85 app
.changeDataSource(cdmDestination
);
86 ITaxonServiceConfigurator
<?
> conf
= TaxonServiceConfiguratorImpl
.NewInstance();
87 conf
.setDoSynonyms(true);
89 conf
.setMatchMode(MatchMode
.BEGINNING
);
90 conf
.setTitleSearchString("L*");
91 conf
.setPageNumber(0);
93 Set
<NamedArea
> areas
= new HashSet
<NamedArea
>();
94 areas
.add(TdwgArea
.getAreaByTdwgAbbreviation("GER"));
95 //conf.setNamedAreas(areas);
97 Pager
<IdentifiableEntity
> taxaAndSyn
= app
.getTaxonService().findTaxaAndNames(conf
);
98 List
<IdentifiableEntity
> taxList
= taxaAndSyn
.getRecords();
100 for (IdentifiableEntity
<?
> ent
: taxList
){
102 System
.err
.println(ent
.getTitleCache());
107 System
.out
.println("End importing Fauna Europaea data");