Project

General

Profile

Download (3.76 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.MarkerType;
24
import eu.etaxonomy.cdm.model.name.Rank;
25
import eu.etaxonomy.cdm.model.permission.User;
26
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
27

    
28
/**
29
 * @author a.mueller
30
 * @since 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
	@Override
74
    public User getUser(String username){
75
		return usernameMap.get(username);
76
	}
77

    
78
	@Override
79
    public void putUser(String username, User user){
80
		usernameMap.put(username, user);
81
	}
82

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

    
90
//	/**
91
//	 * @return the rankMap
92
//	 */
93
//	public Map<Integer, Map<Integer,Rank>> getRankMap() {
94
//		return rankMap;
95
//	}
96

    
97

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

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

    
123

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

    
128

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

    
133

    
134
	public Team getTeam(String str){
135
		return teamMap.get(str);
136
	}
137

    
138
	public Set<AgentBase> getAgents(){
139
		Set<AgentBase> result = new HashSet<AgentBase>();
140
		result.addAll(personMap.values());
141
		result.addAll(teamMap.values());
142
		return result;
143
	}
144

    
145
}
(7-7/10)