Project

General

Profile

Download (2.58 KB) Statistics
| Branch: | Tag: | 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.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.model.common.CdmBase;
19
import eu.etaxonomy.cdm.model.taxon.Classification;
20

    
21
/**
22
 * @author a.mueller
23
 * @created 11.05.2009
24
 * @version 1.0
25
 */
26
public abstract class DbImportStateBase<CONFIG extends ImportConfiguratorBase, STATE extends DbImportStateBase> extends ImportStateBase<CONFIG, CdmImportBase> implements IPartitionedState {
27
	
28
	public static final String CURRENT_OBJECT_NAMESPACE = "CurrentObjectNamespace";
29
	public static final String CURRENT_OBJECT_ID = "CurrentObjectId";
30
	
31
	@SuppressWarnings("unused")
32
	private static final Logger logger = Logger.getLogger(DbImportStateBase.class);
33
	private RelatedObjectsHelper relatedObjectsHelper = new RelatedObjectsHelper();;
34
	//holds the classifications needed for this partition, the key is a value that differentiate classifications
35
	//like the taxons reference (secundum)
36
	
37
	
38
	/**
39
	 * @param config
40
	 */
41
	protected DbImportStateBase(CONFIG config) {
42
		super(config);
43
	}
44
	
45
	/* (non-Javadoc)
46
	 * @see eu.etaxonomy.cdm.io.common.IPartitionedState#addRelatedObject(java.lang.Object, java.lang.String, eu.etaxonomy.cdm.model.common.CdmBase)
47
	 */
48
	public void addRelatedObject(Object namespace, String id, CdmBase relatedObject) {
49
		this.relatedObjectsHelper.addRelatedObjet(namespace, id, relatedObject);
50
	}
51

    
52
	
53
	/* (non-Javadoc)
54
	 * @see eu.etaxonomy.cdm.io.common.IPartitionedState#getRelatedObject(java.lang.Object, java.lang.String)
55
	 */
56
	public CdmBase getRelatedObject(Object namespace, String id) {
57
		return relatedObjectsHelper.getRelatedObject(namespace, id);
58
	}
59

    
60
	/* (non-Javadoc)
61
	 * @see eu.etaxonomy.cdm.io.common.IPartitionedState#getRelatedObject(java.lang.Object, java.lang.String)
62
	 */
63
	public<T extends CdmBase> T getRelatedObject(Object namespace, String id, Class<T> clazz) {
64
		CdmBase cdmBase = relatedObjectsHelper.getRelatedObject(namespace, id);
65
		T result = CdmBase.deproxy(cdmBase, clazz);
66
		return result;
67
	}
68
	
69
	/* (non-Javadoc)
70
	 * @see eu.etaxonomy.cdm.io.common.IPartitionedState#setRelatedObjects(java.util.Map)
71
	 */
72
	public void setRelatedObjects(Map<Object, Map<String, CdmBase>> relatedObjects) {
73
		relatedObjectsHelper.setRelatedObjects(relatedObjects);
74
	}
75

    
76
	
77
}
(14-14/48)