2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.pesi
.erms
.validation
;
12 import java
.sql
.ResultSet
;
13 import java
.sql
.SQLException
;
15 import org
.apache
.logging
.log4j
.LogManager
;
16 import org
.apache
.logging
.log4j
.Logger
;
18 import eu
.etaxonomy
.cdm
.io
.common
.IOValidator
;
19 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
20 import eu
.etaxonomy
.cdm
.io
.pesi
.erms
.ErmsImportConfigurator
;
21 import eu
.etaxonomy
.cdm
.io
.pesi
.erms
.ErmsImportState
;
27 public class ErmsAreaImportValidator
implements IOValidator
<ErmsImportState
>{
29 private static Logger logger
= LogManager
.getLogger();
32 public boolean validate(ErmsImportState state
){
33 boolean result
= true;
34 ErmsImportConfigurator config
= state
.getConfig();
35 logger
.info("Checking for Areas not yet implemented");
36 // result &= checkTaxonStatus(config);
40 private boolean checkTaxonStatus(ErmsImportConfigurator bmiConfig
){
42 boolean result
= true;
43 Source source
= bmiConfig
.getSource();
44 String strSQL
= " SELECT RelPTaxon.RelQualifierFk, RelPTaxon.relPTaxonId, PTaxon.PTNameFk, PTaxon.PTRefFk, PTaxon_1.PTNameFk AS Expr1, PTaxon.RIdentifier, PTaxon_1.RIdentifier AS Expr3, Name.FullNameCache " +
46 " INNER JOIN PTaxon ON RelPTaxon.PTNameFk1 = PTaxon.PTNameFk AND RelPTaxon.PTRefFk1 = PTaxon.PTRefFk " +
47 " INNER JOIN PTaxon AS PTaxon_1 ON RelPTaxon.PTNameFk2 = PTaxon_1.PTNameFk AND RelPTaxon.PTRefFk2 = PTaxon_1.PTRefFk " +
48 " INNER JOIN Name ON PTaxon.PTNameFk = Name.NameId " +
49 " WHERE (dbo.PTaxon.StatusFk = 1) AND ((RelPTaxon.RelQualifierFk = 7) OR (RelPTaxon.RelQualifierFk = 6) OR (RelPTaxon.RelQualifierFk = 2)) ";
50 ResultSet rs
= source
.getResultSet(strSQL
);
51 boolean firstRow
= true;
56 System
.out
.println("========================================================");
57 logger
.warn("There are taxa that have a 'is synonym of' - relationship but having taxon status 'accepted'!");
58 System
.out
.println("========================================================");
60 int rIdentifier
= rs
.getInt("RIdentifier");
61 int nameFk
= rs
.getInt("PTNameFk");
62 int refFk
= rs
.getInt("PTRefFk");
63 int relPTaxonId
= rs
.getInt("relPTaxonId");
64 String taxonName
= rs
.getString("FullNameCache");
66 System
.out
.println("RIdentifier:" + rIdentifier
+ "\n name: " + nameFk
+
67 "\n taxonName: " + taxonName
+ "\n refId: " + refFk
+ "\n RelPTaxonId: " + relPTaxonId
);
68 result
= firstRow
= false;
71 System
.out
.println(" ");
75 } catch (SQLException e
) {