TableRowIterator tri = DatabaseManager.queryTable(context, "item",
"SELECT * FROM item WHERE withdrawal_date IS NOT NULL");
while (tri.hasNext())
{
TableRow row = tri.next();
DCDate d = new DCDate(row.getStringColumn("withdrawal_date"));
row.setColumn("last_modified", d.toDate());
DatabaseManager.update(context, row);
}
tri.close();
// Next, update those items with a date.available
tri = DatabaseManager.query(context,
"SELECT item.item_id, dcvalue.text_value FROM item, dctyperegistry, "+
"dcvalue WHERE item.item_id=dcvalue.item_id AND dcvalue.dc_type_id="+
"dctyperegistry.dc_type_id AND dctyperegistry.element LIKE 'date' "+
"AND dctyperegistry.qualifier LIKE 'available'");
while (tri.hasNext())
{
TableRow resultRow = tri.next();
DCDate d = new DCDate(resultRow.getStringColumn("text_value"));
// Can't update the row, have to do a separate query
TableRow itemRow = DatabaseManager.find(context, "item",
resultRow.getIntColumn("item_id"));
itemRow.setColumn("last_modified", d.toDate());
DatabaseManager.update(context, itemRow);
}
tri.close();
// Finally, for all items that have no date.available or withdrawal