1
|
/**
|
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.redlist;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.net.URISyntaxException;
|
14
|
import java.util.UUID;
|
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.common.IImportConfigurator.DO_REFERENCES;
|
24
|
import eu.etaxonomy.cdm.io.redlist.bfnXml.BfnXmlImportConfigurator;
|
25
|
|
26
|
/**
|
27
|
* @author a.oppermann
|
28
|
* @created 16.07.2013
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class BfnXmlTestActivator {
|
32
|
private static final Logger logger = Logger.getLogger(BfnXmlTestActivator.class);
|
33
|
|
34
|
//database validation status (create, update, validate ...)
|
35
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
36
|
// static final String tcsSource = TcsSources.tcsXml_cichorium();
|
37
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_localhost();
|
38
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_testDB_localhost();
|
39
|
/**
|
40
|
* If Metadata exists this will be overwritten
|
41
|
*/
|
42
|
private static final String sourceReferenceTitle = "Lumbricidae";
|
43
|
|
44
|
|
45
|
static final UUID treeUuid = UUID.fromString("00000000-0c97-48ac-8d33-6099ed68c625");
|
46
|
static final String sourceSecId = "BfnXML";
|
47
|
|
48
|
private static final String strSource = "/eu/etaxonomy/cdm/io/bfnXml/rldb_Lumbricidae.xml";
|
49
|
// private static final String strSource = "/eu/etaxonomy/cdm/io/bfnXml/rldb_Myxo.xml";
|
50
|
static final boolean includeNormalExplicit = true;
|
51
|
|
52
|
//check - import
|
53
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
54
|
|
55
|
//authors
|
56
|
static final boolean doMetaData = false;
|
57
|
//references
|
58
|
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
59
|
//names
|
60
|
static final boolean doTaxonNames = true;
|
61
|
static final boolean doRelNames = false;
|
62
|
|
63
|
//taxa
|
64
|
static final boolean doTaxa = true;
|
65
|
static final boolean doRelTaxa = false;
|
66
|
|
67
|
|
68
|
|
69
|
private void doImport(){
|
70
|
System.out.println("Start import from BfnXML to "+ cdmDestination.getDatabase() + " ...");
|
71
|
|
72
|
//make Source
|
73
|
URI source;
|
74
|
try {
|
75
|
source = this.getClass().getResource(strSource).toURI();
|
76
|
ICdmDataSource destination = cdmDestination;
|
77
|
|
78
|
BfnXmlImportConfigurator bfnImportConfigurator = BfnXmlImportConfigurator.NewInstance(source, destination);
|
79
|
|
80
|
bfnImportConfigurator.setSourceReferenceTitle(sourceReferenceTitle);
|
81
|
|
82
|
bfnImportConfigurator.setClassificationName("Lumbricidae");
|
83
|
bfnImportConfigurator.setClassificationUuid(treeUuid);
|
84
|
bfnImportConfigurator.setSourceSecId(sourceSecId);
|
85
|
|
86
|
//if xmllist has two lists
|
87
|
bfnImportConfigurator.setHasSecondList(false);
|
88
|
|
89
|
bfnImportConfigurator.setDoMetaData(doMetaData);
|
90
|
bfnImportConfigurator.setDoReferences(doReferences);
|
91
|
bfnImportConfigurator.setDoTaxonNames(doTaxonNames);
|
92
|
bfnImportConfigurator.setDoRelNames(doRelNames);
|
93
|
|
94
|
bfnImportConfigurator.setDoTaxa(doTaxa);
|
95
|
bfnImportConfigurator.setDoRelTaxa(doRelTaxa);
|
96
|
|
97
|
bfnImportConfigurator.setCheck(check);
|
98
|
bfnImportConfigurator.setDbSchemaValidation(hbm2dll);
|
99
|
|
100
|
// invoke import
|
101
|
CdmDefaultImport<BfnXmlImportConfigurator> bfnImport = new CdmDefaultImport<BfnXmlImportConfigurator>();
|
102
|
//new Test().invoke(tcsImportConfigurator);
|
103
|
bfnImport.invoke(bfnImportConfigurator);
|
104
|
|
105
|
|
106
|
// IReferenceService refService = tcsImport.getCdmAppController().getReferenceService();
|
107
|
// IBook book = ReferenceFactory.newBook();
|
108
|
// book.setDatePublished(TimePeriod.NewInstance(1945).setEndDay(12).setEndMonth(4));
|
109
|
// refService.saveOrUpdate((Reference)book);
|
110
|
// tcsImport.getCdmAppController().close();
|
111
|
|
112
|
// NormalExplicitTestActivator normExActivator = new NormalExplicitTestActivator();
|
113
|
// normExActivator.doImport(destination, DbSchemaValidation.VALIDATE);
|
114
|
//
|
115
|
logger.info("End");
|
116
|
System.out.println("End import from BfnXML ("+ source.toString() + ")...");
|
117
|
} catch (URISyntaxException e) {
|
118
|
e.printStackTrace();
|
119
|
}
|
120
|
|
121
|
}
|
122
|
|
123
|
/**
|
124
|
* @param args
|
125
|
*/
|
126
|
public static void main(String[] args) {
|
127
|
BfnXmlTestActivator bfnXmlTestActivator = new BfnXmlTestActivator();
|
128
|
bfnXmlTestActivator.doImport();
|
129
|
}
|
130
|
|
131
|
}
|