How do I replicate the following filter from SPARQL in java using rd4j?
FILTER(?endDate > NOW() && ?startDate < NOW() && MONTH(?endDate) = MONTH(NOW()))
I have initialised expressions for MONTH()
and NOW()
as follows, and a graph pattern pattern
, but don't know how to use them to extract the month from variable ?endDate
and from the NOW()
function
Expression<?> nowFunc = Expressions.function(SparqlFunction.NOW );
Expression<?> month = Expressions.function(SparqlFunction.MONTH);
Expression<?> endDateGreaterThan = Expressions.gt(endDate, nowFunc);
Expression<?> startDateLessThan = Expressions.lt(startDate, nowFunc);
The query I have so far is as follows, but I can't figure out how to implement the final part (****) of the filter into the query.
SelectQuery query = Queries.SELECT().prefix(ex).select(letter).where(pattern.filter(Expressions.
and(endDateGreaterThan, startDateLessThan, ****)