new synthesys source
[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_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 // BerlinModel - Pesi-ERMS
56 String dbms = Source.SQL_SERVER_2005;
57 String strServer = "LENOVO-T61";
58 String strDB = "globis";
59 int port = 1433;
60 String userName = "adam";
61 return makeSource(dbms, strServer, strDB, port, userName, null);
62 }
63
64 public static Source GLOBIS_ODBC(){
65 // BerlinModel - Pesi-ERMS
66 String dbms = Source.ODDBC;
67 String strServer = "LENOVO-T61";
68 String strDB = "globis";
69 int port = 1433;
70 String userName = "sa";
71 return makeSource(dbms, strServer, strDB, port, userName, null);
72 }
73
74
75 public static URI SYNTHESYS_SPECIMEN(){
76 // tcsXmlTest.xml
77 URL url = new TcsSources().getClass().getResource("/specimen/SynthesysSpecimenExample.xls");
78 String sourceUrl = url.toString();
79 URI uri = URI.create(sourceUrl);
80 return uri;
81 }
82
83 /**
84 * Initializes the source.
85 * @param dbms
86 * @param strServer
87 * @param strDB
88 * @param port
89 * @param userName
90 * @param pwd
91 * @return the source
92 */
93 private static Source makeSource(String dbms, String strServer, String strDB, int port, String userName, String pwd ){
94 //establish connection
95 Source source = null;
96 source = new Source(dbms, strServer, strDB);
97 source.setPort(port);
98
99 pwd = AccountStore.readOrStorePassword(dbms, strServer, userName, pwd);
100 source.setUserAndPwd(userName, pwd);
101 // write pwd to account store
102 return source;
103 }
104 }