Revision 04b9479a
Added by Katja Luther almost 8 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/PolytomousKeyDaoImpl.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
10 | 10 |
package eu.etaxonomy.cdm.persistence.dao.hibernate.description; |
11 | 11 |
|
12 | 12 |
import java.util.List; |
13 |
import java.util.UUID; |
|
14 |
|
|
13 | 15 |
import org.apache.log4j.Logger; |
14 | 16 |
import org.hibernate.Criteria; |
17 |
import org.springframework.beans.factory.annotation.Autowired; |
|
15 | 18 |
import org.springframework.stereotype.Repository; |
16 | 19 |
|
20 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
17 | 21 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
18 | 22 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
19 | 23 |
import eu.etaxonomy.cdm.persistence.dao.description.IPolytomousKeyDao; |
24 |
import eu.etaxonomy.cdm.persistence.dao.description.IPolytomousKeyNodeDao; |
|
20 | 25 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase; |
21 | 26 |
|
22 | 27 |
/** |
... | ... | |
28 | 33 |
public class PolytomousKeyDaoImpl extends IdentifiableDaoBase<PolytomousKey> implements IPolytomousKeyDao { |
29 | 34 |
private static final Logger logger = Logger.getLogger(PolytomousKeyDaoImpl.class); |
30 | 35 |
|
36 |
@Autowired |
|
37 |
IPolytomousKeyNodeDao nodeDao; |
|
38 |
|
|
31 | 39 |
public PolytomousKeyDaoImpl() { |
32 |
super(PolytomousKey.class);
|
|
40 |
super(PolytomousKey.class); |
|
33 | 41 |
// indexedClasses = new Class[1]; |
34 | 42 |
// indexedClasses[0] = PolytomousKey.class; |
35 | 43 |
} |
36 |
|
|
44 |
|
|
37 | 45 |
|
38 | 46 |
@Override |
39 | 47 |
public List<PolytomousKey> list() { |
40 |
Criteria crit = getSession().createCriteria(type);
|
|
41 |
return crit.list();
|
|
48 |
Criteria crit = getSession().createCriteria(type); |
|
49 |
return crit.list(); |
|
42 | 50 |
} |
43 | 51 |
|
44 |
|
|
52 |
|
|
45 | 53 |
//FIXME rewrite as node has a key attribute now |
46 |
public void loadNodes(PolytomousKeyNode root, List<String> nodePaths) { |
|
54 |
@Override |
|
55 |
public void loadNodes(PolytomousKeyNode root, List<String> nodePaths) { |
|
47 | 56 |
for(PolytomousKeyNode child : root.getChildren()) { |
48 | 57 |
defaultBeanInitializer.initialize(child, nodePaths); |
49 | 58 |
loadNodes(child,nodePaths); |
50 | 59 |
} |
51 | 60 |
} |
52 |
|
|
61 |
|
|
62 |
@Override |
|
63 |
public UUID delete(PolytomousKey key){ |
|
64 |
|
|
65 |
key = HibernateProxyHelper.deproxy(key, PolytomousKey.class); |
|
66 |
if (key.getRoot() != null){ |
|
67 |
PolytomousKeyNode root = HibernateProxyHelper.deproxy(key.getRoot(), PolytomousKeyNode.class); |
|
68 |
nodeDao.delete(root); |
|
69 |
|
|
70 |
} |
|
71 |
getSession().delete(key); |
|
72 |
return key.getUuid(); |
|
73 |
|
|
74 |
} |
|
75 |
|
|
53 | 76 |
} |
Also available in: Unified diff
fix failing Polytomouskey test