1 |
60db1c47
|
p.kelbert
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
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.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
package eu.etaxonomy.cdm.app.proibiosphere;
|
11 |
|
|
|
12 |
|
|
import java.io.File;
|
13 |
|
|
import java.net.URI;
|
14 |
|
|
import java.net.URISyntaxException;
|
15 |
|
|
|
16 |
|
|
import org.apache.log4j.Logger;
|
17 |
|
|
|
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.common.CdmDefaultImport;
|
22 |
|
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
23 |
|
|
import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenSynthesysExcelImportConfigurator;
|
24 |
|
|
import eu.etaxonomy.cdm.model.agent.Person;
|
25 |
|
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
26 |
|
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/**
|
32 |
|
|
* @author PK
|
33 |
|
|
* @created 19.09.2008
|
34 |
|
|
* @version 1.0
|
35 |
|
|
*/
|
36 |
|
|
public class SynthesysCacheActivator {
|
37 |
|
|
@SuppressWarnings("unused")
|
38 |
|
|
private static Logger logger = Logger.getLogger(SynthesysCacheActivator.class);
|
39 |
|
|
|
40 |
|
|
//database validation status (create, update, validate ...)
|
41 |
|
|
|
42 |
f3715fb4
|
p.kelbert
|
// final static String xmlSource = "/home/pkelbert/workspace/proibiosphere/cdmlib-io/target/test-classes/eu/etaxonomy/cdm/io/specimen/excel/in/ExcelImportConfiguratorTest-input.xls";
|
43 |
60db1c47
|
p.kelbert
|
final static String xmlSource = "/home/pkelbert/Documents/Proibiosphere/ChenopodiumQuentin/dca UK records.xls";
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
static final ICdmDataSource cdmDestination = CdmDestinations.mon_cdm();
|
47 |
|
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
48 |
f3715fb4
|
p.kelbert
|
// static final ICdmDataSource cdmDestination = CdmDestinations.proibiosphere_local();
|
49 |
|
|
// static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
50 |
60db1c47
|
p.kelbert
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
51 |
|
|
|
52 |
|
|
/**
|
53 |
|
|
* @param args
|
54 |
|
|
*/
|
55 |
|
|
public static void main(String[] args) {
|
56 |
|
|
URI source;
|
57 |
|
|
try {
|
58 |
|
|
URI uri = new File(xmlSource).toURI();
|
59 |
|
|
source = new URI(uri.toString());
|
60 |
|
|
System.out.println(source.toString());
|
61 |
|
|
System.out.println("Start import from Excel Specimen data("+ source.toString() + ") ...");
|
62 |
|
|
|
63 |
|
|
ICdmDataSource destination = cdmDestination;
|
64 |
|
|
SpecimenSynthesysExcelImportConfigurator specimenImportConfigurator = SpecimenSynthesysExcelImportConfigurator.NewInstance(source, destination);
|
65 |
|
|
|
66 |
|
|
specimenImportConfigurator.setSourceSecId("specimen");
|
67 |
|
|
specimenImportConfigurator.setCheck(check);
|
68 |
|
|
specimenImportConfigurator.setDbSchemaValidation(hbm2dll);
|
69 |
|
|
specimenImportConfigurator.setDoAutomaticParsing(true);
|
70 |
|
|
specimenImportConfigurator.setReUseExistingMetadata(true);
|
71 |
|
|
specimenImportConfigurator.setAskForDate(true);
|
72 |
|
|
specimenImportConfigurator.setDefaultAuthor("L.");
|
73 |
f3715fb4
|
p.kelbert
|
// specimenImportConfigurator.setClassificationName("Chenopodium");
|
74 |
60db1c47
|
p.kelbert
|
|
75 |
|
|
specimenImportConfigurator.setReUseTaxon(true);
|
76 |
|
|
|
77 |
8422c0cd
|
Andreas Müller
|
Reference reference = ReferenceFactory.newGeneric();
|
78 |
60db1c47
|
p.kelbert
|
reference.setTitleCache("Chenopodium vulvaria observations from the Botanical Society of the British Isles", true);
|
79 |
|
|
Person p = Person.NewInstance();
|
80 |
|
|
p.setFirstname("Quentin");
|
81 |
|
|
p.setLastname("Groom");
|
82 |
|
|
p.addEmailAddress("qgroom@bsbi.co.uk");
|
83 |
538c276e
|
Andreas Müller
|
reference.setAuthorship(p);
|
84 |
60db1c47
|
p.kelbert
|
reference.setOrganization("Botanical Society of the British Isles");
|
85 |
|
|
|
86 |
|
|
specimenImportConfigurator.setSourceReference(reference);
|
87 |
|
|
specimenImportConfigurator.setTaxonReference(null);
|
88 |
|
|
|
89 |
|
|
// invoke import
|
90 |
|
|
CdmDefaultImport<SpecimenSynthesysExcelImportConfigurator> specimenImport = new CdmDefaultImport<SpecimenSynthesysExcelImportConfigurator>();
|
91 |
|
|
//new Test().invoke(tcsImportConfigurator);
|
92 |
|
|
specimenImport.invoke(specimenImportConfigurator);
|
93 |
|
|
System.out.println("End import from SpecimenData ("+ source.toString() + ")...");
|
94 |
|
|
} catch (URISyntaxException e) {
|
95 |
|
|
e.printStackTrace();
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
}
|