Manually break an object rule on parent

Manually break an object rule on parent

Old forum URL: forums.lhotka.net/forums/t/12479.aspx


swegele posted on Wednesday, March 12, 2014

Working on a project where there is missing Ref Int on the SQL database.  Business objects have to handle scenario of missing data by IDs.  (ugh I know).

During lazyload of child collection, if I detect there is some piece of data missing from the DB, I skip loading that child.

But I would like to provide feedback (Warning rule) on Parent that alerts user that the BusinessObjects have detected a referential integrity problem and what are the IDs associated with the problem.  This would give the customer some very helpful information to give to their DBA to go fix the issue.

How would I have the child collection tell the root/parent to break a warning rule with relevant info?

How would I write the rule on the root/parent so it only gets broken when the child collection says so.

Seems like broken rules is a good place to put this, maybe I am wrong?


Thanks

Sean

JonnyBee replied on Thursday, March 13, 2014

Hi,

The obvious solution is to have a broken rule with severity Warning and visualize this in some way on your client.

YOU SHOULD NOT INTERACT WITH BROKEN RULES DIRECTLY!!!

The RuleEngine assumes ownership and will clear these rules (and rerun rules) whenever it needs to.

So the recommended solution is to

  1. make the data access/child set a field/property on the parent object to a given value
  2. make this trigger a business rule in the parent object (different techniques for property and object level rules)
  3. make this rule inspect the given value and set the result to a Warning message. 

OR

just add a new text property on the parent object and set in your data access to a given message and display this in your form.

 

Copyright (c) Marimer LLC