String query = "select $date\n" + "from <#ri>\n" + "  subquery(\n" + "    select $volatile\n" + "    from <$ri>\n" + "    where $x0 <" + m_oaiItemID + "> $x1\n" + "      and $x1 <" + VIEW.DISSEMINATES.uri + "> $x2\n" + "      and $x2 <" + VIEW.IS_VOLATILE.uri + "> $volatile\n" + "      and $volatile <" + TUCANA.IS.uri + "> 'true'\n" + "  )\n" + "where $object <" + m_oaiItemID + "> $oaiItemID\n" + "and $object <" + VIEW.DISSEMINATES.uri + "> $diss\n" + "and $diss <" + VIEW.LAST_MODIFIED_DATE.uri + "> $date\n" + "order by $date desc\n" + "limit 1";  TupleIterator tuples = getTuples(query);
TupleIterator tuples = getTuples(getLatestRecordDateQuery());
    public Date latestRecordDate() {        String query = "select $date\n" +                       "from <#ri>\n" +                       "  subquery(\n" +                       "    select $volatile\n" +                       "    from <$ri>\n" +                       "    where $x0 <" + m_oaiItemID + "> $x1\n" +                       "      and $x1 <" + VIEW.DISSEMINATES.uri + "> $x2\n" +                       "      and $x2 <" + VIEW.IS_VOLATILE.uri + "> $volatile\n" +                       "      and $volatile <" + TUCANA.IS.uri + "> 'true'\n" +                       "  )\n" +                       "where $object <" + m_oaiItemID + "> $oaiItemID\n" +                       "and $object <" + VIEW.DISSEMINATES.uri + "> $diss\n" +                       "and $diss <" + VIEW.LAST_MODIFIED_DATE.uri + "> $date\n" +                       "order by $date desc\n" +                       "limit 1";        TupleIterator tuples = getTuples(query);        try {            if (tuples.hasNext()) {                Map row = tuples.next();                if (m_volatile && row.get("volatile") != null && !row.get("volatile").equals("")) {                    // FIXME get current date from the repository                    return new Date();                } else {                    Literal dateLiteral = (Literal) row.get("date");                    if (dateLiteral == null) {                        throw new RepositoryException("A row was returned, but it did not contain a 'date' binding");                    }                    return parseDate(dateLiteral.getLexicalForm());                }            } else {                // no tuples... what to do?                throw new RepositoryException("No rows returned from query");            }        } catch (Exception e) {            throw new RepositoryException("Error querying for latest changed record date: " +                                           e.getMessage(), e);        } finally {            if (tuples != null) {                try {                     tuples.close();                 } catch (Exception e) { }            }        }    }