Project

General

Profile

Download (3.94 KB) Statistics
| Branch: | Revision:
1
/**
2
* Copyright (C) 2009 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.pesi.out;
10

    
11
import java.util.ArrayList;
12
import java.util.HashMap;
13
import java.util.List;
14
import java.util.Map;
15
import java.util.UUID;
16

    
17
import org.apache.log4j.Logger;
18

    
19
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
20
import eu.etaxonomy.cdm.model.common.CdmBase;
21
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
22
import eu.etaxonomy.cdm.model.common.MarkerType;
23
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
24

    
25
/**
26
 * The export state class.
27
 * Holds data needed while the export classes are running.
28
 *
29
 * @author e.-m.lee
30
 * @since 12.02.2010
31
 */
32
public class PesiExportState extends DbExportStateBase<PesiExportConfigurator, PesiTransformer>{
33
	@SuppressWarnings("unused")
34
	private static final Logger logger = Logger.getLogger(PesiExportState.class);
35

    
36
	private static List<Integer> processedSourceList = new ArrayList<>();
37

    
38
	private IdentifiableEntity<?> currentToObject;
39
	private IdentifiableEntity<?> currentFromObject;
40
	private TaxonBase<?> currentTaxon;
41
	private boolean sourceForAdditionalSourceCreated = false;
42

    
43
	private final Map<UUID, MarkerType> markerTypeMap = new HashMap<>();
44
	private final Map<String,Integer> treeIndexKingdomMap = new HashMap<>();
45

    
46

    
47
    public Map<String,Integer> getTreeIndexKingdomMap() {
48
        return treeIndexKingdomMap;
49
    }
50

    
51
	public PesiExportState(PesiExportConfigurator config) {
52
		super(config);
53
	}
54

    
55
	/**
56
	 * Stores the Datawarehouse.id to a specific CDM object originally.
57
	 * Does nothing now since we do not want to store Cdm.id/Datawarehouse.id pairs. This saves precious memory.
58
	 * @param cdmBase
59
	 * @param dbId
60
	 */
61
	@Override
62
	public void putDbId(CdmBase cdmBase, int dbId) {
63
		// Do nothing
64
	}
65

    
66
	/**
67
	 * TODO -> move to PesiExportBase
68
	 * Gets the Datawarehouse.id to a specific CDM object originally.
69
	 * Here it just returns the CDM object's id.
70
	 */
71
	@Override
72
	public Integer getDbId(CdmBase cdmBase) {
73
		return (Integer)getCurrentIO().getDbId(cdmBase, this);
74
	}
75

    
76
	/**
77
	 * Returns whether the given Source object was processed before or not.
78
	 */
79
	public boolean alreadyProcessedSource(Integer sourceId) {
80
		if (processedSourceList.contains(sourceId)) {
81
			return true;
82
		} else {
83
			return false;
84
		}
85
	}
86

    
87
	/**
88
	 * Adds given Source to the list of processed Sources.
89
	 */
90
	public boolean addToProcessedSources(Integer sourceId) {
91
		if (! processedSourceList.contains(sourceId)) {
92
			processedSourceList.add(sourceId);
93
		}
94
		return true;
95
	}
96

    
97
	/**
98
	 * Clears the list of already processed Sources.
99
	 */
100
	public void clearAlreadyProcessedSources() {
101
		processedSourceList.clear();
102
	}
103

    
104
	public IdentifiableEntity<?> getCurrentToObject() {
105
		return currentToObject;
106
	}
107
	public void setCurrentToObject(IdentifiableEntity<?> currentToObject) {
108
		this.currentToObject = currentToObject;
109
	}
110

    
111
	public IdentifiableEntity<?> getCurrentFromObject() {
112
		return currentFromObject;
113
	}
114
	public void setCurrentFromObject(IdentifiableEntity<?> currentFromObject) {
115
		this.currentFromObject = currentFromObject;
116
	}
117

    
118

    
119
	public TaxonBase<?> getCurrentTaxon() {
120
		return currentTaxon;
121
	}
122
	public void setCurrentTaxon(TaxonBase<?> currentTaxon) {
123
		this.currentTaxon = currentTaxon;
124
	}
125

    
126
	public MarkerType getMarkerType(UUID uuid){
127
	    return markerTypeMap.get(uuid);
128
	}
129
	public void putMarkerType(MarkerType markerType) {
130
		markerTypeMap.put(markerType.getUuid(), markerType);
131
	}
132

    
133
	public boolean isSourceForAdditionalSourceCreated() {
134
		return sourceForAdditionalSourceCreated;
135
	}
136
	public void setSourceForAdditionalSourceCreated(
137
			boolean sourceForAdditionalSourceCreated) {
138
		this.sourceForAdditionalSourceCreated = sourceForAdditionalSourceCreated;
139
	}
140
}
(9-9/14)