Project

General

Profile

Download (2.88 KB) Statistics
| Branch: | Tag: | Revision:
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
}
(12-12/53)