Project

General

Profile

Download (3.03 KB) Statistics
| Branch: | Revision:
1
/**
2
* Copyright (C) 2009 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
package eu.etaxonomy.cdm.app.eflora;
10

    
11
import java.net.URL;
12

    
13
import org.apache.log4j.Logger;
14

    
15
import eu.etaxonomy.cdm.common.URI;
16
import eu.etaxonomy.cdm.config.AccountStore;
17
import eu.etaxonomy.cdm.io.common.Source;
18

    
19
/**
20
 * @author a.mueller
21
 * @since 21.04.2010
22
 *
23
 */
24
public class CdmImportSources {
25
	@SuppressWarnings("unused")
26
	private static final Logger logger = Logger.getLogger(CdmImportSources.class);
27

    
28

    
29
	public static Source AFRICA_CHECKLIST_ACCESS(){
30
		//
31
		String dbms = Source.ACCESS;
32
		String strServer = null;
33
		//String strDB = "fernsTest";
34
		String strDB = "C:\\localCopy\\Data\\eflora\\africa\\checklist\\checklist_flore_afrique_centrale_corr.mdb";
35
		int port = 1433;
36
		String userName = "";
37
		return  makeSource(dbms, strServer, strDB, port, userName, null);
38
	}
39

    
40

    
41
	public static Source AFRICA_FERNS_ACCESS(){
42
		//
43
		String dbms = Source.ACCESS;
44
		String strServer = null;
45
		//String strDB = "fernsTest";
46
		String strDB = "C:\\localCopy\\Data\\eflora\\africa\\ferns\\Synopsis_Database_corrected.mdb";
47
		int port = 1433;
48
		String userName = "";
49
		return  makeSource(dbms, strServer, strDB, port, userName, null);
50
	}
51

    
52
	public static Source GLOBIS(){
53
		String dbms = Source.SQL_SERVER_2005;
54
		String strServer = "LENOVO-T61";
55
		String strDB = "globis";
56
		int port = 1433;
57
		String userName = "adam";
58
		return  makeSource(dbms, strServer, strDB, port, userName, null);
59
	}
60

    
61
	public static Source GLOBIS_ODBC(){
62
		String dbms = Source.ODDBC;
63
		String strServer = "LENOVO-T61";
64
		String strDB = "globis";
65
		int port = 1433;
66
		String userName = "sa";
67
		return  makeSource(dbms, strServer, strDB, port, userName, null);
68
	}
69

    
70
	public static Source GLOBIS_MDB(){
71
		String dbms = Source.ACCESS;
72
		String strServer = null;
73
		String strDB = "C:\\localCopy\\Data\\globis\\globis.mdb";
74
		int port = -1;
75
		String userName = "";
76
		return  makeSource(dbms, strServer, strDB, port, userName, null);
77
	}
78

    
79

    
80
	public static URI SYNTHESYS_SPECIMEN(){
81
		//		tcsXmlTest.xml
82
		URL url = new CdmImportSources().getClass().getResource("/specimen/SynthesysSpecimenExample.xls");
83
		String sourceUrl = url.toString();
84
		URI uri = URI.create(sourceUrl);
85
		return uri;
86
	}
87

    
88
	/**
89
	 * Initializes the source.
90
	 * @param dbms
91
	 * @param strServer
92
	 * @param strDB
93
	 * @param port
94
	 * @param userName
95
	 * @param pwd
96
	 * @return the source
97
	 */
98
	private static Source makeSource(String dbms, String strServer, String strDB, int port, String userName, String pwd ){
99
		//establish connection
100
		Source source = null;
101
		source = new Source(dbms, strServer, strDB);
102
		source.setPort(port);
103

    
104
		pwd = AccountStore.readOrStorePassword(dbms, strServer, userName, pwd);
105
		source.setUserAndPwd(userName, pwd);
106
		// write pwd to account store
107
		return source;
108
	}
109
}
(2-2/15)