Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7F3C9200CB6 for ; Thu, 29 Jun 2017 10:53:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7DB9E160BED; Thu, 29 Jun 2017 08:53:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9C8DF160BDF for ; Thu, 29 Jun 2017 10:53:51 +0200 (CEST) Received: (qmail 5900 invoked by uid 500); 29 Jun 2017 08:53:50 -0000 Mailing-List: contact dev-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list dev@syncope.apache.org Received: (qmail 5887 invoked by uid 99); 29 Jun 2017 08:53:50 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jun 2017 08:53:50 +0000 Received: from [192.168.0.3] (93-56-25-79.ip287.fastwebnet.it [93.56.25.79]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 9109E1A0048 for ; Thu, 29 Jun 2017 08:53:48 +0000 (UTC) Subject: Re: AnyObjects query To: dev@syncope.apache.org References: <59c531b5-9edd-5fb1-2626-9c790a21055e@apache.org> <9ed466c0-f6c3-6756-08bc-13a3f55b85db@apache.org> <336ee24b-45ae-3dda-e739-8315f1cc9413@gmail.com> <5ad0fe18-dc91-ecdb-6562-360a7e3218a7@apache.org> <9cc11e36-a2aa-4a40-7cea-c474f70f048c@gmail.com> <4dc1f9a7-efe4-63e1-c86b-587220304da9@gmail.com> From: =?UTF-8?Q?Francesco_Chicchiricc=c3=b2?= Message-ID: Date: Thu, 29 Jun 2017 10:53:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <4dc1f9a7-efe4-63e1-c86b-587220304da9@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US archived-at: Thu, 29 Jun 2017 08:53:52 -0000 On 29/06/2017 10:52, Sergey Beryozkin wrote: > Hi Fabio > > That would not work at the generic level as it would require a 2-way > relationship (cartridge - printer for ex) which is not always > realistic to expect, In the Syncope data model, all Relationships are 2-way. I agree with Fabio: the use case proposed by Colm is doable with current implementation. Naturally, there is always room for improvements, but I don't see much demand ATM. Regards. > On 29/06/17 09:07, Fabio Martelli wrote: >> >> >> Il 28/06/2017 18:34, Colm O hEigeartaigh ha scritto: >>> Thanks for the feedback guys! Let me just expand a bit on the >>> motivation >>> behind my previous example.... >>> >>> Let's say I'm managing hundreds of printers each of which have a >>> relationship to a cartridge (of which there are many hundreds) with a >>> colour attribute. I want to find the printers with a blue cartridge. >>> >>> So I first make a search for a list of "blue" cartridges. Then I >>> search for >>> the printers that have a relationship with these cartridges. The >>> problem is >>> on the second search I end up with a ginormous search expression >>> "relationships%3D%3D7db4512-ad25-40e8-bc78-63ad25c0e894%2C%24relationships%3D%3D16dc6acd-6.....". >>> >>> " that could be an invalid URL. >>> >>> Is there a better way of handling it than this? >> Hi Colm, maybe you can search all the cartridges blue with a >> relationship with a printer. >> The result will be a list of cartridges. Each item will be reported >> including a specific field relationships (if I well remember) about >> all the printers related to the item. >> In this case, you will have all the info you need retrieved by a >> single short query. Don't you agree? >> >> BR, >> F. >>> >>> Colm. >>> >>> On Wed, Jun 28, 2017 at 10:52 AM, Sergey Beryozkin >>> >>> wrote: >>> >>>> Hi Francesco >>>> >>>> One thing I can point to is this code: >>>> >>>> https://github.com/apache/cxf/blob/master/rt/rs/extensions/s >>>> earch/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/Abst >>>> ractJPATypedQueryVisitor.java#L167 >>>> >>>> There, in the end, >>>> >>>> https://github.com/apache/cxf/blob/master/rt/rs/extensions/s >>>> earch/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/Abst >>>> ractJPATypedQueryVisitor.java#L181 >>>> >>>> it branches to either doBuildPredicate() (==> similar to Syncope >>>> SearchCondVisitor.visitPrimitive) or doBuildCollectionPredicate() >>>> >>>> When we have "a.b.c" then if 'b' is a collection then it would >>>> branch to >>>> doBuildCollectionPredicate. >>>> >>>> It was awhile back since I played with the typed JPA2 code, Native >>>> one is >>>> a mystery... >>>> >>>> I agree supporting such queries is not easy...but supporting then can >>>> offer an ultimate search experience :-) >>>> >>>> Cheers, Sergey >>>> >>>> On 28/06/17 10:26, Francesco Chicchiriccò wrote: >>>> >>>>> On 28/06/2017 10:59, Sergey Beryozkin wrote: >>>>> >>>>>> Hi Francesco >>>>>> >>>>>> Thanks for the explanation. >>>>>> >>>>>> I see why the example I pointed to won't be applicable to Syncope. >>>>>> In that case when the linked beans are available, CXF >>>>>> AbstractSearchParser will prepare a bean tree which would be >>>>>> initialized >>>>>> with the values from the expression like "a.b.c" and the OOB >>>>>> visitor like >>>>>> JPA2 one takes care of dealing with these linked beans. >>>>>> >>>>>> In the SearchBean case it is up to the custom visitor whether to >>>>>> react >>>>>> to the '.'s or not where a '.' indicates that for ex 'a' needs to >>>>>> have 'b' >>>>>> with a property 'c'. >>>>>> >>>>>> Do you reckon Syncope custom visitors can be updated to support such >>>>>> queries ? Not sure about ElasticSearch but for SQL it should >>>>>> probably be >>>>>> possible... >>>>>> >>>>> Maybe in principle yes, it could be possible to support such >>>>> queries but: >>>>> >>>>> 1. implementation would be rather complex as the query logic is >>>>> already >>>>> quite involved >>>>> 2. we haven't had may requests for such complex queries so far >>>>> >>>>> ...anyway, as you know, volunteers are welcome :-) >>>>> >>>>> Regards. >>>>> >>>>> On 28/06/17 09:46, Francesco Chicchiriccò wrote: >>>>>>> On 28/06/2017 10:41, Sergey Beryozkin wrote: >>>>>>> >>>>>>>> Hi >>>>>>>> >>>>>>>> I think something similar works for a CXF FIQL JPA2 visitor, for >>>>>>>> example: >>>>>>>> >>>>>>>> https://github.com/apache/cxf/blob/master/rt/rs/extensions/s >>>>>>>> earch/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPAT >>>>>>>> ypedQueryVisitorFiqlTest.java#L65 >>>>>>>> >>>>>>>> (find the books which have been revied done by Ted) >>>>>>>> >>>>>>> Hi Sergey, >>>>>>> that would work if we had straight beans as in the linked sample. >>>>>>> >>>>>>> Syncope data model is instead much more involved as new schema for >>>>>>> attributes can be defined at runtime: this is the reason why we >>>>>>> have >>>>>>> SearchCondVisitor [1] translating FIQL into our internal search >>>>>>> conditions, >>>>>>> which serve as input to one of available implementations of >>>>>>> AnySearchDAO >>>>>>> like as the default one based on SQL views [2] and another >>>>>>> relying on >>>>>>> Elasticsearch-based [3]. >>>>>>> >>>>>>> Regards. >>>>>>> >>>>>>> [1] https://github.com/apache/syncope/blob/2_0_X/core/persistenc >>>>>>> e-api/src/main/java/org/apache/syncope/core/persistenc >>>>>>> e/api/search/SearchCondVisitor.java >>>>>>> [2] https://github.com/apache/syncope/blob/2_0_X/core/persistenc >>>>>>> e-jpa/src/main/java/org/apache/syncope/core/persistenc >>>>>>> e/jpa/dao/JPAAnySearchDAO.java >>>>>>> [3] https://github.com/apache/syncope/blob/2_0_X/ext/elasticsear >>>>>>> ch/persistence-jpa/src/main/java/org/apache/syncope/core/ >>>>>>> persistence/jpa/dao/ElasticsearchAnySearchDAO.java >>>>>>> >>>>>>> On 28/06/17 08:54, Francesco Chicchiriccò wrote: >>>>>>>>> On 27/06/2017 18:18, Colm O hEigeartaigh wrote: >>>>>>>>> >>>>>>>>>> Thanks Francesco! On a related note, let's say I have some >>>>>>>>>> AnyObjects >>>>>>>>>> (Printer) with a relationship to other AnyObjects >>>>>>>>>> (Cartridge). Now I >>>>>>>>>> want >>>>>>>>>> to search for a Printer which has a relationship with a >>>>>>>>>> Cartridge >>>>>>>>>> with a >>>>>>>>>> "colour" attribute of "blue". Is there a way to do this via a >>>>>>>>>> FIQL >>>>>>>>>> expression? >>>>>>>>>> >>>>>>>>> No, you cannot express such condition ATM; you could do for >>>>>>>>> example: >>>>>>>>> >>>>>>>>> SyncopeClient.getAnyObjectSearchConditionBuilder("PRINTER"). >>>>>>>>> inRelationships("ce75249b-76e4-44b6-88ae-0841846faceb"). >>>>>>>>> and().is("colour").equalTo("blue").query(); >>>>>>>>> >>>>>>>>> which translates to FIQL >>>>>>>>> >>>>>>>>> $type==PRINTER;$relationships==ce75249b-76e4-44b6-88ae-0841846faceb;colour==blue >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> but this would rather search for blue printers having a >>>>>>>>> relationship >>>>>>>>> with an any object with key >>>>>>>>> 'ce75249b-76e4-44b6-88ae-0841846faceb'. >>>>>>>>> >>>>>>>>> or alternatively >>>>>>>>> >>>>>>>>> SyncopeClient.getAnyObjectSearchConditionBuilder("PRINTER"). >>>>>>>>> inRelationshipTypes("WITH_CARTDRIGE"). >>>>>>>>> and().is("color").equalTo("blue").query(); >>>>>>>>> >>>>>>>>> which translates to FIQL >>>>>>>>> >>>>>>>>> $type==PRINTER;$relationshipTypes==WITH_CARTDRIGE;color==blue >>>>>>>>> >>>>>>>>> but this would rather search for blue printers having a >>>>>>>>> relationship >>>>>>>>> on type WITH_CARTDRIGE. >>>>>>>>> >>>>>>>>> Regards. >>>>>>>>> >>>>>>>>> On Tue, Jun 27, 2017 at 4:29 PM, Francesco Chicchiriccò < >>>>>>>>>> ilgrosso@apache.org> wrote: >>>>>>>>>> >>>>>>>>>> On 27/06/2017 17:24, Colm O hEigeartaigh wrote: >>>>>>>>>>> Hi all, >>>>>>>>>>>> How can I retrieve a list of AnyObjects? The following >>>>>>>>>>>> returns a >>>>>>>>>>>> 400: >>>>>>>>>>>> >>>>>>>>>>>> curl -I -X GET -u admin:password >>>>>>>>>>>> http://localhost:9080/syncope/rest/anyObjects >>>>>>>>>>>> >>>>>>>>>>>> You must at least provide the AnyType, e.g. >>>>>>>>>>> http://localhost:9080/syncope/rest/anyObjects;fiql=%24type%3 >>>>>>>>>>> D%3DPRINTER >>>>>>>>>>> >>>>>>>>>>> Regards. >>>>>>>>>>> >>> >> > > -- Francesco Chicchiriccò Tirasa - Open Source Excellence http://www.tirasa.net/ Member at The Apache Software Foundation Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail http://home.apache.org/~ilgrosso/