Commit 064e9304 authored by Matija Obreza's avatar Matija Obreza

Merge branch '476-mcpd-download-fo-accessionrefs' into 'master'

Resolve "MCPD download of AccessionRefs"

Closes #476

See merge request genesys-pgr/genesys-server!475
parents 537b7215 2a55b804
......@@ -76,8 +76,6 @@ import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.model.PublishState;
import org.genesys2.server.model.UserRole;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.QAccession;
import org.genesys2.server.model.impl.QSubsetAccessionRef;
import org.genesys2.server.service.DownloadService;
import org.genesys2.server.service.ElasticsearchService;
import org.genesys2.server.service.impl.SearchException;
......@@ -110,7 +108,6 @@ import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.PathBuilder;
import com.querydsl.core.types.dsl.PathBuilderFactory;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.JPQLQuery;
import com.vdurmont.semver4j.SemverException;
......@@ -346,19 +343,16 @@ public class DatasetServiceImpl implements DatasetService {
@Override
public void writeXlsxMCPD(Dataset dataset, OutputStream outputStream) throws IOException {
Predicate predicate = QAccession.accession.id.in(JPAExpressions.selectFrom(QDatasetAccessionRef.datasetAccessionRef)
.select(QDatasetAccessionRef.datasetAccessionRef.accession.id).where(QDatasetAccessionRef.datasetAccessionRef.list.eq(dataset)));
PathBuilder<Accession> builder = new PathBuilderFactory().create(Accession.class);
Querydsl querydsl = new Querydsl(entityManager, builder);
JPQLQuery<Long> queryAccessionId = querydsl.createQuery(QSubsetAccessionRef.subsetAccessionRef)
JPQLQuery<Long> queryAccessionId = querydsl.createQuery(QDatasetAccessionRef.datasetAccessionRef)
// select id only
.select(QSubsetAccessionRef.subsetAccessionRef.accession.id)
.select(QDatasetAccessionRef.datasetAccessionRef.accession.id)
// order by id
.orderBy(QSubsetAccessionRef.subsetAccessionRef.accession.id.asc());
.orderBy(QDatasetAccessionRef.datasetAccessionRef.accession.id.asc());
// Apply where
queryAccessionId.where(predicate);
queryAccessionId.where(QDatasetAccessionRef.datasetAccessionRef.list.eq(dataset));
downloadService.writeXlsxMCPD(queryAccessionId, outputStream, "", "/datasets/" + dataset.getUuid());
}
......
......@@ -48,7 +48,6 @@ import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.model.PublishState;
import org.genesys2.server.model.UserRole;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.QAccession;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.model.impl.QSubset;
import org.genesys2.server.model.impl.QSubsetAccessionRef;
......@@ -94,7 +93,6 @@ import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.PathBuilder;
import com.querydsl.core.types.dsl.PathBuilderFactory;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.JPQLQuery;
/**
......@@ -728,9 +726,6 @@ public class SubsetServiceImpl implements SubsetService {
@Override
public void writeXlsxMCPD(Subset subset, OutputStream outputStream) throws IOException {
Predicate predicate = QAccession.accession.id.in(JPAExpressions.selectFrom(QSubsetAccessionRef.subsetAccessionRef)
.select(QSubsetAccessionRef.subsetAccessionRef.accession.id).where(QSubsetAccessionRef.subsetAccessionRef.list.eq(subset)));
PathBuilder<Accession> builder = new PathBuilderFactory().create(Accession.class);
Querydsl querydsl = new Querydsl(entityManager, builder);
JPQLQuery<Long> queryAccessionId = querydsl.createQuery(QSubsetAccessionRef.subsetAccessionRef)
......@@ -740,7 +735,7 @@ public class SubsetServiceImpl implements SubsetService {
.orderBy(QSubsetAccessionRef.subsetAccessionRef.accession.id.asc());
// Apply where
queryAccessionId.where(predicate);
queryAccessionId.where(QSubsetAccessionRef.subsetAccessionRef.list.eq(subset));
downloadService.writeXlsxMCPD(queryAccessionId, outputStream, "", "/subsets/" + subset.getUuid());
}
......
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