graph.registerListener(new IStatementListener<INamedGraph>() {
@Override
public void statementsAdded(INamedGraph source,
org.openanzo.rdf.Statement... statements) {
// TODO Auto-generated method stub
System.err.println("Statements added to: " +
source.getNamedGraphUri());
for (int i = 0; i < statements.length; i++) {
System.err.println(statements[i]);
}
}
@Override
public void statementsRemoved(INamedGraph source,
org.openanzo.rdf.Statement... statements) {
// TODO Auto-generated method stub
System.err.println("Statements removed from: " +
source.getNamedGraphUri());
for (int i = 0; i < statements.length; i++) {
System.err.println(statements[i]);
}
}});
but I want to use listener for run an inference process when some
statements has been changed? is this the right method to use?
Has someone documentation to suggest me? I 've not found anything
about it on the wiki...
jako
Hi jako,
Yes. That method will work for listening for statements changing within
a graph. Keep in mind that the graph on which you are registering a
listener needs to be a 'replicaGraph' for it to work like that.
There is a code sample in the org.openanzo.client.sample project that
shows this in action. You can get a copy of that project using SVN by
doing something like:
svn export
http://svn.openanzo.org/svn/openanzo/openanzo/branches/releases/openanzo-3.1.0/org.openanzo.client.sample/
The relevant sample code is in the
org.openanzo.client.sample.ReplicaGraph class.
If you can't use a replicaGraph for some reason, such as its contents
are too big to reasonably store a replica of it in client memory, then
you can still monitor changes to it using the 'real time updates'
mechanism. There is a sample of that mechanism in the
org.openanzo.client.sample.RealtimeUpdates class.
--
Jordi Albornoz Mulligan
Founding Engineer - Cambridge Semantics
jo...@cambridgesemantics.com
(617) 401-7321
Actually, I was mistaken in saying that it must be a replicaGraph. It
can either be a replicaGraph or a serverGraph. You'll get the events in
both cases and, with the serverGraph you won't be limited in the size of
the graph since it won't keep a client copy of the data. So you can
choose whichever is more appropriate. The
org.openanzo.client.sample.ServerGraph class has an example using server
graphs.
J
On 8 Feb, 19:42, Jordi Albornoz Mulligan