Revision f905a388
Added by Andreas Müller almost 2 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/mapping/DbImportDistributionCreationMapper.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.io.common.mapping; |
|
11 |
|
|
12 |
import java.sql.ResultSet; |
|
13 |
import java.sql.SQLException; |
|
14 |
|
|
15 |
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.io.common.DbImportStateBase; |
|
18 |
import eu.etaxonomy.cdm.model.description.Distribution; |
|
19 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
|
20 |
|
|
21 |
/** |
|
22 |
* This Mapper creates a distribution and adds it to a taxon. |
|
23 |
* @author a.mueller |
|
24 |
* @since 11.03.2010 |
|
25 |
*/ |
|
26 |
public class DbImportDistributionCreationMapper<STATE extends DbImportStateBase<?,?>> |
|
27 |
extends DbImportDescriptionElementCreationMapperBase<Distribution, DbImportStateBase<?,?>> { |
|
28 |
|
|
29 |
@SuppressWarnings("unused") |
|
30 |
private static final Logger logger = LogManager.getLogger(DbImportDistributionCreationMapper.class); |
|
31 |
|
|
32 |
//******************************** FACTORY METHOD ***************************************************/ |
|
33 |
|
|
34 |
/** |
|
35 |
* Creates a Distribution and adds it to the description of a taxon. |
|
36 |
* @param dbIdAttribute |
|
37 |
* @param objectToCreateNamespace |
|
38 |
* @param dbTaxonFkAttribute |
|
39 |
* @param taxonNamespace |
|
40 |
* @return |
|
41 |
*/ |
|
42 |
public static DbImportDistributionCreationMapper<?> NewInstance(String dbIdAttribute, String objectToCreateNamespace, String dbTaxonFkAttribute, String taxonNamespace){ |
|
43 |
PresenceAbsenceTerm status = null; |
|
44 |
return new DbImportDistributionCreationMapper<>(dbIdAttribute, objectToCreateNamespace, dbTaxonFkAttribute, taxonNamespace, status); |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Creates a Distribution with status <code>status</code> and adds it to the description of a taxon. |
|
49 |
*/ |
|
50 |
public static DbImportDistributionCreationMapper<?> NewFixedStatusInstance(String dbIdAttribute, String objectToCreateNamespace, String dbTaxonFkAttribute, String taxonNamespace, PresenceAbsenceTerm status){ |
|
51 |
return new DbImportDistributionCreationMapper<>(dbIdAttribute, objectToCreateNamespace, dbTaxonFkAttribute, taxonNamespace, status); |
|
52 |
} |
|
53 |
|
|
54 |
//******************************* ATTRIBUTES ***************************************/ |
|
55 |
|
|
56 |
protected PresenceAbsenceTerm status; |
|
57 |
|
|
58 |
//********************************* CONSTRUCTOR ****************************************/ |
|
59 |
|
|
60 |
protected DbImportDistributionCreationMapper(String dbIdAttribute, String objectToCreateNamespace, String dbTaxonFkAttribute, String taxonNamespace, PresenceAbsenceTerm status) { |
|
61 |
super(dbIdAttribute, objectToCreateNamespace, dbTaxonFkAttribute, taxonNamespace); |
|
62 |
this.status = status; |
|
63 |
} |
|
64 |
|
|
65 |
//************************************ METHODS *******************************************/ |
|
66 |
|
|
67 |
@Override |
|
68 |
protected Distribution createObject(ResultSet rs) throws SQLException { |
|
69 |
Distribution distribution = Distribution.NewInstance(null, null); |
|
70 |
distribution.setStatus(status); |
|
71 |
return distribution; |
|
72 |
} |
|
73 |
} |
|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.io.common.mapping; |
|
11 |
|
|
12 |
import java.sql.ResultSet; |
|
13 |
import java.sql.SQLException; |
|
14 |
|
|
15 |
import org.apache.logging.log4j.LogManager; |
|
16 |
import org.apache.logging.log4j.Logger; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.io.common.DbImportStateBase; |
|
19 |
import eu.etaxonomy.cdm.model.description.Distribution; |
|
20 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
|
21 |
|
|
22 |
/** |
|
23 |
* This Mapper creates a distribution and adds it to a taxon. |
|
24 |
* @author a.mueller |
|
25 |
* @since 11.03.2010 |
|
26 |
*/ |
|
27 |
public class DbImportDistributionCreationMapper<STATE extends DbImportStateBase<?,?>> |
|
28 |
extends DbImportDescriptionElementCreationMapperBase<Distribution, DbImportStateBase<?,?>> { |
|
29 |
|
|
30 |
@SuppressWarnings("unused") |
|
31 |
private static final Logger logger = LogManager.getLogger(); |
|
32 |
|
|
33 |
//******************************** FACTORY METHOD ***************************************************/ |
|
34 |
|
|
35 |
/** |
|
36 |
* Creates a Distribution and adds it to the description of a taxon. |
|
37 |
* @param dbIdAttribute |
|
38 |
* @param objectToCreateNamespace |
|
39 |
* @param dbTaxonFkAttribute |
|
40 |
* @param taxonNamespace |
|
41 |
* @return |
|
42 |
*/ |
|
43 |
public static DbImportDistributionCreationMapper<?> NewInstance(String dbIdAttribute, String objectToCreateNamespace, String dbTaxonFkAttribute, String taxonNamespace){ |
|
44 |
PresenceAbsenceTerm status = null; |
|
45 |
return new DbImportDistributionCreationMapper<>(dbIdAttribute, objectToCreateNamespace, dbTaxonFkAttribute, taxonNamespace, status); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Creates a Distribution with status <code>status</code> and adds it to the description of a taxon. |
|
50 |
*/ |
|
51 |
public static DbImportDistributionCreationMapper<?> NewFixedStatusInstance(String dbIdAttribute, String objectToCreateNamespace, String dbTaxonFkAttribute, String taxonNamespace, PresenceAbsenceTerm status){ |
|
52 |
return new DbImportDistributionCreationMapper<>(dbIdAttribute, objectToCreateNamespace, dbTaxonFkAttribute, taxonNamespace, status); |
|
53 |
} |
|
54 |
|
|
55 |
//******************************* ATTRIBUTES ***************************************/ |
|
56 |
|
|
57 |
protected PresenceAbsenceTerm status; |
|
58 |
|
|
59 |
//********************************* CONSTRUCTOR ****************************************/ |
|
60 |
|
|
61 |
protected DbImportDistributionCreationMapper(String dbIdAttribute, String objectToCreateNamespace, String dbTaxonFkAttribute, String taxonNamespace, PresenceAbsenceTerm status) { |
|
62 |
super(dbIdAttribute, objectToCreateNamespace, dbTaxonFkAttribute, taxonNamespace); |
|
63 |
this.status = status; |
|
64 |
} |
|
65 |
|
|
66 |
//************************************ METHODS *******************************************/ |
|
67 |
|
|
68 |
@Override |
|
69 |
protected Distribution createObject(ResultSet rs) throws SQLException { |
|
70 |
Distribution distribution = Distribution.NewInstance(null, null); |
|
71 |
distribution.setStatus(status); |
|
72 |
return distribution; |
|
73 |
} |
|
74 |
} |
Also available in: Unified diff
cleanup