{
final Iterator<Triple> mGraphIterator = metaGraph.filter(null, RDF.type, BACKUP.MGraph);
while (mGraphIterator.hasNext()) {
GraphNode graphGN = new GraphNode(mGraphIterator.next().getSubject(), metaGraph);
String fileName = graphGN.getLiterals(BACKUP.file).next().getLexicalForm();
TripleCollection extracted = extractedTc.get(fileName);
MGraph mGraph;
boolean created = false;
try {
mGraph = target.getMGraph((UriRef)graphGN.getNode());
try {
mGraph.clear();
} catch (UnsupportedOperationException ex) {
log.warn("could not restore "+graphGN.getNode()+" as the exsting triple "
+ "collection could not be cleared");
continue;
}
} catch (NoSuchEntityException ex) {
mGraph = target.createMGraph((UriRef)graphGN.getNode());
created = true;
}
try {
mGraph.addAll(extracted);
} catch (Exception ex) {
String actionDone = created ? "created" : "cleared";
log.error("after the mgraph "+graphGN.getNode()+" could successfully be "+actionDone
+ ", an exception occured adding the data", ex);
}
}
}
{
final Iterator<Triple> graphIterator = metaGraph.filter(null, RDF.type, BACKUP.Graph);
while (graphIterator.hasNext()) {
GraphNode graphGN = new GraphNode(graphIterator.next().getSubject(), metaGraph);
String fileName = graphGN.getLiterals(BACKUP.file).next().getLexicalForm();
TripleCollection extracted = extractedTc.get(fileName);
try {
target.deleteTripleCollection((UriRef)graphGN.getNode());
} catch (UnsupportedOperationException ex) {
log.warn("could not restore "+graphGN.getNode()+" as the exsting triple "
+ "collection could not be deleted");