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.cdmLight;
|
10
|
|
11
|
import java.io.File;
|
12
|
import java.util.HashMap;
|
13
|
import java.util.Map;
|
14
|
|
15
|
import eu.etaxonomy.cdm.io.common.ExportResult;
|
16
|
import eu.etaxonomy.cdm.io.common.ExportResult.ExportResultState;
|
17
|
import eu.etaxonomy.cdm.io.common.ExportStateBase;
|
18
|
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
|
19
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
20
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
21
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
24
|
|
25
|
/**
|
26
|
* @author k.luther
|
27
|
* @date 15.03.2017
|
28
|
*
|
29
|
*/
|
30
|
public class CdmLightExportState
|
31
|
extends ExportStateBase<CdmLightExportConfigurator, IExportTransformer, File>{
|
32
|
|
33
|
private ExportResult result;
|
34
|
|
35
|
private CdmLightExportResultProcessor processor = new CdmLightExportResultProcessor(this);
|
36
|
|
37
|
private TaxonBase<?> actualTaxonBase;
|
38
|
|
39
|
private Map<Integer, HomotypicalGroup> homotypicalGroupStore = new HashMap<>();
|
40
|
private Map<Integer, TeamOrPersonBase<?>> authorStore = new HashMap<>();
|
41
|
|
42
|
private Map<Integer, SpecimenOrObservationBase> specimenStore = new HashMap<>();
|
43
|
private Map<Integer, Reference> referenceStore = new HashMap<>();
|
44
|
|
45
|
/**
|
46
|
* @param config
|
47
|
*/
|
48
|
protected CdmLightExportState(CdmLightExportConfigurator config) {
|
49
|
super(config);
|
50
|
result = ExportResult.NewInstance(config.getResultType());
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* @return the result
|
55
|
*/
|
56
|
@Override
|
57
|
public ExportResult getResult() {
|
58
|
return result;
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* @param result the result to set
|
63
|
*/
|
64
|
@Override
|
65
|
public void setResult(ExportResult result) {
|
66
|
this.result = result;
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
*
|
71
|
*/
|
72
|
public void setEmptyData() {
|
73
|
this.result.setState(ExportResultState.SUCCESS_BUT_NO_DATA);
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* @return the processor
|
78
|
*/
|
79
|
public CdmLightExportResultProcessor getProcessor() {
|
80
|
return processor;
|
81
|
}
|
82
|
|
83
|
public void setActualTaxonBase(TaxonBase<?> actualTaxonBase){
|
84
|
this.actualTaxonBase = actualTaxonBase;
|
85
|
}
|
86
|
|
87
|
public TaxonBase<?> getActualTaxonBase() {
|
88
|
return actualTaxonBase;
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
* @return the homotypicalGroupStore
|
93
|
*/
|
94
|
public Map<Integer, HomotypicalGroup> getHomotypicalGroupStore() {
|
95
|
return homotypicalGroupStore;
|
96
|
}
|
97
|
|
98
|
/**
|
99
|
* @param homotypicalGroupStore the homotypicalGroupStore to set
|
100
|
*/
|
101
|
public void addHomotypicalGroupToStore(HomotypicalGroup homotypicalGroup) {
|
102
|
this.homotypicalGroupStore.put(homotypicalGroup.getId(), homotypicalGroup);
|
103
|
}
|
104
|
|
105
|
public HomotypicalGroup getHomotypicalGroupFromStore(Integer id){
|
106
|
return homotypicalGroupStore.get(id);
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* @return the specimenStore
|
111
|
*/
|
112
|
public Map<Integer, SpecimenOrObservationBase> getSpecimenStore() {
|
113
|
return specimenStore;
|
114
|
}
|
115
|
|
116
|
|
117
|
|
118
|
/**
|
119
|
* @param specimenStore the specimenStore to set
|
120
|
*/
|
121
|
public void setSpecimenStore(Map<Integer, SpecimenOrObservationBase> specimenStore) {
|
122
|
this.specimenStore = specimenStore;
|
123
|
}
|
124
|
|
125
|
|
126
|
|
127
|
|
128
|
|
129
|
/**
|
130
|
* @param homotypicalGroupStore the homotypicalGroupStore to set
|
131
|
*/
|
132
|
public void setHomotypicalGroupStore(Map<Integer, HomotypicalGroup> homotypicalGroupStore) {
|
133
|
this.homotypicalGroupStore = homotypicalGroupStore;
|
134
|
}
|
135
|
|
136
|
/**
|
137
|
* @param authorStore the authorStore to set
|
138
|
*/
|
139
|
public void setAuthorStore(Map<Integer, TeamOrPersonBase<?>> authorStore) {
|
140
|
this.authorStore = authorStore;
|
141
|
}
|
142
|
|
143
|
/**
|
144
|
* @param homotypicalGroupStore the homotypicalGroupStore to set
|
145
|
*/
|
146
|
public void addAuthorToStore(TeamOrPersonBase<?> author) {
|
147
|
this.authorStore.put(author.getId(), author);
|
148
|
}
|
149
|
|
150
|
/**
|
151
|
* @return the homotypicalGroupStore
|
152
|
*/
|
153
|
public Map<Integer, TeamOrPersonBase<?>> getAuthorStore() {
|
154
|
return authorStore;
|
155
|
}
|
156
|
|
157
|
|
158
|
public TeamOrPersonBase<?> getAuthorFromStore(Integer id){
|
159
|
return authorStore.get(id);
|
160
|
}
|
161
|
|
162
|
|
163
|
public void addSpecimenToStore(SpecimenOrObservationBase specimen) {
|
164
|
this.specimenStore.put(specimen.getId(), specimen);
|
165
|
|
166
|
}
|
167
|
|
168
|
|
169
|
public SpecimenOrObservationBase getSpecimenFromStore(Integer id){
|
170
|
return specimenStore.get(id);
|
171
|
}
|
172
|
|
173
|
public Reference getReferenceFromStore(Integer id){
|
174
|
return referenceStore.get(id);
|
175
|
}
|
176
|
public void addReferenceToStore(Reference ref) {
|
177
|
this.referenceStore.put(ref.getId(), ref);
|
178
|
|
179
|
}
|
180
|
/**
|
181
|
* @param referenceStore the referenceStore to set
|
182
|
*/
|
183
|
public void setReferenceStore(Map<Integer, Reference> referenceStore) {
|
184
|
this.referenceStore = referenceStore;
|
185
|
}
|
186
|
/**
|
187
|
* @return the referenceStore
|
188
|
*/
|
189
|
public Map<Integer, Reference> getReferenceStore() {
|
190
|
return referenceStore;
|
191
|
}
|
192
|
|
193
|
}
|