1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 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
|
|
11
|
package eu.etaxonomy.cdm.io.pesi.erms.validation;
|
12
|
|
13
|
import java.sql.ResultSet;
|
14
|
import java.sql.SQLException;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
|
18
|
|
19
|
import eu.etaxonomy.cdm.io.common.IOValidator;
|
20
|
import eu.etaxonomy.cdm.io.common.Source;
|
21
|
import eu.etaxonomy.cdm.io.pesi.erms.ErmsImportConfigurator;
|
22
|
import eu.etaxonomy.cdm.io.pesi.erms.ErmsImportState;
|
23
|
|
24
|
/**
|
25
|
* @author a.mueller
|
26
|
* @created 17.02.2010
|
27
|
* @version 1.0
|
28
|
*/
|
29
|
public class ErmsSourceUsesImportValidator implements IOValidator<ErmsImportState>{
|
30
|
private static final Logger logger = Logger.getLogger(ErmsSourceUsesImportValidator.class);
|
31
|
|
32
|
public boolean validate(ErmsImportState state){
|
33
|
boolean result = true;
|
34
|
ErmsImportConfigurator config = state.getConfig();
|
35
|
logger.warn("Checking for source uses not yet fully implemented");
|
36
|
// result &= checkTaxonStatus(config);
|
37
|
// result &= checkInactivated(config);
|
38
|
return result;
|
39
|
}
|
40
|
|
41
|
|
42
|
|
43
|
private boolean checkTaxonStatus(ErmsImportConfigurator bmiConfig){
|
44
|
try {
|
45
|
boolean result = true;
|
46
|
Source source = bmiConfig.getSource();
|
47
|
String strSQL = " SELECT tu_sources.sourceuse_id, sourceuses.sourceuse_name, tu.tu_acctaxon, tu.tu_parent, tu.id, tu.tu_name, " +
|
48
|
" tu.tu_authority, tu.tu_displayname, status.status_name " +
|
49
|
" FROM tu_sources " +
|
50
|
" INNER JOIN sourceuses ON tu_sources.sourceuse_id = sourceuses.sourceuse_id " +
|
51
|
" INNER JOIN tu ON tu_sources.tu_id = tu.id " +
|
52
|
" INNER JOIN status ON dbo.tu.tu_status = dbo.status.status_id " +
|
53
|
" WHERE (tu_sources.sourceuse_id = 4) ";
|
54
|
ResultSet rs = source.getResultSet(strSQL);
|
55
|
boolean firstRow = true;
|
56
|
int i = 0;
|
57
|
while (rs.next()){
|
58
|
i++;
|
59
|
if (firstRow){
|
60
|
System.out.println("========================================================");
|
61
|
logger.warn("There are source uses of typ 'source of synonymy' having equal 'id' and 'tu_acctaxon'");
|
62
|
System.out.println("========================================================");
|
63
|
}
|
64
|
int id = rs.getInt("id");
|
65
|
String tu_displayname = rs.getString("tu_displayname");
|
66
|
String status_name = rs.getString("status_name");
|
67
|
|
68
|
System.out.println("id:" + id + "\n name: " + tu_displayname +
|
69
|
"\n status name: " + status_name );
|
70
|
result = firstRow = false;
|
71
|
}
|
72
|
if (i > 0){
|
73
|
System.out.println(" ");
|
74
|
}
|
75
|
|
76
|
return result;
|
77
|
} catch (SQLException e) {
|
78
|
e.printStackTrace();
|
79
|
return false;
|
80
|
}
|
81
|
}
|
82
|
|
83
|
|
84
|
|
85
|
}
|