Re: Tweaking the model on start-up

2016-06-03 Thread Paul Hoadley
Hi Mark,

On 3 Jun 2016, at 5:44 AM, Mark Gowdy  wrote:

> Is there a convenient way to update an Entity details when the app starts up?
> 
> e.g.
> 'Model Framework’ (A) has an Entity called ‘User’
> ‘Model Framework’ (B) has an Entity called ‘Hub’ that is joined (to-one) with 
> to ‘User’
> i.e.
> com.B.Hub   —> com.A.User
> (where ‘User’ knows nothing about ‘Hub’, it is out of scope)
> 
> I can create a class in (B) called 
> com.B.User extends com.A.User

At the risk of being that guy on the list who doesn’t answer your specific 
question, but veers off to discuss a semi-related topic, have you considered 
using partial entities?

https://jenkins.wocommunity.org/job/Wonder7/lastSuccessfulBuild/javadoc/er/extensions/partials/package-summary.html
 


If User was your framework-level base entity, and you needed a domain-specific 
User-like entity in another context, you could create com.B.BUser as a partial 
entity on com.A.User, adding the to-many relationship com.B.BUser.hubs right 
there in the model. The only obvious caveat here is that you describe B as a 
“Model Framework” as well, in which case you couldn’t have any _further_ 
specialisation of User via partial entities (as a partial entity cannot augment 
another partial) if you needed something more at the application level.

In any case, if this pattern fits, we’ve been using partial entities for years. 
The package is completely stable.


-- 
Paul Hoadley
http://logicsquad.net/



 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Tweaking the model on start-up

2016-06-03 Thread Chuck Hill
Ugh.  Have a look at ERXEntityClassDescription$Factory.  It does not deal well 
with this.  A sub-class of Factory is one way to approach this.  Make 
registerDescriptionForEntity public and call it.  Though you might need to get 
rid of the old class description.

Another way is to listen for the EntityLoadedNotification and change the class 
there.  That should be before ERXEntityClassDescription$Factory gets involved.

Chuck

From: Mark Gowdy 
Date: Friday, June 3, 2016 at 4:50 AM
To: Chuck Hill 
Cc: WebObjects-Dev 
Subject: Re: Tweaking the model on start-up


On 3 Jun 2016, at 11:49, Mark Gowdy mailto:m...@gowdy.co.uk>> 
wrote:


On 2 Jun 2016, at 21:18, Chuck Hill 
mailto:ch...@gevityinc.com>> wrote:

finishInitialization() in your application.

I have attempted to tweak my ‘User’ entity at 
‘Application.finishInitialization()’,
But when the app tries to get a User object, it blows up:

ERROR er.extensions.eof.ERXEntityClassDescription  - Unable to register 
descriptions for class: class com.es.eo.User
RuntimeException: Dummy
  at 
er.extensions.eof.ERXEntityClassDescription$Factory.registerDescriptionForClass(ERXEntityClassDescription.java:615)
  at 
er.extensions.eof.ERXEntityClassDescription$Factory.classDescriptionNeededForClass(ERXEntityClassDescription.java:392)

The smallest change that causes the error above is:
---
EOEditingContext tmpEc = ERXEC.newEditingContext();
EOEntity entity = EOUtilities.entityNamed(tmpEc, "User");
entity.setClassName("com.es.eo.User"); // changed from 'com.mg.users.eo.User'
---

I guess I need to re-initialise or register something, but I am not sure what 
exactly.

I discovered that the other tweaks to the model (adding the ‘User' —>> ‘Hubs’) 
actually worked.

My problem appears to primarily be the class name change.
It looks like I need to register it somehow.  Any ideas?

Mark




Thanks,

Mark



Chuck


From: 
mailto:webobjects-dev-bounces+chill=gevityinc@lists.apple.com>>
 on behalf of Mark Gowdy mailto:m...@gowdy.co.uk>>
Date: Thursday, June 2, 2016 at 1:14 PM
To: WebObjects-Dev 
mailto:webobjects-dev@lists.apple.com>>
Subject: Tweaking the model on start-up

Hi,

Is there a convenient way to update an Entity details when the app starts up?

e.g.
'Model Framework’ (A) has an Entity called ‘User’
‘Model Framework’ (B) has an Entity called ‘Hub’ that is joined (to-one) with 
to ‘User’
i.e.
com.B.Hub   —> com.A.User
(where ‘User’ knows nothing about ‘Hub’, it is out of scope)

I can create a class in (B) called
com.B.User extends com.A.User

so that I can add the additional set/get code,

and then apply something like this (at start-up):
{
className = "com.B.User";
relationships = (
{
destination = Hub;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = ({destinationAttribute = userID; sourceAttribute = id; });
name = hubs;
}
);
}

Any suggestions?

Mark

_
Mark Gowdy
Gowdy Associates Ltd
Skype: markgowdy





_
Mark Gowdy
Gowdy Associates Ltd
M: +44 7808 400 941
Skype: markgowdy

_
Mark Gowdy
Gowdy Associates Ltd
M: +44 7808 400 941
Skype: markgowdy



 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Tweaking the model on start-up

2016-06-03 Thread Mark Gowdy

> On 3 Jun 2016, at 11:49, Mark Gowdy  wrote:
> 
>> 
>> On 2 Jun 2016, at 21:18, Chuck Hill > > wrote:
>> 
>> finishInitialization() in your application. 
> 
> I have attempted to tweak my ‘User’ entity at 
> ‘Application.finishInitialization()’,
> But when the app tries to get a User object, it blows up:
> 
> ERROR er.extensions.eof.ERXEntityClassDescription  - Unable to register 
> descriptions for class: class com.es.eo.User
> RuntimeException: Dummy
>   at 
> er.extensions.eof.ERXEntityClassDescription$Factory.registerDescriptionForClass(ERXEntityClassDescription.java:615)
>   at 
> er.extensions.eof.ERXEntityClassDescription$Factory.classDescriptionNeededForClass(ERXEntityClassDescription.java:392)
> 
> The smallest change that causes the error above is:
> ---
> EOEditingContext tmpEc = ERXEC.newEditingContext();
> EOEntity entity = EOUtilities.entityNamed(tmpEc, "User");
> entity.setClassName("com.es.eo.User"); // changed from 'com.mg.users.eo.User'
> ---
> 
> I guess I need to re-initialise or register something, but I am not sure what 
> exactly.

I discovered that the other tweaks to the model (adding the ‘User' —>> ‘Hubs’) 
actually worked.

My problem appears to primarily be the class name change.
It looks like I need to register it somehow.  Any ideas?

Mark


> 
> Thanks, 
> 
> Mark
> 
>>  
>> Chuck
>>  
>>  
>> From: > > on 
>> behalf of Mark Gowdy mailto:m...@gowdy.co.uk>>
>> Date: Thursday, June 2, 2016 at 1:14 PM
>> To: WebObjects-Dev > >
>> Subject: Tweaking the model on start-up
>>  
>> Hi,  
>>  
>> Is there a convenient way to update an Entity details when the app starts up?
>>  
>> e.g.
>> 'Model Framework’ (A) has an Entity called ‘User’
>> ‘Model Framework’ (B) has an Entity called ‘Hub’ that is joined (to-one) 
>> with to ‘User’
>> i.e.
>> com.B.Hub   —> com.A.User
>> (where ‘User’ knows nothing about ‘Hub’, it is out of scope)
>>  
>> I can create a class in (B) called 
>> com.B.User extends com.A.User
>>  
>> so that I can add the additional set/get code, 
>>  
>> and then apply something like this (at start-up):
>> {
>> className = "com.B.User";
>> relationships = (
>> {
>> destination = Hub; 
>> isToMany = Y; 
>> joinSemantic = EOInnerJoin; 
>> joins = ({destinationAttribute = userID; sourceAttribute = id; }); 
>> name = hubs; 
>> }
>> );
>> }
>>  
>> Any suggestions?
>>  
>> Mark
>>  
>> _
>> Mark Gowdy
>> Gowdy Associates Ltd
>> Skype: markgowdy
>> 
>> 
>> 
>>  
> 
> _
> Mark Gowdy
> Gowdy Associates Ltd
> M: +44 7808 400 941
> Skype: markgowdy

_
Mark Gowdy
Gowdy Associates Ltd
M: +44 7808 400 941
Skype: markgowdy




 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Tweaking the model on start-up

2016-06-03 Thread Mark Gowdy

> On 2 Jun 2016, at 21:18, Chuck Hill  wrote:
> 
> finishInitialization() in your application. 

I have attempted to tweak my ‘User’ entity at 
‘Application.finishInitialization()’,
But when the app tries to get a User object, it blows up:

ERROR er.extensions.eof.ERXEntityClassDescription  - Unable to register 
descriptions for class: class com.es.eo.User
RuntimeException: Dummy
  at 
er.extensions.eof.ERXEntityClassDescription$Factory.registerDescriptionForClass(ERXEntityClassDescription.java:615)
  at 
er.extensions.eof.ERXEntityClassDescription$Factory.classDescriptionNeededForClass(ERXEntityClassDescription.java:392)

The smallest change that causes the error above is:
---
EOEditingContext tmpEc = ERXEC.newEditingContext();
EOEntity entity = EOUtilities.entityNamed(tmpEc, "User");
entity.setClassName("com.es.eo.User"); // changed from 'com.mg.users.eo.User'
---

I guess I need to re-initialise or register something, but I am not sure what 
exactly.

Thanks, 

Mark

>  
> Chuck
>  
>  
> From:  on behalf 
> of Mark Gowdy 
> Date: Thursday, June 2, 2016 at 1:14 PM
> To: WebObjects-Dev 
> Subject: Tweaking the model on start-up
>  
> Hi,  
>  
> Is there a convenient way to update an Entity details when the app starts up?
>  
> e.g.
> 'Model Framework’ (A) has an Entity called ‘User’
> ‘Model Framework’ (B) has an Entity called ‘Hub’ that is joined (to-one) with 
> to ‘User’
> i.e.
> com.B.Hub   —> com.A.User
> (where ‘User’ knows nothing about ‘Hub’, it is out of scope)
>  
> I can create a class in (B) called 
> com.B.User extends com.A.User
>  
> so that I can add the additional set/get code, 
>  
> and then apply something like this (at start-up):
> {
> className = "com.B.User";
> relationships = (
> {
> destination = Hub; 
> isToMany = Y; 
> joinSemantic = EOInnerJoin; 
> joins = ({destinationAttribute = userID; sourceAttribute = id; }); 
> name = hubs; 
> }
> );
> }
>  
> Any suggestions?
>  
> Mark
>  
> _
> Mark Gowdy
> Gowdy Associates Ltd
> Skype: markgowdy
> 
> 
> 
>  

_
Mark Gowdy
Gowdy Associates Ltd
M: +44 7808 400 941
Skype: markgowdy




 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com