Project

General

Profile

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

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

    
13
import java.util.HashMap;
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.ImportStateBase;
20
import eu.etaxonomy.cdm.model.common.TermVocabulary;
21
import eu.etaxonomy.cdm.model.location.NamedArea;
22

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

    
32

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

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

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

    
48

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

    
63

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

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

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

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

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

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

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

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

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

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

    
137

    
138
}
(9-9/20)