Project

General

Profile

Download (3.58 KB) Statistics
| Branch: | Revision:
1
/**
2
* Copyright (C) 2007 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

    
10
package eu.etaxonomy.cdm.io.pesi.faunaEuropaea;
11

    
12
import java.util.HashMap;
13
import java.util.Map;
14
import java.util.UUID;
15

    
16
import org.apache.log4j.Logger;
17

    
18
import eu.etaxonomy.cdm.io.common.ImportStateBase;
19
import eu.etaxonomy.cdm.model.location.NamedArea;
20
import eu.etaxonomy.cdm.model.term.TermVocabulary;
21

    
22
/**
23
 * @author a.mueller
24
 * @since 11.05.2009
25
 * @version 1.0
26
 */
27
public class FaunaEuropaeaImportState extends ImportStateBase<FaunaEuropaeaImportConfigurator, FaunaEuropaeaImportBase>{
28
	@SuppressWarnings("unused")
29
	private static final Logger logger = Logger.getLogger(FaunaEuropaeaImportState.class);
30

    
31

    
32
	public FaunaEuropaeaImportState(FaunaEuropaeaImportConfigurator config) {
33
		super(config);
34
	}
35

    
36
	private Map<Integer, FaunaEuropaeaTaxon> fauEuTaxonMap = new HashMap<Integer, FaunaEuropaeaTaxon>();
37
	private Map<UUID, UUID> childParentMap = new HashMap<UUID, UUID>();
38
	private Map<Integer, UUID> agentUUIDMap = new HashMap<Integer, UUID>();
39
	private final HashMap<String,UUID> idToUUID = new HashMap<String, UUID>();
40
	private TermVocabulary<NamedArea> areaVoc;
41

    
42
	/* Highest taxon index in the FauEu database */
43
//	private int highestTaxonIndex = 305755;
44
	/* Max number of taxa to be saved with one service call */
45
//	private int limit = 20000;
46

    
47

    
48
//	/**
49
//	 * @return the limit
50
//	 */
51
//	public int getLimit() {
52
//		return limit;
53
//	}
54
//
55
//	/**
56
//	 * @param limit the limit to set
57
//	 */
58
//	public void setLimit(int limit) {
59
//		this.limit = limit;
60
//	}
61

    
62

    
63
	/**
64
	 * @return the fauEuTaxonMap
65
	 */
66
	public Map<Integer, FaunaEuropaeaTaxon> getFauEuTaxonMap() {
67
		return fauEuTaxonMap;
68
	}
69

    
70
	/**
71
	 * @param fauEuTaxonMap the fauEuTaxonMap to set
72
	 */
73
	public void setFauEuTaxonMap(Map<Integer, FaunaEuropaeaTaxon> fauEuTaxonMap) {
74
		this.fauEuTaxonMap = fauEuTaxonMap;
75
	}
76

    
77
	/**
78
	 * @return the childParentMap
79
	 */
80
	public Map<UUID, UUID> getChildParentMap() {
81
		return childParentMap;
82
	}
83

    
84
	/**
85
	 * @param childParentMap the childParentMap to set
86
	 */
87
	public void setChildParentMap(Map<UUID, UUID> childParentMap) {
88
		this.childParentMap = childParentMap;
89
	}
90

    
91
    /**
92
     * @return the agentMap
93
     */
94
    public Map<Integer, UUID> getAgentMap() {
95
        return agentUUIDMap;
96
    }
97
    /**
98
     * @return the agentMap
99
     */
100
    public void setAgentMap(Map<Integer, UUID> agentUUIDMap) {
101
        this.agentUUIDMap = agentUUIDMap;
102
    }
103

    
104
    public NamedArea areaId2NamedArea(FaunaEuropaeaDistribution dis, FaunaEuropaeaImportState state){
105
        UUID uuid = idToUUID.get(dis.getAreaCode());
106
        return state.getNamedArea(uuid);
107
    }
108

    
109
    public void setIdToUuid(String id, UUID uuid){
110
        if (idToUUID.get(id) != null && !idToUUID.get(id).equals(uuid)){
111
            logger.error("There are two different uuids for one id.");
112
        }
113
        idToUUID.put(id, uuid);
114
    }
115

    
116
    @Override
117
    public void putNamedArea(NamedArea namedArea){
118
        super.putNamedArea(namedArea);
119
        setIdToUuid(namedArea.getIdInVocabulary(), namedArea.getUuid());
120
    }
121

    
122
    /**
123
     * @return the areaVoc
124
     */
125
    public TermVocabulary<NamedArea> getAreaVoc() {
126
        return areaVoc;
127
    }
128

    
129
    /**
130
     * @param areaVoc the areaVoc to set
131
     */
132
    public void setAreaVoc(TermVocabulary<NamedArea> areaVoc) {
133
        this.areaVoc = areaVoc;
134
    }
135

    
136

    
137
}
(9-9/20)