Re: Emulating left outer joins with JDOQL

2016-01-28 Thread Dan Haywood
Could you copy all the relevant code so that I can write this up as an faq
?
On 28 Jan 2016 17:17, "Willie Loyd Tandingan" 
wrote:

> It worked! "datanucleus.query.jdoql.{varName}.join" had to be set to
> OUTERJOIN for both pt and t. Thanks!
>
> On Sun, Jan 24, 2016 at 2:45 AM, Willie Loyd Tandingan <
> tandingan@gmail.com> wrote:
>
> > I'm gonna try that one back at work next week. Thanks!
> >
> > Admittedly, I thought of that one before but didn't try it out since I
> > thought it would generate an inner join instead and didn't think of
> turning
> > SQL logging on. We tried this erroneous funny query which we thought was
> > kind of correct but DN didn't accept anyway:
> >
> > SELECT this, IF (pt.person == this) THEN pt.template ELSE null FROM
> Person
> > p VARIABLES PersonTemplate pt
> >
> > I will have to read thoroughly the DN documentation again.
> >
> > On Sat, Jan 23, 2016 at 3:36 AM, Andy Jefferson 
> > wrote:
> >
> >> On Friday 22 Jan 2016 19:25:24 Andy Jefferson wrote:
> >> > > > SELECT p.*, t.* FROM Person p
> >> > > > LEFT JOIN PersonTemplate pt ON p.id = pt.personId
> >> > > > LEFT JOIN Template t ON pt.templateId = t.id
> >> > > >
> >> > > > With this query, I can get Persons even if they don't have a
> >> Template.
> >> > > Which is what you would do if you followed the example I suggested,
> >> using JDOQL variables.
> >> > >
> >> > > SELECT p, t FROM mydomain.Person WHERE pt.person == this && pt.t ==
> t
> >> > > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> >> >
> >> > That should be
> >> >
> >> > SELECT p, t FROM mydomain.Person WHERE pt.person == this &&
> pt.template
> >> == t
> >> > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> >>
> >>
> >> Duh, and fixing the Person alias also that should be
> >>
> >> SELECT this, t FROM mydomain.Person WHERE pt.person == this &&
> >> pt.template == t
> >> VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> >>
> >>
> >> but then its simple if you just try it.
> >>
> >>
> >> --
> >> Andy
> >> DataNucleus (Web: http://www.datanucleus.org   Twitter: @datanucleus)
> >>
> >
> >
>


Re: Emulating left outer joins with JDOQL

2016-01-28 Thread Willie Loyd Tandingan
It worked! "datanucleus.query.jdoql.{varName}.join" had to be set to
OUTERJOIN for both pt and t. Thanks!

On Sun, Jan 24, 2016 at 2:45 AM, Willie Loyd Tandingan <
tandingan@gmail.com> wrote:

> I'm gonna try that one back at work next week. Thanks!
>
> Admittedly, I thought of that one before but didn't try it out since I
> thought it would generate an inner join instead and didn't think of turning
> SQL logging on. We tried this erroneous funny query which we thought was
> kind of correct but DN didn't accept anyway:
>
> SELECT this, IF (pt.person == this) THEN pt.template ELSE null FROM Person
> p VARIABLES PersonTemplate pt
>
> I will have to read thoroughly the DN documentation again.
>
> On Sat, Jan 23, 2016 at 3:36 AM, Andy Jefferson 
> wrote:
>
>> On Friday 22 Jan 2016 19:25:24 Andy Jefferson wrote:
>> > > > SELECT p.*, t.* FROM Person p
>> > > > LEFT JOIN PersonTemplate pt ON p.id = pt.personId
>> > > > LEFT JOIN Template t ON pt.templateId = t.id
>> > > >
>> > > > With this query, I can get Persons even if they don't have a
>> Template.
>> > > Which is what you would do if you followed the example I suggested,
>> using JDOQL variables.
>> > >
>> > > SELECT p, t FROM mydomain.Person WHERE pt.person == this && pt.t == t
>> > > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
>> >
>> > That should be
>> >
>> > SELECT p, t FROM mydomain.Person WHERE pt.person == this && pt.template
>> == t
>> > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
>>
>>
>> Duh, and fixing the Person alias also that should be
>>
>> SELECT this, t FROM mydomain.Person WHERE pt.person == this &&
>> pt.template == t
>> VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
>>
>>
>> but then its simple if you just try it.
>>
>>
>> --
>> Andy
>> DataNucleus (Web: http://www.datanucleus.org   Twitter: @datanucleus)
>>
>
>


Re: Emulating left outer joins with JDOQL

2016-01-28 Thread Willie Loyd Tandingan
The setup was as follows:

final Query query = getJdoPersistenceManager().newQuery(Employee.class);
query.setResult("this, p");
query.setResultClass(EmployeePayslipTemplate.class);
query.setFilter("ept.employee == this && ept.payslipTemplate == p");
query.declareVariables("domain.EmployeePayslipTemplate ept;
domain.PayslipTemplate p");
query.addExtension("datanucleus.query.jdoql.ept.join", "LEFTOUTERJOIN");
query.addExtension("datanucleus.query.jdoql.p.join", "LEFTOUTERJOIN");
return (List) query.execute();


Domain objects:
* Employee
* EmployeePayslipTemplate
- Employee employee
- PayslipTemplate payslipTemplate
* PayslipTemplate

View model:
* EmployeePayslipTemplateView
- public EmployeePayslipTemplateView(Employee employee, PayslipTemplate
payslipTemplate) { ... }
- Employee employee
- PayslipTemplate payslipTemplate

On Fri, Jan 29, 2016 at 1:22 AM, Dan Haywood 
wrote:

> Could you copy all the relevant code so that I can write this up as an faq
> ?
> On 28 Jan 2016 17:17, "Willie Loyd Tandingan" 
> wrote:
>
> > It worked! "datanucleus.query.jdoql.{varName}.join" had to be set to
> > OUTERJOIN for both pt and t. Thanks!
> >
> > On Sun, Jan 24, 2016 at 2:45 AM, Willie Loyd Tandingan <
> > tandingan@gmail.com> wrote:
> >
> > > I'm gonna try that one back at work next week. Thanks!
> > >
> > > Admittedly, I thought of that one before but didn't try it out since I
> > > thought it would generate an inner join instead and didn't think of
> > turning
> > > SQL logging on. We tried this erroneous funny query which we thought
> was
> > > kind of correct but DN didn't accept anyway:
> > >
> > > SELECT this, IF (pt.person == this) THEN pt.template ELSE null FROM
> > Person
> > > p VARIABLES PersonTemplate pt
> > >
> > > I will have to read thoroughly the DN documentation again.
> > >
> > > On Sat, Jan 23, 2016 at 3:36 AM, Andy Jefferson 
> > > wrote:
> > >
> > >> On Friday 22 Jan 2016 19:25:24 Andy Jefferson wrote:
> > >> > > > SELECT p.*, t.* FROM Person p
> > >> > > > LEFT JOIN PersonTemplate pt ON p.id = pt.personId
> > >> > > > LEFT JOIN Template t ON pt.templateId = t.id
> > >> > > >
> > >> > > > With this query, I can get Persons even if they don't have a
> > >> Template.
> > >> > > Which is what you would do if you followed the example I
> suggested,
> > >> using JDOQL variables.
> > >> > >
> > >> > > SELECT p, t FROM mydomain.Person WHERE pt.person == this && pt.t
> ==
> > t
> > >> > > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> > >> >
> > >> > That should be
> > >> >
> > >> > SELECT p, t FROM mydomain.Person WHERE pt.person == this &&
> > pt.template
> > >> == t
> > >> > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> > >>
> > >>
> > >> Duh, and fixing the Person alias also that should be
> > >>
> > >> SELECT this, t FROM mydomain.Person WHERE pt.person == this &&
> > >> pt.template == t
> > >> VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> > >>
> > >>
> > >> but then its simple if you just try it.
> > >>
> > >>
> > >> --
> > >> Andy
> > >> DataNucleus (Web: http://www.datanucleus.org   Twitter: @datanucleus)
> > >>
> > >
> > >
> >
>


Re: JAXB annotated classes as domain objects

2016-01-28 Thread Dan Haywood
Hi Vishma,
At the moment JAXB view models are immutable; only view models that
explicitly implement ViewModel.Cloneable are "editable".

That said, Willie (I think it was) also raised the same issue, and I've
raised ISIS-1299 [1] to see if we can fix that.

As an aside though, our personal experience is to use actions on objects
rather than the edit capability... it helps drive the conversation as to
why the business user wants to change the data.  I can see in the future
that we might make domain objects non-editable by default (perhaps for Isis
2.0, in 2017 sometime).

Thx
Dan


[1] https://issues.apache.org/jira/browse/ISIS-1299

On 26 January 2016 at 05:14, Vishma Senadhi Dias 
wrote:

> Hi Dan,
>
> Can you please tell me a way to enter data into a view model? I cannot
> find a way to update contents of the view model created via JAXB
> annotations.
>
> On 1/25/2016 5:25 PM, Dan Haywood wrote:
>
>> Hi Vishma,
>>
>> What's the objective here... what do you want the end user to be able to
>> do, and what do you want to be shown in the app?  What's are the domain
>> concepts involved?
>>
>> Perhaps you could share some of the code you've written thus far to help
>> us
>> understand.  If you can upload what you have as a simple example on
>> github,
>> so much the better.
>>
>> You also mentioned fixtures ... just to say that these are intended for
>> setting up the system for either prototyping or testing, they aren't
>> generally intended to be for use in the "production" app itself.  Wasn't
>> sure from your mail if this was clear to you or not.
>>
>> Thx
>> Dan
>>
>>
>> On 25 January 2016 at 11:44, Vishma Senadhi Dias > >
>> wrote:
>>
>> Hi,
>>>   I need some assistance with displaying web ui according to the SOAP
>>> response.
>>> Simple Example:
>>>   Let's say I have a JAXB annotated object called "Temperature". I
>>> have
>>> a SOAP web service which needs a place co-ordinates as an input and
>>> returns
>>> Temperature value as an Output. I have written a JAX-WS client to capture
>>> this response and send this inputs on a seperate project.
>>>
>>> What I had planned is to create JAXB annotated Temperature object in Dom
>>> package and update the list via Fixtures. These Fixtures are created
>>> according to the response. But I cannot update Temperature List with JAXB
>>> annotations.
>>>
>>> Can you please suggest a proper way to fulfill my task? Sorry if some
>>> details are not clear as I'm still new to this framework. I'm using
>>> simple
>>> archetype archetypeVersion=1.11.0 and wicket viewer.
>>>
>>> Thanks in advance.
>>>
>>>
>


Re: Emulating left outer joins with JDOQL

2016-01-28 Thread Jeroen van der Wal
Very elegant, nice!

On 28 January 2016 at 18:55, Willie Loyd Tandingan 
wrote:

> The setup was as follows:
>
> final Query query = getJdoPersistenceManager().newQuery(Employee.class);
> query.setResult("this, p");
> query.setResultClass(EmployeePayslipTemplate.class);
> query.setFilter("ept.employee == this && ept.payslipTemplate == p");
> query.declareVariables("domain.EmployeePayslipTemplate ept;
> domain.PayslipTemplate p");
> query.addExtension("datanucleus.query.jdoql.ept.join", "LEFTOUTERJOIN");
> query.addExtension("datanucleus.query.jdoql.p.join", "LEFTOUTERJOIN");
> return (List) query.execute();
>
>
> Domain objects:
> * Employee
> * EmployeePayslipTemplate
> - Employee employee
> - PayslipTemplate payslipTemplate
> * PayslipTemplate
>
> View model:
> * EmployeePayslipTemplateView
> - public EmployeePayslipTemplateView(Employee employee, PayslipTemplate
> payslipTemplate) { ... }
> - Employee employee
> - PayslipTemplate payslipTemplate
>
> On Fri, Jan 29, 2016 at 1:22 AM, Dan Haywood  >
> wrote:
>
> > Could you copy all the relevant code so that I can write this up as an
> faq
> > ?
> > On 28 Jan 2016 17:17, "Willie Loyd Tandingan" 
> > wrote:
> >
> > > It worked! "datanucleus.query.jdoql.{varName}.join" had to be set to
> > > OUTERJOIN for both pt and t. Thanks!
> > >
> > > On Sun, Jan 24, 2016 at 2:45 AM, Willie Loyd Tandingan <
> > > tandingan@gmail.com> wrote:
> > >
> > > > I'm gonna try that one back at work next week. Thanks!
> > > >
> > > > Admittedly, I thought of that one before but didn't try it out since
> I
> > > > thought it would generate an inner join instead and didn't think of
> > > turning
> > > > SQL logging on. We tried this erroneous funny query which we thought
> > was
> > > > kind of correct but DN didn't accept anyway:
> > > >
> > > > SELECT this, IF (pt.person == this) THEN pt.template ELSE null FROM
> > > Person
> > > > p VARIABLES PersonTemplate pt
> > > >
> > > > I will have to read thoroughly the DN documentation again.
> > > >
> > > > On Sat, Jan 23, 2016 at 3:36 AM, Andy Jefferson <
> a...@datanucleus.org>
> > > > wrote:
> > > >
> > > >> On Friday 22 Jan 2016 19:25:24 Andy Jefferson wrote:
> > > >> > > > SELECT p.*, t.* FROM Person p
> > > >> > > > LEFT JOIN PersonTemplate pt ON p.id = pt.personId
> > > >> > > > LEFT JOIN Template t ON pt.templateId = t.id
> > > >> > > >
> > > >> > > > With this query, I can get Persons even if they don't have a
> > > >> Template.
> > > >> > > Which is what you would do if you followed the example I
> > suggested,
> > > >> using JDOQL variables.
> > > >> > >
> > > >> > > SELECT p, t FROM mydomain.Person WHERE pt.person == this && pt.t
> > ==
> > > t
> > > >> > > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> > > >> >
> > > >> > That should be
> > > >> >
> > > >> > SELECT p, t FROM mydomain.Person WHERE pt.person == this &&
> > > pt.template
> > > >> == t
> > > >> > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> > > >>
> > > >>
> > > >> Duh, and fixing the Person alias also that should be
> > > >>
> > > >> SELECT this, t FROM mydomain.Person WHERE pt.person == this &&
> > > >> pt.template == t
> > > >> VARIABLES mydomain.PersonTemplate pt, mydomain.Template t
> > > >>
> > > >>
> > > >> but then its simple if you just try it.
> > > >>
> > > >>
> > > >> --
> > > >> Andy
> > > >> DataNucleus (Web: http://www.datanucleus.org   Twitter:
> @datanucleus)
> > > >>
> > > >
> > > >
> > >
> >
>