Project

General

Profile

Download (2.18 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.out;
11

    
12
import java.sql.Types;
13

    
14
import org.apache.log4j.Logger;
15
import org.joda.time.DateTime;
16

    
17
/**
18
 * @author a.mueller
19
 * @since 12.05.2009
20
 */
21
public class DbDateMapper extends DbSingleAttributeExportMapperBase implements IDbExportMapper {
22

    
23
	@SuppressWarnings("unused")
24
	private static final Logger logger = Logger.getLogger(DbStringMapper.class);
25

    
26
	public static DbDateMapper NewInstance(String cdmAttributeString, String dbAttributeString){
27
		return new DbDateMapper(cdmAttributeString, dbAttributeString, null);
28
	}
29

    
30
	public static DbDateMapper NewInstance(String cdmAttributeString, String dbAttributeString, DateTime defaultValue){
31
		return new DbDateMapper(cdmAttributeString, dbAttributeString, defaultValue);
32
	}
33

    
34
	private DbDateMapper(String cdmAttributeString, String dbAttributeString, DateTime defaultValue) {
35
		super(cdmAttributeString, dbAttributeString, defaultValue);
36
	}
37

    
38
//	@Override
39
//	protected boolean doInvoke(CdmBase cdmBase) throws SQLException{
40
//		boolean obligat = true;
41
//		try {
42
//			DateTime value = (DateTime)ImportHelper.getValue(
43
//					cdmBase, this.getSourceAttribute(), this.getTypeClass(), false, obligat);
44
//			if (value == null){
45
//				getPreparedStatement().setNull(getIndex(), Types.DATE);
46
//			}else{
47
//				java.util.Date date = value.toDate();
48
//				long t = date.getTime();
49
//				java.sql.Date sqlDate = new java.sql.Date(t);
50
//				getPreparedStatement().setDate(getIndex(), sqlDate);
51
//			}
52
//			return true;
53
//		} catch (SQLException e) {
54
//			logger.warn("SQL Exception: " + e.getLocalizedMessage());
55
//			throw e;
56
//		}
57
//	}
58

    
59
//	@Override
60
//	protected Object getValue(CdmBase cdmBase) {
61
//		boolean obligat = true;
62
//		return (DateTime)ImportHelper.getValue(cdmBase, this.getSourceAttribute(), this.getTypeClass(), false, obligat);
63
//	}
64

    
65

    
66

    
67
	@Override
68
	protected int getSqlType() {
69
		return Types.DATE;
70
	}
71

    
72
	@Override
73
	public Class<?> getTypeClass() {
74
		return DateTime.class;
75
	}
76
}
(9-9/44)