RoteListeDbImport, in work
[cdmlib-apps.git] / app-import / src / main / java / eu / etaxonomy / cdm / io / redlist / RoteListeDbImportConfigurator.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.redlist;
11
12 import org.apache.log4j.Logger;
13
14 import eu.etaxonomy.cdm.database.ICdmDataSource;
15 import eu.etaxonomy.cdm.io.common.IImportConfigurator;
16 import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
17 import eu.etaxonomy.cdm.io.common.ImportStateBase;
18 import eu.etaxonomy.cdm.io.common.Source;
19 import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
20 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
21 import eu.etaxonomy.cdm.model.reference.Reference;
22 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
23
24
25 /**
26 * @author a.mueller
27 * @created 27.08.2012
28 * @version 1.0
29 */
30 public class RoteListeDbImportConfigurator extends ImportConfiguratorBase<RoteListeDbImportState, Source> implements IImportConfigurator{
31 @SuppressWarnings("unused")
32 private static Logger logger = Logger.getLogger(RoteListeDbImportConfigurator.class);
33
34 public static RoteListeDbImportConfigurator NewInstance(Source ermsSource, ICdmDataSource destination){
35 return new RoteListeDbImportConfigurator(ermsSource, destination);
36 }
37
38 /* Max number of records to be saved with one service call */
39 private int recordsPerTransaction = 1000; //defaultValue
40
41 private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
42 private boolean doTaxa = true;
43
44
45 private static IInputTransformer defaultTransformer = new RoteListeDbTransformer();
46
47 protected void makeIoClassList(){
48 ioClassList = new Class[]{
49 RoteListeDbTaxonImport.class,
50 };
51 }
52
53
54 /* (non-Javadoc)
55 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
56 */
57 public ImportStateBase getNewState() {
58 return new RoteListeDbImportState(this);
59 }
60
61
62
63 private RoteListeDbImportConfigurator(Source source, ICdmDataSource destination) {
64 super(defaultTransformer);
65 setNomenclaturalCode(NomenclaturalCode.ICZN); //default for ERMS
66 setSource(source);
67 setDestination(destination);
68 }
69
70
71 public Source getSource() {
72 return (Source)super.getSource();
73 }
74 public void setSource(Source berlinModelSource) {
75 super.setSource(berlinModelSource);
76 }
77
78 /* (non-Javadoc)
79 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
80 */
81 public Reference getSourceReference() {
82 if (sourceReference == null){
83 sourceReference = ReferenceFactory.newDatabase();
84 if (getSource() != null){
85 sourceReference.setTitleCache(getSource().getDatabase(), true);
86 }
87 }
88 return sourceReference;
89 }
90
91 /* (non-Javadoc)
92 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
93 */
94 public String getSourceNameString() {
95 if (this.getSource() == null){
96 return null;
97 }else{
98 return this.getSource().getDatabase();
99 }
100 }
101
102 /**
103 * @return the limitSave
104 */
105 public int getRecordsPerTransaction() {
106 return recordsPerTransaction;
107 }
108
109 /**
110 * @param limitSave the limitSave to set
111 */
112 public void setRecordsPerTransaction(int recordsPerTransaction) {
113 this.recordsPerTransaction = recordsPerTransaction;
114 }
115
116 public DO_REFERENCES getDoReferences() {
117 return doReferences;
118 }
119 public void setDoReferences(DO_REFERENCES doReferences) {
120 this.doReferences = doReferences;
121 }
122
123 public boolean isDoTaxa() {
124 return doTaxa;
125 }
126 public void setDoTaxa(boolean doTaxa) {
127 this.doTaxa = doTaxa;
128 }
129
130
131
132 }