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
.algaterra
.validation
;
13 import java
.sql
.ResultSet
;
14 import java
.sql
.SQLException
;
16 import org
.apache
.commons
.lang
.StringUtils
;
17 import org
.apache
.log4j
.Logger
;
19 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportConfigurator
;
20 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportState
;
21 import eu
.etaxonomy
.cdm
.io
.common
.IOValidator
;
22 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
29 public class AlgaTerraTypeImportValidator
implements IOValidator
<BerlinModelImportState
> {
30 private static final Logger logger
= Logger
.getLogger(AlgaTerraTypeImportValidator
.class);
33 * @see eu.etaxonomy.cdm.io.common.IOValidator#validate(eu.etaxonomy.cdm.io.common.IoStateBase)
35 public boolean validate(BerlinModelImportState state
) {
36 boolean result
= true;
37 BerlinModelImportConfigurator bmiConfig
= state
.getConfig();
38 result
&= checkMultipleEntriesInTypeSpecimenDesignation(bmiConfig
);
39 //result &= checkPartOfJournal(bmiConfig);
40 System
.out
.println("Checking for Specimen not yet fully implemented");
45 //******************************** CHECK *************************************************
47 private static boolean checkMultipleEntriesInTypeSpecimenDesignation(BerlinModelImportConfigurator config
){
49 boolean result
= true;
50 Source source
= config
.getSource();
51 String strQuery
= " SELECT COUNT(*) AS n, TypeSpecimenFk " +
52 " FROM TypeSpecimenDesignation " +
53 " GROUP BY TypeSpecimenFk " +
54 " HAVING (COUNT(*) > 1) ";
56 ResultSet resulSet
= source
.getResultSet(strQuery
);
58 System
.out
.println("========================================================");
59 System
.out
.println("There are multiple TypeSpecimenDesignations sharing the same TypeSpecimen!");
60 System
.out
.println("This is not supported by the current import and will lead to duplicates!");
61 System
.out
.println("========================================================");
65 strQuery
= " SELECT COUNT(*) AS n, TypeDesignationFk " +
66 " FROM TypeSpecimenDesignation " +
67 " GROUP BY TypeDesignationFk " +
68 " HAVING (COUNT(*) > 1) ";
70 resulSet
= source
.getResultSet(strQuery
);
72 System
.out
.println("========================================================");
73 System
.out
.println("There are multiple TypeSpecimenDesignations sharing the same TypeDesignation!");
74 System
.out
.println("This is not supported by the current import and will lead to duplicates!");
75 System
.out
.println("========================================================");
81 } catch (SQLException e
) {