Commit 17ea9ae7 authored by Matija Obreza's avatar Matija Obreza Committed by Matija Obreza
Browse files

Included "lists" in AccessionDetails for ES

parent 4243392e
......@@ -93,8 +93,8 @@ public class AccessionDetails {
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String acceUrl;
@Field(type = FieldType.Nested)
private Set<AccessionList> lists;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private Set<String> lists;
public static AccessionDetails from(AccessionData accession) {
AccessionDetails ad = new AccessionDetails();
......@@ -116,7 +116,10 @@ public class AccessionDetails {
ad.art15 = accession.getInTrust();
ad.sampStat = accession.getSampleStatus();
ad.storage = new ArrayList<Integer>(accession.getStoRage());
ad.lists = accession.getAccessionId().getLists();
ad.lists = new HashSet<String>();
for (AccessionList al : accession.getAccessionId().getLists()) {
ad.lists.add(al.getUuid().toString());
}
ad.taxonomy = Taxonomy.from(accession.getTaxonomy());
ad.acceUrl = accession.getAcceUrl();
......@@ -219,11 +222,11 @@ public class AccessionDetails {
public Float getSeqNo() {
return seqNo;
}
public void setSeqNo(Float seqNo) {
this.seqNo = seqNo;
}
public String getAcqDate() {
return acqDate;
}
......@@ -462,4 +465,12 @@ public class AccessionDetails {
public void setAcceUrl(String acceUrl) {
this.acceUrl = acceUrl;
}
public Set<String> getLists() {
return lists;
}
public void setLists(Set<String> lists) {
this.lists = lists;
}
}
......@@ -72,7 +72,7 @@ public class AccessionListRepositoryCustomImpl implements AccessionListCustomRep
@Override
public int removeAll(AccessionList accessionList) {
Query q = entityManager.createNativeQuery("delete from accelistitems ali where ali.listid = ?1");
Query q = entityManager.createNativeQuery("delete from accelistitems where listid = ?1");
q.setParameter(1, accessionList);
return q.executeUpdate();
}
......
......@@ -77,6 +77,6 @@ public interface FilterConstants {
public static final String SEQUENTIAL_NUMBER = "seqNo";
public static final String LIST = "list";
public static final String LISTS = "lists";
}
......@@ -104,14 +104,14 @@ public class DirectMysqlQuery {
}
protected DirectMysqlQuery join(AppliedFilters filters) {
if (hasFilter(filters, FilterConstants.LIST)) {
if (filters.hasFilter(FilterConstants.LISTS)) {
innerJoin("accelistitems", "ali", "ali.acceid=a.id");
innerJoin("accelist", "al", "al.id=ali.listid");
}
if (filters.hasFilter(FilterConstants.CROPS) || filters.hasFilter(FilterConstants.TAXONOMY_GENUS)
|| filters.hasFilter(FilterConstants.TAXONOMY_SPECIES) || filters.hasFilter(FilterConstants.TAXONOMY_SUBTAXA)
|| filters.hasFilter(FilterConstants.TAXONOMY_SCINAME)) {
if (filters.hasFilter(FilterConstants.CROPS) || filters.hasFilter(FilterConstants.TAXONOMY_GENUS) || filters.hasFilter(FilterConstants.TAXONOMY_SPECIES)
|| filters.hasFilter(FilterConstants.TAXONOMY_SUBTAXA) || filters.hasFilter(FilterConstants.TAXONOMY_SCINAME)) {
innerJoin("taxonomy2", "t", "t.id=a.taxonomyId2");
......@@ -167,7 +167,7 @@ public class DirectMysqlQuery {
createQuery(whereBuffer, "t.taxGenus", filters.get("genusId"), params);
createQuery(whereBuffer, "t.taxSpecies", filters.get("speciesId"), params);
}
createQuery(whereBuffer, "al.uuid", filters.get(FilterConstants.LIST), params);
createQuery(whereBuffer, "al.uuid", filters.get(FilterConstants.LISTS), params);
createQuery(whereBuffer, "a.acceNumb", filters.get(FilterConstants.ACCENUMB), params);
createQuery(whereBuffer, "a.seqNo", filters.get(FilterConstants.SEQUENTIAL_NUMBER), params);
createQuery(whereBuffer, "a.orgCty", filters.get(FilterConstants.ORGCTY_ISO3), params);
......@@ -406,7 +406,7 @@ public class DirectMysqlQuery {
addParam(params, ((LiteralValueFilter) filterValue).getValue());
}
}
if (counter == 0) {
// Nothing..
} else if (counter == 1) {
......@@ -427,7 +427,7 @@ public class DirectMysqlQuery {
private void addParam(List<Object> params, Object object) {
if (object instanceof UUID) {
params.add(toBytes((UUID) object));
} else{
} else {
params.add(object);
}
}
......
......@@ -88,7 +88,7 @@ public class FilterHandler {
this.availableFilters = new ArrayList<GenesysFilter>();
this.availableFilters.add(new BasicFilter(FilterConstants.CROPS, DataType.STRING));
this.availableFilters.add(new BasicFilter(FilterConstants.LIST, DataType.STRING));
this.availableFilters.add(new BasicFilter(FilterConstants.LISTS, DataType.STRING));
this.availableFilters.add(new I18nListFilter<Integer>(FilterConstants.SAMPSTAT, DataType.NUMERIC).build("accession.sampleStatus", new Integer[] { 100,
110, 120, 130, 200, 300, 400, 410, 411, 412, 413, 414, 415, 416, 420, 421, 422, 423, 500, 600, 999 }));
......
......@@ -126,7 +126,7 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
LOG.info("Total count: " + totalCount);
if (totalCount > 0 && pageable.getPageNumber() * pageable.getPageSize() <= totalCount) {
final List<Long> results = this.jdbcTemplate.queryForList(directQuery.getQuery("a.id"), directQuery.getParameters(), Long.class);
final List<Long> results = this.jdbcTemplate.queryForList(directQuery.getQuery("distinct a.id"), directQuery.getParameters(), Long.class);
LOG.info("Getting accessions " + results.size());
return new PageImpl<Accession>(results.size() == 0 ? new ArrayList<Accession>() : accessionRepository.listById(results,
......
......@@ -475,6 +475,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
for (AccessionData a : accessionRepository.findAll(accessionIds)) {
AllStuff all = map.get(a.getAccessionId().getId());
all.accession = a;
a.getAccessionId().getLists().size();
// Don't use a#getStorage()
a.getStoRage().size();
all.names = new ArrayList<AccessionAlias>();
......@@ -1560,7 +1561,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public PDCI loadPDCI(Long accessionId) {
return accessionId==null ? null : repoPdci.findByAccessionId(accessionId);
return accessionId == null ? null : repoPdci.findByAccessionId(accessionId);
}
@Override
......
......@@ -410,6 +410,7 @@ filter.internal.message.between=Between {0}
filter.internal.message.and={0} and {0}
filter.internal.message.more=More than {0}
filter.internal.message.less=Less than {0}
filter.lists=Listed on accession list
search.page.title=Full-text Search
......
......@@ -161,7 +161,7 @@ public class AccessionListReal {
assertThat("No change in list size expected", accessionListService.sizeOf(loaded), is(count));
final AppliedFilters filters2 = new AppliedFilters();
filters2.add(new AppliedFilter().setFilterName(FilterConstants.LIST).addFilterValue(new FilterHandler.LiteralValueFilter(loaded.getUuid())));
filters2.add(new AppliedFilter().setFilterName(FilterConstants.LISTS).addFilterValue(new FilterHandler.LiteralValueFilter(loaded.getUuid())));
Page<Accession> res = genesysFilterService.listAccessions(filters2, new PageRequest(0, 50));
assertThat("Page.total must match", res.getTotalElements(), is((long)count));
......
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