Project

General

Profile

Download (3.05 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.globis;
12

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

    
16
import org.apache.log4j.Logger;
17

    
18
import eu.etaxonomy.cdm.io.common.DbImportStateBase;
19
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
20
import eu.etaxonomy.cdm.model.common.MarkerType;
21
import eu.etaxonomy.cdm.model.common.User;
22
import eu.etaxonomy.cdm.model.name.Rank;
23

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

    
33
	Map<String, DefinedTermBase> dbCdmDefTermMap = new HashMap<String, DefinedTermBase>();
34
	
35
	Map<String, User> usernameMap = new HashMap<String, User>();
36
	
37
	private Map<Integer, Map<Integer,Rank>> rankMap;
38
	
39
	/* (non-Javadoc)
40
	 * @see eu.etaxonomy.cdm.io.common.IoStateBase#initialize(eu.etaxonomy.cdm.io.common.IoConfiguratorBase)
41
	 */
42
	@Override
43
	public void initialize(GlobisImportConfigurator config) {
44
//		super(config);
45
		String tableName = "WebMarkerCategory_";
46
		//webMarkerCategory
47
		dbCdmDefTermMap.put(tableName + 1, MarkerType.COMPLETE());
48
	}
49

    
50
	public GlobisImportState(GlobisImportConfigurator config) {
51
		super(config);
52
	}
53

    
54
	public Map<String, DefinedTermBase> getDbCdmDefinedTermMap(){
55
		return this.dbCdmDefTermMap;
56
	}
57
	
58
	public void putDefinedTermToMap(String tableName, String id, DefinedTermBase term){
59
		 this.dbCdmDefTermMap.put(tableName + "_" + id, term);
60
	}
61
	
62
	public void putDefinedTermToMap(String tableName, int id, DefinedTermBase term){
63
		putDefinedTermToMap(tableName, String.valueOf(id), term);
64
	}
65
	
66
	public User getUser(String username){
67
		return usernameMap.get(username);
68
	}
69

    
70
	public void putUser(String username, User user){
71
		usernameMap.put(username, user);
72
	}
73

    
74
	/**
75
	 * @param rankMap the rankMap to set
76
	 */
77
	public void setRankMap(Map<Integer, Map<Integer,Rank>> rankMap) {
78
		this.rankMap = rankMap;
79
	}
80

    
81
//	/**
82
//	 * @return the rankMap
83
//	 */
84
//	public Map<Integer, Map<Integer,Rank>> getRankMap() {
85
//		return rankMap;
86
//	}
87
	
88
 
89
	/**
90
	 * Returns the CDM rank depending on the ERMS rankId and the ERMS kingdomId. Returns <code>
91
	 * null</code> if the rank does not exist.
92
	 * Throws a RuntimeException if the rank map has not been initialized before.
93
	 * @param rankId
94
	 * @param kingdomId
95
	 * @return
96
	 * @throws RuntimeException
97
	 **/
98
	public Rank getRank (int rankId, int  kingdomId){
99
		Rank result = null;
100
		if (this.rankMap == null){
101
			throw new RuntimeException("rank map not initialized");
102
		}
103
		Map<Integer, Rank> kingdomMap = rankMap.get(rankId);
104
		if (kingdomMap != null){
105
			result = kingdomMap.get(kingdomId);
106
		}
107
		return result;
108
	}
109

    
110
    
111
}
(5-5/9)