1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.validation;
|
11
|
|
12
|
import org.apache.log4j.Logger;
|
13
|
|
14
|
import eu.etaxonomy.cdm.io.common.IOValidator;
|
15
|
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.CentralAfricaFernsImportConfigurator;
|
16
|
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.CentralAfricaFernsImportState;
|
17
|
|
18
|
/**
|
19
|
* @author a.mueller
|
20
|
* @created 17.02.2010
|
21
|
* @version 1.0
|
22
|
*/
|
23
|
public class CentralAfricaFernsTaxonImportValidator implements IOValidator<CentralAfricaFernsImportState>{
|
24
|
private static final Logger logger = Logger.getLogger(CentralAfricaFernsTaxonImportValidator.class);
|
25
|
|
26
|
public boolean validate(CentralAfricaFernsImportState state){
|
27
|
boolean result = true;
|
28
|
CentralAfricaFernsImportConfigurator config = state.getConfig();
|
29
|
logger.warn("Checking for Taxa not yet fully implemented");
|
30
|
// result &= checkParentTaxonStatus(config);
|
31
|
// result &= checkAccParentTaxonStatus(config);
|
32
|
result &= checkSynonymsAcceptedTaxonStatus(config);
|
33
|
return result;
|
34
|
}
|
35
|
|
36
|
// private boolean checkAccParentTaxonStatus(CentralAfricaFernsImportConfigurator bmiConfig){
|
37
|
// try {
|
38
|
// boolean result = true;
|
39
|
// Source source = bmiConfig.getSource();
|
40
|
// String strSQL =
|
41
|
// " SELECT myTaxon.id AS childId, childStatus.status_name AS childStatus, myTaxon.tu_status, " +
|
42
|
// " myTaxon.tu_displayname AS childDisplayName, parent.id AS parentId, parent.tu_status AS parentStatusId, parentStatus.status_name AS parentStatus, " +
|
43
|
// " parent.tu_displayname as parentName, parentAcc.id AS parentAccId, parentAccStatus.status_name AS parentAccStatus, parentAcc.tu_displayname AS parentAccName, " +
|
44
|
// " parentAcc.tu_status AS Expr1 " +
|
45
|
// " FROM status AS parentAccStatus INNER JOIN " +
|
46
|
// " tu AS parentAcc ON parentAccStatus.status_id = parentAcc.tu_status RIGHT OUTER JOIN " +
|
47
|
// " tu AS parent ON parentAcc.id = parent.tu_acctaxon RIGHT OUTER JOIN " +
|
48
|
// " tu AS myTaxon ON parent.id = myTaxon.tu_parent LEFT OUTER JOIN " +
|
49
|
// " status AS parentStatus ON parent.tu_status = parentStatus.status_id LEFT OUTER JOIN " +
|
50
|
// " status AS childStatus ON myTaxon.tu_status = childStatus.status_id " +
|
51
|
// " WHERE (myTaxon.tu_status = 1) AND (parent.tu_status <> 1) " +
|
52
|
// " ORDER BY parentStatusId";
|
53
|
// ResultSet rs = source.getResultSet(strSQL);
|
54
|
// boolean firstRow = true;
|
55
|
// int i = 0;
|
56
|
// while (rs.next()){
|
57
|
// i++;
|
58
|
// if (firstRow){
|
59
|
// System.out.println("========================================================");
|
60
|
// logger.warn("There are accepted taxa that have an unaccepted parent and also the parents accepted taxon (tu_acctaxon) is not accepted. ");
|
61
|
// System.out.println("========================================================");
|
62
|
// }
|
63
|
// int childId = rs.getInt("childId");
|
64
|
// String childName = rs.getString("childDisplayName");
|
65
|
//
|
66
|
// int parentId = rs.getInt("parentId");
|
67
|
// String parentName = rs.getString("parentName");
|
68
|
// String parentStatus = rs.getString("parentStatus");
|
69
|
//
|
70
|
// int accParentId = rs.getInt("parentAccId");
|
71
|
// String accParentName = rs.getString("parentAccName");
|
72
|
// String accParentStatus = rs.getString("parentAccStatus");
|
73
|
//
|
74
|
// System.out.println(
|
75
|
// "ChildId:" + childId + "\n childName: " + childName +
|
76
|
// "\n ParentId: " + parentId + "\n parentName: " + parentName + "\n parentStatus: " + parentStatus +
|
77
|
// "\n ParentAccId: " + accParentId + "\n accParentName: " + accParentName + "\n accParentStatus: " + accParentStatus );
|
78
|
// result = firstRow = false;
|
79
|
// }
|
80
|
// if (i > 0){
|
81
|
// System.out.println(" ");
|
82
|
// }
|
83
|
//
|
84
|
// return result;
|
85
|
// } catch (SQLException e) {
|
86
|
// e.printStackTrace();
|
87
|
// return false;
|
88
|
// }
|
89
|
// }
|
90
|
|
91
|
private boolean checkSynonymsAcceptedTaxonStatus(CentralAfricaFernsImportConfigurator bmiConfig){
|
92
|
// try {
|
93
|
// boolean result = true;
|
94
|
//// Source source = bmiConfig.getSource();
|
95
|
//// String strSQL =
|
96
|
//// " SELECT myTaxon.id AS synonymId, myTaxon.tu_displayname AS synonymName, synonymStatus.status_name AS synonymStatus, " +
|
97
|
//// " accTaxon.id AS acceptedId, accTaxon.tu_displayname AS acceptedName, acceptedStatus.status_name AS acceptedStatus " +
|
98
|
//// " FROM tu AS myTaxon INNER JOIN " +
|
99
|
//// " tu AS accTaxon ON myTaxon.tu_acctaxon = accTaxon.id INNER JOIN " +
|
100
|
//// " status AS synonymStatus ON myTaxon.tu_status = synonymStatus.status_id INNER JOIN " +
|
101
|
//// " status AS acceptedStatus ON accTaxon.tu_status = acceptedStatus.status_id " +
|
102
|
//// " WHERE (myTaxon.tu_status <> 1) AND (accTaxon.tu_status <> 1) " +
|
103
|
//// " ORDER BY myTaxon.tu_status, accTaxon.tu_status ";
|
104
|
//// ResultSet rs = source.getResultSet(strSQL);
|
105
|
//// boolean firstRow = true;
|
106
|
//// int i = 0;
|
107
|
//// while (rs.next()){
|
108
|
//// i++;
|
109
|
//// if (firstRow){
|
110
|
//// System.out.println("========================================================");
|
111
|
//// logger.warn("There are accepted synonyms that have an unaccepted taxon that has no status 'accepted'. ");
|
112
|
//// System.out.println("========================================================");
|
113
|
//// }
|
114
|
//// int synonymId = rs.getInt("synonymId");
|
115
|
//// String synonymName = rs.getString("synonymName");
|
116
|
//// String synonymStatus = rs.getString("synonymStatus");
|
117
|
////
|
118
|
//// int acceptedId = rs.getInt("acceptedId");
|
119
|
//// String acceptedName = rs.getString("acceptedName");
|
120
|
//// String acceptedStatus = rs.getString("acceptedStatus");
|
121
|
////
|
122
|
//// System.out.println(
|
123
|
//// "SynonymId:" + synonymId + "\n synonymName: " + synonymName + "\n synonymStatus: " + synonymStatus +
|
124
|
//// "\n AcceptedId: " + acceptedId + "\n acceptedName: " + acceptedName + "\n acceptedStatus: " + acceptedStatus
|
125
|
////// + "\n parentAccId: " + acceptedId + "\n accParentName: " + accParentName + "\n accParentStatus: " + accParentStatus
|
126
|
//// );
|
127
|
//// result = firstRow = false;
|
128
|
//// }
|
129
|
//// if (i > 0){
|
130
|
//// System.out.println(" ");
|
131
|
//// }
|
132
|
////
|
133
|
// return result;
|
134
|
// } catch (SQLException e) {
|
135
|
// e.printStackTrace();
|
136
|
// return false;
|
137
|
// }
|
138
|
return true;
|
139
|
}
|
140
|
|
141
|
|
142
|
|
143
|
}
|