Commit cc97e931 authored by Matija Obreza's avatar Matija Obreza

Filter for accessions with images

- Update imageCount when linking folders with accessions
parent bcfa454d
......@@ -27,6 +27,7 @@ import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
......@@ -65,7 +66,8 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "acce")
@Table(name = "acce", indexes = {
@Index(name = "IX_imageCount", columnList = "imageCount") })
@Audited
public class AccessionId extends AuditedVersionedModel implements IdUUID {
......
......@@ -616,6 +616,13 @@ public class AdminController {
if (accession != null) {
LOG.warn("Folder for accession {}:{} is {}", instCode, accession.getAccessionNumber(), acceFolder.getPath());
accession.getAccessionId().setRepositoryFolder(acceFolder);
{
// Get number of images in the gallery
ImageGallery gallery = acceFolder.getGallery();
if (gallery != null) {
accession.getAccessionId().setImageCount(gallery.getImages().size());
}
}
accessionIdRepository.save(accession.getAccessionId());
} else {
LOG.warn("No accession {}:{} for folder {}", instCode, acceFolder.getName(), acceFolder.getPath());
......
......@@ -35,6 +35,8 @@ import com.querydsl.core.types.Predicate;
*/
public class AccessionFilter extends UuidModelFilter<AccessionFilter, Accession> implements Serializable {
private static final long serialVersionUID = -1441103961567816877L;
/** The historic. */
public Boolean historic;
......@@ -94,6 +96,9 @@ public class AccessionFilter extends UuidModelFilter<AccessionFilter, Accession>
/** accession aliases */
public StringFilter alias;
/** accessions with images */
public Boolean images;
/* (non-Javadoc)
......@@ -180,7 +185,13 @@ public class AccessionFilter extends UuidModelFilter<AccessionFilter, Accession>
if (sgsv != null) {
and.and(accession.accessionId.duplSite.any().eq("NOR051"));
}
if (images != null) {
if (images == Boolean.TRUE) {
and.and(accession.accessionId.imageCount.gt(0));
} else {
and.and(accession.accessionId.imageCount.eq(0));
}
}
return and;
}
......
......@@ -167,7 +167,7 @@ public class AccessionServiceImpl implements AccessionService {
if (folder != null) {
accessionDetails.files = folder.getFiles().stream().filter((file) -> !file.getContentType().contains("image/")).collect(Collectors.toList());
ImageGallery imageGallery = imageGalleryService.loadImageGallery(folder);
ImageGallery imageGallery = imageGalleryService.getImageGallery(folder);
if (imageGallery != null) {
if (imageGallery.getImages() != null) {
imageGallery.getImages().size();
......
......@@ -4761,3 +4761,15 @@ databaseChangeLog:
columnNames: folderId
constraintName: UK_3x3s9vul09xif4y29o2rwx939
tableName: acce
- changeSet:
id: 1547568102000-1
author: mobreza
comment: Add index on acce#imageCount
changes:
- createIndex:
columns:
- column:
name: imageCount
indexName: IX_imageCount
tableName: acce
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment