Revision 4012cbc4
Added by Katja Luther over 2 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java | ||
---|---|---|
94 | 94 |
import eu.etaxonomy.cdm.persistence.dao.term.ITermVocabularyDao; |
95 | 95 |
import eu.etaxonomy.cdm.persistence.dto.FeatureDto; |
96 | 96 |
import eu.etaxonomy.cdm.persistence.dto.MergeResult; |
97 |
import eu.etaxonomy.cdm.persistence.dto.SortableTaxonNodeQueryResult; |
|
98 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
|
97 | 99 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
98 | 100 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
99 | 101 |
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; |
... | ... | |
668 | 670 |
return deleteDescription(dao.load(descriptionUuid)); |
669 | 671 |
} |
670 | 672 |
|
673 |
|
|
674 |
|
|
671 | 675 |
@Override |
672 | 676 |
public DeleteResult isDeletable(UUID descriptionUuid){ |
673 | 677 |
DeleteResult result = new DeleteResult(); |
... | ... | |
1079 | 1083 |
public DescriptionBaseDto loadDto(UUID descriptionUuid) { |
1080 | 1084 |
String sqlSelect = DescriptionBaseDto.getDescriptionBaseDtoSelect(); |
1081 | 1085 |
Query query = getSession().createQuery(sqlSelect); |
1082 |
query.setParameter("uuid", descriptionUuid); |
|
1086 |
List<UUID> uuids = new ArrayList<UUID>(); |
|
1087 |
uuids.add(descriptionUuid); |
|
1088 |
query.setParameterList("uuid", uuids); |
|
1083 | 1089 |
|
1084 | 1090 |
@SuppressWarnings("unchecked") |
1085 | 1091 |
List<Object[]> result = query.list(); |
... | ... | |
1119 | 1125 |
return null; |
1120 | 1126 |
} |
1121 | 1127 |
|
1128 |
} |
|
1129 |
@Override |
|
1130 |
public List<DescriptionBaseDto> loadDtos(Set<UUID> descriptionUuids) { |
|
1131 |
String sqlSelect = DescriptionBaseDto.getDescriptionBaseDtoSelect(); |
|
1132 |
Query query = getSession().createQuery(sqlSelect); |
|
1133 |
query.setParameterList("uuid", descriptionUuids); |
|
1134 |
|
|
1135 |
@SuppressWarnings("unchecked") |
|
1136 |
List<Object[]> result = query.list(); |
|
1137 |
|
|
1138 |
List<DescriptionBaseDto> list = DescriptionBaseDto.descriptionBaseDtoListFrom(result); |
|
1139 |
|
|
1140 |
for (DescriptionBaseDto dto: list){ |
|
1141 |
|
|
1142 |
//get categorical data |
|
1143 |
sqlSelect = CategoricalDataDto.getCategoricalDtoSelect(); |
|
1144 |
query = getSession().createQuery(sqlSelect); |
|
1145 |
query.setParameter("uuid", dto.getDescriptionUuid()); |
|
1146 |
@SuppressWarnings("unchecked") |
|
1147 |
List<Object[]> resultCat = query.list(); |
|
1148 |
List<CategoricalDataDto> listCategorical = CategoricalDataDto.categoricalDataDtoListFrom(resultCat); |
|
1149 |
|
|
1150 |
List<UUID> featureUuids = new ArrayList<>(); |
|
1151 |
for (CategoricalDataDto catDto: listCategorical){ |
|
1152 |
featureUuids.add(catDto.getFeatureUuid()); |
|
1153 |
} |
|
1154 |
Map<UUID, TermDto> featureDtos = termService.findFeatureByUUIDsAsDtos(featureUuids); |
|
1155 |
for (CategoricalDataDto catDto: listCategorical){ |
|
1156 |
FeatureDto featuredto = (FeatureDto)featureDtos.get(catDto.getFeatureUuid()); |
|
1157 |
catDto.setFeatureDto(featuredto); |
|
1158 |
} |
|
1159 |
dto.getElements().addAll(listCategorical); |
|
1160 |
//get quantitative data |
|
1161 |
sqlSelect = QuantitativeDataDto.getQuantitativeDataDtoSelect(); |
|
1162 |
query = getSession().createQuery(sqlSelect); |
|
1163 |
query.setParameter("uuid", dto.getDescriptionUuid()); |
|
1164 |
@SuppressWarnings("unchecked") |
|
1165 |
List<Object[]> resultQuant = query.list(); |
|
1166 |
List<QuantitativeDataDto> listQuant = QuantitativeDataDto.quantitativeDataDtoListFrom(resultQuant); |
|
1167 |
dto.getElements().addAll(listQuant); |
|
1168 |
|
|
1169 |
} |
|
1170 |
return list; |
|
1171 |
|
|
1122 | 1172 |
} |
1123 | 1173 |
|
1124 | 1174 |
@Override |
... | ... | |
1136 | 1186 |
|
1137 | 1187 |
} |
1138 | 1188 |
|
1189 |
@Override |
|
1190 |
public TaxonNodeDto findTaxonNodeDtoForIndividualAssociation(UUID specimenUuid, UUID classificationUuid) { |
|
1191 |
//get specimen used in description |
|
1192 |
//get individial associations with this specimen |
|
1193 |
//get taxon node for the classification |
|
1194 |
@SuppressWarnings("unchecked") |
|
1195 |
List<SortableTaxonNodeQueryResult> result = dao.getNodeOfIndividualAssociationForSpecimen(specimenUuid, classificationUuid); |
|
1196 |
|
|
1197 |
if (!result.isEmpty()){ |
|
1198 |
List<TaxonNodeDto> dtos = taxonNodeDao.createNodeDtos(result); |
|
1199 |
if (dtos.size() == 1){ |
|
1200 |
return dtos.get(0); |
|
1201 |
}else{ |
|
1202 |
logger.debug("There is more than one taxon associated to the specimen with uuid: " + specimenUuid + " return the first in the list"); |
|
1203 |
return dtos.get(0); |
|
1204 |
} |
|
1205 |
} |
|
1206 |
|
|
1207 |
|
|
1208 |
|
|
1209 |
return null; |
|
1210 |
} |
|
1211 |
|
|
1212 |
|
|
1213 |
|
|
1139 | 1214 |
|
1140 | 1215 |
} |
Also available in: Unified diff
ref #9842: first steps removing objects in dto creation - continue