Commit b0940005 authored by Matija Obreza's avatar Matija Obreza
Browse files

Fixed #15

parent 7dfdbe09
......@@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
public interface GenesysFilterService {
String[] DEFAULT_FILTERS = { "crop", "genus", "taxon", "orgCty", "latitude", "longitude", "organization", "instCode", "acceNumb", "available", "mlsStat", "inTrust",
String[] DEFAULT_FILTERS = { "crop", "sampStat", "genus", "taxon", "orgCty", "latitude", "longitude", "organization", "instCode", "acceNumb", "available", "mlsStat", "inTrust",
"inSvalbard" };
Page<Accession> listAccessions(ObjectNode jsonTree, Pageable pageable);
......@@ -45,7 +45,7 @@ public interface GenesysFilterService {
}
public enum FilterType {
EXACT, RANGE, LIST, AUTOCOMPLETE
EXACT, RANGE, LIST, AUTOCOMPLETE, I18NLIST
}
}
......
......@@ -103,6 +103,7 @@ public class DirectMysqlQuery {
createQuery(whereBuffer, "a.inSGSV", jsonTree.get("inSvalbard"), params);
createQuery(whereBuffer, "a.mlsStat", jsonTree.get("mlsStat"), params);
createQuery(whereBuffer, "a.inTrust", jsonTree.get("inTrust"), params);
createQuery(whereBuffer, "a.sampStat", jsonTree.get("sampStat"), params);
createQuery(whereBuffer, "a.available", jsonTree.get("available"), params);
createQuery(whereBuffer, "org.slug", jsonTree.get("organization"), params);
createQuery(whereBuffer, "t.genus", jsonTree.get("genus"), params);
......
......@@ -33,6 +33,7 @@ import javax.sql.DataSource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.list.UnmodifiableList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.genesys2.server.model.genesys.Accession;
......@@ -108,6 +109,8 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
this.availableFilters = new ArrayList<GenesysFilter>();
this.availableFilters.add(new GenesysFilterImpl("crop", DataType.STRING));
this.availableFilters.add(new GenesysI18nListFilterImpl<Integer>("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 }));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("genus", "/explore/ac/genus"));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("taxon", "/explore/ac/taxonomy"));
......@@ -417,6 +420,27 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
}
}
public static class GenesysI18nListFilterImpl<T> extends GenesysFilterImpl {
private List<ValueName<T>> options = new ArrayList<ValueName<T>>();
public GenesysI18nListFilterImpl(String name, DataType dataType) {
super(name, dataType, FilterType.I18NLIST);
}
public GenesysFilter build(String prefix, @SuppressWarnings("unchecked") T... options) {
List<ValueName<T>> opts = new ArrayList<ValueName<T>>();
for (T opt : options) {
opts.add(new ValueName<T>(opt, prefix + "." + opt));
}
this.options = new UnmodifiableList<ValueName<T>>(opts);
return this;
}
public List<ValueName<T>> getOptions() {
return options;
}
}
@Override
public void listGeo(ObjectNode jsonTree, Integer limit, RowCallbackHandler rowHandler) {
listGeoTile(false, jsonTree, limit, -1, 0, 0, rowHandler);
......
......@@ -267,7 +267,7 @@ accession.sampleStatus.416=Clonal selection
accession.sampleStatus.420=Genetic stock
accession.sampleStatus.421=Mutant
accession.sampleStatus.422=Cytogenetic stocks
accession.sampleStatus.422=Other genetic stocks
accession.sampleStatus.423=Other genetic stocks
accession.sampleStatus.500=Advanced/improved cultivar
accession.sampleStatus.600=GMO
accession.sampleStatus.999=Other
......@@ -321,6 +321,7 @@ filter.crop=Crop
filter.countryOfOrigin=Country of Origin
filter.holdingInstitute=Holding Institute
filter.orgCty=Country of Origin
filter.sampStat=Status of Sample
filter.instCode=Holding Institute
filter.latitude=Latitude
filter.longitude=Longitude
......
......@@ -41,6 +41,13 @@
</c:forEach>
</div>
</c:when>
<c:when test="${filter.filterType=='I18NLIST'}">
<div class="">
<c:forEach items="${filter.options}" var="option">
<div><label><input type="checkbox" value="${option.value}" /> <spring:message code="${option.name}" /></label></div>
</c:forEach>
</div>
</c:when>
<c:when test="${filter.filterType=='AUTOCOMPLETE'}">
<div class="ui-front">
<div class="form-group input-group"><span class="input-group-btn"><input class="span2 form-control autocomplete-filter" x-source="${filter.autocompleteUrl}" type="text" /><button class="btn notimportant">+</button></span></div>
......
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