AT: committing merge changes
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / common / DbExportConfiguratorBase.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;
11
12 import org.apache.log4j.Logger;
13
14 import eu.etaxonomy.cdm.database.ICdmDataSource;
15 import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
16 import eu.etaxonomy.cdm.model.reference.IDatabase;
17 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
18
19
20 /**
21 * @author a.mueller
22 * @created 20.03.2008
23 * @version 1.0
24 */
25 public abstract class DbExportConfiguratorBase<STATE extends ExportStateBase, TRANSFORM extends IExportTransformer> extends ExportConfiguratorBase<Source, STATE, TRANSFORM> implements IExportConfigurator<STATE, TRANSFORM>{
26 @SuppressWarnings("unused")
27 private static Logger logger = Logger.getLogger(DbExportConfiguratorBase.class);
28
29
30 public enum IdType{
31 CDM_ID,
32 CDM_ID_WITH_EXCEPTIONS,
33 ORIGINAL_SOURCE_ID,
34 MAX_ID
35 }
36
37 private IdType idType = IdType.CDM_ID;
38
39 public DbExportConfiguratorBase(TRANSFORM transformer) {
40 super(transformer);
41 }
42
43
44 /**
45 * @return the idType
46 */
47 public IdType getIdType() {
48 return idType;
49 }
50
51 /**
52 * @param idType the idType to set
53 */
54 public void setIdType(IdType idType) {
55 this.idType = idType;
56 }
57
58
59 /* (non-Javadoc)
60 * @see eu.etaxonomy.cdm.io.common.IIoConfigurator#getDestinationNameString()
61 */
62 public String getDestinationNameString() {
63 if (getDestination() != null){
64 return getDestination().getDatabase();
65 }else{
66 return null;
67 }
68 }
69
70
71 public ICdmDataSource getSource() {
72 return (ICdmDataSource)super.getSource();
73 }
74 public void setSource(ICdmDataSource cdmSource) {
75 super.setSource(cdmSource);
76 }
77
78 /* (non-Javadoc)
79 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
80 */
81 public String getSourceNameString() {
82 if (this.getSource() == null){
83 return null;
84 }else{
85 return this.getSource().getDatabase();
86 }
87 }
88
89
90 /* (non-Javadoc)
91 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
92 */
93 public IDatabase getSourceReference() {
94
95 if (sourceReference == null){
96 sourceReference = ReferenceFactory.newDatabase();
97 if (getSource() != null){
98 sourceReference.setTitleCache(getSource().getDatabase(), true);
99 }
100 }
101 return sourceReference;
102 }
103 }