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 32FAD200C5A for ; Tue, 18 Apr 2017 19:06:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 31986160BA1; Tue, 18 Apr 2017 17:06:18 +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 4EA96160B87 for ; Tue, 18 Apr 2017 19:06:17 +0200 (CEST) Received: (qmail 71744 invoked by uid 500); 18 Apr 2017 17:06:16 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 71733 invoked by uid 99); 18 Apr 2017 17:06:16 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Apr 2017 17:06:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id B947B1A061A for ; Tue, 18 Apr 2017 17:06:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id UWJthd01Jsfb for ; Tue, 18 Apr 2017 17:06:12 +0000 (UTC) Received: from post.selbstdenker.com (mail.selbstdenker.com [81.27.166.251]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id C3581619E2 for ; Tue, 18 Apr 2017 17:06:11 +0000 (UTC) X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.19.2 (ClamAV engine v0.99.2) Received: from [88.217.26.66] (account maik@selbstdenker.ag HELO [192.168.20.92]) by selbstdenker.ag (CommuniGate Pro SMTP 6.1.15) with ESMTPSA id 12689672 for user@cayenne.apache.org; Tue, 18 Apr 2017 19:06:10 +0200 From: Maik Musall Content-Type: multipart/signed; boundary=Apple-Mail-7C6F8985-25B4-4249-82BE-7DA506735A18; protocol="application/pkcs7-signature"; micalg=sha1 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Date: Tue, 18 Apr 2017 19:06:09 +0200 Subject: Re: in-memory filter by Expression accessing regular methods Message-Id: <13B2BCE8-E6CA-4192-93D9-9A010FCBAF81@selbstdenker.ag> References: <6185480A-9BAA-4B9A-AFB9-CDEE2AC9AC85@wardle.org> <15F28D11-CA92-4982-9EDF-6D96B37382F0@selbstdenker.ag> In-Reply-To: To: user@cayenne.apache.org X-Mailer: iPhone Mail (14E304) archived-at: Tue, 18 Apr 2017 17:06:18 -0000 --Apple-Mail-7C6F8985-25B4-4249-82BE-7DA506735A18 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Michael, in the meantime I remembered I had already implemented NSKeyValueCodingAddit= ions for my DataObject subclass, so I just used that :-) Maik > Am 18.04.2017 um 18:23 schrieb Michael Gentry : >=20 > Hi Maik, >=20 > I'm late to this, but you likely could've used > obj.readProperty("responsibleUser") as well. >=20 > mrg >=20 >=20 >> On Sun, Apr 16, 2017 at 7:13 AM, Musall, Maik wrot= e: >>=20 >> Wow, Mark, good guess! >>=20 >> That's it. Added a get=E2=80=A6 method around each part of the path's acc= essed >> methods, and it works. Didn't occur to me at all, because those methods a= re >> not getters in the strict sense. But I could have discovered this before,= >> by looking at the BeanAcccessor implementation. Dang. >>=20 >> I suppose there is no way in Cayenne to inject a different behaviour for >> this, through DI or something? It doesn't look like it from the code >> (BeanAccessor, PropertyUtils, and the readSimpleProperty() method in >> CayennDataObject is even marked final). Because I know I will run into th= is >> again and again, given the existing large code base. >>=20 >> Maik >>=20 >>=20 >>=20 >>> Am 15.04.2017 um 23:18 schrieb Mark Wardle : >>>=20 >>> Can't try it as only have phone at the moment but have you tried adding >> "get" as a prefix to your method declaration? >>>=20 >>> I still find it difficult to not name getters without the get. >>>=20 >>> -- >>> Dr. Mark Wardle >>> Consultant Neurologist, Cardiff, UK >>> (Sent from my mobile) >>>=20 >>>=20 >>>> On 13 Apr 2017, at 10:44, Musall, Maik wrote: >>>>=20 >>>> Hi John, >>>>=20 >>>> can you elaborate that on this example? >>>>=20 >>>> Previously, I did this to filter: >>>>=20 >>>> result =3D ExpressionFactory.matchExp( filterPath, filterValue >> ).filterObjects( result ); >>>>=20 >>>> Now I tried: >>>>=20 >>>> result =3D result.stream() >>>> .filter( obj -> PropertyUtils.getProperty( obj, filterPath >> ).equals( filterValue ) ) >>>> .collect( Collectors.toList() ); >>>>=20 >>>> Both times, I get: >>>>=20 >>>> java.lang.IllegalArgumentException: Property 'responsibleUser' is not >> readable >>>>=20 >>>> where "result" is like a List with Foo being a DataObject that has= >> a method called "responsibleUser", returning another DataObject subclass.= >>>>=20 >>>> Maik >>>>=20 >>>>=20 >>>>> Am 12.04.2017 um 19:11 schrieb John Huss : >>>>>=20 >>>>> Ok, you can use property utils in conjunction to call a method using >>>>> reflection (with a string name) >>>>>> On Wed, Apr 12, 2017 at 6:07 PM Musall, Maik >> wrote: >>>>>>=20 >>>>>> Hi John, >>>>>>=20 >>>>>> how do you mean that? Those filter paths come from the UI, passed on >> by >>>>>> the user assembling filter criteria. I wouldn't use string filter >> paths if >>>>>> the criteria would be constant. >>>>>>=20 >>>>>> Maik >>>>>>=20 >>>>>>> Am 12.04.2017 um 19:03 schrieb John Huss : >>>>>>>=20 >>>>>>> Just use a java 8 stream and lambda in addition or instead of. >>>>>>> On Wed, Apr 12, 2017 at 4:48 PM Musall, Maik >>>>>> wrote: >>>>>>>=20 >>>>>>>> Hi, >>>>>>>>=20 >>>>>>>> when filtering a list of objects by expression.filterObjects( list >> ), is >>>>>>>> there a way for the expression to access regular methods instead of= >>>>>> Cayenne >>>>>>>> db properties? >>>>>>>>=20 >>>>>>>> Use Case: I have a class A that has several relationships to class >> B, >>>>>> and >>>>>>>> it depends on a number of factors which is relevant in this case. S= o >>>>>> there >>>>>>>> is a method that returns either this or that relation to class B. I= >>>>>> would >>>>>>>> like to include the method name in the expression path. (This was >>>>>> possible >>>>>>>> in EOF, and I just found that it doesn't work in Cayenne.) >>>>>>>>=20 >>>>>>>> Thanks >>>>>>>> Maik >>>>>>>>=20 >>>>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>=20 >>=20 >>=20 --Apple-Mail-7C6F8985-25B4-4249-82BE-7DA506735A18 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIFRDCCBUAw ggQooAMCAQICEQCL1J68HHVjs12XqL5Ul/VRMA0GCSqGSIb3DQEBCwUAMIGbMQswCQYDVQQGEwJH QjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQK ExFDT01PRE8gQ0EgTGltaXRlZDFBMD8GA1UEAxM4Q09NT0RPIFNIQS0yNTYgQ2xpZW50IEF1dGhl bnRpY2F0aW9uIGFuZCBTZWN1cmUgRW1haWwgQ0EwHhcNMTYxMDAxMDAwMDAwWhcNMTcxMDAxMjM1 OTU5WjAlMSMwIQYJKoZIhvcNAQkBFhRtYWlrQHNlbGJzdGRlbmtlci5hZzCCASIwDQYJKoZIhvcN AQEBBQADggEPADC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