Project

General

Profile

Download (3.67 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.excel.taxa;
11

    
12

    
13
import eu.etaxonomy.cdm.common.URI;
14
import java.util.UUID;
15

    
16
import org.apache.log4j.Logger;
17

    
18
import eu.etaxonomy.cdm.database.DbSchemaValidation;
19
import eu.etaxonomy.cdm.database.ICdmDataSource;
20
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
21
import eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator;
22
import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase;
23
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
24
import eu.etaxonomy.cdm.model.reference.Reference;
25
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
26

    
27
public class NormalExplicitImportConfigurator extends ExcelImportConfiguratorBase implements IImportConfigurator, IMatchingImportConfigurator {
28
	private static final Logger logger = Logger.getLogger(NormalExplicitImportConfigurator.class);
29

    
30
	private boolean isDoMatchTaxa = true;
31

    
32
	private UUID parentUUID;
33

    
34

    
35

    
36

    
37

    
38
	//	@SuppressWarnings("unchecked")
39
	@Override
40
    protected void makeIoClassList() {
41
		ioClassList = new Class[] {
42
				NormalExplicitImport.class
43
		};
44
	}
45

    
46
	public static NormalExplicitImportConfigurator NewInstance(URI uri, ICdmDataSource destination,
47
						NomenclaturalCode nomenclaturalCode, DbSchemaValidation dbSchemaValidation){
48
		return new NormalExplicitImportConfigurator(uri, destination, nomenclaturalCode, dbSchemaValidation);
49
	}
50

    
51

    
52

    
53
	/**
54
	 * @param url
55
	 * @param destination
56
	 */
57
	private NormalExplicitImportConfigurator(URI uri, ICdmDataSource destination, NomenclaturalCode nomenclaturalCode, DbSchemaValidation dbSchemaValidation) {
58
		super(uri, destination);
59
		if (dbSchemaValidation == null){
60
			dbSchemaValidation = DbSchemaValidation.CREATE;
61
		}
62
		setSource(uri);
63
		setDestination(destination);
64
		setDbSchemaValidation(dbSchemaValidation);
65
		setNomenclaturalCode(nomenclaturalCode);
66
	}
67

    
68
	/**
69
     * @param stream
70
     * @param destination
71
     */
72
    private NormalExplicitImportConfigurator(byte[] stream, ICdmDataSource destination, NomenclaturalCode nomenclaturalCode, DbSchemaValidation dbSchemaValidation) {
73
        super(null, destination);
74
        if (dbSchemaValidation == null){
75
            dbSchemaValidation = DbSchemaValidation.CREATE;
76
        }
77
        setStream(stream);
78
        setDestination(destination);
79
        setDbSchemaValidation(dbSchemaValidation);
80
        setNomenclaturalCode(nomenclaturalCode);
81
    }
82

    
83

    
84

    
85

    
86
	/* (non-Javadoc)
87
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
88
	 */
89
	@Override
90
    public TaxonExcelImportState getNewState() {
91
		return new TaxonExcelImportState(this);
92
	}
93

    
94

    
95
	/* (non-Javadoc)
96
	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
97
	 */
98
	@Override
99
	public Reference getSourceReference() {
100
		//TODO
101
		if (this.sourceReference == null){
102
			logger.warn("getSource Reference not yet fully implemented");
103
			sourceReference = ReferenceFactory.newGeneric();
104
			sourceReference.setTitleCache("Excel Taxon import", true);
105
		}
106
		return sourceReference;
107
	}
108

    
109

    
110
	@Override
111
    public boolean isReuseExistingTaxaWhenPossible() {
112
		return isDoMatchTaxa;
113
	}
114

    
115
	@Override
116
    public void setReuseExistingTaxaWhenPossible(boolean isDoMatchTaxa) {
117
		this.isDoMatchTaxa = isDoMatchTaxa;
118
	}
119

    
120

    
121
    public UUID getParentUUID(){
122
        return parentUUID;
123
    }
124

    
125

    
126
    public void setParentUUID(UUID parentUUID) {
127
        this.parentUUID = parentUUID;
128
    }
129

    
130

    
131

    
132

    
133
}
(3-3/8)