Project

General

Profile

Download (3.75 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.globis;
11

    
12
import java.util.HashMap;
13
import java.util.HashSet;
14
import java.util.Map;
15
import java.util.Set;
16

    
17
import org.apache.log4j.Logger;
18

    
19
import eu.etaxonomy.cdm.io.common.DbImportStateBase;
20
import eu.etaxonomy.cdm.model.agent.AgentBase;
21
import eu.etaxonomy.cdm.model.agent.Person;
22
import eu.etaxonomy.cdm.model.agent.Team;
23
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
24
import eu.etaxonomy.cdm.model.common.MarkerType;
25
import eu.etaxonomy.cdm.model.common.User;
26
import eu.etaxonomy.cdm.model.name.Rank;
27

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

    
37
	private Map<String, DefinedTermBase> dbCdmDefTermMap = new HashMap<String, DefinedTermBase>();
38
	
39
	private Map<String, User> usernameMap = new HashMap<String, User>();
40
	
41
	private Map<Integer, Map<Integer,Rank>> rankMap;
42

    
43
	private Map<String, Person> personMap = new HashMap<String, Person>();
44
	
45
	private Map<String, Team> teamMap = new HashMap<String, Team>();
46
	
47
	
48
	
49
	@Override
50
	public void initialize(GlobisImportConfigurator config) {
51
//		super(config);
52
		String tableName = "WebMarkerCategory_";
53
		//webMarkerCategory
54
		dbCdmDefTermMap.put(tableName + 1, MarkerType.COMPLETE());
55
	}
56

    
57
	public GlobisImportState(GlobisImportConfigurator config) {
58
		super(config);
59
	}
60

    
61
	public Map<String, DefinedTermBase> getDbCdmDefinedTermMap(){
62
		return this.dbCdmDefTermMap;
63
	}
64
	
65
	public void putDefinedTermToMap(String tableName, String id, DefinedTermBase term){
66
		 this.dbCdmDefTermMap.put(tableName + "_" + id, term);
67
	}
68
	
69
	public void putDefinedTermToMap(String tableName, int id, DefinedTermBase term){
70
		putDefinedTermToMap(tableName, String.valueOf(id), term);
71
	}
72
	
73
	public User getUser(String username){
74
		return usernameMap.get(username);
75
	}
76

    
77
	public void putUser(String username, User user){
78
		usernameMap.put(username, user);
79
	}
80

    
81
	/**
82
	 * @param rankMap the rankMap to set
83
	 */
84
	public void setRankMap(Map<Integer, Map<Integer,Rank>> rankMap) {
85
		this.rankMap = rankMap;
86
	}
87

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

    
117
	public void putPerson(String str, Person person){
118
		personMap.put(str, person);
119
	}
120
	
121

    
122
	public Person getPerson(String str){
123
		return personMap.get(str);
124
	}
125

    
126

    
127
	public void putTeam(String str, Team team){
128
		teamMap.put(str, team);
129
	}
130
	
131

    
132
	public Team getTeam(String str){
133
		return teamMap.get(str);
134
	}
135
	
136
	public Set<AgentBase> getAgents(){
137
		Set<AgentBase> result = new HashSet<AgentBase>();
138
		result.addAll(personMap.values());
139
		result.addAll(teamMap.values());
140
		return result;
141
	}
142
	
143
}
(7-7/10)