in which EO behalf a ValueFactory works?

2018-08-22 Thread ocs@ocs
Hi there,

quite unrelated to the other things, I would need to exploit the 
ValueFactory/ValueConversion support of EOF to store my own complex values in 
BLOBs.

There's a catch though: for a ValueFactory-generated object, I would need to 
know which EO it belongs to (so that, iff the object's own internal state 
changes, it can change the EO contents appropriately).

Is there any way to do that?

If important, here's the rationale: so far, I have used two distinct 
attributes, conceptually like this:

===
class DBSomething extends ERXCustomObject {
  NSData attributeBlob() { storedValueForKey("attributeBlob") } // modelled. 
Never used directly, but for the cases below
  MyCustomObject attribute() { new 
MyCustomObject(attributeBlob,this,"attributeBlob") }
}
class MyCustomObject {
  MyCustomObject(NSData contents, ERXEnterpriseObject owner, String key) {
... ...
NSData blobRepresentation() { ... ... }
void didChange() { owner.takeStoredValueForKey(blobRepresentation(), key) }
}
===

but it seems to me it would be cleaner if I could defer creation of 
MyCustomObject to the ValueFactory, storing the changes to the ValueConversion, 
and get rid of the ugly dichotomy of foo and fooBlob, removing fooBlob 
completely and seeing only foo (of type MyCustomObject) at the code level.

Thanks and all the best,
OC

 ___
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


Weird D2W rule selection

2018-08-22 Thread Markus Ruggiero
I just had a debugging session with a customer. He complained that 
"CreateProduct" page conf did not list the correct displayPropertyKeys. And 
indeed they are wrong. But why?

Rule I want to work (list of properties truncated to anonymize the customer):

100 : (pageConfiguration = 'CreateProduct' and region = 'europe') => 
displayPropertyKeys = ("productCode",  ) 
[com.webobjects.directtoweb.Assignment](list of properties I want)

Rule that actually fires

100 : pageConfiguration = 'CreateProduct' => displayPropertyKeys = 
("productCode", ) [com.webobjects.directtoweb.Assignment]   (fallback rule 
with different list of properties

That can be when region is not properly defined, BUT it is.

Opening D2W debug output in the resulting browser shows at the very top when 
hovering over the "?" the list from the second, less qualified rule
When entering "displayPropertyKeys into the little debug textfield I do get the 
expected list of properties (the one for 'europe').

When manually asking for the displayPropertyKeys the first rule fires (which is 
what I expect) but the D2W template resolves via the second rule. Even reducing 
the priority of that rule to e.g. 80 does not give prio to the more qualified 
first rule. D2WTraceRuleFiringEnabled shows what is displayed in the app.

Other pageConfigurations like EditProduct have similar rules but there the rule 
with "region" is firing - as it should.

I inject the region code into d2wContext in the PageWrapper.awake() with the 
fillowing code lines:

public void awake() {
super.awake();
D2WContext ctx = d2wContext();
if (ctx != null) {
Application application = (Application)Application.application();
ctx.takeValueForKey( application.region().code(), "region" );
}
}

public D2WContext d2wContext() {
if (context().page() instanceof D2WPage) {
D2WPage d2wPage = (D2WPage) context().page();
return d2wPage.d2wContext();
}
return null;
}

Any idea why this happens? Could this be a timing issue?

---markus---
 ___
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


OSCPool/EO stack management/relaunch (was: Should ERXEC get sharedEC automagically?)

2018-08-22 Thread ocs@ocs
Chuck,

hmmm... coudn't I somehow switch off temporarily the OSCPool, so that the 
initialisation code happens precisely as if there was no pool at all, and only 
then, when done, the pool starts behaving as normally? Actually I could benefit 
— if it is possible — from that, not only due to the SEC, but for other reasons 
as well (it would help if I could run the initialisation code against the DB in 
the “isolation=serializable/locking=pessimistic” mode, switching to 
“isolation=read_committed/locking=optimistic” for the normal processing).

The init code just reads some objects from the db (including 
INFORMATION_SCHEMA, which is the reason for the DB mode), checks them, 
potentially updates them, and that's that — if at this moment the application 
quits and immediately runs again without the init code, it would work just as 
well. But for the objects in the shared EC, there's no EO which the init code 
would create/fetch and a later session-based code would use anyhow.

I might switch off the SEC for the initialisation completely: I would run the 
init code using an EC with its SEC explicitly set to null, then somehow trash 
the init EO stack completely and start afresh with a new one (or ones with 
OSCPool) and normal session-based processing.

Can this, i.e.,

- to begin without OSCPool and connecting to DB in the 
“isolation=serializable/locking=pessimistic” mode;
- do some stuff (without SEC), save changes;
- completely trash the EO stack;
- create a new one with OSCPool connecting to DB in the 
“isolation=read_committed/locking=optimistic” mode with SEC, and run happily 
ever after

be done in some cleaner way than, well, restarting the application — which with 
some trickery exploiting Auto Recover in JavaMonitor might even prove possible, 
but would be super-ugly and I would rather do without?

Thanks,
OC

> On 22 Aug 2018, at 5:11 AM, Chuck Hill  wrote:
> 
> That is a good question.  I’ve not used the combination.   There must be some 
> code that uses the default instead of getting the SEC from the 
> EOEditingContext.  There is a lot of code in Wonder (and some in WO) that 
> assumes the defaultWhatever is the only one that will ever exist.  You would 
> have to step into the code to see where this is happening, or enable the 
> logging of stack traces of fetches.  It should be a simple fix once you find 
> the spot.
>  
> Chuck
>  
> From: "ocs@ocs" mailto:o...@ocs.cz>>
> Date: Tuesday, August 21, 2018 at 1:02 PM
> To: Chuck Hill mailto:ch...@gevityinc.com>>
> Cc: "webobjects-dev@lists.apple.com " 
> mailto:webobjects-dev@lists.apple.com>>
> Subject: Re: Should ERXEC get sharedEC automagically?
>  
> Indeed! If I switch off the OSCPool, it starts to work properly.
>  
> Thanks just again! 
>  
> Nevertheless, I still must be missing something of grave importance, for with 
> OCSPool (I use ), I would presume the SEC for the pool being currently used 
> by the ERXEC would load the shared objects?
>  
> It does not: the global one does automatically load the shared objects, but 
> the SEC-based one of ERXEC remains empty.
>  
> Note: the code in question does not run in a session context; it is performed 
> at launch, before the first session is created. Might that be important 
> perhaps?
>  
> All the best,
> OC
>  
> 
> 
> On 21 Aug 2018, at 9:42 PM, Chuck Hill  > wrote:
>  
> Are you using the ERXObjectStoreCoordinatorPool?  It keeps one SEC per pool, 
> not one shared globally.  
> EOSharedEditingContext.defaultSharedEditingContext() is the global one.
>  
> Chuck
>  
> From: "ocs@ocs" mailto:o...@ocs.cz>>
> Date: Tuesday, August 21, 2018 at 12:23 PM
> To: Chuck Hill mailto:ch...@gevityinc.com>>
> Cc: "webobjects-dev@lists.apple.com " 
> mailto:webobjects-dev@lists.apple.com>>
> Subject: Re: Should ERXEC get sharedEC automagically?
>  
> P.S. It seems ERX completely ignores the default shared EC, using its own 
> one. If I try e.g., this:
>  
> ===
> println "The default sharedEC is 
> ${EOSharedEditingContext.defaultSharedEditingContext()}"
> 6.times {
> def e=ERXEC.newEditingContext()
> println "EC $e gets sec $e.sharedEditingContext"
> }
> println "The default sharedEC still is 
> ${EOSharedEditingContext.defaultSharedEditingContext()}"
> ===
>  
> it looks like this:
>  
> ===
> The default sharedEC is 
> com.webobjects.eocontrol.EOSharedEditingContext@26bbe604
> 2005 [main] INFO er.extensions.eof.ERXObjectStoreCoordinatorPool  - 
> initializing Pool...
> 2008 [main] INFO er.extensions.eof.ERXObjectStoreCoordinatorPool  - 
> initializing Pool finished
> EC er.extensions.eof.ERXEC@40e32762 gets sec 
> com.webobjects.eocontrol.EOSharedEditingContext@5875de6a
> EC er.extensions.eof.ERXEC@7d78f3d5 gets sec 
> com.webobjects.eocontrol.EOSharedEditingContext@5875de6a
> EC er.extensions.eof.ERXEC@f5b6e78 gets sec 
> com.webobjects.eocontrol.EOSharedEditingContext@5875de6a
> EC 

Re: Should loading a shared object try to fetch? (was: Should ERXEC get sharedEC automagically?)

2018-08-22 Thread ocs@ocs
Chuck,

> On 22 Aug 2018, at 5:03 AM, Chuck Hill  wrote:
> Assuming that we are looking at the same version of ERXGenericRecord

Probably we are: I have downloaded Wonder-Applications.tar.gz just yesterday, 
to replace v6 which I have been using before. The ERExtension framework's 
Info.plist says “7.1-SNAPSHOT”. Is there a build # or a build time somewhere in 
the frameworks to check?

The main problem was that yesternight, I have been a bit at the sleepy side, 
and I have pursued a wrong exception (caused, it seems, by a bug in my catch 
block); terribly sorry I have bothered you with that, too :/

What really happens there is that faultWithPrimaryKeyValue — the first time it 
is called, which also is the first time the DB is accessed at all — causes the 
SEC to initialise, load the shared objects... and then throws

java.lang.IllegalArgumentException: The shared context recently initialized the 
object  which is already registered in this context.  
Objects must be unique in both contexts.

(full trace for reference below, caused directly by WO code, alas, so we can't 
check the source).

Far as I understand this, I sort of suspect with faultWithPrimaryKeyValue the 
following might be what happens:

(i) ERXEC.faultWithPrimaryKeyValue somehow starts with creating a globalID for 
entity/PK and registering it itself (even though the ERXEC has a SEC)
(ii) further processing on-demand creates the DB stack, which creates the SEC 
yadda yadda...
(iii) ... and SEC dutifully loads the shared objects
(iv) and, the inconsistence betw. a shared object just loaded into SEC and the 
registered gid of (i) is found and throws.

To make sure it is not caused by the fact that at the moment of the first 
faultWithPrimaryKeyValue the ERXEC has not a SEC yet (for no DB operation has 
been performed yet and thus 
EODefaultSharedEditingContextWasInitializedNotification did not come yet), I 
tried to add

===
if (!ec.sharedEditingContext) 
ec.sharedEditingContext=EOSharedEditingContext.defaultSharedEditingContext()
object=EOUtilities.faultWithPrimaryKeyValue(ec,ename,pk)
===

but that did not help. Then, recalling with objectWithPrimaryKeyValue it did 
work (but for the superfluous fetch), I have tried

===
if (!ec.sharedEditingContext) 
object=EOUtilities.objectWithPrimaryKeyValue(ec,ename,pk)
else
  object=EOUtilities.faultWithPrimaryKeyValue(ec,ename,pk)
===

and this did help: the first time, objectWithPrimaryKeyValue is called, causes 
the SEC to initialise and load shared EOs without any problem (but for, of 
course, the superfluous harmless SELECT being sent to DB). From the time on, 
faultWithPrimaryKeyValue is being used, and it works as expected — no fetch, 
shared EOs returned directly.

Well work it does, but isn't that a super-ugly contraption? :(

Incidentally, since yesternight I have added awakeFromInsertion logging, I have 
found another suspicious thing: for the shared EOs (loaded as a side-effect of 
the first objectWithPrimaryKeyValue call) I do not get awakeFromInsertion at 
all! (Before I haven't noticed, for I did not log it.) The sharedEC loads all 
the shared objects all right, but never awakeFromInsertion comes. Is this the 
intended behaviour?

Aside of that, quite unimportant followup:

> the NPE is from here:
>  
> EOGlobalID gid = 
> editingContext.globalIDForObject(this);
> if (gid.isTemporary()) {
>  
> That suggests that editingContext != this.editingContext()

Just before super.awakeFromInsertion, this.EC has been null; that caused the 
problem.

> In other words, that the object is registered in an editing context that is 
> different from the parameter to the awakeFromInsertion method.  Can you check 
> what ECs those are?  I am not sure how you would get them to be different…

The mess has been caused by a bug in my exception handler, which I have alas 
overlooked — before trying faultWithPrimaryKeyValue the handler has never been 
used :)

> Also, I see two awakeFromInsertion methods in your code:
> at 
> cz.ocs.model.OCSEnterpriseObject.super$4$awakeFromInsertion(OCSEnterpriseObject.groovy)
> and
> at 
> cz.ocs.model.OCSEnterpriseObject.awakeFromInsertion(OCSEnterpriseObject.groovy:265)
>  // [*]
>  
> Or that just an artifact from using Groovy?

Yup, for some reason, the thing inserts its own stub for each supercall.

Thanks and all the best,
OC

Here's the full trace of the real exception:
===
java.lang.IllegalArgumentException: The shared context recently initialized the 
object  which is already registered in this context.  
Objects must be unique in both contexts.
at 
com.webobjects.eocontrol.EOEditingContext._processInitializedObjectsInSharedContext(EOEditingContext.java:2602)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 

Re: Replacing the delete button in a D2W ListTask

2018-08-22 Thread Savas Celik
Hello Fabian,

Thank you for replying.
It works perfectly now.

Savas

> On 22 Aug 2018, at 10:53, Fabian Peters  wrote:
> 
> Hi Savas,
> 
> This will add a "fooAction" on the right side:
> 
> 100 : pageConfiguration = 'ListAddress' => actions = {"right" = 
> ("deleteAction", "fooAction"); } [com.webobjects.directtoweb.Assignment]
> 
> And this will tell D2W which component to use for it:
> 
> 100 : propertyKey = 'fooAction' => componentName = "FooButton" 
> [com.webobjects.directtoweb.Assignment]
> 
> Fabian
> 
> P.S.: Please keep the mails on the list.
> 
>> Am 22.08.2018 um 10:41 schrieb Savas Celik :
>> 
>> Thank you very much Fabian, 
>> 
>> the first rule works it's replacing the delete button. But what if, I do not 
>> want to replace it but just add a custom button next to it? How would this 
>> work?
>> 
>> Savas
>>> On 22 Aug 2018, at 09:19, Fabian Peters  wrote:
>>> 
>>> Hi Savas,
>>> 
>>> That's certainly possible. This rule in ERModernLook should be the one to 
>>> modify:
>>> 
>>> 20 : (look = 'ERModernLook' and propertyKey = 'deleteAction') => 
>>> componentName = "ERMDDeleteButton" 
>>> [com.webobjects.directtoweb.Assignment]:Default modern button component 
>>> names
>>> 
>>> There's also ERMDRemoveRelatedButton, which is used in 
>>> ERMODEditRelationshipPage:
>>> 
>>> 20 : (look = 'ERModernLook' and propertyKey = 'removeRelatedAction') => 
>>> componentName = "ERMDRemoveRelatedButton" 
>>> [com.webobjects.directtoweb.Assignment]:Default modern button component 
>>> names
>>> 
>>> Fabian
>>> 
 Am 22.08.2018 um 08:18 schrieb Savas Celik :
 
 Hello,
 
 how can I replace the delete button with a custom made button in a list 
 task? or is this even possible?
 
 Thanks in advance.
 Savas
 ___
 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/lists.fabian%40e-lumo.com
 
 This email sent to lists.fab...@e-lumo.com
>>> 
>> 
> 

 ___
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: Replacing the delete button in a D2W ListTask

2018-08-22 Thread Fabian Peters
Hi Savas,

This will add a "fooAction" on the right side:

100 : pageConfiguration = 'ListAddress' => actions = {"right" = 
("deleteAction", "fooAction"); } [com.webobjects.directtoweb.Assignment]

And this will tell D2W which component to use for it:

100 : propertyKey = 'fooAction' => componentName = "FooButton" 
[com.webobjects.directtoweb.Assignment]

Fabian

P.S.: Please keep the mails on the list.

> Am 22.08.2018 um 10:41 schrieb Savas Celik :
> 
> Thank you very much Fabian, 
> 
> the first rule works it's replacing the delete button. But what if, I do not 
> want to replace it but just add a custom button next to it? How would this 
> work?
> 
> Savas
>> On 22 Aug 2018, at 09:19, Fabian Peters  wrote:
>> 
>> Hi Savas,
>> 
>> That's certainly possible. This rule in ERModernLook should be the one to 
>> modify:
>> 
>> 20 : (look = 'ERModernLook' and propertyKey = 'deleteAction') => 
>> componentName = "ERMDDeleteButton" 
>> [com.webobjects.directtoweb.Assignment]:Default modern button component names
>> 
>> There's also ERMDRemoveRelatedButton, which is used in 
>> ERMODEditRelationshipPage:
>> 
>> 20 : (look = 'ERModernLook' and propertyKey = 'removeRelatedAction') => 
>> componentName = "ERMDRemoveRelatedButton" 
>> [com.webobjects.directtoweb.Assignment]:Default modern button component names
>> 
>> Fabian
>> 
>>> Am 22.08.2018 um 08:18 schrieb Savas Celik :
>>> 
>>> Hello,
>>> 
>>> how can I replace the delete button with a custom made button in a list 
>>> task? or is this even possible?
>>> 
>>> Thanks in advance.
>>> Savas
>>> ___
>>> 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/lists.fabian%40e-lumo.com
>>> 
>>> This email sent to lists.fab...@e-lumo.com
>> 
> 

 ___
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: Replacing the delete button in a D2W ListTask

2018-08-22 Thread Fabian Peters
Hi Savas,

That's certainly possible. This rule in ERModernLook should be the one to 
modify:

20 : (look = 'ERModernLook' and propertyKey = 'deleteAction') => componentName 
= "ERMDDeleteButton" [com.webobjects.directtoweb.Assignment]:Default modern 
button component names

There's also ERMDRemoveRelatedButton, which is used in 
ERMODEditRelationshipPage:

20 : (look = 'ERModernLook' and propertyKey = 'removeRelatedAction') => 
componentName = "ERMDRemoveRelatedButton" 
[com.webobjects.directtoweb.Assignment]:Default modern button component names

Fabian

> Am 22.08.2018 um 08:18 schrieb Savas Celik :
> 
> Hello,
> 
> how can I replace the delete button with a custom made button in a list task? 
> or is this even possible?
> 
> Thanks in advance.
> Savas
> ___
> 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/lists.fabian%40e-lumo.com
> 
> This email sent to lists.fab...@e-lumo.com

 ___
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


Replacing the delete button in a D2W ListTask

2018-08-22 Thread Savas Celik
Hello,

how can I replace the delete button with a custom made button in a list task? 
or is this even possible?

Thanks in advance.
Savas
 ___
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