3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.io
.globis
;
13 import java
.util
.HashMap
;
14 import java
.util
.HashSet
;
18 import org
.apache
.log4j
.Logger
;
20 import eu
.etaxonomy
.cdm
.io
.common
.DbImportStateBase
;
21 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
22 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
23 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
24 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
25 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
26 import eu
.etaxonomy
.cdm
.model
.common
.User
;
27 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
34 public class GlobisImportState
extends DbImportStateBase
<GlobisImportConfigurator
, GlobisImportState
>{
35 @SuppressWarnings("unused")
36 private static final Logger logger
= Logger
.getLogger(GlobisImportState
.class);
38 private Map
<String
, DefinedTermBase
> dbCdmDefTermMap
= new HashMap
<String
, DefinedTermBase
>();
40 private Map
<String
, User
> usernameMap
= new HashMap
<String
, User
>();
42 private Map
<Integer
, Map
<Integer
,Rank
>> rankMap
;
44 private Map
<String
, Person
> personMap
= new HashMap
<String
, Person
>();
46 private Map
<String
, Team
> teamMap
= new HashMap
<String
, Team
>();
51 public void initialize(GlobisImportConfigurator config
) {
53 String tableName
= "WebMarkerCategory_";
55 dbCdmDefTermMap
.put(tableName
+ 1, MarkerType
.COMPLETE());
58 public GlobisImportState(GlobisImportConfigurator config
) {
62 public Map
<String
, DefinedTermBase
> getDbCdmDefinedTermMap(){
63 return this.dbCdmDefTermMap
;
66 public void putDefinedTermToMap(String tableName
, String id
, DefinedTermBase term
){
67 this.dbCdmDefTermMap
.put(tableName
+ "_" + id
, term
);
70 public void putDefinedTermToMap(String tableName
, int id
, DefinedTermBase term
){
71 putDefinedTermToMap(tableName
, String
.valueOf(id
), term
);
74 public User
getUser(String username
){
75 return usernameMap
.get(username
);
78 public void putUser(String username
, User user
){
79 usernameMap
.put(username
, user
);
83 * @param rankMap the rankMap to set
85 public void setRankMap(Map
<Integer
, Map
<Integer
,Rank
>> rankMap
) {
86 this.rankMap
= rankMap
;
90 // * @return the rankMap
92 // public Map<Integer, Map<Integer,Rank>> getRankMap() {
98 * Returns the CDM rank depending on the ERMS rankId and the ERMS kingdomId. Returns <code>
99 * null</code> if the rank does not exist.
100 * Throws a RuntimeException if the rank map has not been initialized before.
104 * @throws RuntimeException
106 public Rank
getRank (int rankId
, int kingdomId
){
108 if (this.rankMap
== null){
109 throw new RuntimeException("rank map not initialized");
111 Map
<Integer
, Rank
> kingdomMap
= rankMap
.get(rankId
);
112 if (kingdomMap
!= null){
113 result
= kingdomMap
.get(kingdomId
);
118 public void putPerson(String str
, Person person
){
119 personMap
.put(str
, person
);
123 public Person
getPerson(String str
){
124 return personMap
.get(str
);
128 public void putTeam(String str
, Team team
){
129 teamMap
.put(str
, team
);
133 public Team
getTeam(String str
){
134 return teamMap
.get(str
);
137 public Set
<AgentBase
> getAgents(){
138 Set
<AgentBase
> result
= new HashSet
<AgentBase
>();
139 result
.addAll(personMap
.values());
140 result
.addAll(teamMap
.values());