Merge pull request #1937 from OpenRefine/issue1936

Provide default identifierSpace and schemaSpace for reconciliation services
This commit is contained in:
Antonin Delpeuch 2019-02-02 17:25:58 +01:00 committed by GitHub
commit b2124d5bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -75,6 +75,9 @@ import com.google.refine.util.ParsingUtilities;
public class StandardReconConfig extends ReconConfig {
final static Logger logger = LoggerFactory.getLogger("refine-standard-recon");
private static final String DEFAULT_SCHEMA_SPACE = "http://localhost/schema";
private static final String DEFAULT_IDENTIFIER_SPACE = "http://localhost/identifier";
static public class ColumnDetail {
@JsonProperty("column")
final public String columnName;
@ -208,8 +211,8 @@ public class StandardReconConfig extends ReconConfig {
int limit
) {
this.service = service;
this.identifierSpace = identifierSpace;
this.schemaSpace = schemaSpace;
this.identifierSpace = identifierSpace != null ? identifierSpace : DEFAULT_IDENTIFIER_SPACE;
this.schemaSpace = schemaSpace != null ? schemaSpace : DEFAULT_SCHEMA_SPACE;
this.typeID = typeID;
this.typeName = typeName;

View File

@ -154,6 +154,19 @@ public class StandardReconConfigTests extends RefineTest {
assertNull(config.typeName);
}
@Test
public void testReconstructNoIdentifierSchemaSpaces() throws IOException {
String json = "{\"mode\":\"standard-service\","
+ "\"service\":\"https://tools.wmflabs.org/openrefine-wikidata/en/api\","
+ "\"type\":null,"
+ "\"autoMatch\":true,"
+ "\"columnDetails\":[],"
+ "\"limit\":0}";
StandardReconConfig config = StandardReconConfig.reconstruct(json);
assertEquals(config.identifierSpace, "http://localhost/identifier");
assertEquals(config.schemaSpace, "http://localhost/schema");
}
@Test
public void formulateQueryTest() throws IOException {
Project project = createCSVProject("title,director\n"