Package org.openrefine.wikibase.schema
Class WikibaseSchema
- java.lang.Object
-
- org.openrefine.wikibase.schema.WikibaseSchema
-
- All Implemented Interfaces:
OverlayModel
public class WikibaseSchema extends Object implements OverlayModel
Main class representing a skeleton of Wikibase edits with OpenRefine columns as variables.- Author:
- Antonin Delpeuch
-
-
Field Summary
Fields Modifier and Type Field Description protected List<WbExpression<? extends EntityEdit>>
entityEditExprs
protected Map<String,String>
entityTypeSiteIri
protected String
mediaWikiApiEndpoint
protected String
siteIri
protected boolean
validated
-
Constructor Summary
Constructors Constructor Description WikibaseSchema()
Constructor.WikibaseSchema(List<WbExpression<? extends EntityEdit>> exprs, List<WbItemEditExpr> legacyItemExprs, String siteIri, Map<String,String> entityTypeSiteIri, String mediaWikiApiEndpoint)
Constructor for deserialization via Jackson
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose(Project project)
boolean
equals(Object other)
List<EntityEdit>
evaluate(ColumnModel columnModel, Iterable<IndexedRow> indexedRows, QAWarningStore warningStore)
Evaluates the schema on a list of rows, returning a list of EntityUpdates generated by the schema.List<EntityEdit>
evaluate(Grid grid, Engine engine)
Same as above, ignoring any warnings.List<EntityEdit>
evaluate(Grid grid, Engine engine, QAWarningStore warningStore)
Evaluates the schema on a project, returning a list of EntityUpdates generated by the schema.List<EntityEdit>
evaluateEntityDocuments(ExpressionContext ctxt)
Evaluates all entity documents in a particular expression context.List<WbExpression<? extends EntityEdit>>
getEntityDocumentExpressions()
Map<String,String>
getEntityTypeSiteIri()
String
getMediaWikiApiEndpoint()
String
getSiteIri()
static WikibaseSchema
load(Project project, String obj)
void
onAfterSave(Project project)
void
onBeforeSave(Project project)
static WikibaseSchema
reconstruct(String json)
void
validate(ValidationState validationContext)
Checks that this schema is complete.
-
-
-
Field Detail
-
entityEditExprs
protected List<WbExpression<? extends EntityEdit>> entityEditExprs
-
siteIri
protected String siteIri
-
mediaWikiApiEndpoint
protected String mediaWikiApiEndpoint
-
validated
protected boolean validated
-
-
Constructor Detail
-
WikibaseSchema
public WikibaseSchema()
Constructor. TODO remove this, it does not create a valid schema.
-
WikibaseSchema
public WikibaseSchema(List<WbExpression<? extends EntityEdit>> exprs, List<WbItemEditExpr> legacyItemExprs, String siteIri, Map<String,String> entityTypeSiteIri, String mediaWikiApiEndpoint)
Constructor for deserialization via Jackson
-
-
Method Detail
-
validate
public void validate(ValidationState validationContext)
Checks that this schema is complete.- Parameters:
validationContext
-
-
getSiteIri
public String getSiteIri()
- Returns:
- the site IRI of the Wikibase instance referenced by this schema
-
getEntityTypeSiteIri
public Map<String,String> getEntityTypeSiteIri()
- Returns:
- the site IRI of the Wikibase instance referenced by this schema
-
getEntityDocumentExpressions
public List<WbExpression<? extends EntityEdit>> getEntityDocumentExpressions()
- Returns:
- the list of document expressions for this schema
-
getMediaWikiApiEndpoint
public String getMediaWikiApiEndpoint()
-
evaluateEntityDocuments
public List<EntityEdit> evaluateEntityDocuments(ExpressionContext ctxt) throws QAWarningException
Evaluates all entity documents in a particular expression context. This specifies, among others, a row where the values of the variables will be read.- Parameters:
ctxt
- the context in which the schema should be evaluated.- Returns:
- Throws:
QAWarningException
-
evaluate
public List<EntityEdit> evaluate(Grid grid, Engine engine, QAWarningStore warningStore)
Evaluates the schema on a project, returning a list of EntityUpdates generated by the schema. Some warnings will be emitted in the warning store: those are only the ones that are generated at evaluation time (such as invalid formats for dates). Issues detected on candidate statements (such as constraint violations) are not included at this stage.- Parameters:
grid
- the grid on which the schema should be evaluatedengine
- the engine, which gives access to the current facetswarningStore
- a store in which issues will be emitted- Returns:
- entity updates are stored in their generating order (not merged yet).
-
evaluate
public List<EntityEdit> evaluate(ColumnModel columnModel, Iterable<IndexedRow> indexedRows, QAWarningStore warningStore)
Evaluates the schema on a list of rows, returning a list of EntityUpdates generated by the schema.Some warnings will be emitted in the warning store: those are only the ones that are generated at evaluation time (such as invalid formats for dates). Issues detected on candidate statements (such as constraint violations) are not included at this stage.
- Parameters:
columnModel
- the column model of the grid on which the schema should be evaluatedindexedRows
- the rows to evaluate the schema onwarningStore
- a store in which issues will be emitted- Returns:
- entity updates are stored in their generating order (not merged yet).
-
evaluate
public List<EntityEdit> evaluate(Grid grid, Engine engine)
Same as above, ignoring any warnings.
-
reconstruct
public static WikibaseSchema reconstruct(String json) throws IOException
- Throws:
IOException
-
load
public static WikibaseSchema load(Project project, String obj) throws Exception
- Throws:
Exception
-
onBeforeSave
public void onBeforeSave(Project project)
- Specified by:
onBeforeSave
in interfaceOverlayModel
-
onAfterSave
public void onAfterSave(Project project)
- Specified by:
onAfterSave
in interfaceOverlayModel
-
dispose
public void dispose(Project project)
- Specified by:
dispose
in interfaceOverlayModel
-
-