Hi Tsuy
I think something like the following should do:
//wondering why there isn't one method (maybe in user amanger)
returning the current user as graphNode
String userName = getUserName();
GraphNode agent = userManager.getUserGraphNode(userName);
if(!(node.getObjects(PLATFORM.user).hasNext())) {
node.addProperty(PLATFORM.user, agent.getNode());
node = new GraphNode(node.getNode(), new UnionMGraph(node.getGraph(),
agent.getGraph()));
} else {
Resource user = node.getObjects(PLATFORM.user).next();
//make an editable clone of the GraphNode
GraphNode agentClone = new GraphNode(agent.getNode(), new
SimpleMGraph(agent.getGraph()));
agentClone.replaceWith(user);
node.getGraph().addAll(agentClone.getGraph());
}
return node;
cheers,
reto
On Sat, Feb 6, 2010 at 5:53 PM, Tsuyoshi Ito <[email protected]> wrote:
> Hi there
>
> Currently I try to implement a UserContextProvider, which contains
> information about the user (see CLEREZZA-87).
>
> I am not sure how to add information to the user node if PLATFORM.user
> property already exists in the context-node/graph.
>
>
> String userName = getUserName();
> GraphNode agent = userManager.getUserGraphNode(userName);
> if(!(node.getObjects(PLATFORM.user).hasNext())) {
> node.addProperty(PLATFORM.user, agent.getNode());
> } else {
> Resource user = node.getObjects(PLATFORM.user).next();
>
> //TODO: adding triples to the existing resource.
> }
>
> node = new GraphNode(node.getNode(), new UnionMGraph(node.getGraph(),
> agent.getGraph()));
>
> Thanks for your help.
>
> CHeers
> Tsuy
>
>