Project

General

Profile

Download (2.97 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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
package eu.etaxonomy.cdm.io.distribution.excelupdate;
10

    
11
import java.net.URI;
12
import java.util.UUID;
13

    
14
import eu.etaxonomy.cdm.database.ICdmDataSource;
15
import eu.etaxonomy.cdm.io.common.ImportStateBase;
16
import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase;
17
import eu.etaxonomy.cdm.model.reference.Reference;
18
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
19

    
20
/**
21
 * @author a.mueller
22
 * @since 06.04.2017
23
 */
24
public class ExcelDistributionUpdateConfigurator extends ExcelImportConfiguratorBase{
25

    
26
    private static final long serialVersionUID = -2464249013501268222L;
27

    
28
    private UUID areaVocabularyUuid;
29

    
30
    private boolean createNewDistribution = true;
31

    
32
    public static ExcelDistributionUpdateConfigurator NewInstance(URI uri, ICdmDataSource destination, UUID areaVocabularyUuid){
33
        ExcelDistributionUpdateConfigurator result = new ExcelDistributionUpdateConfigurator(uri, destination, areaVocabularyUuid);
34
        return result;
35
    }
36

    
37
    protected ExcelDistributionUpdateConfigurator(URI uri, ICdmDataSource destination, UUID areaVocabularyUuid) {
38
        super(uri, destination, null);
39
        this.areaVocabularyUuid = areaVocabularyUuid;
40
    }
41

    
42
    @Override
43
    public <STATE extends ImportStateBase> STATE getNewState() {
44
        return (STATE)new ExcelDistributionUpdateState(this);
45
    }
46

    
47
    @Override
48
    protected void makeIoClassList() {
49
        ioClassList = new Class[]{
50
                ExcelDistributionUpdate.class
51
        };
52
    }
53

    
54
    @Override
55
    public boolean isValid(){
56
        if (this.areaVocabularyUuid != null && (this.getStream() != null || this.getSource() != null)){
57
            return true;
58
        } else {
59
            return false;
60
        }
61
    }
62

    
63
    @Override
64
    public Reference getSourceReference() {
65
        if (this.sourceReference == null){
66
            sourceReference = ReferenceFactory.newGeneric();
67
            if (this.getSource() == null){
68
                sourceReference.setTitleCache("Excel Distribution Update " + getDateString(), true);
69
            }else{
70
                sourceReference.setTitleCache(getSource().toString(), true);
71
            }
72
        }
73
        return sourceReference;
74
    }
75

    
76
    protected boolean needsNomenclaturalCode() {
77
        return false;
78
    }
79

    
80
// ********************** GETTER / SETTER **************************/
81

    
82
    public UUID getAreaVocabularyUuid() {
83
        return this.areaVocabularyUuid;
84
    }
85

    
86
    public void setAreaVocabularyUuid(UUID areaVocabularyUuid) {
87
        this.areaVocabularyUuid = areaVocabularyUuid;
88
    }
89

    
90
    public boolean isCreateNewDistribution() {
91
        return createNewDistribution;
92
    }
93

    
94
    public void setCreateNewDistribution(boolean createNewDistribution) {
95
        this.createNewDistribution = createNewDistribution;
96
    }
97
}
(2-2/3)