Print Page | Close Window

Where to place Business rules

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2603
Printed Date: 29-Jul-2026 at 8:30pm


Topic: Where to place Business rules
Posted By: rbautistaole
Subject: Where to place Business rules
Date Posted: 01-Apr-2011 at 6:42pm
Hi.
I´m evaluating DevForce and i have any questions about the place for some business rules.
 
Imagine an use case to place a purchase order. In the process when a product is selected to the order, i want to verify the existences for the product (how you suggest implement this calidation rule?) , later when the order is placed, in the server i want to make the same validation BUT WITH FRESH stock items, since the stock may be changed in the interim, and if all is correct, then the existences must be updated maybe creating a stock object, or updating a field in the product object.
 
Can you give to me a suggest to implement ths use cas with devforce?
 
With RIA SERVICES I think isolated the business rules in a Domain Service to purchase orders.
 
Excuse my bad english.
 



Replies:
Posted By: DenisK
Date Posted: 04-Apr-2011 at 7:57pm
Hi rbautistaole;

If I understand correctly, you want to do the following:

1. You have a customer who wants to purchase a product.

2. You present the customer with the product.

3. When the customer commits the purchase order, you want to check whether the product is still in stock because it's possible for another customer to buy the last product.

For this use case, I believe the appropriate way to handle it is using concurrency.

This is quite a broad topic in DevForce. See if this can get you started.

http://drc.ideablade.com/xwiki/bin/view/Documentation/save-concurrency - http://drc.ideablade.com/xwiki/bin/view/Documentation/save-concurrency

I hope I've understood your requirement correctly. If not, please feel free to let me know.


Posted By: Hunter
Date Posted: 08-Apr-2011 at 9:35am

DenisK,

I have the same question, but it is not related to concurrency.
 
I have other subprocesses related to system-to-system communication that I want to execute.
 
So, I save a transaction and the state of that transaction changes to a state that lets the system know that it now needs to send send a message to another system. I like being able to just change the state of a field on a record and save it, but I do not see how to make DevForce have a server side process that inspects this save and then does other work based on the state and possible reject the state if the other system is down. (I know this last part can be debated, but in the current architecture there is no middleware that can be used to store the message if the other system is down.) 
 
I look forward to learning how to do this in DevForce.
 
Take care...


Posted By: DenisK
Date Posted: 11-Apr-2011 at 11:56am
Hi Hunter;

Based on this statement,

"how to make DevForce have a server side process that inspects this save......."

it sounds like you want to intercept and inspect the save. We can do this by using EntityServerSaveInterceptor. Please see the following links for further details.

http://drc.ideablade.com/xwiki/bin/view/Documentation/save-lifecycle-server - http://drc.ideablade.com/xwiki/bin/view/Documentation/save-lifecycle-server

http://drc.ideablade.com/ApiDocumentation/webframe.html?IdeaBlade.EntityModel.Server~IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor~AuthorizeSave.html - http://drc.ideablade.com/ApiDocumentation/webframe.html?IdeaBlade.EntityModel.Server~IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor~AuthorizeSave.html

I hope this is what you're looking for. If not, please let me know.


Posted By: rbautistaole
Date Posted: 11-Apr-2011 at 6:48pm
Hi again.
 
My requeriments is more like Hunter described. I have many scenarios for this, as example:
1.- I have a multilevel net of objects where the cost of an object is the sum of the previous level of objects, in such case i want to make persistent the cost of the object as the sum of your object components to avoid load the full net when i need the cost of a object in top levels. For this, in legacy implementation when a object in low level is saved i recalculate the cost of the parent level as cost += objectchild.cost - objectchild.originalcost.
2.- When i save a purchase order item, i need to CREATE an object to save the  stock for the associated product, i need intercept the save of purchase order item an as part of the same transaction create the stock item.
 
I dont like the save interceptor because i think that the onsaving event should be an "as class" event to encapsulate the logic by each class and not for all class entities. (I have used XPOBJECT ORM by DevExpress and using the Onsaving event in my object to ths business rules)
 
Do you have another alternative to my requeriments?
thanks.


Posted By: DenisK
Date Posted: 12-Apr-2011 at 12:20pm
Hi rbautistaole;

It sounds like you want a better separation of concerns and granularity with EntityServerSaveInterceptor. This has been added as a feature request. According to the lead developer, this is planned for 6.1.1 release. As of now, another alternative could be the Remote Server Methods.  http://drc.ideablade.com/xwiki/bin/view/Documentation/rsmc-query - http://drc.ideablade.com/xwiki/bin/view/Documentation/rsmc-query




Posted By: s_tristan
Date Posted: 13-Apr-2011 at 6:04am
Is there an estimate when release 6.1.1 will be available?


Posted By: DenisK
Date Posted: 13-Apr-2011 at 10:26am
Hi s_tristan;

6.1.1 will be released around mid June.



Print Page | Close Window