Revision b6d3c69f
Added by Patrick Plitzner about 5 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IFeatureTreeDao.java | ||
---|---|---|
12 | 12 |
import java.util.List; |
13 | 13 |
import java.util.UUID; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
15 | 16 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
16 | 17 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
17 | 18 |
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao; |
19 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
18 | 20 |
|
19 | 21 |
/** |
20 | 22 |
* @author a.mueller |
... | ... | |
27 | 29 |
public UUID DefaultFeatureTreeUuid = UUID.fromString("ac8d4e58-926d-4f81-ac77-cebdd295df7c"); |
28 | 30 |
|
29 | 31 |
/** |
30 |
* Loads nodes and the nodes child nodes recursivly |
|
32 |
* Loads nodes and the nodes child nodes recursively
|
|
31 | 33 |
* @param nodes |
32 | 34 |
* @param nodePaths |
33 | 35 |
*/ |
34 | 36 |
public void deepLoadNodes(List<FeatureNode> nodes, List<String> nodePaths); |
37 |
|
|
38 |
public <S extends FeatureTree> List<UuidAndTitleCache<S>> getUuidAndTitleCacheByTermType(Class<S> clazz, TermType termType, Integer limit, |
|
39 |
String pattern); |
|
35 | 40 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/FeatureTreeDaoImpl.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import org.apache.log4j.Logger; |
17 | 17 |
import org.hibernate.Criteria; |
18 |
import org.hibernate.Query; |
|
19 |
import org.hibernate.Session; |
|
18 | 20 |
import org.springframework.beans.factory.annotation.Autowired; |
19 | 21 |
import org.springframework.stereotype.Repository; |
20 | 22 |
|
23 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
21 | 24 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
22 | 25 |
import eu.etaxonomy.cdm.model.common.VocabularyEnum; |
23 | 26 |
import eu.etaxonomy.cdm.model.description.Feature; |
... | ... | |
26 | 29 |
import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao; |
27 | 30 |
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureTreeDao; |
28 | 31 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase; |
32 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
29 | 33 |
|
30 | 34 |
/** |
31 | 35 |
* @author a.mueller |
... | ... | |
104 | 108 |
return featureTree; |
105 | 109 |
} |
106 | 110 |
|
111 |
@Override |
|
112 |
public <S extends FeatureTree> List<UuidAndTitleCache<S>> getUuidAndTitleCacheByTermType(Class<S> clazz, TermType termType, Integer limit, |
|
113 |
String pattern) { |
|
114 |
Session session = getSession(); |
|
115 |
Query query = session.createQuery( |
|
116 |
" SELECT uuid, id, titleCache " |
|
117 |
+ " FROM " + clazz.getSimpleName() |
|
118 |
+ (pattern!=null?" WHERE titleCache LIKE :pattern":" WHERE 1 = 1 ") |
|
119 |
+ (termType!=null?" AND termType = :termType ":"") |
|
120 |
); |
|
121 |
if(pattern!=null){ |
|
122 |
pattern = pattern.replace("*", "%"); |
|
123 |
pattern = pattern.replace("?", "_"); |
|
124 |
pattern = pattern + "%"; |
|
125 |
query.setParameter("pattern", pattern); |
|
126 |
} |
|
127 |
if(termType!=null){ |
|
128 |
query.setParameter("termType", termType); |
|
129 |
} |
|
130 |
if (limit != null){ |
|
131 |
query.setMaxResults(limit); |
|
132 |
} |
|
133 |
return getUuidAndTitleCache(query); |
|
134 |
} |
|
135 |
|
|
107 | 136 |
|
108 | 137 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/FeatureTreeServiceImpl.java | ||
---|---|---|
25 | 25 |
import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling; |
26 | 26 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
27 | 27 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
28 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
28 | 29 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
29 | 30 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
30 | 31 |
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureNodeDao; |
31 | 32 |
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureTreeDao; |
33 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
32 | 34 |
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; |
33 | 35 |
|
34 | 36 |
@Service |
... | ... | |
136 | 138 |
return result; |
137 | 139 |
|
138 | 140 |
} |
141 |
|
|
142 |
@Override |
|
143 |
public <S extends FeatureTree> List<UuidAndTitleCache<S>> getUuidAndTitleCacheByTermType(Class<S> clazz, TermType termType, Integer limit, |
|
144 |
String pattern) { |
|
145 |
return dao.getUuidAndTitleCacheByTermType(clazz, termType, limit, pattern); |
|
146 |
} |
|
139 | 147 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IFeatureTreeService.java | ||
---|---|---|
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 |
*/ |
|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.api.service; |
11 | 11 |
|
... | ... | |
14 | 14 |
import java.util.Map; |
15 | 15 |
import java.util.UUID; |
16 | 16 |
|
17 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
17 | 18 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
18 | 19 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
20 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
19 | 21 |
|
20 | 22 |
public interface IFeatureTreeService extends IIdentifiableEntityService<FeatureTree> { |
21 |
|
|
23 |
|
|
22 | 24 |
public List<FeatureNode> getFeatureNodesAll(); |
23 |
|
|
25 |
|
|
24 | 26 |
/** |
25 |
* Loads a feature tree including all of its nodes (all the way down to the tips of the tree).
|
|
27 |
* Loads a feature tree including all of its nodes (all the way down to the tips of the tree). |
|
26 | 28 |
* Because this method automatically adds feature nodes recursively, adding "root" to property paths |
27 | 29 |
* is supurfluous - the propertyPaths argument should be used to initialize property paths <i>in addition</i> |
28 |
* to the feature nodes. The nodePaths argument is applied to each node in turn, so again, adding "children"
|
|
30 |
* to the feature nodes. The nodePaths argument is applied to each node in turn, so again, adding "children" |
|
29 | 31 |
* is also supurfluous. The nodePaths argument should be used to specify additional propertys of the featureNode |
30 | 32 |
* to initialize (e.g. feature). |
31 |
*
|
|
33 |
* |
|
32 | 34 |
*/ |
33 | 35 |
public FeatureTree loadWithNodes(UUID uuid, List<String> propertyPaths, List<String> nodePaths); |
34 | 36 |
|
35 | 37 |
public Map<UUID, FeatureNode> saveFeatureNodesAll(Collection<FeatureNode> featureNodeCollection); |
36 |
|
|
38 |
|
|
37 | 39 |
public Map<UUID, FeatureNode> saveOrUpdateFeatureNodesAll(Collection<FeatureNode> featureNodeCollection); |
38 |
|
|
40 |
|
|
39 | 41 |
public FeatureTree createTransientDefaultFeatureTree(); |
42 |
|
|
43 |
public <S extends FeatureTree> List<UuidAndTitleCache<S>> getUuidAndTitleCacheByTermType(Class<S> clazz, TermType termType, Integer limit, |
|
44 |
String pattern); |
|
40 | 45 |
} |
Also available in: Unified diff
ref #8146 Add service method for UuidAndTitleCache by termType for trees