Project

General

Profile

Download (3.88 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.indexFungorum;
12

    
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.HashSet;
16
import java.util.List;
17
import java.util.Map;
18
import java.util.Set;
19
import java.util.UUID;
20

    
21
import org.apache.log4j.Logger;
22

    
23
import eu.etaxonomy.cdm.io.common.DbImportStateBase;
24
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
25
import eu.etaxonomy.cdm.model.common.User;
26
import eu.etaxonomy.cdm.model.name.Rank;
27
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
28

    
29
/**
30
 * @author a.mueller
31
 * @created 11.05.2009
32
 * @version 1.0
33
 */
34
public class IndexFungorumImportState extends DbImportStateBase<IndexFungorumImportConfigurator, IndexFungorumImportState>{
35
	@SuppressWarnings("unused")
36
	private static final Logger logger = Logger.getLogger(IndexFungorumImportState.class);
37

    
38
	Map<String, DefinedTermBase> dbCdmDefTermMap = new HashMap<String, DefinedTermBase>();
39

    
40
	Map<String, User> usernameMap = new HashMap<String, User>();
41

    
42
	private Map<Integer, Map<Integer,Rank>> rankMap;
43

    
44
	private Map<String, TaxonBase> speciesMap;
45
	
46
	private List<UUID> infraspecificTaxaUUIDs = new ArrayList<UUID>();
47

    
48

    
49

    
50

    
51
    public List<UUID> getInfraspecificTaxaUUIDs() {
52
		return infraspecificTaxaUUIDs;
53
	}
54

    
55

    
56
	public void setInfraspecificTaxaUUIDs(List<UUID> infraspecificTaxaUUIDs) {
57
		this.infraspecificTaxaUUIDs = infraspecificTaxaUUIDs;
58
	}
59

    
60

    
61
	public IndexFungorumImportState(IndexFungorumImportConfigurator config) {
62
		super(config);
63
	}
64

    
65

    
66
	/* (non-Javadoc)
67
	 * @see eu.etaxonomy.cdm.io.common.IoStateBase#initialize(eu.etaxonomy.cdm.io.common.IoConfiguratorBase)
68
	 */
69
	@Override
70
	public void initialize(IndexFungorumImportConfigurator config) {
71
//		super(config);
72
	}
73

    
74

    
75
	public Map<String, DefinedTermBase> getDbCdmDefinedTermMap(){
76
		return this.dbCdmDefTermMap;
77
	}
78

    
79
	public void putDefinedTermToMap(String tableName, String id, DefinedTermBase term){
80
		 this.dbCdmDefTermMap.put(tableName + "_" + id, term);
81
	}
82

    
83
	public void putDefinedTermToMap(String tableName, int id, DefinedTermBase term){
84
		putDefinedTermToMap(tableName, String.valueOf(id), term);
85
	}
86

    
87
	@Override
88
    public User getUser(String username){
89
		return usernameMap.get(username);
90
	}
91

    
92
	@Override
93
    public void putUser(String username, User user){
94
		usernameMap.put(username, user);
95
	}
96
	/**
97
     * @return the speciesMap
98
     */
99
    public Map<String, TaxonBase> getSpeciesMap() {
100
        return speciesMap;
101
    }
102

    
103

    
104
    /**
105
     * @param speciesMap the speciesMap to set
106
     */
107
    public void setSpeciesMap(Map<String, TaxonBase> speciesMap) {
108
        this.speciesMap = speciesMap;
109
    }
110

    
111
	/**
112
	 * @param rankMap the rankMap to set
113
	 */
114
	public void setRankMap(Map<Integer, Map<Integer,Rank>> rankMap) {
115
		this.rankMap = rankMap;
116
	}
117

    
118
//	/**
119
//	 * @return the rankMap
120
//	 */
121
//	public Map<Integer, Map<Integer,Rank>> getRankMap() {
122
//		return rankMap;
123
//	}
124

    
125

    
126
	/**
127
	 * Returns the CDM rank depending on the ERMS rankId and the ERMS kingdomId. Returns <code>
128
	 * null</code> if the rank does not exist.
129
	 * Throws a RuntimeException if the rank map has not been initialized before.
130
	 * @param rankId
131
	 * @param kingdomId
132
	 * @return
133
	 * @throws RuntimeException
134
	 **/
135
	public Rank getRank (int rankId, int  kingdomId){
136
		Rank result = null;
137
		if (this.rankMap == null){
138
			throw new RuntimeException("rank map not initialized");
139
		}
140
		if (kingdomId == 147415 && rankId == 10){
141
			result = Rank.KINGDOM();
142
		}else{
143
			Map<Integer, Rank> kingdomMap = rankMap.get(rankId);
144
			if (kingdomMap != null){
145
				result = kingdomMap.get(kingdomId);
146
			}
147
		}
148
		return result;
149
	}
150

    
151

    
152
}
(6-6/10)