37 |
37 |
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
38 |
38 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
39 |
39 |
import eu.etaxonomy.cdm.model.description.Feature;
|
|
40 |
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
|
40 |
41 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
|
41 |
42 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
|
42 |
43 |
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
... | ... | |
691 |
692 |
}
|
692 |
693 |
|
693 |
694 |
|
|
695 |
@Override
|
|
696 |
public List<Integer> getIndividualAssociationSpecimenIDs(UUID taxonUuid,
|
|
697 |
Set<Feature> features, Integer pageSize,
|
|
698 |
Integer pageNumber, List<String> propertyPaths){
|
|
699 |
Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, IndividualsAssociation.class, pageSize, pageNumber, "de.associatedSpecimenOrObservation.id");
|
|
700 |
@SuppressWarnings("unchecked")
|
|
701 |
List<Integer> results = query.list();
|
|
702 |
return results;
|
|
703 |
}
|
|
704 |
|
694 |
705 |
@Override
|
695 |
706 |
public <T extends DescriptionElementBase> List<T> getDescriptionElementForTaxon(
|
696 |
707 |
UUID taxonUuid, Set<Feature> features,
|
... | ... | |
699 |
710 |
|
700 |
711 |
// Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE);
|
701 |
712 |
|
702 |
|
Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, pageSize, pageNumber, false);
|
|
713 |
Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, pageSize, pageNumber, "de");
|
703 |
714 |
|
704 |
715 |
if (logger.isDebugEnabled()){logger.debug(" dao: get list ...");}
|
705 |
716 |
@SuppressWarnings("unchecked")
|
... | ... | |
716 |
727 |
public <T extends DescriptionElementBase> long countDescriptionElementForTaxon(
|
717 |
728 |
UUID taxonUuid, Set<Feature> features, Class<T> type) {
|
718 |
729 |
|
719 |
|
Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, null, null, true);
|
|
730 |
Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, null, null, "count(de)");
|
720 |
731 |
|
721 |
732 |
return (Long)query.uniqueResult();
|
722 |
733 |
}
|
723 |
734 |
|
724 |
|
/**
|
725 |
|
* @param taxon
|
726 |
|
* @param features
|
727 |
|
* @param type
|
728 |
|
* @param pageSize
|
729 |
|
* @param pageNumber
|
730 |
|
* @return
|
731 |
|
*/
|
732 |
735 |
private <T extends DescriptionElementBase> Query prepareGetDescriptionElementForTaxon(UUID taxonUuid,
|
733 |
|
Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, boolean asCountQuery) {
|
734 |
|
|
735 |
|
String listOrCount;
|
736 |
|
if(asCountQuery){
|
737 |
|
listOrCount = "count(de)";
|
738 |
|
} else {
|
739 |
|
listOrCount = "de";
|
740 |
|
}
|
|
736 |
Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, String selectString) {
|
741 |
737 |
|
742 |
|
String queryString = "SELECT " + listOrCount + " FROM DescriptionElementBase AS de" +
|
|
738 |
String queryString = "SELECT " + selectString + " FROM DescriptionElementBase AS de" +
|
743 |
739 |
" LEFT JOIN de.inDescription AS d" +
|
744 |
740 |
" LEFT JOIN d.taxon AS t" +
|
745 |
741 |
" WHERE d.class = 'TaxonDescription' AND t.uuid = :taxon_uuid ";
|
ref #7095 Add dao method for individually associated specimens