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.common;
|
12
|
|
13
|
import java.util.HashMap;
|
14
|
import java.util.Map;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
|
18
|
import eu.etaxonomy.cdm.api.service.IService;
|
19
|
import eu.etaxonomy.cdm.model.agent.Person;
|
20
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
21
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
22
|
import eu.etaxonomy.cdm.model.common.User;
|
23
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
24
|
import eu.etaxonomy.cdm.model.occurrence.Specimen;
|
25
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
26
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
27
|
import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
|
28
|
|
29
|
/**
|
30
|
* @author a.mueller
|
31
|
* @created 11.05.2009
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public abstract class ImportStateBase<CONFIG extends ImportConfiguratorBase> extends IoStateBase<CONFIG> {
|
35
|
@SuppressWarnings("unused")
|
36
|
private static final Logger logger = Logger.getLogger(ImportStateBase.class);
|
37
|
|
38
|
private Map<ReferenceBase,TaxonomicTree> treeMap = new HashMap<ReferenceBase,TaxonomicTree>();
|
39
|
|
40
|
protected ImportStateBase(CONFIG config){
|
41
|
this.config = config;
|
42
|
stores.put(ICdmIO.USER_STORE, new MapWrapper<User>(service));
|
43
|
stores.put(ICdmIO.PERSON_STORE, new MapWrapper<Person>(service));
|
44
|
stores.put(ICdmIO.TEAM_STORE, new MapWrapper<TeamOrPersonBase<?>>(service));
|
45
|
stores.put(ICdmIO.REFERENCE_STORE, new MapWrapper<ReferenceBase>(service));
|
46
|
stores.put(ICdmIO.NOMREF_STORE, new MapWrapper<ReferenceBase>(service));
|
47
|
stores.put(ICdmIO.NOMREF_DETAIL_STORE, new MapWrapper<ReferenceBase>(service));
|
48
|
stores.put(ICdmIO.REF_DETAIL_STORE, new MapWrapper<ReferenceBase>(service));
|
49
|
stores.put(ICdmIO.TAXONNAME_STORE, new MapWrapper<TaxonNameBase<?,?>>(service));
|
50
|
stores.put(ICdmIO.TAXON_STORE, new MapWrapper<TaxonBase>(service));
|
51
|
stores.put(ICdmIO.SPECIMEN_STORE, new MapWrapper<Specimen>(service));
|
52
|
}
|
53
|
|
54
|
//different type of stores that are used by the known imports
|
55
|
protected Map<String, MapWrapper<? extends CdmBase>> stores = new HashMap<String, MapWrapper<? extends CdmBase>>();
|
56
|
|
57
|
protected IService<CdmBase> service = null;
|
58
|
|
59
|
/**
|
60
|
* @return the stores
|
61
|
*/
|
62
|
public Map<String, MapWrapper<? extends CdmBase>> getStores() {
|
63
|
return stores;
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* @param stores the stores to set
|
68
|
*/
|
69
|
public void setStores(Map<String, MapWrapper<? extends CdmBase>> stores) {
|
70
|
this.stores = stores;
|
71
|
}
|
72
|
|
73
|
|
74
|
public MapWrapper<? extends CdmBase> getStore(String storeLabel){
|
75
|
return (MapWrapper<? extends CdmBase>) stores.get(storeLabel);
|
76
|
}
|
77
|
|
78
|
|
79
|
/**
|
80
|
* @return the treeMap
|
81
|
*/
|
82
|
public TaxonomicTree getTree(ReferenceBase ref) {
|
83
|
return treeMap.get(ref);
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* @param treeMap the treeMap to set
|
88
|
*/
|
89
|
public void putTree(ReferenceBase ref, TaxonomicTree tree) {
|
90
|
if (tree != null){
|
91
|
this.treeMap.put(ref, tree);
|
92
|
}
|
93
|
}
|
94
|
|
95
|
}
|