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
|
|
20
|
/**
|
21
|
* The export state class.
|
22
|
* Holds data needed while the export classes are running.
|
23
|
* @author e.-m.lee
|
24
|
* @date 12.02.2010
|
25
|
*
|
26
|
*/
|
27
|
public class PesiExportState extends DbExportStateBase<PesiExportConfigurator>{
|
28
|
private static final Logger logger = Logger.getLogger(PesiExportState.class);
|
29
|
private static List<Integer> processedSourceList = new ArrayList<Integer>();
|
30
|
|
31
|
/**
|
32
|
* @param config
|
33
|
*/
|
34
|
public PesiExportState(PesiExportConfigurator config) {
|
35
|
super(config);
|
36
|
}
|
37
|
|
38
|
|
39
|
/**
|
40
|
* Stores the Datawarehouse.id to a specific CDM object originally.
|
41
|
* Does nothing now since we do not want to store Cdm.id/Datawarehouse.id pairs. This saves precious memory.
|
42
|
* @param cdmBase
|
43
|
* @param dbId
|
44
|
*/
|
45
|
@Override
|
46
|
public void putDbId(CdmBase cdmBase, int dbId) {
|
47
|
// Do nothing
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
* Gets the Datawarehouse.id to a specific CDM object originally.
|
52
|
* Here it just returns the CDM object's id.
|
53
|
* @param cdmBase
|
54
|
* @return
|
55
|
*/
|
56
|
@Override
|
57
|
public Integer getDbId(CdmBase cdmBase) {
|
58
|
// We use the Cdm.id for Datawarehouse.id
|
59
|
if (cdmBase == null) {
|
60
|
return null;
|
61
|
} else {
|
62
|
return cdmBase.getId();
|
63
|
}
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* Returns whether the given Source object was processed before or not.
|
68
|
* @param
|
69
|
* @return
|
70
|
*/
|
71
|
public boolean alreadyProcessedSource(Integer sourceId) {
|
72
|
if (processedSourceList.contains(sourceId)) {
|
73
|
return true;
|
74
|
} else {
|
75
|
return false;
|
76
|
}
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* Adds given Source to the list of processed Sources.
|
81
|
*/
|
82
|
public boolean addToProcessedSources(Integer sourceId) {
|
83
|
if (! processedSourceList.contains(sourceId)) {
|
84
|
processedSourceList.add(sourceId);
|
85
|
}
|
86
|
|
87
|
return true;
|
88
|
}
|
89
|
|
90
|
/**
|
91
|
* Clears the list of already processed Sources.
|
92
|
*/
|
93
|
public void clearAlreadyProcessedSources() {
|
94
|
processedSourceList.clear();
|
95
|
}
|
96
|
|
97
|
}
|