Commit 84d2d6b0 authored by Matija Obreza's avatar Matija Obreza
Browse files

Using accession/explore instead of accession/data to address #21

parent 100f26c1
......@@ -20,6 +20,7 @@ import java.util.Collection;
import java.util.List;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.service.impl.GenesysFilterServiceImpl.LabelValue;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -49,7 +50,7 @@ public interface GenesysFilterService {
}
}
List<GenesysFilter> selectFilters(String[] selectedFilters);
List<GenesysFilter> selectFilters(Crop crop, String[] selectedFilters);
Collection<GenesysFilter> generateFilters(Collection<Long> methodIds);
......
......@@ -40,6 +40,7 @@ import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.Method;
import org.genesys2.server.model.genesys.TraitCode;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.persistence.domain.AccessionRepository;
import org.genesys2.server.persistence.domain.MethodRepository;
......@@ -134,11 +135,15 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
}
@Override
public List<GenesysFilter> selectFilters(String[] selectedFilters) {
public List<GenesysFilter> selectFilters(Crop crop, String[] selectedFilters) {
List<GenesysFilter> filters = new ArrayList<GenesysFilter>();
Set<Long> methodIds = new HashSet<Long>();
for (final String selectedFilter : selectedFilters) {
if (crop != null && selectedFilter.equals("crop")) {
// Skip filter
continue;
}
if (selectedFilter.startsWith("gm:")) {
try {
methodIds.add(Long.parseLong(selectedFilter.substring(3)));
......
......@@ -149,7 +149,7 @@ public class AccessionController extends BaseController {
model.addAttribute("jsonFilter", "{\"genusId\":[\"" + taxGenusId + "\"]}");
return "/accession/data";
return "/accession/explore";
}
/**
......@@ -186,7 +186,7 @@ public class AccessionController extends BaseController {
model.addAttribute("jsonFilter", "{\"speciesId\":[\"" + taxSpeciesId + "\"]}");
return "/accession/data";
return "/accession/explore";
}
}
......@@ -130,6 +130,6 @@ public class CountryController extends BaseController {
model.addAttribute("filters", filters);
model.addAttribute("jsonFilter", "{\"orgCty\":[\"" + country.getCode3() + "\"]}");
return "/accession/data";
return "/accession/explore";
}
}
......@@ -109,7 +109,7 @@ public class CropController extends BaseController {
model.addAttribute("jsonFilter", "{\"crop\":[\"" + crop.getShortName() + "\"]}");
return "/accession/data";
return "/accession/explore";
}
@RequestMapping("/{shortName}/descriptors")
......
......@@ -192,6 +192,12 @@ public class ExplorerController extends BaseController {
public String showFilters(ModelMap model, @RequestParam(value = "filter", required = false, defaultValue = "{}") String jsonFilter,
@RequestParam(value = "pick", required = false) String pick, @RequestParam(value = "crop", required = false) String shortName) {
Crop crop = null;
if (StringUtils.isNotBlank(shortName)) {
crop = cropService.getCrop(shortName);
model.addAttribute("crop", crop);
}
String[] selectedFilters = GenesysFilterService.DEFAULT_FILTERS;
if (StringUtils.isNotBlank(pick)) {
try {
......@@ -220,7 +226,7 @@ public class ExplorerController extends BaseController {
_logger.warn(e.getMessage(), e);
}
model.addAttribute("selectedFilters", filterService.selectFilters(selectedFilters));
model.addAttribute("selectedFilters", filterService.selectFilters(crop, selectedFilters));
try {
if (selectedFilters != null && selectedFilters.length > 0)
......@@ -229,13 +235,6 @@ public class ExplorerController extends BaseController {
_logger.warn(e.getMessage(), e);
}
if (StringUtils.isNotBlank(shortName)) {
Crop crop = cropService.getCrop(shortName);
if (crop != null) {
model.addAttribute("crop", crop);
}
}
return "/filter/filter";
}
......
......@@ -167,7 +167,7 @@ public class OrganizationController extends BaseController {
model.addAttribute("filters", filters);
model.addAttribute("jsonFilter", "{\"organization\":[\"" + organization.getSlug() + "\"]}");
return "/accession/data";
return "/accession/explore";
}
}
......@@ -171,7 +171,7 @@ public class WiewsController extends BaseController {
model.addAttribute("filters", filters);
model.addAttribute("jsonFilter", "{\"instCode\":[\"" + faoInstitute.getCode() + "\"]}");
return "/accession/data";
return "/accession/explore";
}
@RequestMapping("/{wiewsCode}/t/{genus}/{species:.+}")
......@@ -201,7 +201,7 @@ public class WiewsController extends BaseController {
model.addAttribute("filters", filters);
model.addAttribute("jsonFilter", "{\"instCode\":[\"" + faoInstitute.getCode() + "\"],\"species\":[\"" + taxonomyId + "\"]}");
return "/accession/data";
return "/accession/explore";
}
@RequestMapping(value = "/{wiewsCode}/dwca", method = RequestMethod.POST)
......
......@@ -37,45 +37,40 @@
</div>
</div>
<div class="applied-filters">
<spring:message code="filters.data-is-filtered" />
<div class="applied-filters">
<c:if test="${filters ne null}">
<c:forEach items="${filters.keySet()}" var="by">
<c:set value="${filters[by].getClass().simpleName}" var="clazz" />
<div>
<spring:message code="${by}" />: <b>
<c:choose>
<c:when test="${clazz eq 'Taxonomy'}">
${filters[by].taxonName}
</c:when>
<c:when test="${clazz eq 'Crop'}">
<a href="<c:url value="/c/${filters[by].shortName}" />">${filters[by].getName(pageContext.response.locale)}</a>
</c:when>
<c:when test="${clazz eq 'Country'}">
<a href="<c:url value="/geo/${filters[by].code3.toLowerCase()}" />"><c:out value="${filters[by].getName(pageContext.response.locale)}" /></a>
</c:when>
<c:when test="${clazz eq 'FaoInstitute'}">
<a href="<c:url value="/wiews/${filters[by].code.toLowerCase()}" />"><c:out value="${filters[by].fullName}" /></a>
</c:when>
<c:when test="${clazz eq 'Organization'}">
<a href="<c:url value="/org/${filters[by].slug}" />"><c:out value="${filters[by].title}" /></a>
</c:when>
<c:otherwise>
${filters[by]}
</c:otherwise>
</c:choose>
</b>
</div>
<c:remove var="clazz" />
</c:forEach>
</c:if>
<a href="<spring:url value="/explore/filter"><spring:param name="crop" value="${crop.shortName}" /><spring:param name="filter" value="${jsonFilter}" /><spring:param name="pick" value="${jsonPick}" /></spring:url>"><spring:message code="filters.modify-filters" /></a>
</div>
<c:if test="${filters ne null}">
<div class="applied-filters">
<c:forEach items="${filters.keySet()}" var="by">
<c:set value="${filters[by].getClass().simpleName}" var="clazz" />
<div>
<spring:message code="${by}" />: <b>
<c:choose>
<c:when test="${clazz eq 'Taxonomy'}">
${filters[by].taxonName}
</c:when>
<c:when test="${clazz eq 'Crop'}">
<a href="<c:url value="/c/${filters[by].shortName}" />">${filters[by].getName(pageContext.response.locale)}</a>
</c:when>
<c:when test="${clazz eq 'Country'}">
<a href="<c:url value="/geo/${filters[by].code3.toLowerCase()}" />"><c:out value="${filters[by].getName(pageContext.response.locale)}" /></a>
</c:when>
<c:when test="${clazz eq 'FaoInstitute'}">
<a href="<c:url value="/wiews/${filters[by].code.toLowerCase()}" />"><c:out value="${filters[by].fullName}" /></a>
</c:when>
<c:when test="${clazz eq 'Organization'}">
<a href="<c:url value="/org/${filters[by].slug}" />"><c:out value="${filters[by].title}" /></a>
</c:when>
<c:otherwise>
${filters[by]}
</c:otherwise>
</c:choose>
</b>
</div>
<c:remove var="clazz" />
</c:forEach>
<a href="<spring:url value="/explore/filter"><spring:param name="filter" value="${jsonFilter}" /><spring:param name="pick" value="${jsonPick}" /></spring:url>"><spring:message code="filters.modify-filters" /></a>
</div>
</c:if>
<table class="accessions">
<thead>
<tr>
......
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