NIHVIVO-1797 handle non-standard date formats that appear in weill DB

This commit is contained in:
sjm222 2011-01-19 18:15:18 +00:00
parent 6fe1b3c1ab
commit 4151edf34c
3 changed files with 11 additions and 6 deletions

View file

@ -148,10 +148,10 @@ public class DateTimeMigration {
*/ */
public void updateLiterals() throws IOException { public void updateLiterals() throws IOException {
//TODO: look into java locale note: not handling timezones - they are not expected to be in the 1.1.1 data
DateFormat yearFormat = new SimpleDateFormat("yyyy"); DateFormat yearFormat = new SimpleDateFormat("yyyy");
DateFormat yearMonthFormat = new SimpleDateFormat("yyyy-MM"); DateFormat yearMonthFormat = new SimpleDateFormat("yyyy-MM");
DateFormat yearMonthDayFormat = new SimpleDateFormat("yyyy-MM-dd"); DateFormat yearMonthDayFormat = new SimpleDateFormat("yyyy-MM-dd");
DateFormat yearMonthDayFormat2 = new SimpleDateFormat("dd-MMM-yy");
aboxModel.enterCriticalSection(Lock.WRITE); aboxModel.enterCriticalSection(Lock.WRITE);
@ -189,9 +189,14 @@ public class DateTimeMigration {
try { try {
date = yearMonthDayFormat.parse(stmt.getObject().asLiteral().getLexicalForm()); date = yearMonthDayFormat.parse(stmt.getObject().asLiteral().getLexicalForm());
newStmt = ResourceFactory.createStatement(stmt.getSubject(), stmt.getPredicate(), getDateTimeLiteral(date) ); newStmt = ResourceFactory.createStatement(stmt.getSubject(), stmt.getPredicate(), getDateTimeLiteral(date) );
} catch (ParseException pe) { } catch (ParseException pe) {
logger.log("Parse Exception for yearMonthDay literal: " + stmt.getObject().asLiteral().getLexicalForm() + try {
". The following statement has been removed from the knowledge base " + ABoxUpdater.stmtString(stmt)); date = yearMonthDayFormat2.parse(stmt.getObject().asLiteral().getLexicalForm());
newStmt = ResourceFactory.createStatement(stmt.getSubject(), stmt.getPredicate(), getDateTimeLiteral(date) );
} catch (ParseException pe2) {
logger.log("Parse Exception for yearMonthDay literal: " + stmt.getObject().asLiteral().getLexicalForm() +
". The following statement has been removed from the knowledge base " + ABoxUpdater.stmtString(stmt));
}
} }
} else if (ymdtPrecisionURI.equals(precision)) { } else if (ymdtPrecisionURI.equals(precision)) {
logger.log("WARNING: unhandled precision found for individual " + stmt.getSubject().getURI() + ": " + precision + logger.log("WARNING: unhandled precision found for individual " + stmt.getSubject().getURI() + ": " + precision +

View file

@ -64,6 +64,7 @@ public class KnowledgeBaseUpdater {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
System.out.println("Migrating the knowledge base"); System.out.println("Migrating the knowledge base");
logger.log("Started");
try { try {
performUpdate(); performUpdate();

View file

@ -17,8 +17,7 @@ public class SimpleChangeLogger implements ChangeLogger {
private boolean errorsWritten = false; private boolean errorsWritten = false;
public SimpleChangeLogger( String logPath, public SimpleChangeLogger( String logPath, String errorPath ) {
String errorPath ) {
File logFile = new File(logPath); File logFile = new File(logPath);
File errorFile = new File(errorPath); File errorFile = new File(errorPath);
try { try {