Project

General

Profile

Download (6.65 KB) Statistics
| Branch: | Revision:
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.eflora.centralAfrica.ferns.validation;
12

    
13
import org.apache.log4j.Logger;
14

    
15
import eu.etaxonomy.cdm.io.common.IOValidator;
16
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.CentralAfricaFernsImportConfigurator;
17
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.CentralAfricaFernsImportState;
18

    
19
/**
20
 * @author a.mueller
21
 * @created 17.02.2010
22
 * @version 1.0
23
 */
24
public class CentralAfricaFernsReferenceImportValidator implements IOValidator<CentralAfricaFernsImportState>{
25
	private static final Logger logger = Logger.getLogger(CentralAfricaFernsReferenceImportValidator.class);
26

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

    
143

    
144
}
(1-1/2)