Project

General

Profile

Download (2.83 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;
11

    
12
import java.lang.reflect.Method;
13

    
14
import org.apache.commons.lang3.StringUtils;
15
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
16

    
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
19
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
20
import eu.etaxonomy.cdm.model.reference.Reference;
21
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
22

    
23
/**
24
 * @author a.mueller
25
 * @since 20.03.2008
26
 */
27
public abstract class DbImportConfiguratorBase<STATE extends DbImportStateBase>
28
            extends ImportConfiguratorBase<STATE, Source> {
29

    
30
    private static final long serialVersionUID = 3474072167155099394L;
31
	@SuppressWarnings("unused")
32
    private static Logger logger = LogManager.getLogger(DbImportConfiguratorBase.class);
33

    
34
	private Method userTransformationMethod;
35

    
36
	/* Max number of records to be saved with one service call */
37
	private int recordsPerTransaction = 1000;
38

    
39
	protected DbImportConfiguratorBase(Source source, ICdmDataSource destination, NomenclaturalCode code, IInputTransformer defaultTransformer) {
40
	   super(defaultTransformer);
41
	   setNomenclaturalCode(code);
42
	   setSource(source);
43
	   setDestination(destination);
44
	}
45

    
46
	@Override
47
    public Source getSource() {
48
		return super.getSource();
49
	}
50
	@Override
51
    public void setSource(Source berlinModelSource) {
52
		super.setSource(berlinModelSource);
53
	}
54

    
55
	@Override
56
    public Reference getSourceReference() {
57
		if (sourceReference == null){
58
			sourceReference =  ReferenceFactory.newDatabase();
59
			if (StringUtils.isNotBlank(getSourceReferenceTitle())){
60
			    sourceReference.setTitleCache(getSourceReferenceTitle(), true);
61
			}else if (getSource() != null){
62
				sourceReference.setTitleCache(getSource().getDatabase(), true);
63
			}
64
			if (getSourceRefUuid() != null){
65
				sourceReference.setUuid(getSourceRefUuid());
66
			}
67
		}
68
		return sourceReference;
69
	}
70

    
71
	@Override
72
    public String getSourceNameString() {
73
		if (this.getSource() == null){
74
			return null;
75
		}else{
76
			return this.getSource().getDatabase();
77
		}
78
	}
79

    
80
	public int getRecordsPerTransaction() {
81
		return recordsPerTransaction;
82
	}
83
	public void setRecordsPerTransaction(int recordsPerTransaction) {
84
		this.recordsPerTransaction = recordsPerTransaction;
85
	}
86

    
87
	public Method getUserTransformationMethod() {
88
		return userTransformationMethod;
89
	}
90
	public void setUserTransformationMethod(Method userTransformationMethod) {
91
		this.userTransformationMethod = userTransformationMethod;
92
	}
93
}
(14-14/65)