[
https://jira.jboss.org/jira/browse/DNA-215?page=com.atlassian.jira.plugin...
]
Randall Hauch commented on DNA-215:
-----------------------------------
Created a new API implementation that evolved from the two previous prototypes. This
design is actually pretty efficient, since very few intermediate API objects are created
(unlike the previous prototypes), and it offers the ability to execute requests
immediately (by invoking methods directly on the graph) or to batch together multiple
requests (by first using Graph.batch() to obtain a batch, then adding various requests to
the batch, and finally executing the batch to obtain the batch results.
Like the previous designs, this API uses an internal DSL approach to make the code that
uses the API more readable, and to rely upon returned interfaces to help guide the
developer (especially when they have code-completion in their IDE). Method chaining is
also possible with this design.
Here are a few simple examples of using this new API:
for ( Property property : graph.getProperties().on("/a/b") ) { ... }
for ( Location child : graph.getChildren().of("/a/b") ) { ... }
Node node = graph.getNodeAt("/a/b");
Subgraph subgraph = graph.getSubgraphOfDepth(3).at("/c/d");
graph.delete("/a/b/c").and().move(uuid).into(path1);
graph.create("/a/b/c/d", property1, property2, property3);
Obviously this is just a sample, but it shows the main intent of the design. Notice that
these operations are invoked directly on the graph (which is returned by the
"and()" method, allowing methods to be chained). These operations are executed
immediately upon completion, and the read methods return their results immediately.
It's also possible to do similar operations in batches:
graph.batch().delete("/a/b/c").
and().move(uuid).into(path1).
and().create("/a/b/c/d", property1, property2,
property3).execute();
Here, all 3 requests (1 delete, 1 move, and 1 create) are submitted to the repository
source in a single CompositeRequest when the "execute()" method is called. It
is possible to read information, too, but the results must be fetched after execution:
Results results = graph.batch().delete("/a/b/c").
and().move(uuid).into(path1).
and().create("/a/b/c/d", property1, property2, property3).
and().read("/j/k/m").and().readSubgraphOfDepth(3).at("/x/y").execute();
Node jkm = results.getNode("/j/k/m");
for ( Location child : jkm.getChildren() ) { ... }
Node xy = results.getNode("/x/y");
for ( Location child : xy ) {
for ( Property prop : child.getProperties() ) {...}
}
Again, these samples just show a few of the things that are possible. For more
information, see the org.jboss.dna.graph.Graph class (as well as its test case).
Graph API for working with repository content
---------------------------------------------
Key: DNA-215
URL:
https://jira.jboss.org/jira/browse/DNA-215
Project: DNA
Issue Type: Feature Request
Components: API, Connectors
Affects Versions: 0.2
Reporter: Randall Hauch
Assignee: Randall Hauch
Priority: Blocker
Fix For: 0.3
Attachments: dna-graph2.patch, dna-spi.patch
We need to make it easier to work with the content provided by the connectors. The
command framework is okay, but it is entirely oriented towards the connector, not the user
of the connector. Instead, we need an API that hides the command system (as much as
possible) and that provides an easy way to work with the content.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira