before any api publishing all named graph related to previous aggregation for that api are dropped
This commit is contained in:
parent
8530e488d0
commit
15cc87456c
|
@ -18,6 +18,7 @@ import org.eclipse.rdf4j.repository.Repository;
|
|||
import org.eclipse.rdf4j.repository.RepositoryConnection;
|
||||
import org.eclipse.rdf4j.repository.RepositoryResult;
|
||||
import org.eclipse.rdf4j.repository.manager.RemoteRepositoryManager;
|
||||
import org.eclipse.rdf4j.repository.util.Repositories;
|
||||
import org.eclipse.rdf4j.rio.RDFFormat;
|
||||
|
||||
import eu.dnetlib.ariadneplus.publisher.AriadnePlusPublisherException;
|
||||
|
@ -250,17 +251,24 @@ public class GraphDBClient {
|
|||
IRI datasourceApisGraph = factory.createIRI(getGraphDBBaseURI(), "datasourceApis");
|
||||
Statement numPartitionsStmt = null;
|
||||
try (RepositoryConnection con = repository.getConnection()) {
|
||||
int numPartitions = 0;
|
||||
log.debug("Removing datasourceApi partition info s:" + rApi.toString() + " p:" + HAS_NUM_PARTITIONS + " g:" + datasourceApisGraph );
|
||||
RepositoryResult<Statement> numPartitionsStmts = con.getStatements(rApi, HAS_NUM_PARTITIONS, null, false, datasourceApisGraph);
|
||||
if (numPartitionsStmts.hasNext()) {
|
||||
con.begin();
|
||||
numPartitionsStmt = numPartitionsStmts.next();
|
||||
int numPartitions = Integer.parseInt(numPartitionsStmt.getObject().stringValue());
|
||||
numPartitions = Integer.parseInt(numPartitionsStmt.getObject().stringValue());
|
||||
log.debug(" old partitions count: " + numPartitions);
|
||||
con.remove(rApi, HAS_NUM_PARTITIONS, factory.createLiteral(numPartitions), datasourceApisGraph);
|
||||
con.commit();
|
||||
con.close();
|
||||
}
|
||||
for (int numPartition=1; numPartition<=numPartitions; numPartition++) {
|
||||
String namedGraph = String.format("api_________::ariadne_plus::ads::1_partition_%d", numPartition);
|
||||
IRI graph = factory.createIRI(namedGraph);
|
||||
log.debug("removing namedGraph: " + graph);
|
||||
Repositories.consume(repository, conn -> conn.clear(graph));
|
||||
}
|
||||
}
|
||||
catch (RDF4JException e) {
|
||||
log.error("error removing datasourceApi partition info ", e);
|
||||
|
@ -275,6 +283,10 @@ public class GraphDBClient {
|
|||
throw new AriadnePlusPublisherException(e);
|
||||
}
|
||||
}
|
||||
|
||||
//CLEAR GRAPH <https://ariadne-infrastructure.eu/datasourceApis>
|
||||
|
||||
|
||||
|
||||
private String getRecordURI(final String objIdentifier, final String datasourceApi) {
|
||||
return "/" + datasourceApi + "/" + objIdentifier;
|
||||
|
|
Loading…
Reference in New Issue