3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.validation
;
13 import java
.sql
.ResultSet
;
14 import java
.sql
.SQLException
;
16 import org
.apache
.log4j
.Logger
;
18 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportConfigurator
;
19 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportState
;
20 import eu
.etaxonomy
.cdm
.io
.common
.IOValidator
;
21 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
28 public class BerlinModelFactsImportValidator
implements IOValidator
<BerlinModelImportState
> {
29 private static final Logger logger
= Logger
.getLogger(BerlinModelFactsImportValidator
.class);
32 * @see eu.etaxonomy.cdm.io.common.IOValidator#validate(eu.etaxonomy.cdm.io.common.IoStateBase)
34 public boolean validate(BerlinModelImportState state
) {
35 boolean result
= true;
36 result
&= checkDesignationRefsExist(state
);
37 result
&= checkFactsForSynonyms(state
);
42 private boolean checkDesignationRefsExist(BerlinModelImportState state
){
44 boolean result
= true;
45 Source source
= state
.getConfig().getSource();
46 String strQueryArticlesWithoutJournal
= "SELECT Count(*) as n " +
48 " WHERE (NOT (PTDesignationRefFk IS NULL) ) OR " +
49 " (NOT (PTDesignationRefDetailFk IS NULL) )";
50 ResultSet rs
= source
.getResultSet(strQueryArticlesWithoutJournal
);
52 int count
= rs
.getInt("n");
54 System
.out
.println("========================================================");
55 logger
.warn("There are "+count
+" Facts with not empty designation references. Designation references are not imported.");
57 System
.out
.println("========================================================");
60 } catch (SQLException e
) {
67 private boolean checkFactsForSynonyms(BerlinModelImportState state
){
69 boolean result
= true;
70 Source source
= state
.getConfig().getSource();
71 String strQueryArticlesWithoutJournal
= "SELECT Count(*) as n " +
73 "INNER JOIN PTaxon ON Fact.PTNameFk = PTaxon.PTNameFk AND Fact.PTRefFk = PTaxon.PTRefFk" +
74 " WHERE PTaxon.StatusFk IN (2, 3, 4)";
75 ResultSet rs
= source
.getResultSet(strQueryArticlesWithoutJournal
);
77 int count
= rs
.getInt("n");
79 System
.out
.println("========================================================");
80 logger
.warn("There are "+count
+" Facts with attached synonyms.");
82 System
.out
.println("========================================================");
85 } catch (SQLException e
) {