1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.api.service;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
import org.springframework.stereotype.Service;
|
18
|
import org.springframework.transaction.annotation.Propagation;
|
19
|
import org.springframework.transaction.annotation.Transactional;
|
20
|
|
21
|
import eu.etaxonomy.cdm.common.IProgressMonitor;
|
22
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
23
|
import eu.etaxonomy.cdm.persistence.dao.description.IPolytomousKeyDao;
|
24
|
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
25
|
|
26
|
@Service
|
27
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
|
28
|
public class PolytomousKeyServiceImpl extends IdentifiableServiceBase<PolytomousKey, IPolytomousKeyDao> implements IPolytomousKeyService {
|
29
|
|
30
|
@Autowired
|
31
|
protected void setDao(IPolytomousKeyDao dao) {
|
32
|
this.dao = dao;
|
33
|
}
|
34
|
|
35
|
|
36
|
/* (non-Javadoc)
|
37
|
* @see eu.etaxonomy.cdm.api.service.IIdentifiableEntityService#updateTitleCache(java.lang.Integer, eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy)
|
38
|
*/
|
39
|
@Override
|
40
|
public void updateTitleCache(Class<? extends PolytomousKey> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<PolytomousKey> cacheStrategy, IProgressMonitor monitor) {
|
41
|
if (clazz == null){
|
42
|
clazz = PolytomousKey.class;
|
43
|
}
|
44
|
super.updateTitleCacheImpl(clazz, stepSize, cacheStrategy, monitor);
|
45
|
}
|
46
|
|
47
|
|
48
|
/* (non-Javadoc)
|
49
|
* @see eu.etaxonomy.cdm.api.service.IFeatureTreeService#loadWithNodes(java.util.UUID, java.util.List, java.util.List)
|
50
|
*/
|
51
|
public PolytomousKey loadWithNodes(UUID uuid, List<String> propertyPaths, List<String> nodePaths) {
|
52
|
nodePaths.add("children");
|
53
|
|
54
|
List<String> rootPaths = new ArrayList<String>();
|
55
|
rootPaths.add("root");
|
56
|
for(String path : nodePaths) {
|
57
|
rootPaths.add("root." + path);
|
58
|
}
|
59
|
|
60
|
if(propertyPaths != null) {
|
61
|
rootPaths.addAll(propertyPaths);
|
62
|
}
|
63
|
|
64
|
PolytomousKey polytomousKey = load(uuid, rootPaths);
|
65
|
dao.loadNodes(polytomousKey.getRoot(),nodePaths);
|
66
|
return polytomousKey;
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Returns the polytomous key specified by the given <code>uuid</code>.
|
71
|
* The specified polytomous key either can be one of those stored in the CDM database or can be the
|
72
|
* DefaultFeatureTree (contains all Features in use).
|
73
|
* The uuid of the DefaultFeatureTree is defined in {@link IFeatureTreeService#DefaultFeatureTreeUuid}.
|
74
|
* The DefaultFeatureTree is also returned if no feature tree at all is stored in the cdm database.
|
75
|
*
|
76
|
* @see eu.etaxonomy.cdm.api.service.ServiceBase#load(java.util.UUID, java.util.List)
|
77
|
*/
|
78
|
@Override
|
79
|
public PolytomousKey load(UUID uuid, List<String> propertyPaths) {
|
80
|
return super.load(uuid, propertyPaths);
|
81
|
}
|
82
|
|
83
|
}
|