1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.app.eflora;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.net.URL;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.common.AccountStore;
|
18
|
import eu.etaxonomy.cdm.io.common.Source;
|
19
|
|
20
|
/**
|
21
|
* @author a.mueller
|
22
|
* @date 21.04.2010
|
23
|
*
|
24
|
*/
|
25
|
public class CdmImportSources {
|
26
|
@SuppressWarnings("unused")
|
27
|
private static final Logger logger = Logger.getLogger(CdmImportSources.class);
|
28
|
|
29
|
|
30
|
public static Source AFRICA_CHECKLIST_ACCESS(){
|
31
|
//
|
32
|
String dbms = Source.ACCESS;
|
33
|
String strServer = null;
|
34
|
//String strDB = "fernsTest";
|
35
|
String strDB = "C:\\localCopy\\Data\\eflora\\africa\\checklist\\checklist_flore_afrique_centrale_corr.mdb";
|
36
|
int port = 1433;
|
37
|
String userName = "";
|
38
|
return makeSource(dbms, strServer, strDB, port, userName, null);
|
39
|
}
|
40
|
|
41
|
|
42
|
public static Source AFRICA_FERNS_ACCESS(){
|
43
|
//
|
44
|
String dbms = Source.ACCESS;
|
45
|
String strServer = null;
|
46
|
//String strDB = "fernsTest";
|
47
|
String strDB = "C:\\localCopy\\Data\\eflora\\africa\\ferns\\Synopsis_Database_corrected.mdb";
|
48
|
int port = 1433;
|
49
|
String userName = "";
|
50
|
return makeSource(dbms, strServer, strDB, port, userName, null);
|
51
|
}
|
52
|
|
53
|
public static Source GLOBIS(){
|
54
|
String dbms = Source.SQL_SERVER_2005;
|
55
|
String strServer = "LENOVO-T61";
|
56
|
String strDB = "globis";
|
57
|
int port = 1433;
|
58
|
String userName = "adam";
|
59
|
return makeSource(dbms, strServer, strDB, port, userName, null);
|
60
|
}
|
61
|
|
62
|
public static Source GLOBIS_ODBC(){
|
63
|
String dbms = Source.ODDBC;
|
64
|
String strServer = "LENOVO-T61";
|
65
|
String strDB = "globis";
|
66
|
int port = 1433;
|
67
|
String userName = "sa";
|
68
|
return makeSource(dbms, strServer, strDB, port, userName, null);
|
69
|
}
|
70
|
|
71
|
public static Source GLOBIS_MDB(){
|
72
|
String dbms = Source.ACCESS;
|
73
|
String strServer = null;
|
74
|
String strDB = "C:\\localCopy\\Data\\globis\\globis.mdb";
|
75
|
int port = -1;
|
76
|
String userName = "";
|
77
|
return makeSource(dbms, strServer, strDB, port, userName, null);
|
78
|
}
|
79
|
|
80
|
|
81
|
public static URI SYNTHESYS_SPECIMEN(){
|
82
|
// tcsXmlTest.xml
|
83
|
URL url = new CdmImportSources().getClass().getResource("/specimen/SynthesysSpecimenExample.xls");
|
84
|
String sourceUrl = url.toString();
|
85
|
URI uri = URI.create(sourceUrl);
|
86
|
return uri;
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* Initializes the source.
|
91
|
* @param dbms
|
92
|
* @param strServer
|
93
|
* @param strDB
|
94
|
* @param port
|
95
|
* @param userName
|
96
|
* @param pwd
|
97
|
* @return the source
|
98
|
*/
|
99
|
private static Source makeSource(String dbms, String strServer, String strDB, int port, String userName, String pwd ){
|
100
|
//establish connection
|
101
|
Source source = null;
|
102
|
source = new Source(dbms, strServer, strDB);
|
103
|
source.setPort(port);
|
104
|
|
105
|
pwd = AccountStore.readOrStorePassword(dbms, strServer, userName, pwd);
|
106
|
source.setUserAndPwd(userName, pwd);
|
107
|
// write pwd to account store
|
108
|
return source;
|
109
|
}
|
110
|
}
|