Hello Claude, I didn't understand what QueryBuilder was supposed to do at first, or how to use it. Luckily there are tests in the project, kudos for writing those, very helpful. I liked the idea, and for users familiar with Java Jooq, PHP and Ruby ActiveRecord that's definitely an intuitive API.
In order to test it, I first created some dummy data. PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX : <http://example.org/> INSERT DATA { :bruno foaf:name "Bruno" . :jorge foaf:name "Jorge" . :bruno :brotherOf :jorge } Then I retrieved the data with a simple SELECT. PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX : <http://example.org/> SELECT * { ?a ?b ?c } --------------------------------- | a | b | c | ================================= | :bruno | foaf:name | "Bruno" | | :bruno | :brotherOf | :jorge | | :jorge | foaf:name | "Jorge" | --------------------------------- I tried to recreate the same query with QueryBuilder, but alas it didn't work. I have probably made something really stupid [1]. My output is always: PREFIX : <http://example.org/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> WHERE { ?a ?b ?c . } I just wanted to validate that I could recreate the same query with QueryBuilder. But I couldn't figure how that works. Looking at WhereClauseTest, I thought that addVar("*") would result in "SELECT *". The prefixes is not keeping the order it was added, thus that's probably not an issue. The SelectBuilder throws ParseException, which extends Exception. I think **if** the Query Builder is supposed to be used by programmers for writing their Web applications or similar, then perhaps it could extend a RuntimeException? Just my 0.002 cents Thanks Bruno [1] https://gist.github.com/kinow/b50a5d3b875f2155b7bb >________________________________ > From: Claude Warren <[email protected]> >To: [email protected] >Sent: Wednesday, September 17, 2014 7:22 PM >Subject: Query Builder > > >Greetings, > >I have created a QueryBuilder that builds a query without constructing the >text version first. The classes (AskBuilder, ConstructBuilder, and >SelectBuilder) allows you to construct the query by adding Construct, >Dataset, Prolog Select SolutionModifer and Where clauses. > >In addition there is some templating in that variables anywhere in the >query structure can be replaced by calling setVar( var, node ) before >calling the build() method. > >The code is currently hosted at https://github.com/Claudenw/querybuilder > >I have not completed the setVar() tests yet, but I think that the code is >stable enough for people to play with. > >Claude > >-- >I like: Like Like - The likeliest place on the web ><http://like-like.xenei.com> >LinkedIn: http://www.linkedin.com/in/claudewarren > > >
