Commit 793660cf authored by Matija Obreza's avatar Matija Obreza

ORGANIZATION to INSTITUTE_NETWORK

parent c95547e0
......@@ -40,8 +40,6 @@ public interface FilterConstants {
public static final String INSTCODE = "institute.code";
public static final String ORGANIZATION = "organization";
public static final String GEO_ELEVATION = "geo.elevation";
public static final String GEO_LONGITUDE = "geo.longitude";
......@@ -63,4 +61,10 @@ public interface FilterConstants {
public static final String DONORCODE = "donorCode";
public static final String INSTITUTE_COUNTRY_ISO3 = "institute.country.iso3";
public static final String INSTITUTE_NETWORK = "institute.networks";
public static final String IN_SGSV = "inSgsv";
public static final String TAXONOMY_GENUSSPECIES = "taxonomy.genusSpecies";
}
......@@ -102,7 +102,7 @@ public class DirectMysqlQuery {
innerJoin("crop", null, "crop.id=ct.cropId");
}
}
if (hasFilter(filters, FilterConstants.ORGANIZATION)) {
if (hasFilter(filters, FilterConstants.INSTITUTE_NETWORK)) {
innerJoin("faoinstitute", "fao", "fao.id=a.instituteId");
innerJoin("organizationinstitute", "oi", "oi.instituteId=fao.id");
innerJoin("organization", "org", "org.id=oi.organizationId");
......@@ -145,7 +145,7 @@ public class DirectMysqlQuery {
createQuery(whereBuffer, "a.inTrust", filters.get(FilterConstants.ART15), params);
createQuery(whereBuffer, "a.sampStat", filters.get(FilterConstants.SAMPSTAT), params);
createQuery(whereBuffer, "a.available", filters.get(FilterConstants.AVAILABLE), params);
createQuery(whereBuffer, "org.slug", filters.get(FilterConstants.ORGANIZATION), params);
createQuery(whereBuffer, "org.slug", filters.get(FilterConstants.INSTITUTE_NETWORK), params);
createQuery(whereBuffer, "t.genus", filters.get(FilterConstants.TAXONOMY_GENUS), params);
createQuery(whereBuffer, "t.species", filters.get(FilterConstants.TAXONOMY_SPECIES), params);
createQuery(whereBuffer, "t.taxonName", filters.get(FilterConstants.TAXONOMY_SCINAME), params);
......
......@@ -18,8 +18,6 @@ import org.elasticsearch.search.sort.SortOrder;
import org.genesys2.server.model.elastic.AccessionDetails;
import org.genesys2.server.model.filters.GenesysFilter;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.model.impl.Organization;
import org.genesys2.server.service.ElasticService;
import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysFilterService;
......@@ -119,6 +117,8 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
FacetRequest termFacetRequest;
if (FilterConstants.DUPLSITE.equals(term)) {
termFacetRequest = new TermFacetRequestBuilder("f").applyQueryFilter().fields(term).excludeTerms("nor051").size(size).build();
} else if (FilterConstants.SGSV.equals(term)) {
termFacetRequest = new TermFacetRequestBuilder("f").applyQueryFilter().fields(FilterConstants.IN_SGSV).size(size).build();
} else {
termFacetRequest = new TermFacetRequestBuilder("f").applyQueryFilter().fields(term).size(size).build();
}
......@@ -213,30 +213,8 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
} else {
// terms
if (FilterConstants.ORGANIZATION.equals(key)) {
Set<String> instCodes = new HashSet<String>();
for (Object literal : literals) {
if (literal instanceof String) {
Organization organization = organizationService.getOrganization((String) literal);
if (organization != null)
for (FaoInstitute inst : organizationService.getMembers(organization)) {
instCodes.add(inst.getCode());
}
}
}
if (!instCodes.isEmpty()) {
orFilter.add(FilterBuilders.termsFilter(FilterConstants.INSTCODE, instCodes).execution("or"));
}
} else if (FilterConstants.SGSV.equals(key)) {
// Check if exists
if (filterValues.contains(new LiteralValueFilter(true))) {
// true:
orFilter.add(FilterBuilders.notFilter(FilterBuilders.missingFilter(FilterConstants.SGSV)));
}
if (filterValues.contains(new LiteralValueFilter(false))) {
// false:
orFilter.add(FilterBuilders.missingFilter(FilterConstants.SGSV));
}
if (FilterConstants.SGSV.equals(key)) {
orFilter.add(FilterBuilders.termsFilter(FilterConstants.IN_SGSV, literals).execution("or"));
} else {
orFilter.add(FilterBuilders.termsFilter(key, literals).execution("or"));
}
......
......@@ -91,7 +91,7 @@ public class FilterHandler {
this.availableFilters.add(new BasicFilter(FilterConstants.GEO_LONGITUDE, DataType.NUMERIC));
this.availableFilters.add(new BasicFilter(FilterConstants.GEO_ELEVATION, DataType.NUMERIC));
this.availableFilters.add(new BasicFilter(FilterConstants.ORGANIZATION, DataType.STRING));
this.availableFilters.add(new BasicFilter(FilterConstants.INSTITUTE_NETWORK, DataType.STRING));
this.availableFilters.add(new AutocompleteFilter(FilterConstants.INSTCODE, "/explore/ac/instCode"));
this.availableFilters.add(new BasicFilter(FilterConstants.ACCENUMB, DataType.STRING).setAnalyzed(true));
this.availableFilters.add(new BasicFilter(FilterConstants.ALIAS, DataType.STRING).setAnalyzed(true));
......
......@@ -163,7 +163,7 @@ public class ExplorerController extends BaseController {
// JSP works with JsonObject
final Map<String, List<String>> filters = mapper.readValue(appliedFilters.toString(), Map.class);
final Map<?, ?> filters = mapper.readValue(appliedFilters.toString(), Map.class);
model.addAttribute("filters", filters);
......@@ -222,7 +222,7 @@ public class ExplorerController extends BaseController {
// JSP works with JsonObject
final Map<String, List<String>> filters = mapper.readValue(appliedFilters.toString(), Map.class);
final Map<?, ?> filters = mapper.readValue(appliedFilters.toString(), Map.class);
model.addAttribute("filters", filters);
......@@ -450,7 +450,7 @@ public class ExplorerController extends BaseController {
model.addAttribute("currentFilters", currentFilters);
// JSP works with JsonObject
final Map<String, List<String>> filters = mapper.readValue(appliedFilters.toString(), Map.class);
final Map<?, ?> filters = mapper.readValue(appliedFilters.toString(), Map.class);
model.addAttribute("filters", filters);
model.addAttribute("jsonFilter", appliedFilters.toString());
......@@ -487,7 +487,7 @@ public class ExplorerController extends BaseController {
private void overviewComposition(ModelMap model, AppliedFilters appliedFilters) throws SearchException {
model.addAttribute("statsGenus", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.TAXONOMY_GENUS, 10));
model.addAttribute("statsSpecies", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.TAXONOMY_SPECIES, 10));
model.addAttribute("statsSpecies", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.TAXONOMY_GENUSSPECIES, 10));
model.addAttribute("statsCrops", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.CROPS, 30));
model.addAttribute("statsSampStat", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.SAMPSTAT, 30));
}
......
......@@ -154,7 +154,7 @@ public class OrganizationController extends BaseController {
throw new ResourceNotFoundException();
}
model.addAttribute("filter", "{\"" + FilterConstants.ORGANIZATION + "\":[\"" + organization.getSlug() + "\"]}");
model.addAttribute("filter", "{\"" + FilterConstants.INSTITUTE_NETWORK + "\":[\"" + organization.getSlug() + "\"]}");
model.addAttribute("page", page);
return "redirect:/explore";
}
......
......@@ -385,7 +385,7 @@ organization.page.list.title=Organizations and Networks
organization.page.profile.title={0}
organization.slug=Organization or Network acronym
organization.title=Full name
filter.organization=Organization or Network
filter.institute.networks=Network
menu.report-an-issue=Report an issue
......
......@@ -182,14 +182,6 @@
<h3><spring:message code="data-overview.management" /></h3>
<div class="row">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-storage"><spring:message code="filter.storage" /></h4>
<c:set var="type" value="i18n.accession.storage" />
<c:set var="termResult" value="${statsStorage}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-duplsite"><spring:message code="filter.duplSite" /></h4>
<c:set var="type" value="instCode" />
......@@ -198,7 +190,6 @@
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<%-- TODO FIXME enable #inSgsv
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-duplsite"><spring:message code="filter.sgsv" /></h4>
<c:set var="type" value="bool" />
......@@ -207,9 +198,17 @@
<c:remove var="termResult" />
<c:remove var="type" />
</div>
--%>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-storage"><spring:message code="filter.storage" /></h4>
<c:set var="type" value="i18n.accession.storage" />
<c:set var="termResult" value="${statsStorage}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
</div>
<content tag="javascript">
<script type="text/javascript">
......
......@@ -413,7 +413,7 @@ public class ElasticsearchTest {
@Test
public void testOrganization() throws JsonProcessingException, SearchException {
AppliedFilters filters = new AppliedFilters();
filters.add(new AppliedFilter().setFilterName(FilterConstants.ORGANIZATION).addFilterValue(new FilterHandler.LiteralValueFilter("EURISCO")));
filters.add(new AppliedFilter().setFilterName(FilterConstants.INSTITUTE_NETWORK).addFilterValue(new FilterHandler.LiteralValueFilter("EURISCO")));
Set<String> organizationInst = new HashSet<String>();
Organization org = organizationService.getOrganization("EURISCO");
......
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