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