Issue 534 - Attempt to recover recon links which have become corrupted

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2454 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2012-03-08 00:37:29 +00:00
parent dbdbd906b7
commit 5a962b1768

View File

@ -1,6 +1,6 @@
/* /*
Copyright 2010, Google Inc. Copyright 2010,2012. Google Inc.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -51,6 +51,9 @@ import com.google.refine.util.Pool;
public class Recon implements HasFields, Jsonizable { public class Recon implements HasFields, Jsonizable {
private static final String FREEBASE_SCHEMA_SPACE = "http://rdf.freebase.com/ns/type.object.id";
private static final String FREEBASE_IDENTIFIER_SPACE = "http://rdf.freebase.com/ns/type.object.mid";
static public enum Judgment { static public enum Judgment {
None, None,
Matched, Matched,
@ -112,8 +115,8 @@ public class Recon implements HasFields, Jsonizable {
static public Recon makeFreebaseRecon(long judgmentHistoryEntry) { static public Recon makeFreebaseRecon(long judgmentHistoryEntry) {
return new Recon( return new Recon(
judgmentHistoryEntry, judgmentHistoryEntry,
"http://rdf.freebase.com/ns/type.object.mid", FREEBASE_IDENTIFIER_SPACE,
"http://rdf.freebase.com/ns/type.object.id"); FREEBASE_SCHEMA_SPACE);
} }
public Recon(long judgmentHistoryEntry, String identifierSpace, String schemaSpace) { public Recon(long judgmentHistoryEntry, String identifierSpace, String schemaSpace) {
@ -249,8 +252,8 @@ public class Recon implements HasFields, Jsonizable {
public class Features implements HasFields { public class Features implements HasFields {
@Override @Override
public Object getField(String name, Properties bindings) { public Object getField(String name, Properties bindings) {
int index = s_featureMap.get(name); int index = s_featureMap.containsKey(name) ? s_featureMap.get(name) : -1;
return index < features.length ? features[index] : null; return (index > 0 && index < features.length) ? features[index] : null;
} }
@Override @Override
@ -395,8 +398,14 @@ public class Recon implements HasFields, Jsonizable {
recon.service = jp.getText(); recon.service = jp.getText();
} else if ("identifierSpace".equals(fieldName)) { } else if ("identifierSpace".equals(fieldName)) {
recon.identifierSpace = jp.getText(); recon.identifierSpace = jp.getText();
if ("null".equals(recon.identifierSpace)) {
recon.identifierSpace = FREEBASE_IDENTIFIER_SPACE;
}
} else if ("schemaSpace".equals(fieldName)) { } else if ("schemaSpace".equals(fieldName)) {
recon.schemaSpace = jp.getText(); recon.schemaSpace = jp.getText();
if ("null".equals(recon.schemaSpace)) {
recon.schemaSpace = FREEBASE_SCHEMA_SPACE;
}
} else if ("judgmentAction".equals(fieldName)) { } else if ("judgmentAction".equals(fieldName)) {
recon.judgmentAction = jp.getText(); recon.judgmentAction = jp.getText();
} else if ("judgmentBatchSize".equals(fieldName)) { } else if ("judgmentBatchSize".equals(fieldName)) {