fixed.
On Sat, Sep 20, 2014 at 10:57 PM, Andy Seaborne <[email protected]> wrote:
> On 20/09/14 21:27, Claude Warren wrote:
>
>> Andy,
>>
>> 1 and 2 implemented.
>>
>
> Off by one error :-)
>
> SelectBuilder sb = new SelectBuilder() ;
> sb.addPrefix("abcd:", "http://example/") ;
> Query query = sb.build() ;
> System.out.println(query) ;
>
> ==> PREFIX abc: <http://example/>
>
> and
>
> .addPrefix(":", "http://example/") ;
> ==>
> "String index out of range"
>
>
> In
> private String canonicalPfx(String x) {
> if (x.endsWith(":"))
> return x.substring(0, x.length() - 1);
> return x;
> }
>
> -1 (it was -2)
>
> Andy
>
>
> 3 was another issue with the testTriple() and has been fixed.
>>
>> Tests were added.
>>
>> On Sat, Sep 20, 2014 at 6:50 PM, Andy Seaborne <[email protected]> wrote:
>>
>> Hi Claude,
>>>
>>> 1/ Suggestion
>>> if there is no addVar then the query defaults to SELECT *.
>>>
>>> 2/ Suggestion
>>> Strip any trailing ":" from the prefix name so
>>> .addPrefix(":", "http://example/")
>>> works.
>>>
>>> 3/ I tried:
>>>
>>> SelectBuilder sb = new SelectBuilder() ;
>>> sb.addVar("*")
>>> .addPrefix("", "http://example/")
>>> .addWhere(":S", "?p", "?o") ;
>>> Query query = sb.build() ;
>>> System.out.println(query) ;
>>>
>>> and got:
>>> -----------------
>>> Exception in thread "main" java.lang.IllegalArgumentException: Predicate
>>> (?p) must be a URI , variable, or a wildcard.
>>> Is a prefix missing? Prefix must be defined before use.
>>>
>>> org.apache.jena.arq.querybuilder.handlers.WhereHandler.testTriple(
>>> WhereHandler.java:124)
>>> org.apache.jena.arq.querybuilder.handlers.WhereHandler.addWhere(
>>> WhereHandler.java:129)
>>> org.apache.jena.arq.querybuilder.SelectBuilder.
>>> addWhere(SelectBuilder.java:194)
>>> org.apache.jena.arq.querybuilder.SelectBuilder.
>>> addWhere(SelectBuilder.java:206)
>>> dev.QBuild.main(QBuild.java:34)
>>> -----------------
>>> while
>>> ("?s", "?p", "?o") works.
>>> Andy
>>>
>>>
>>> On 19/09/14 22:51, Claude Warren wrote:
>>>
>>> I have added license and javadoc comments as well as a readme.md In
>>>> addition the above mentioned bug is now fixed and addVar( "*" ) works
>>>> as
>>>> expected.
>>>>
>>>> On Fri, Sep 19, 2014 at 1:24 PM, Claude Warren <[email protected]>
>>>> wrote:
>>>>
>>>> I started looking at it this AM. I think the proper solution is to
>>>>
>>>>> accept
>>>>> "*" as a var in the selecthandler. I will look at it over the weekend
>>>>> and
>>>>> will add documentation (javadoc at least)
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Sep 19, 2014 at 10:14 AM, Andy Seaborne <[email protected]>
>>>>> wrote:
>>>>>
>>>>> On 19/09/14 05:18, Bruno P. Kinoshita wrote:
>>>>>
>>>>>>
>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>> Ditto.
>>>>>>
>>>>>> (I have just pushed a fix to Wherehandler.testTriple.)
>>>>>>
>>>>>> Andy
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> I like: Like Like - The likeliest place on the web
>>>>> <http://like-like.xenei.com>
>>>>> LinkedIn: http://www.linkedin.com/in/claudewarren
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>
--
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren