1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.io.pesi.out;
|
11
|
|
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 org.apache.log4j.Logger;
|
19
|
import org.springframework.beans.factory.annotation.Autowired;
|
20
|
|
21
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
22
|
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
|
23
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
24
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
25
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
26
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
27
|
|
28
|
/**
|
29
|
* The export state class.
|
30
|
* Holds data needed while the export classes are running.
|
31
|
* @author e.-m.lee
|
32
|
* @date 12.02.2010
|
33
|
*
|
34
|
*/
|
35
|
public class PesiExportState extends DbExportStateBase<PesiExportConfigurator, PesiTransformer>{
|
36
|
@SuppressWarnings("unused")
|
37
|
private static final Logger logger = Logger.getLogger(PesiExportState.class);
|
38
|
|
39
|
private static List<Integer> processedSourceList = new ArrayList<Integer>();
|
40
|
|
41
|
private IdentifiableEntity<?> currentToObject;
|
42
|
private IdentifiableEntity<?> currentFromObject;
|
43
|
private TaxonBase<?> currentTaxon;
|
44
|
private boolean sourceForAdditionalSourceCreated = false;
|
45
|
|
46
|
private Map<UUID, MarkerType> markerTypeMap = new HashMap<UUID, MarkerType>();
|
47
|
public static final UUID uuidUserDefinedMarkerTypeVocabulary = UUID.fromString("5f02a261-fd7d-4fce-bbe4-21472de8cd51");
|
48
|
|
49
|
@Autowired
|
50
|
//@Qualifier("termService")
|
51
|
private ITermService termService;
|
52
|
|
53
|
|
54
|
/**
|
55
|
* @param config
|
56
|
*/
|
57
|
public PesiExportState(PesiExportConfigurator config) {
|
58
|
super(config);
|
59
|
}
|
60
|
|
61
|
|
62
|
/**
|
63
|
* Stores the Datawarehouse.id to a specific CDM object originally.
|
64
|
* Does nothing now since we do not want to store Cdm.id/Datawarehouse.id pairs. This saves precious memory.
|
65
|
* @param cdmBase
|
66
|
* @param dbId
|
67
|
*/
|
68
|
@Override
|
69
|
public void putDbId(CdmBase cdmBase, int dbId) {
|
70
|
// Do nothing
|
71
|
}
|
72
|
|
73
|
/**
|
74
|
* TODO -> move to PesiExportBase
|
75
|
* Gets the Datawarehouse.id to a specific CDM object originally.
|
76
|
* Here it just returns the CDM object's id.
|
77
|
* @param cdmBase
|
78
|
* @return
|
79
|
*/
|
80
|
@Override
|
81
|
public Integer getDbId(CdmBase cdmBase) {
|
82
|
return (Integer)getCurrentIO().getDbId(cdmBase, this);
|
83
|
}
|
84
|
|
85
|
private ITermService getTermService(){
|
86
|
return this.termService;
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* Returns whether the given Source object was processed before or not.
|
91
|
* @param
|
92
|
* @return
|
93
|
*/
|
94
|
public boolean alreadyProcessedSource(Integer sourceId) {
|
95
|
if (processedSourceList.contains(sourceId)) {
|
96
|
return true;
|
97
|
} else {
|
98
|
return false;
|
99
|
}
|
100
|
}
|
101
|
|
102
|
/**
|
103
|
* Adds given Source to the list of processed Sources.
|
104
|
*/
|
105
|
public boolean addToProcessedSources(Integer sourceId) {
|
106
|
if (! processedSourceList.contains(sourceId)) {
|
107
|
processedSourceList.add(sourceId);
|
108
|
}
|
109
|
|
110
|
return true;
|
111
|
}
|
112
|
|
113
|
/**
|
114
|
* Clears the list of already processed Sources.
|
115
|
*/
|
116
|
public void clearAlreadyProcessedSources() {
|
117
|
processedSourceList.clear();
|
118
|
}
|
119
|
|
120
|
|
121
|
public IdentifiableEntity<?> getCurrentToObject() {
|
122
|
return currentToObject;
|
123
|
}
|
124
|
|
125
|
|
126
|
public void setCurrentToObject(IdentifiableEntity<?> currentToObject) {
|
127
|
this.currentToObject = currentToObject;
|
128
|
}
|
129
|
|
130
|
|
131
|
public IdentifiableEntity<?> getCurrentFromObject() {
|
132
|
return currentFromObject;
|
133
|
}
|
134
|
|
135
|
|
136
|
public void setCurrentFromObject(IdentifiableEntity<?> currentFromObject) {
|
137
|
this.currentFromObject = currentFromObject;
|
138
|
}
|
139
|
|
140
|
|
141
|
public TaxonBase<?> getCurrentTaxon() {
|
142
|
return currentTaxon;
|
143
|
}
|
144
|
|
145
|
|
146
|
public void setCurrentTaxon(TaxonBase<?> currentTaxon) {
|
147
|
this.currentTaxon = currentTaxon;
|
148
|
}
|
149
|
|
150
|
public void putMarkerType(MarkerType markerType) {
|
151
|
|
152
|
markerTypeMap.put(markerType.getUuid(), markerType);
|
153
|
|
154
|
}
|
155
|
|
156
|
|
157
|
public MarkerType getMarkerType(UUID uuid){
|
158
|
return markerTypeMap.get(uuid);
|
159
|
}
|
160
|
|
161
|
|
162
|
public boolean isSourceForAdditionalSourceCreated() {
|
163
|
return sourceForAdditionalSourceCreated;
|
164
|
}
|
165
|
|
166
|
|
167
|
public void setSourceForAdditionalSourceCreated(
|
168
|
boolean sourceForAdditionalSourceCreated) {
|
169
|
this.sourceForAdditionalSourceCreated = sourceForAdditionalSourceCreated;
|
170
|
}
|
171
|
|
172
|
|
173
|
|
174
|
|
175
|
}
|