some smush improvements
This commit is contained in:
parent
eafbc664c2
commit
a85683d99b
1 changed files with 16 additions and 2 deletions
|
@ -111,7 +111,7 @@ public class JenaIngestUtils {
|
||||||
}
|
}
|
||||||
if (stmt != null) {
|
if (stmt != null) {
|
||||||
Resource outRes = stmt.getSubject();
|
Resource outRes = stmt.getSubject();
|
||||||
ResourceUtils.renameResource(outRes,namespaceEtc+random.nextInt());
|
ResourceUtils.renameResource(outRes,getNextURI(namespaceEtc, dedupUnionModel));
|
||||||
doneSet.add(res.getId().toString());
|
doneSet.add(res.getId().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ public class JenaIngestUtils {
|
||||||
String nextURI = null;
|
String nextURI = null;
|
||||||
boolean duplicate = true;
|
boolean duplicate = true;
|
||||||
while (duplicate) {
|
while (duplicate) {
|
||||||
nextURI = namespaceEtc+random.nextInt();
|
nextURI = namespaceEtc+random.nextInt(9999999);
|
||||||
Resource res = ResourceFactory.createResource(nextURI);
|
Resource res = ResourceFactory.createResource(nextURI);
|
||||||
duplicate = false;
|
duplicate = false;
|
||||||
ClosableIterator closeIt = model.listStatements(res, (Property)null, (RDFNode)null);
|
ClosableIterator closeIt = model.listStatements(res, (Property)null, (RDFNode)null);
|
||||||
|
@ -303,6 +303,7 @@ public class JenaIngestUtils {
|
||||||
*/
|
*/
|
||||||
public Model smushResources(Model inModel, Property prop) {
|
public Model smushResources(Model inModel, Property prop) {
|
||||||
Model outModel = ModelFactory.createDefaultModel();
|
Model outModel = ModelFactory.createDefaultModel();
|
||||||
|
outModel.add(inModel);
|
||||||
inModel.enterCriticalSection(Lock.READ);
|
inModel.enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
ClosableIterator closeIt = inModel.listObjectsOfProperty(prop);
|
ClosableIterator closeIt = inModel.listObjectsOfProperty(prop);
|
||||||
|
@ -318,16 +319,29 @@ public class JenaIngestUtils {
|
||||||
if (first) {
|
if (first) {
|
||||||
smushToThisResource = subj;
|
smushToThisResource = subj;
|
||||||
first = false;
|
first = false;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClosableIterator closgIt = inModel.listStatements(subj,(Property)null,(RDFNode)null);
|
ClosableIterator closgIt = inModel.listStatements(subj,(Property)null,(RDFNode)null);
|
||||||
try {
|
try {
|
||||||
for (Iterator stmtIt = closgIt; stmtIt.hasNext();) {
|
for (Iterator stmtIt = closgIt; stmtIt.hasNext();) {
|
||||||
Statement stmt = (Statement) stmtIt.next();
|
Statement stmt = (Statement) stmtIt.next();
|
||||||
|
outModel.remove(stmt.getSubject(), stmt.getPredicate(), stmt.getObject());
|
||||||
outModel.add(smushToThisResource, stmt.getPredicate(), stmt.getObject());
|
outModel.add(smushToThisResource, stmt.getPredicate(), stmt.getObject());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
closgIt.close();
|
closgIt.close();
|
||||||
}
|
}
|
||||||
|
closgIt = inModel.listStatements((Resource) null, (Property)null, subj);
|
||||||
|
try {
|
||||||
|
for (Iterator stmtIt = closgIt; stmtIt.hasNext();) {
|
||||||
|
Statement stmt = (Statement) stmtIt.next();
|
||||||
|
outModel.remove(stmt.getSubject(), stmt.getPredicate(), stmt.getObject());
|
||||||
|
outModel.add(stmt.getSubject(), stmt.getPredicate(), smushToThisResource);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
closgIt.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
closfIt.close();
|
closfIt.close();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue