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.api.service;
|
12
|
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.Collections;
|
15
|
import java.util.Comparator;
|
16
|
import java.util.List;
|
17
|
import java.util.UUID;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
import org.springframework.beans.factory.annotation.Autowired;
|
21
|
import org.springframework.stereotype.Service;
|
22
|
import org.springframework.transaction.annotation.Propagation;
|
23
|
import org.springframework.transaction.annotation.Transactional;
|
24
|
|
25
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
26
|
import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;
|
27
|
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeDao;
|
28
|
|
29
|
/**
|
30
|
* @author n.hoffmann
|
31
|
* @created Apr 9, 2010
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
@Service
|
35
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
|
36
|
public class TaxonNodeServiceImpl extends AnnotatableServiceBase<TaxonNode, ITaxonNodeDao> implements ITaxonNodeService{
|
37
|
private static final Logger logger = Logger
|
38
|
.getLogger(TaxonNodeServiceImpl.class);
|
39
|
|
40
|
@Autowired
|
41
|
private BeanInitializer defaultBeanInitializer;
|
42
|
|
43
|
private Comparator<? super TaxonNode> taxonNodeComparator;
|
44
|
@Autowired
|
45
|
public void setTaxonNodeComparator(ITaxonNodeComparator<? super TaxonNode> taxonNodeComparator){
|
46
|
this.taxonNodeComparator = (Comparator<? super TaxonNode>) taxonNodeComparator;
|
47
|
}
|
48
|
|
49
|
public TaxonNode getTaxonNodeByUuid(UUID uuid) {
|
50
|
return dao.findByUuid(uuid);
|
51
|
}
|
52
|
|
53
|
public List<TaxonNode> loadChildNodesOfTaxonNode(TaxonNode taxonNode,
|
54
|
List<String> propertyPaths) {
|
55
|
taxonNode = dao.load(taxonNode.getUuid());
|
56
|
List<TaxonNode> childNodes = new ArrayList<TaxonNode>(taxonNode.getChildNodes());
|
57
|
Collections.sort(childNodes, taxonNodeComparator);
|
58
|
defaultBeanInitializer.initializeAll(childNodes, propertyPaths);
|
59
|
return childNodes;
|
60
|
}
|
61
|
|
62
|
/* (non-Javadoc)
|
63
|
* @see eu.etaxonomy.cdm.api.service.ServiceBase#setDao(eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao)
|
64
|
*/
|
65
|
@Override
|
66
|
@Autowired
|
67
|
protected void setDao(ITaxonNodeDao dao) {
|
68
|
this.dao = dao;
|
69
|
}
|
70
|
}
|