incubator-clerezza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reto Bachmann-Gmuer <reto.bachm...@trialox.org>
Subject Re: Implementing UserContextProvider
Date Sat, 06 Feb 2010 19:48:24 GMT
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 <tsuy.ito@trialox.org> 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
>
>

Mime
View raw message