32ce7c8c4e618948a9474edf300fa598d7267c7f
[cdmlib-apps.git] / app-import / src / main / java / eu / etaxonomy / cdm / app / common / CdmImportSources.java
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.common;
11
12 import java.net.URI;
13 import java.net.URL;
14
15 import org.apache.log4j.Logger;
16
17 import eu.etaxonomy.cdm.app.tcs.TcsSources;
18 import eu.etaxonomy.cdm.common.AccountStore;
19 import eu.etaxonomy.cdm.io.common.Source;
20
21 /**
22 * @author a.mueller
23 * @date 21.04.2010
24 *
25 */
26 public class CdmImportSources {
27 @SuppressWarnings("unused")
28 private static final Logger logger = Logger.getLogger(CdmImportSources.class);
29
30
31 public static Source AFRICA_CHECKLIST_ACCESS(){
32 //
33 String dbms = Source.ACCESS;
34 String strServer = null;
35 //String strDB = "fernsTest";
36 String strDB = "C:\\localCopy\\Data\\eflora\\africa\\checklist\\checklist_flore_afrique_centrale_corr.mdb";
37 int port = 1433;
38 String userName = "";
39 return makeSource(dbms, strServer, strDB, port, userName, null);
40 }
41
42
43 public static Source AFRICA_FERNS_ACCESS(){
44 //
45 String dbms = Source.ACCESS;
46 String strServer = null;
47 //String strDB = "fernsTest";
48 String strDB = "C:\\localCopy\\Data\\eflora\\africa\\ferns\\Synopsis_Database_corrected.mdb";
49 int port = 1433;
50 String userName = "";
51 return makeSource(dbms, strServer, strDB, port, userName, null);
52 }
53
54 public static Source GLOBIS(){
55 String dbms = Source.SQL_SERVER_2005;
56 String strServer = "LENOVO-T61";
57 String strDB = "globis";
58 int port = 1433;
59 String userName = "adam";
60 return makeSource(dbms, strServer, strDB, port, userName, null);
61 }
62
63 public static Source GLOBIS_ODBC(){
64 String dbms = Source.ODDBC;
65 String strServer = "LENOVO-T61";
66 String strDB = "globis";
67 int port = 1433;
68 String userName = "sa";
69 return makeSource(dbms, strServer, strDB, port, userName, null);
70 }
71
72 public static Source GLOBIS_MDB(){
73 String dbms = Source.ACCESS;
74 String strServer = null;
75 String strDB = "C:\\localCopy\\Data\\globis\\globis.mdb";
76 int port = -1;
77 String userName = "";
78 return makeSource(dbms, strServer, strDB, port, userName, null);
79 }
80
81
82 public static URI SYNTHESYS_SPECIMEN(){
83 // tcsXmlTest.xml
84 URL url = new TcsSources().getClass().getResource("/specimen/SynthesysSpecimenExample.xls");
85 String sourceUrl = url.toString();
86 URI uri = URI.create(sourceUrl);
87 return uri;
88 }
89
90 /**
91 * Initializes the source.
92 * @param dbms
93 * @param strServer
94 * @param strDB
95 * @param port
96 * @param userName
97 * @param pwd
98 * @return the source
99 */
100 private static Source makeSource(String dbms, String strServer, String strDB, int port, String userName, String pwd ){
101 //establish connection
102 Source source = null;
103 source = new Source(dbms, strServer, strDB);
104 source.setPort(port);
105
106 pwd = AccountStore.readOrStorePassword(dbms, strServer, userName, pwd);
107 source.setUserAndPwd(userName, pwd);
108 // write pwd to account store
109 return source;
110 }
111 }