improvement to annotation migration
This commit is contained in:
parent
9901d50010
commit
f8ab3d1016
1 changed files with 20 additions and 8 deletions
|
@ -476,11 +476,24 @@ public class TBoxUpdater {
|
||||||
" FILTER (regex(str(?vitroProp), \"" + VitroVocabulary.vitroURI + "\")) } \n" +
|
" FILTER (regex(str(?vitroProp), \"" + VitroVocabulary.vitroURI + "\")) } \n" +
|
||||||
"} \n" ;
|
"} \n" ;
|
||||||
|
|
||||||
Model userChangesModel = construct(
|
Model userAnnotations = construct(
|
||||||
propertyAnnotationsQuery, userAnnotationsModel).difference(
|
propertyAnnotationsQuery, userAnnotationsModel);
|
||||||
construct(propertyAnnotationsQuery, oldAnnotationsModel));
|
Model oldAnnotations = construct(propertyAnnotationsQuery, oldAnnotationsModel);
|
||||||
|
|
||||||
if(userChangesModel.size() == 0) {
|
Model diff = userAnnotations.difference(oldAnnotations);
|
||||||
|
|
||||||
|
// migrate all current values for any predicate that has been modified
|
||||||
|
// from the default
|
||||||
|
Model valuesToMigrate = ModelFactory.createDefaultModel();
|
||||||
|
StmtIterator sit = diff.listStatements();
|
||||||
|
while(sit.hasNext()) {
|
||||||
|
Statement stmt = sit.nextStatement();
|
||||||
|
valuesToMigrate.add(userAnnotations.listStatements(
|
||||||
|
null, stmt.getPredicate(), (RDFNode) null));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(valuesToMigrate.size() == 0) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
log.info("Updating PropertyConfig.n3 to include locally-changed " +
|
log.info("Updating PropertyConfig.n3 to include locally-changed " +
|
||||||
|
@ -521,11 +534,10 @@ public class TBoxUpdater {
|
||||||
FileInputStream fis = new FileInputStream(file);
|
FileInputStream fis = new FileInputStream(file);
|
||||||
configModel.read(fis, null, "N3");
|
configModel.read(fis, null, "N3");
|
||||||
|
|
||||||
Model currentUnion = ModelFactory.createUnion(configModel,
|
Model userChangesUnion = ModelFactory.createUnion(configModel, valuesToMigrate);
|
||||||
userAnnotationsModel);
|
|
||||||
|
|
||||||
Model userAnnotationsAsConfig = construct(newQuery, currentUnion);
|
Model userAnnotationsAsConfig = construct(newQuery, userChangesUnion);
|
||||||
Model currentDefaultConfig = construct(existingQuery, currentUnion);
|
Model currentDefaultConfig = construct(existingQuery, configModel);
|
||||||
|
|
||||||
Model additions = userAnnotationsAsConfig.difference(currentDefaultConfig);
|
Model additions = userAnnotationsAsConfig.difference(currentDefaultConfig);
|
||||||
Model retractions = currentDefaultConfig.difference(userAnnotationsAsConfig);
|
Model retractions = currentDefaultConfig.difference(userAnnotationsAsConfig);
|
||||||
|
|
Loading…
Add table
Reference in a new issue