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.csv.in;
|
10
|
|
11
|
import java.util.Map;
|
12
|
|
13
|
import eu.etaxonomy.cdm.io.common.ImportStateBase;
|
14
|
import eu.etaxonomy.cdm.io.common.utils.ImportDeduplicationHelper;
|
15
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
16
|
|
17
|
/**
|
18
|
* State class for {@link CsvImportBase csv imports}. This
|
19
|
* class can either be used directly or being subclassed
|
20
|
* according to the needs of a certain import.
|
21
|
*
|
22
|
* @author a.mueller
|
23
|
\* @since 08.07.2017
|
24
|
*
|
25
|
*/
|
26
|
public class CsvImportState<CONFIG extends CsvImportConfiguratorBase>
|
27
|
extends ImportStateBase<CONFIG, CsvImportBase>{
|
28
|
|
29
|
private Map<String, String> currentRecord;
|
30
|
private int row;
|
31
|
|
32
|
private ImportDeduplicationHelper<CsvImportState> dedupHelper;
|
33
|
private Reference sourceReference;
|
34
|
|
35
|
protected CsvImportState(CONFIG config) {
|
36
|
super(config);
|
37
|
}
|
38
|
|
39
|
public void resetSession(){
|
40
|
getDedupHelper().restartSession(getCurrentIO(), this.getResult());
|
41
|
this.sourceReference = null;
|
42
|
}
|
43
|
|
44
|
|
45
|
/**
|
46
|
* Map representation of the current line.
|
47
|
* @return The String map representing the current line in the csv.
|
48
|
*/
|
49
|
public Map<String, String> getCurrentRecord() {
|
50
|
return currentRecord;
|
51
|
}
|
52
|
public void setCurrentRecord(Map<String, String> currentRecord) {
|
53
|
this.currentRecord = currentRecord;
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* Integer representation of the line number in the csv.
|
58
|
* {@link #getLine()}
|
59
|
* @return the line number
|
60
|
*/
|
61
|
public int getRow() {
|
62
|
return row;
|
63
|
}
|
64
|
public void setRow(int row) {
|
65
|
this.row = row;
|
66
|
}
|
67
|
|
68
|
/**
|
69
|
* String representation of the line number in the csv
|
70
|
* {@link #getRow()}
|
71
|
* @return the line string
|
72
|
*/
|
73
|
public String getLine(){
|
74
|
return String.valueOf(row);
|
75
|
}
|
76
|
|
77
|
|
78
|
public ImportDeduplicationHelper<CsvImportState> getDedupHelper() {
|
79
|
if (this.dedupHelper == null){
|
80
|
this.dedupHelper = ImportDeduplicationHelper.NewInstance(getCurrentIO(), this);
|
81
|
}
|
82
|
return dedupHelper;
|
83
|
}
|
84
|
|
85
|
|
86
|
public void setDedupHelper(ImportDeduplicationHelper<CsvImportState> dedupHelper) {
|
87
|
this.dedupHelper = dedupHelper;
|
88
|
}
|
89
|
|
90
|
|
91
|
public Reference getSourceReference() {
|
92
|
return sourceReference;
|
93
|
}
|
94
|
public void setSourceReference(Reference sourceReference) {
|
95
|
this.sourceReference = sourceReference;
|
96
|
}
|
97
|
|
98
|
}
|