use of uk.ac.ebi.spot.goci.sparql.pussycat.query.QuerySolutionMapper in project goci by EBISPOT.
the class SparqlPussycatSession method loadAssociations.
private List<URI> loadAssociations(SparqlTemplate sparqlTemplate, String queryString, List<Filter> filters) {
List<AssociationLocation> associationLocations = null;
if (filters.size() == 0) {
associationLocations = sparqlTemplate.query(queryString, /*had to add this line in to exclude "NR" bands as they break the AssociationLocation bit below
and can't be rendered anyway*/
new QuerySolutionMapper<AssociationLocation>() {
@Override
public AssociationLocation mapQuerySolution(QuerySolution qs) {
URI association = URI.create(qs.getResource("association").getURI());
String bandName = qs.getLiteral("band").getLexicalForm();
return new AssociationLocation(association, bandName);
}
});
} else if (filters.size() == 1) {
for (Filter filter : filters) {
if (filter.getFilteredType().equals(Association.class)) {
associationLocations = sparqlTemplate.query(queryString, /*had to add this line in to exclude "NR" bands as they break the AssociationLocation bit below
and can't be rendered anyway*/
new QuerySolutionMapper<AssociationLocation>() {
@Override
public AssociationLocation mapQuerySolution(QuerySolution qs) {
URI association = URI.create(qs.getResource("association").getURI());
String bandName = qs.getLiteral("band").getLexicalForm();
return new AssociationLocation(association, bandName);
}
}, filter.getFilteredValues().get(1), filter.getFilteredValues().get(0));
} else if (filter.getFilteredType().equals(Study.class)) {
associationLocations = sparqlTemplate.query(queryString, /*had to add this line in to exclude "NR" bands as they break the AssociationLocation bit below
and can't be rendered anyway*/
new QuerySolutionMapper<AssociationLocation>() {
@Override
public AssociationLocation mapQuerySolution(QuerySolution qs) {
URI association = URI.create(qs.getResource("association").getURI());
String bandName = qs.getLiteral("band").getLexicalForm();
return new AssociationLocation(association, bandName);
}
}, filter.getFilteredRange().to(), filter.getFilteredRange().from());
}
}
} else {
Object pval_min = null, pval_max = null, date_min = null, date_max = null;
for (Filter filter : filters) {
if (filter.getFilteredType().equals(Association.class)) {
pval_min = filter.getFilteredValues().get(0);
pval_max = filter.getFilteredValues().get(1);
} else if (filter.getFilteredType().equals(Publication.class)) {
date_min = filter.getFilteredRange().from();
date_max = filter.getFilteredRange().to();
}
}
associationLocations = sparqlTemplate.query(queryString, /*had to add this line in to exclude "NR" bands as they break the AssociationLocation bit below
and can't be rendered anyway*/
new QuerySolutionMapper<AssociationLocation>() {
@Override
public AssociationLocation mapQuerySolution(QuerySolution qs) {
URI association = URI.create(qs.getResource("association").getURI());
String bandName = qs.getLiteral("band").getLexicalForm();
return new AssociationLocation(association, bandName);
}
}, pval_max, pval_min, date_max, date_min);
}
Collections.sort(associationLocations);
List<URI> associations = new ArrayList<URI>();
for (AssociationLocation al : associationLocations) {
associations.add(al.getAssociation());
}
return associations;
}
Aggregations