Revision 9fb87bef
Added by Katja Luther almost 2 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptiveDataSetDao.java | ||
---|---|---|
202 | 202 |
|
203 | 203 |
private List<UUID> getNodeUuidsForDescriptiveDataSet(UUID uuid) { |
204 | 204 |
Session session = getSession(); |
205 |
|
|
205 |
|
|
206 | 206 |
String queryString = "SELECT t.uuid FROM DescriptiveDataSet a JOIN a.taxonSubtreeFilter as t WHERE a.uuid = :uuid"; |
207 | 207 |
Query<UUID> query = session.createQuery(queryString, UUID.class); |
208 | 208 |
query.setParameter("uuid", uuid); |
... | ... | |
260 | 260 |
} |
261 | 261 |
//get taxon nodes |
262 | 262 |
List<UUID> nodeUuids = getNodeUuidsForDescriptiveDataSet(uuid); |
263 |
List<TaxonNodeDto> nodeDtos = nodeDao.getTaxonNodeDtos(nodeUuids); |
|
263 |
List<TaxonNodeDto> nodeDtos = nodeDao.getTaxonNodeDtosWithoutParent(nodeUuids);
|
|
264 | 264 |
Set<TaxonNodeDto> nodeSet = new HashSet<>(nodeDtos); |
265 | 265 |
dto.setSubTreeFilter(nodeSet); |
266 | 266 |
|
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java | ||
---|---|---|
1156 | 1156 |
|
1157 | 1157 |
String queryString = getTaxonNodeDtoQuery(); |
1158 | 1158 |
queryString += " WHERE tn.uuid = :uuid "; |
1159 |
Query<SortableTaxonNodeQueryResult> query = getSession().createQuery(queryString, SortableTaxonNodeQueryResult.class); |
|
1159 |
Query<SortableTaxonNodeQueryResult> query = getSession().createNativeQuery(queryString, SortableTaxonNodeQueryResult.class);
|
|
1160 | 1160 |
query.setParameter("uuid", nodeUuid); |
1161 | 1161 |
|
1162 | 1162 |
List<SortableTaxonNodeQueryResult> result = query.list(); |
... | ... | |
1168 | 1168 |
} |
1169 | 1169 |
|
1170 | 1170 |
private String getTaxonNodeDtoQuery() { |
1171 |
/* |
|
1172 |
* select value(i) |
|
1173 |
from Product p |
|
1174 |
join p.images i |
|
1175 |
where p.id = 123 |
|
1176 |
*/ |
|
1177 |
|
|
1178 |
String queryString = "SELECT new " + SortableTaxonNodeQueryResult.class.getName() + "(" |
|
1171 |
String queryString = "SELECT new " + SortableTaxonNodeQueryResult.class.getName() + "(" |
|
1179 | 1172 |
+ "tn.uuid, tn.id, tn.treeIndex, t.uuid, t.titleCache, name.titleCache, rank, p.uuid, index(tn), cl.uuid, t.publish, tn.status, note " |
1180 | 1173 |
+ ") " |
1181 | 1174 |
+ " FROM TaxonNode p " |
... | ... | |
1188 | 1181 |
return queryString; |
1189 | 1182 |
} |
1190 | 1183 |
|
1184 |
public String getTaxonNodeDtoQueryWithoutParent() { |
|
1185 |
String queryString = "SELECT new " + SortableTaxonNodeQueryResult.class.getName() + "(" |
|
1186 |
+ "tn.uuid, tn.id, t.titleCache"// rank " |
|
1187 |
|
|
1188 |
// + "tn.uuid, tn.id, t.uuid, t.titleCache, name.titleCache, rank, cl.uuid, t.publish, tn.status, note " |
|
1189 |
+ ") " |
|
1190 |
+ " FROM TaxonNode tn " |
|
1191 |
+ " LEFT JOIN tn.taxon AS t " ; |
|
1192 |
// + " LEFT JOIN t.name AS name " |
|
1193 |
// + " INNER JOIN tn.classification AS cl "; |
|
1194 |
// + " LEFT OUTER JOIN tn.statusNote as note "; |
|
1195 |
// + " LEFT OUTER JOIN name.rank AS rank "; |
|
1196 |
return queryString; |
|
1197 |
} |
|
1198 |
|
|
1191 | 1199 |
|
1192 | 1200 |
|
1193 | 1201 |
@Override |
... | ... | |
1204 | 1212 |
|
1205 | 1213 |
return list; |
1206 | 1214 |
} |
1215 |
|
|
1216 |
@Override |
|
1217 |
public List<TaxonNodeDto> getTaxonNodeDtosWithoutParent(List<UUID> nodeUuids) { |
|
1218 |
String queryString = getTaxonNodeDtoQueryWithoutParent(); |
|
1219 |
queryString = queryString + " WHERE tn.uuid IN (:uuid) "; |
|
1220 |
|
|
1221 |
Query<SortableTaxonNodeQueryResult> query = getSession().createQuery(queryString, SortableTaxonNodeQueryResult.class); |
|
1222 |
query.setParameterList("uuid", nodeUuids); |
|
1223 |
|
|
1224 |
List<SortableTaxonNodeQueryResult> result = query.list(); |
|
1225 |
|
|
1226 |
List<TaxonNodeDto> list = createNodeDtos(result); |
|
1227 |
|
|
1228 |
return list; |
|
1229 |
} |
|
1207 | 1230 |
@Override |
1208 | 1231 |
public List<TaxonNodeDto> getTaxonNodeDtosFromTaxon(UUID taxonUuid, String subTreeIndex) { |
1209 | 1232 |
String queryString = getTaxonNodeDtoQuery(); |
... | ... | |
1269 | 1292 |
Classification classification, Integer limit, String pattern, boolean searchForClassifications) { |
1270 | 1293 |
return getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification, limit, pattern, searchForClassifications, false); |
1271 | 1294 |
} |
1295 |
|
|
1296 |
|
|
1272 | 1297 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonNodeDao.java | ||
---|---|---|
217 | 217 |
* @return |
218 | 218 |
*/ |
219 | 219 |
List<TaxonNodeDto> getTaxonNodeDtosFromTaxon(UUID taxonUuid, String subTreeIndex); |
220 |
|
|
221 |
List<TaxonNodeDto> getTaxonNodeDtosWithoutParent(List<UUID> nodeUuids); |
|
222 |
|
|
223 |
|
|
220 | 224 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/SortableTaxonNodeQueryResult.java | ||
---|---|---|
116 | 116 |
public SortableTaxonNodeQueryResult(UUID taxonNodeUuid, Integer taxonNodeId, String taxonTitleCache) { |
117 | 117 |
this(taxonNodeUuid, taxonNodeId, null, null, taxonTitleCache, null, null); |
118 | 118 |
} |
119 |
|
|
120 |
//tn.uuid, tn.id, t.uuid, t.titleCache, name.titleCache, rank, cl.uuid, t.publish, tn.status, note |
|
119 | 121 |
|
120 | 122 |
public UUID getTaxonNodeUuid() { |
121 | 123 |
return taxonNodeUuid; |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java | ||
---|---|---|
219 | 219 |
UuidAndTitleCache<SpecimenOrObservationBase> specimen = description.getSpecimenDto(); |
220 | 220 |
//get taxon node |
221 | 221 |
|
222 |
|
|
222 |
|
|
223 | 223 |
return descriptionService.findTaxonNodeDtoForIndividualAssociation(specimen.getUuid(), descriptiveDataSet.getSubTreeFilter().iterator().next().getClassificationUUID()); |
224 | 224 |
//NOTE: don't remove cast as it does not compile on some systems |
225 | 225 |
// List<DescriptionBaseDto> descDtos = descriptionService.loadDtos(descriptiveDataSet.getDescriptionUuids()); |
Also available in: Unified diff
ref #10076: fix taxonnodeDto creation for nodes without taxon and parent