Project

General

Profile

Download (2.99 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;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
}
(12-12/53)