incubator-isis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Meyer - KMZ" <ke...@kmz.co.za>
Subject Re: Problem with non-support of Collections as arguments.
Date Fri, 08 Jul 2011 15:33:34 GMT
Hi Iain,

If I understand what you described originally, you have a class 
structure that looks something like:

class YourDomainIsisWrapperClass extends EObjectClass {
...
} 

where EObjectClass is any class that extends EObject (e.g. your 
generated class).


Isis is having a problem when it introspects this 
YourDomainIsisWrapperClass, as EObject has a method "public void 
addAll(int x, java.util.Collection y)", and Isis does not support 
collections in actions.

What Dan is saying is that for all methods (there may be more than 
one) that Isis can't handle because of Collection parameters, you add 
an override in YourDomainIsisWrapperClass:

class YourDomainIsisWrapperClass extends EObjectClass {
...
 // {{ Isis hacks
 @Ignore
 @Override
 public void addAll(int x, java.util.Collection y) {
    super.addAll(x, y);
 }
 //}}
}


The @Ignore annotation should tell Isis to not support that method as 
an action. The method does not need to be invoked, it's mere 
presence is enough to upset Isis.

This solution has not been tested.

This solution should also be static against changes to your generated 
EObjectClass - you will not need to reedit it as your EObjectClass is 
regenerated.

Regards,
Kevin


On 8 Jul 2011 at 11:28, Iain Flynn wrote:

> Hi Dan,
> 
> Sorry it's taken me so long to get back to you. Been moving houses and such, what fun!
> 
> I think your diagnosis seems probable, but I'm not sure how I could
> force an override of it, as none of the generated classes are
> invoking it themselves. I can see a class in a JAR file EMF depends
> on that invokes it, but I'm drawing a blank on how I can get Isis to
> see that operation and ignore it. 
> 
> I can manually strip code to get around the problem, but doing so
> involves repeated work upon each generation of code, so much so that
> I wouldn't really think it practical to employ code generation. 
> 
> If you or anyone else here has some pointers, I'd really appreciate it.
> 
> Thanks for reading and thank you for the help you've given me so far,
> 
> - Iain
> 
> On 28 Jun 2011, at 17:49, dan haywood wrote:
> 
> > Hi Iain,
> > What's (probably) happening here is that the addAll(int, Collection) method
> > is being interpreted as an action, and Isis does not allow actions to take
> > Collections as arguments (only values or entities).
> > 
> > The work-around should be to mark the action using
> > @org.apache.isis.annotation.Ignore.  Since this is an inherited method I
> > guess you'll need to trivially override the method in order to annotate it,
> > ie:
> > 
> > @Ignore
> > @Override
> > public void addAll(int x, java.util.Collection y) {
> >    super.addAll(x, y);
> > }
> > 
> > The above is all slightly theoretical, so let us know if it doesn't work.
> > 
> > An alternative approach might be to use delegation instead of inheritance
> > (ie make the generated class a delegate of a wrapper that Isis sees).
> > 
> > HTH
> > Dan
> > 
> > 
> > 
> > On 28 June 2011 17:41, Iain Flynn <flynni7@cs.man.ac.uk> wrote:
> > 
> >> Hello again.
> >> 
> >> Part of my MSc project involves attempting to generate domain classes from
> >> a model using Emfatic and integrate those with Isis.
> >> 
> >> In order to do this, I have created a wrapper class that inherits from
> >> Emfatic's mandatory EObject supertype while calling all the functions of
> >> AbstractDomainType. I've tested this with hand-coded Isis domain classes and
> >> they work fine.
> >> 
> >> However, implementing the generated domain classes with hand-coded
> >> repositories causes Isis to throw an error, citing EMF's EList's addAll(int,
> >> java.util.Collection) function (which appears to be inherited from
> >> java.util.List rather than being to do with EList).
> >> 
> >> I've searched through my code attempting to see where this is called, with
> >> no success. the EObject supertype does not appear to call it either - it
> >> seems like the very appearance of such a method is causing Isis to throw an
> >> exception (I added a nonsense method with a Collection argument to an
> >> already-working class in an already-working project and Isis threw an
> >> identical exception).
> >> 
> >> Does anyone have any advice?
> >> 
> >> Thank you for reading,
> >> 
> >> - Iain Flynn.
> 


Mime
View raw message