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