*renaming files
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / common / DbImportConfiguratorBase.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 java.lang.reflect.Method;
13
14 import org.apache.log4j.Logger;
15
16 import eu.etaxonomy.cdm.database.ICdmDataSource;
17 import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
18 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
19 import eu.etaxonomy.cdm.model.reference.Reference;
20 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
21
22 /**
23 * @author a.mueller
24 * @created 20.03.2008
25 * @version 1.0
26 */
27 public abstract class DbImportConfiguratorBase<STATE extends DbImportStateBase> extends ImportConfiguratorBase<STATE, Source> implements IImportConfigurator{
28 @SuppressWarnings("unused")
29 private static Logger logger = Logger.getLogger(DbImportConfiguratorBase.class);
30
31 private Method userTransformationMethod;
32
33 /* Max number of records to be saved with one service call */
34 private int recordsPerTransaction = 1000;
35
36 /**
37 * @param source
38 * @param destination
39 * @param code
40 */
41 protected DbImportConfiguratorBase(Source source, ICdmDataSource destination, NomenclaturalCode code, IInputTransformer defaultTransformer) {
42 super(defaultTransformer);
43 setNomenclaturalCode(code);
44 setSource(source);
45 setDestination(destination);
46 }
47
48
49 public Source getSource() {
50 return (Source)super.getSource();
51 }
52 public void setSource(Source berlinModelSource) {
53 super.setSource(berlinModelSource);
54 }
55
56
57 /* (non-Javadoc)
58 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
59 */
60 public Reference getSourceReference() {
61 if (sourceReference == null){
62 sourceReference = ReferenceFactory.newDatabase();
63 if (getSource() != null){
64 sourceReference.setTitleCache(getSource().getDatabase(), true);
65 }
66 if (getSourceRefUuid() != null){
67 sourceReference.setUuid(getSourceRefUuid());
68 }
69 }
70 return sourceReference;
71 }
72
73
74 /* (non-Javadoc)
75 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
76 */
77 public String getSourceNameString() {
78 if (this.getSource() == null){
79 return null;
80 }else{
81 return this.getSource().getDatabase();
82 }
83 }
84
85 /**
86 * @return the limitSave
87 */
88 public int getRecordsPerTransaction() {
89 return recordsPerTransaction;
90 }
91
92 /**
93 * @param limitSave the limitSave to set
94 */
95 public void setRecordsPerTransaction(int recordsPerTransaction) {
96 this.recordsPerTransaction = recordsPerTransaction;
97 }
98
99
100 /**
101 * @return the userTransformationMethod
102 */
103 public Method getUserTransformationMethod() {
104 return userTransformationMethod;
105 }
106
107 /**
108 * @param userTransformationMethod the userTransformationMethod to set
109 */
110 public void setUserTransformationMethod(Method userTransformationMethod) {
111 this.userTransformationMethod = userTransformationMethod;
112 }
113
114
115 }