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
|
*/
|
25
|
public class ExcelDistributionUpdateConfigurator extends ExcelImportConfiguratorBase{
|
26
|
|
27
|
private static final long serialVersionUID = -2464249013501268222L;
|
28
|
|
29
|
private UUID areaVocabularyUuid;
|
30
|
|
31
|
private boolean createNewDistribution = true;
|
32
|
|
33
|
public static ExcelDistributionUpdateConfigurator NewInstance(URI uri, ICdmDataSource destination, UUID areaVocabularyUuid){
|
34
|
ExcelDistributionUpdateConfigurator result = new ExcelDistributionUpdateConfigurator(uri, destination, areaVocabularyUuid);
|
35
|
return result;
|
36
|
}
|
37
|
|
38
|
/**
|
39
|
* @param uri
|
40
|
* @param destination
|
41
|
* @param transformer
|
42
|
*/
|
43
|
protected ExcelDistributionUpdateConfigurator(URI uri, ICdmDataSource destination, UUID areaVocabularyUuid) {
|
44
|
super(uri, destination, null);
|
45
|
this.areaVocabularyUuid = areaVocabularyUuid;
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* {@inheritDoc}
|
50
|
*/
|
51
|
@Override
|
52
|
public <STATE extends ImportStateBase> STATE getNewState() {
|
53
|
return (STATE)new ExcelDistributionUpdateState(this);
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* {@inheritDoc}
|
58
|
*/
|
59
|
@Override
|
60
|
protected void makeIoClassList() {
|
61
|
ioClassList = new Class[]{
|
62
|
ExcelDistributionUpdate.class
|
63
|
};
|
64
|
}
|
65
|
|
66
|
|
67
|
@Override
|
68
|
public boolean isValid(){
|
69
|
if (this.areaVocabularyUuid != null && (this.getStream() != null || this.getSource() != null)){
|
70
|
return true;
|
71
|
} else {
|
72
|
return false;
|
73
|
}
|
74
|
}
|
75
|
|
76
|
|
77
|
@Override
|
78
|
public Reference getSourceReference() {
|
79
|
if (this.sourceReference == null){
|
80
|
sourceReference = ReferenceFactory.newGeneric();
|
81
|
if (this.getSource() == null){
|
82
|
sourceReference.setTitleCache("Excel Distribution Update " + getDateString(), true);
|
83
|
}else{
|
84
|
sourceReference.setTitleCache(getSource().toString(), true);
|
85
|
}
|
86
|
}
|
87
|
return sourceReference;
|
88
|
}
|
89
|
|
90
|
protected boolean needsNomenclaturalCode() {
|
91
|
return false;
|
92
|
}
|
93
|
|
94
|
// ********************** GETTER / SETTER **************************/
|
95
|
|
96
|
public UUID getAreaVocabularyUuid() {
|
97
|
return this.areaVocabularyUuid;
|
98
|
}
|
99
|
|
100
|
public void setAreaVocabularyUuid(UUID areaVocabularyUuid) {
|
101
|
this.areaVocabularyUuid = areaVocabularyUuid;
|
102
|
}
|
103
|
|
104
|
public boolean isCreateNewDistribution() {
|
105
|
return createNewDistribution;
|
106
|
}
|
107
|
|
108
|
public void setCreateNewDistribution(boolean createNewDistribution) {
|
109
|
this.createNewDistribution = createNewDistribution;
|
110
|
}
|
111
|
|
112
|
}
|