isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nacho Cánovas Rejón <n.cano...@gesconsultor.com>
Subject ISIS-1044 issue with Collections
Date Thu, 20 Aug 2015 08:39:45 GMT
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 = 
ObjectAdapter.InvokeUtils.invoke(method, owningAdapter);

*NEW Code*

final Object collectionOrArray = 
ObjectAdapter.InvokeUtils.invoke(method, owningAdapter);

final ObjectAdapter collectionAdapter = 
getAdapterManager().adapterFor(collectionOrArray);

final FacetedMethod facetedMethod = (FacetedMethod) getFacetHolder();
final Class<?> collectionElementType = facetedMethod.getType();

final List<ObjectAdapter> visibleAdapters =
         ObjectAdapter.Util.visibleAdapters(
                 collectionAdapter,
                 authenticationSession, deploymentCategory);
final List<Object> visibleObjects = 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<Product> customSelectedProducts = new TreeSet<Product>();

public SortedSet<Product> getCustomSelectedProducts() {
     return this.customSelectedProducts;
}

public void setCustomSelectedProducts(
         final SortedSet<Product> customSelectedProducts) {
     this.customSelectedProducts = 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 
it will failed on get method.

I did some dirty and not to well modification for performance to work 
with it in order to advance changing next code:

final List<Object> visibleObjects = 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<Object> visibleObjects =
         Lists.newArrayList(Lists.transform(
                 visibleAdapters, ObjectAdapter.Functions.getObject()));
final ObjectAdapter visibleObjectsAsAdapter = 
getAdapterManager().adapterFor(visibleObjects);

*to*

((Collection<Object>) result).clear();
((Collection<Object>) 
result).addAll(Lists.newArrayList(Lists.transform(visibleAdapters, 
ObjectAdapter.Functions.getObject())));

final ObjectAdapter visibleObjectsAsAdapter = 
this.getAdapterManager().adapterFor(result);

I hope you're well.

Best regards and thanks.

-- 
Ignacio Cánovas Rejón
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ón 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ío a su dirección electrónica;
no deberá copiar el mensaje ni divulgar su contenido a ninguna persona.

Su dirección de correo electrónico 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é información disponemos de Ud., modificarla, y en su caso, cancelarla, puede hacerlo
enviando un escrito al efecto, acompañado de una fotocopia de su D.N.I. a la siguiente dirección:
GESDATOS SOFTWARE S.L. Av. Cortes Valencianas 50-1º-C, C.P.  46015 de Valencia. Asimismo,
es su responsabilidad comprobar que este mensaje o sus archivos adjuntos no contengan virus
informáticos, y en caso que los tuvieran eliminarlos.



---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
http://www.avast.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message