*/
private ProvenanceCondition getProvenanceCondition(XAQLToken collection, VersionIndex versionIndex) throws org.dbwiki.exception.WikiException {
if (collection.type() != XAQLToken.PROVENANCE_EXPRESSION) {
throw new WikiFatalException("Invalid token type " + collection.type() + " in getProvenanceCondition()");
}
Date startDate = null;
Date endDate = null;
String dateOp = null;
byte provenanceType = Provenance.ProvenanceTypeUnknown;
String username = null;
for (int iToken = 0; iToken < collection.children().size(); iToken++) {
XAQLToken token = collection.children().get(iToken);
if (token.type() == XAQLToken.PROVENANCE_DATE_OPERATOR) {
dateOp = token.value();
iToken++;
try {
if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordAfter)) {
startDate = org.dbwiki.lib.DateTime.getDate(collection.children().get(iToken).value());
} else if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordBefore)) {
endDate = org.dbwiki.lib.DateTime.getDate(collection.children().get(iToken).value());
} else if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordSince)) {
startDate = org.dbwiki.lib.DateTime.getDate(collection.children().get(iToken).value());
} else if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordUntil)) {
endDate = org.dbwiki.lib.DateTime.getDate(collection.children().get(iToken).value());
} else if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordBetween)) {
startDate = org.dbwiki.lib.DateTime.getDate(collection.children().get(iToken).value());
iToken++;
endDate = org.dbwiki.lib.DateTime.getDate(collection.children().get(iToken).value());
} else {
throw new WikiFatalException("Unknown date operation " + token.value() + " in getProvenanceCondition()");
}
} catch (java.text.ParseException parseException) {
throw new WikiFatalException(parseException);
}
} else if (token.type() == XAQLToken.PROVENANCE_USER_NAME) {
username = token.value().substring(1, token.value().length() - 1);
} else if (token.type() == XAQLToken.PROVENANCE_OPERATION) {
if (token.value().equalsIgnoreCase(XAQLSyntaxParser.KeywordCopy)) {
provenanceType = Provenance.ProvenanceTypeCopy;
} else if (token.value().equalsIgnoreCase(XAQLSyntaxParser.KeywordDelete)) {
provenanceType = Provenance.ProvenanceTypeDelete;
} else if (token.value().equalsIgnoreCase(XAQLSyntaxParser.KeywordInsert)) {
provenanceType = Provenance.ProvenanceTypeInsert;
} else if (token.value().equalsIgnoreCase(XAQLSyntaxParser.KeywordUpdate)) {
provenanceType = Provenance.ProvenanceTypeUpdate;
} else {
throw new WikiFatalException("Unknown operation name " + token.value() + " in getProvenanceCondition()");
}
} else {
throw new WikiFatalException("Invalid token type " + token.type() + " in getProvenanceCondition()");
}
}
assert(startDate != null); // because the condition list is nonempty
assert(endDate != null); // because the condition list is nonempty