use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class HTTPRepositoryConnection method removeWithoutCommit.
@Override
protected void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
if (this.getRepository().useCompatibleMode()) {
txn.add(new RemoveStatementsOperation(subject, predicate, object, contexts));
return;
}
flushTransactionState(Protocol.Action.DELETE);
if (toRemove == null) {
toRemove = new LinkedHashModel();
}
if (subject == null) {
subject = SESAME.WILDCARD;
}
if (predicate == null) {
predicate = SESAME.WILDCARD;
}
if (object == null) {
object = SESAME.WILDCARD;
}
toRemove.add(subject, predicate, object, contexts);
}
use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class HTTPRepositoryConnection method addWithoutCommit.
/*
* @Override public void remove(Resource subject, URI predicate, Value object, Resource... contexts)
* throws RepositoryException { if (!isActive()) { // operation is not part of a transaction - just send
* directly OpenRDFUtil.verifyContextNotNull(contexts); if (subject == null) { subject = SESAME.WILDCARD;
* } if (predicate == null) { predicate = SESAME.WILDCARD; } if (object == null) { object =
* SESAME.WILDCARD; } final Model m = new LinkedHashModel(); m.add(subject, predicate, object, contexts);
* removeModel(m); } else { super.remove(subject, predicate, object, contexts); } }
*/
@Override
protected void addWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
if (this.getRepository().useCompatibleMode()) {
txn.add(new AddStatementOperation(subject, predicate, object, contexts));
return;
}
flushTransactionState(Protocol.Action.ADD);
if (toAdd == null) {
toAdd = new LinkedHashModel();
}
toAdd.add(subject, predicate, object, contexts);
}
use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class RemoteRepositoryManager method getRepositoryConfig.
@Override
public RepositoryConfig getRepositoryConfig(String id) throws RepositoryException {
Model model = new LinkedHashModel();
try (RDF4JProtocolSession httpClient = getSesameClient().createRDF4JProtocolSession(serverURL)) {
httpClient.setUsernameAndPassword(username, password);
httpClient.setRepository(Protocol.getRepositoryLocation(serverURL, SystemRepository.ID));
httpClient.getStatements(null, null, null, true, new StatementCollector(model));
} catch (IOException | QueryEvaluationException | UnauthorizedException ue) {
throw new RepositoryException(ue);
}
return RepositoryConfigUtil.getRepositoryConfig(model, id);
}
use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class RemoteRepositoryManager method addRepositoryConfig.
@Override
public void addRepositoryConfig(RepositoryConfig config) throws RepositoryException, RepositoryConfigException {
try (RDF4JProtocolSession httpClient = getSesameClient().createRDF4JProtocolSession(serverURL)) {
String baseURI = Protocol.getRepositoryLocation(serverURL, config.getID());
Resource ctx = SimpleValueFactory.getInstance().createIRI(baseURI + "#" + config.getID());
httpClient.setUsernameAndPassword(username, password);
httpClient.setRepository(Protocol.getRepositoryLocation(serverURL, SystemRepository.ID));
Model model = new LinkedHashModel();
config.export(model, ctx);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Rio.write(model, baos, httpClient.getPreferredRDFFormat());
removeRepository(config.getID());
try (InputStream contents = new ByteArrayInputStream(baos.toByteArray())) {
httpClient.upload(contents, baseURI, httpClient.getPreferredRDFFormat(), false, true, ctx);
}
} catch (IOException | QueryEvaluationException | UnauthorizedException ue) {
throw new RepositoryException(ue);
}
}
use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class HTTPRepositoryConnection method add.
@Override
public void add(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
if (!isActive()) {
logger.debug("adding statement directly: {} {} {} {}", new Object[] { subject, predicate, object, contexts });
// operation is not part of a transaction - just send directly
OpenRDFUtil.verifyContextNotNull(contexts);
final Model m = new LinkedHashModel();
m.add(subject, predicate, object, contexts);
addModel(m);
} else {
logger.debug("adding statement in txn: {} {} {} {}", new Object[] { subject, predicate, object, contexts });
super.add(subject, predicate, object, contexts);
}
}
Aggregations