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.List;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
|
18
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
19
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
20
|
|
21
|
/**
|
22
|
* The export state class.
|
23
|
* Holds data needed while the export classes are running.
|
24
|
* @author e.-m.lee
|
25
|
* @date 12.02.2010
|
26
|
*
|
27
|
*/
|
28
|
public class PesiExportState extends DbExportStateBase<PesiExportConfigurator>{
|
29
|
@SuppressWarnings("unused")
|
30
|
private static final Logger logger = Logger.getLogger(PesiExportState.class);
|
31
|
|
32
|
private static List<Integer> processedSourceList = new ArrayList<Integer>();
|
33
|
|
34
|
private IdentifiableEntity<?> currentToObject;
|
35
|
private IdentifiableEntity<?> currentFromObject;
|
36
|
|
37
|
|
38
|
/**
|
39
|
* @param config
|
40
|
*/
|
41
|
public PesiExportState(PesiExportConfigurator config) {
|
42
|
super(config);
|
43
|
}
|
44
|
|
45
|
|
46
|
/**
|
47
|
* Stores the Datawarehouse.id to a specific CDM object originally.
|
48
|
* Does nothing now since we do not want to store Cdm.id/Datawarehouse.id pairs. This saves precious memory.
|
49
|
* @param cdmBase
|
50
|
* @param dbId
|
51
|
*/
|
52
|
@Override
|
53
|
public void putDbId(CdmBase cdmBase, int dbId) {
|
54
|
// Do nothing
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* TODO -> move to PesiExportBase
|
59
|
* Gets the Datawarehouse.id to a specific CDM object originally.
|
60
|
* Here it just returns the CDM object's id.
|
61
|
* @param cdmBase
|
62
|
* @return
|
63
|
*/
|
64
|
@Override
|
65
|
public Integer getDbId(CdmBase cdmBase) {
|
66
|
return (Integer)getCurrentIO().getDbId(cdmBase, this);
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Returns whether the given Source object was processed before or not.
|
71
|
* @param
|
72
|
* @return
|
73
|
*/
|
74
|
public boolean alreadyProcessedSource(Integer sourceId) {
|
75
|
if (processedSourceList.contains(sourceId)) {
|
76
|
return true;
|
77
|
} else {
|
78
|
return false;
|
79
|
}
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* Adds given Source to the list of processed Sources.
|
84
|
*/
|
85
|
public boolean addToProcessedSources(Integer sourceId) {
|
86
|
if (! processedSourceList.contains(sourceId)) {
|
87
|
processedSourceList.add(sourceId);
|
88
|
}
|
89
|
|
90
|
return true;
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* Clears the list of already processed Sources.
|
95
|
*/
|
96
|
public void clearAlreadyProcessedSources() {
|
97
|
processedSourceList.clear();
|
98
|
}
|
99
|
|
100
|
|
101
|
public IdentifiableEntity<?> getCurrentToObject() {
|
102
|
return currentToObject;
|
103
|
}
|
104
|
|
105
|
|
106
|
public void setCurrentToObject(IdentifiableEntity<?> currentToObject) {
|
107
|
this.currentToObject = currentToObject;
|
108
|
}
|
109
|
|
110
|
|
111
|
public IdentifiableEntity<?> getCurrentFromObject() {
|
112
|
return currentFromObject;
|
113
|
}
|
114
|
|
115
|
|
116
|
public void setCurrentFromObject(IdentifiableEntity<?> currentFromObject) {
|
117
|
this.currentFromObject = currentFromObject;
|
118
|
}
|
119
|
|
120
|
}
|