1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 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
|
package eu.etaxonomy.taxeditor.remoting.cache;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.HashMap;
|
14
|
import java.util.HashSet;
|
15
|
import java.util.List;
|
16
|
import java.util.Map;
|
17
|
import java.util.Set;
|
18
|
import java.util.TreeMap;
|
19
|
import java.util.TreeSet;
|
20
|
|
21
|
import org.hibernate.collection.internal.PersistentList;
|
22
|
import org.hibernate.collection.internal.PersistentMap;
|
23
|
import org.hibernate.collection.internal.PersistentSet;
|
24
|
import org.hibernate.collection.internal.PersistentSortedMap;
|
25
|
import org.hibernate.collection.internal.PersistentSortedSet;
|
26
|
import org.hibernate.collection.spi.PersistentCollection;
|
27
|
|
28
|
import eu.etaxonomy.cdm.model.common.PersistentMultiLanguageText;
|
29
|
import eu.etaxonomy.taxeditor.remoting.CdmRemotingException;
|
30
|
|
31
|
/**
|
32
|
* @author cmathew
|
33
|
* @date 17 Feb 2015
|
34
|
*
|
35
|
*/
|
36
|
public class ProxyUtils {
|
37
|
|
38
|
public static Object getObject(PersistentCollection pc) {
|
39
|
if(pc != null) {
|
40
|
if(pc instanceof PersistentSet) {
|
41
|
return new HashSet((Set)pc);
|
42
|
}
|
43
|
if(pc instanceof PersistentSortedSet) {
|
44
|
return new TreeSet((Set)pc);
|
45
|
}
|
46
|
if(pc instanceof PersistentList) {
|
47
|
return new ArrayList((List)pc);
|
48
|
}
|
49
|
if(pc instanceof PersistentMap || pc instanceof PersistentMultiLanguageText) {
|
50
|
return new HashMap((Map)pc);
|
51
|
}
|
52
|
if(pc instanceof PersistentSortedMap) {
|
53
|
return new TreeMap((Map)pc);
|
54
|
}
|
55
|
throw new CdmRemotingException("Cannot get Collection field for type " + pc.getClass().getName());
|
56
|
}
|
57
|
return null;
|
58
|
}
|
59
|
|
60
|
}
|