Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Best practice: Running a "server constraint" or DMI after a Queue finishes (and not after every request)

    Hi Isomorphic,

    I'm going to create a function for my product next year where I allow the user to define some kind of process.
    My process will consist of steps:
    1. Do A
    2. If after time n the status did not change, do B
    3. If after time m the status did not change, do C
    4. ...
    The defined process will be executed in PL/SQL as Job, so this is not SmartGWT related. But the process definition is. Here I'll have some general business rules for all user-defined processes disallowing useless combinations.
    A process will be displayed and edited in a ListGrid "SELECT * FROM process where id=4711 ORDER BY position".
    After every change of a row a "server constraint" should run. As the rules depend on many fields and also previous rows(!), I'll either use DataSource.validateRecord() you introduced here or a DMI I call to Create/Update/Remove after request.execute() (on violation of the rules, I'll return new DSResponse.setFailure(reason) then). So far I don't see problems here.

    Now for the easy of editing, also persisted reordering like in this sample should be possible. This always results in a Queue with many operations. Here I only want to run my business-rule-check after the last request in the transaction. My questions are: How do I do this best? I think in validateRecord() can get from context -> getDSRequest() -> getRPCManager() to the RPCManager, but what then? How do I find out I'm not at the last request and should therefore skip my logic? Same for the DMI way, where I also have the RPCManager available: How do I find out I'm in the last request of a Queue?

    Perhaps a boolean DSRequest.isFirstRequest() and boolean DSRequest.isLastRequest() would make sense?

    More abstract: I'm looking for a way to express an INITIALLY DEFERRED constraint (or better: ASSERTION) in SmartGWT server code. How to do this best?
    As this is not planned this year anymore, it is not urgent for me, but I'm very interested in your best practice here.

    For anyone interested in the topic: With some luck, we are going to get CREATE ASSERTION in the next Oracle version, which would be really great IMHO.

    Thank you & Best regards
    Blama

    #2
    validateRecord() is not the right place to put logic that is spans multiple DataSource records.

    You can get an RPCManager in a DMI - it's one of the standard arguments. We would suggest using the RPCManager to detect that you are the last request and then either creating of modifying the existing errors object to add your errors, if they occur.

    You could also put such logic in an override of the IDACall servlet if you prefer.

    Comment

    Working...
    X