Return-Path: X-Original-To: apmail-isis-users-archive@www.apache.org Delivered-To: apmail-isis-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2325917A8B for ; Thu, 20 Aug 2015 09:27:05 +0000 (UTC) Received: (qmail 46174 invoked by uid 500); 20 Aug 2015 09:27:05 -0000 Delivered-To: apmail-isis-users-archive@isis.apache.org Received: (qmail 46145 invoked by uid 500); 20 Aug 2015 09:27:05 -0000 Mailing-List: contact users-help@isis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@isis.apache.org Delivered-To: mailing list users@isis.apache.org Received: (qmail 46133 invoked by uid 99); 20 Aug 2015 09:27:04 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Aug 2015 09:27:04 +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 1552D1AA880 for ; Thu, 20 Aug 2015 09:15:37 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.101 X-Spam-Level: **** X-Spam-Status: No, score=4.101 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, KAM_COUK=1.1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id sIQbdYdIXrhG for ; Thu, 20 Aug 2015 09:15:30 +0000 (UTC) Received: from mail-io0-f182.google.com (mail-io0-f182.google.com [209.85.223.182]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 941D521115 for ; Thu, 20 Aug 2015 09:15:30 +0000 (UTC) Received: by iodt126 with SMTP id t126so39197856iod.2 for ; Thu, 20 Aug 2015 02:15:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=FzfC4snpkLPPVoJqiRXjR+zyh94cwo8IO+Hhwie1evE=; b=KfTZb/Uky6ZxDi6NweTWrPDMk9jLHxHydrwtnbW7tjGSPYudKDGbpFDLXNqmfeEwBg jll0xQMFv1xRg54LXuRs3lXol6PVPM2XEpfUXi8eki7WXC6f8ixJcGnWRnzUgTjOd7AF pqI+8esW6IcMVVwRpVWcnCSi3uoGMK4tBuH/NbKj097eiwQTHCDOshk5iNhmiWgyO0dA ImR9a6vkNf81318P1EbYIGOy6sDd8VxVCnRI7bESmeX1DRaaHbeZrMBGcYYTfTz6wzoS fSYENsXdS0HvQNtLYFvvlaSF6nb1X8xgqudL36Nu6ogzieaR0g42wYPHuSYUaJeoCMq0 DZcw== X-Gm-Message-State: ALoCoQkp21gkNmAzdeK+542xFa01x2jVBMYHWF13H6/9vOsVeVFaVqmtmRL3XBW399Vczufv1j0l MIME-Version: 1.0 X-Received: by 10.107.12.163 with SMTP id 35mr1450482iom.78.1440062129853; Thu, 20 Aug 2015 02:15:29 -0700 (PDT) Received: by 10.107.134.68 with HTTP; Thu, 20 Aug 2015 02:15:29 -0700 (PDT) X-Originating-IP: [86.161.14.64] Received: by 10.107.134.68 with HTTP; Thu, 20 Aug 2015 02:15:29 -0700 (PDT) In-Reply-To: <55D59251.5070709@gesconsultor.com> References: <55D59251.5070709@gesconsultor.com> Date: Thu, 20 Aug 2015 10:15:29 +0100 Message-ID: Subject: Re: ISIS-1044 issue with Collections From: Dan Haywood To: users Content-Type: multipart/alternative; boundary=001a113de654b47181051dba97a4 --001a113de654b47181051dba97a4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Nacho, Thanks for checking this out, and you are right, of course... the code should take the return type of the getter into account. I'll tidy up your code by way of a fix. Thanks again, Dan On 20 Aug 2015 09:40, "Nacho C=C3=A1novas Rej=C3=B3n" wrote: > Hi Dan. > > In order to test new changes on 1.9.0 release, I think I find some bug. > > My problem is in "*ISIS-1044: fixing by filtering the > PropertyAccessorFacet and CollectionAccessorFacet, also the > ActionInvocationFacet (for contributed collections/properties):*" issue. > > You modified "*getProperty*" method on class > "*CollectionAccessorFacetViaAccessor*". I show you the code: > > *OLD Code* > > final Object collectionOrArray =3D ObjectAdapter.InvokeUtils.invoke(metho= d, > owningAdapter); > > *NEW Code* > > final Object collectionOrArray =3D ObjectAdapter.InvokeUtils.invoke(metho= d, > owningAdapter); > > final ObjectAdapter collectionAdapter =3D > getAdapterManager().adapterFor(collectionOrArray); > > final FacetedMethod facetedMethod =3D (FacetedMethod) getFacetHolder(); > final Class collectionElementType =3D facetedMethod.getType(); > > final List visibleAdapters =3D > ObjectAdapter.Util.visibleAdapters( > collectionAdapter, > authenticationSession, deploymentCategory); > final List visibleObjects =3D Lists.newArrayList( > Iterables.transform(visibleAdapters, > ObjectAdapter.Functions.getObject())); > > return visibleObjects; > > Now I explain my problem. > > I have for example this property defined in one of my entities. > > private SortedSet customSelectedProducts =3D new TreeSet(); > > public SortedSet getCustomSelectedProducts() { > return this.customSelectedProducts; > } > > public void setCustomSelectedProducts( > final SortedSet customSelectedProducts) { > this.customSelectedProducts =3D customSelectedProducts; > } > > And when I try to get his value, I received: > > java.lang.ClassCastException: java.util.ArrayList cannot be cast to > java.util.SortedSet > > You will see that you return always an ArrayList when it's a Collection, > but maybe there is other kind of collections (SortedSet in my case) and i= t > will failed on get method. > > I did some dirty and not to well modification for performance to work wit= h > it in order to advance changing next code: > > final List visibleObjects =3D Lists.newArrayList( > Iterables.transform(visibleAdapters, > ObjectAdapter.Functions.getObject())); > > return visibleObjects; > * > **to* > > ((Collection) collectionOrArray).clear(); > ((Collection) collectionOrArray).addAll(Lists.newArrayList( > Iterables.transform(visibleAdapters, > ObjectAdapter.Functions.getObject()))); > > return collectionOrArray; > > I have the same problem in method "*invoke*" from class > "*ActionInvocationFacetForDomainEventAbstract*" and I fixed it with a > similar way than last mail: > > final List visibleObjects =3D > Lists.newArrayList(Lists.transform( > visibleAdapters, ObjectAdapter.Functions.getObject())); > final ObjectAdapter visibleObjectsAsAdapter =3D > getAdapterManager().adapterFor(visibleObjects); > > *to* > > ((Collection) result).clear(); > ((Collection) > result).addAll(Lists.newArrayList(Lists.transform(visibleAdapters, > ObjectAdapter.Functions.getObject()))); > > final ObjectAdapter visibleObjectsAsAdapter =3D > this.getAdapterManager().adapterFor(result); > > I hope you're well. > > Best regards and thanks. > > -- > Ignacio C=C3=A1novas Rej=C3=B3n > Tel. 902 900 231 > Fax 96 353 19 09 > n.canovas@gesconsultor.com > www.gesconsultor.com > > Este mensaje y los ficheros anexos son confidenciales. Los mismos > contienen informaci=C3=B3n reservada que no puede ser difundida. Si usted= ha > recibido este correo por error, tenga la amabilidad de eliminarlo de su > sistema y avisar al remitente mediante reenv=C3=ADo a su direcci=C3=B3n e= lectr=C3=B3nica; > no deber=C3=A1 copiar el mensaje ni divulgar su contenido a ninguna perso= na. > > Su direcci=C3=B3n de correo electr=C3=B3nico junto a sus datos personales= constan en > un fichero titularidad de GESDATOS SOFTWARE S.L. cuya finalidad es la de > mantener el contacto con Ud. Si quiere saber de qu=C3=A9 informaci=C3=B3n= disponemos > de Ud., modificarla, y en su caso, cancelarla, puede hacerlo enviando un > escrito al efecto, acompa=C3=B1ado de una fotocopia de su D.N.I. a la sig= uiente > direcci=C3=B3n: GESDATOS SOFTWARE S.L. Av. Cortes Valencianas 50-1=C2=BA-= C, C.P. > 46015 de Valencia. Asimismo, es su responsabilidad comprobar que este > mensaje o sus archivos adjuntos no contengan virus inform=C3=A1ticos, y e= n caso > que los tuvieran eliminarlos. > > > > --- > El software de antivirus Avast ha analizado este correo electr=C3=B3nico = en > busca de virus. > http://www.avast.com > --001a113de654b47181051dba97a4--