Project

General

Profile

Download (4.55 KB) Statistics
| Branch: | Revision:
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 final Map<UUID, MarkerType> markerTypeMap = new HashMap<UUID, MarkerType>();
47
	private final Map<String,Integer> treeIndexKingdomMap = new HashMap<String,Integer>();
48
	/**
49
     * @return the treeIndexKingdomMap
50
     */
51
    public Map<String,Integer> getTreeIndexKingdomMap() {
52
        return treeIndexKingdomMap;
53
    }
54

    
55

    
56
    public static final UUID uuidUserDefinedMarkerTypeVocabulary = UUID.fromString("5f02a261-fd7d-4fce-bbe4-21472de8cd51");
57

    
58
	@Autowired
59
	//@Qualifier("termService")
60
	private ITermService termService;
61

    
62

    
63
	/**
64
	 * @param config
65
	 */
66
	public PesiExportState(PesiExportConfigurator config) {
67
		super(config);
68
	}
69

    
70

    
71
	/**
72
	 * Stores the Datawarehouse.id to a specific CDM object originally.
73
	 * Does nothing now since we do not want to store Cdm.id/Datawarehouse.id pairs. This saves precious memory.
74
	 * @param cdmBase
75
	 * @param dbId
76
	 */
77
	@Override
78
	public void putDbId(CdmBase cdmBase, int dbId) {
79
		// Do nothing
80
	}
81

    
82
	/**
83
	 * TODO -> move to PesiExportBase
84
	 * Gets the Datawarehouse.id to a specific CDM object originally.
85
	 * Here it just returns the CDM object's id.
86
	 * @param cdmBase
87
	 * @return
88
	 */
89
	@Override
90
	public Integer getDbId(CdmBase cdmBase) {
91
		return (Integer)getCurrentIO().getDbId(cdmBase, this);
92
	}
93

    
94
	private ITermService getTermService(){
95
		return this.termService;
96
	}
97

    
98
	/**
99
	 * Returns whether the given Source object was processed before or not.
100
	 * @param
101
	 * @return
102
	 */
103
	public boolean alreadyProcessedSource(Integer sourceId) {
104
		if (processedSourceList.contains(sourceId)) {
105
			return true;
106
		} else {
107
			return false;
108
		}
109
	}
110

    
111
	/**
112
	 * Adds given Source to the list of processed Sources.
113
	 */
114
	public boolean addToProcessedSources(Integer sourceId) {
115
		if (! processedSourceList.contains(sourceId)) {
116
			processedSourceList.add(sourceId);
117
		}
118

    
119
		return true;
120
	}
121

    
122
	/**
123
	 * Clears the list of already processed Sources.
124
	 */
125
	public void clearAlreadyProcessedSources() {
126
		processedSourceList.clear();
127
	}
128

    
129

    
130
	public IdentifiableEntity<?> getCurrentToObject() {
131
		return currentToObject;
132
	}
133

    
134

    
135
	public void setCurrentToObject(IdentifiableEntity<?> currentToObject) {
136
		this.currentToObject = currentToObject;
137
	}
138

    
139

    
140
	public IdentifiableEntity<?> getCurrentFromObject() {
141
		return currentFromObject;
142
	}
143

    
144

    
145
	public void setCurrentFromObject(IdentifiableEntity<?> currentFromObject) {
146
		this.currentFromObject = currentFromObject;
147
	}
148

    
149

    
150
	public TaxonBase<?> getCurrentTaxon() {
151
		return currentTaxon;
152
	}
153

    
154

    
155
	public void setCurrentTaxon(TaxonBase<?> currentTaxon) {
156
		this.currentTaxon = currentTaxon;
157
	}
158

    
159
	public void putMarkerType(MarkerType markerType) {
160

    
161
		markerTypeMap.put(markerType.getUuid(), markerType);
162

    
163
	}
164

    
165

    
166
	public MarkerType getMarkerType(UUID uuid){
167
		return markerTypeMap.get(uuid);
168
	}
169

    
170

    
171
	public boolean isSourceForAdditionalSourceCreated() {
172
		return sourceForAdditionalSourceCreated;
173
	}
174

    
175

    
176
	public void setSourceForAdditionalSourceCreated(
177
			boolean sourceForAdditionalSourceCreated) {
178
		this.sourceForAdditionalSourceCreated = sourceForAdditionalSourceCreated;
179
	}
180

    
181

    
182

    
183

    
184
}
(7-7/12)