not to water down the Drool initiative this is something I have pondered
on.. if you are familiar with Excel or Spreadsheet they have a programming interface for their macro code. the interface includes a function list you can select functions to add to your macro. The Artifact(webtools) lends it self to the idea of that concept. Html allows selection of from a list similar to Excel, spreadsheet. I selected "BASIC"since that is what business men are use to. If you present to a business man, some thing like Shark, BIRT, Drool they will not use it, but get someone in their organization to do it. Some even freak at Basic. So how can ofbiz beat the competition. Make the interface the way a business man uses tools today. some years back I was commissioned to write an interface to excel that handled Data Warehouse information and make a Cross tab presentation in excel. Then provide Templates for different Departments. I see that same possibility in Ofbiz and programing a openoffice spreadsheet from Ofbiz. the Business man wold, in ofbiz build his application then it would be exported to openoffice like we build pdf now. the business person would still be hooked up to live data through the ofbiz to openoffice interface. The Data model of ofbiz has Budgeting and Budget Scenario that can also be leverage this way. I like the design of Drool but think we need to go one step higher and see this as how to run a business. ========================= BJ Freeman <http://bjfreeman.elance.com> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=52> Specialtymarket.com <http://www.specialtymarket.com/> Systems Integrator-- Glad to Assist Chat Y! messenger: bjfr33man |
BJ - take a look at Guvnor to see a more business end user oriented
environment for drools. On Jul 29, 2010 7:15am, BJ Freeman <[hidden email]> wrote: > not to water down the Drool initiative this is something I have pondered > on.. > if you are familiar with Excel or Spreadsheet they have a programming > interface for their macro code. > the interface includes a function list you can select functions to add to > your macro. > The Artifact(webtools) lends it self to the idea of that concept. > Html allows selection of from a list similar to Excel, spreadsheet. > I selected "BASIC"since that is what business men are use to. > If you present to a business man, some thing like Shark, BIRT, Drool they > will not use it, but get someone in their organization to do it. > Some even freak at Basic. > So how can ofbiz beat the competition. Make the interface the way a > business man uses tools today. > some years back I was commissioned to write an interface to excel that > handled Data Warehouse information and make a Cross tab presentation in > excel. Then provide Templates for different Departments. > I see that same possibility in Ofbiz and programing a openoffice > spreadsheet from Ofbiz. the Business man wold, in ofbiz build his > application then it would be exported to openoffice like we build pdf > now. the business person would still be hooked up to live data through > the ofbiz to openoffice interface. > The Data model of ofbiz has Budgeting and Budget Scenario that can also > be leverage this way. > I like the design of Drool but think we need to go one step higher and > see this as how to run a business. > ========================= > BJ Freeman http://bjfreeman.elance.com> > Strategic Power Office with Supplier Automation > http://www.businessesnetwork.com/automation/viewforum.php?f=52> > Specialtymarket.com http://www.specialtymarket.com/> > Systems Integrator-- Glad to Assist > Chat Y! messenger: bjfr33man |
so how would that integrate with the ofbiz data model?
[hidden email] sent the following on 7/29/2010 4:09 AM: > BJ - take a look at Guvnor to see a more business end user oriented > environment for drools. > > On Jul 29, 2010 7:15am, BJ Freeman <[hidden email]> wrote: >> not to water down the Drool initiative this is something I have >> pondered on.. > >> if you are familiar with Excel or Spreadsheet they have a programming >> interface for their macro code. > >> the interface includes a function list you can select functions to add >> to your macro. > >> The Artifact(webtools) lends it self to the idea of that concept. > >> Html allows selection of from a list similar to Excel, spreadsheet. > >> I selected "BASIC"since that is what business men are use to. > >> If you present to a business man, some thing like Shark, BIRT, Drool >> they will not use it, but get someone in their organization to do it. > >> Some even freak at Basic. > > > >> So how can ofbiz beat the competition. Make the interface the way a >> business man uses tools today. > > > >> some years back I was commissioned to write an interface to excel that >> handled Data Warehouse information and make a Cross tab presentation >> in excel. Then provide Templates for different Departments. > > > >> I see that same possibility in Ofbiz and programing a openoffice >> spreadsheet from Ofbiz. the Business man wold, in ofbiz build his >> application then it would be exported to openoffice like we build pdf >> now. the business person would still be hooked up to live data through >> the ofbiz to openoffice interface. > > > >> The Data model of ofbiz has Budgeting and Budget Scenario that can >> also be leverage this way. > > > >> I like the design of Drool but think we need to go one step higher and >> see this as how to run a business. > > > > > > > > > >> ========================= > >> BJ Freeman http://bjfreeman.elance.com> > >> Strategic Power Office with Supplier Automation >> http://www.businessesnetwork.com/automation/viewforum.php?f=52> > >> Specialtymarket.com http://www.specialtymarket.com/> > >> Systems Integrator-- Glad to Assist > > > >> Chat Y! messenger: bjfr33man > > > > |
Hi BJ, I was responding to your comment:
"I like the design of Drool but think we need to go one step higher and see this as how to run a business." Guvnor has an abstraction on top of drools that is aimed at the business user. I don't know enough about drools to comment on how it would be integrated with the business model. I still have a lot more learning to do around the subject... On Thu, Jul 29, 2010 at 12:32 PM, BJ Freeman <[hidden email]> wrote: > so how would that integrate with the ofbiz data model? > > [hidden email] sent the following on 7/29/2010 4:09 AM: >> >> BJ - take a look at Guvnor to see a more business end user oriented >> environment for drools. >> >> On Jul 29, 2010 7:15am, BJ Freeman <[hidden email]> wrote: >>> >>> not to water down the Drool initiative this is something I have >>> pondered on.. >> >>> if you are familiar with Excel or Spreadsheet they have a programming >>> interface for their macro code. >> >>> the interface includes a function list you can select functions to add >>> to your macro. >> >>> The Artifact(webtools) lends it self to the idea of that concept. >> >>> Html allows selection of from a list similar to Excel, spreadsheet. >> >>> I selected "BASIC"since that is what business men are use to. >> >>> If you present to a business man, some thing like Shark, BIRT, Drool >>> they will not use it, but get someone in their organization to do it. >> >>> Some even freak at Basic. >> >> >> >>> So how can ofbiz beat the competition. Make the interface the way a >>> business man uses tools today. >> >> >> >>> some years back I was commissioned to write an interface to excel that >>> handled Data Warehouse information and make a Cross tab presentation >>> in excel. Then provide Templates for different Departments. >> >> >> >>> I see that same possibility in Ofbiz and programing a openoffice >>> spreadsheet from Ofbiz. the Business man wold, in ofbiz build his >>> application then it would be exported to openoffice like we build pdf >>> now. the business person would still be hooked up to live data through >>> the ofbiz to openoffice interface. >> >> >> >>> The Data model of ofbiz has Budgeting and Budget Scenario that can >>> also be leverage this way. >> >> >> >>> I like the design of Drool but think we need to go one step higher and >>> see this as how to run a business. >> >> >> >> >> >> >> >> >> >>> ========================= >> >>> BJ Freeman http://bjfreeman.elance.com> >> >>> Strategic Power Office with Supplier Automation >>> http://www.businessesnetwork.com/automation/viewforum.php?f=52> >> >>> Specialtymarket.com http://www.specialtymarket.com/> >> >>> Systems Integrator-- Glad to Assist >> >> >> >>> Chat Y! messenger: bjfr33man >> >> >> >> > |
W dniu 2010-07-29 15:14, chris snow pisze:
> Hi BJ, I was responding to your comment: > > "I like the design of Drool but think we need to go one step higher > and see this as how to run a business." > > Guvnor has an abstraction on top of drools that is aimed at the > business user. I don't know enough about drools to comment on how it > would be integrated with the business model. I still have a lot more > learning to do around the subject... > > > source) ERP. But it not like excel. You can write calculation rules but Drools would not order them automatically based on dependencies. (e.g. calc line total before sum of order). But in many ways it is very powerful tool. There are example rules for simple Order (I could send whole project): package com.sample import com.sample.Order; import com.sample.OrderItem import com.sample.OrderTaxLine; import com.sample.OrderTaxSummary; import com.sample.OrderDiscount; import com.sample.Product; import com.sample.Tax; import com.sample.TaxCalculator; import com.sample.Discount; import com.sample.DiscountCalculator; dialect "java" function Tax calcTax(int customerId,int productId) { return TaxCalculator.calculateTax(customerId,productId); } rule "order item price" dialect "mvel" agenda-group "Items" lock-on-active true salience 9 when $item : OrderItem(); then modify($item){ setPrice($item.product.price); } end rule "order item amountNetto" dialect "mvel" lock-on-active true agenda-group "Items" salience 8 when $item : OrderItem(); then modify($item){ setAmountNetto($item.price * $item.quantity); } end rule "order item tax" dialect "mvel" lock-on-active true agenda-group "Items" salience 7 when $item : OrderItem(); then modify($item){ setTaxes(calcTax($item.order.partyDelivery.partyId.intValue(),$item.product.productId.intValue())); } end rule "order item amountTax" dialect "mvel" lock-on-active true agenda-group "Items" salience 6 when $item : OrderItem(); then modify($item){ setAmountTax($item.tax.rateTax * $item.amountNetto); } end rule "order item amountBrutto" dialect "mvel" lock-on-active true agenda-group "Items" salience 5 when $item : OrderItem(); then modify($item){ setAmountBrutto($item.amountNetto + $item.amountTax); } end rule "Switch to Order" dialect "mvel" lock-on-active true agenda-group "Items" salience -100000 when $item : OrderItem(); then drools.setFocus("Order"); end rule "order calucations" dialect "mvel" lock-on-active true agenda-group "Order" salience 4 when $order : Order(); $amountTax : Number() from accumulate (OrderItem( order==$order, amountTax!=null,$amount:amountTax), sum($amount)); then $order.amountTax = $amountTax; end rule "order calucations 2" dialect "mvel" lock-on-active true agenda-group "Order" salience 3 when $order : Order(); $amountNetto : Number() from accumulate (OrderItem( order==$order, amountNetto!=null, $amount:amountNetto), sum($amount)); then $order.amountNetto = $amountNetto; end rule "order calucations 3" dialect "mvel" lock-on-active true agenda-group "Order" salience 2 when $order : Order(amountTax !=null,amountNetto!=null); then $order.amountBrutto = ($order.amountTax + $order.amountNetto); end Maybe facts assertions should not be like above "OrderLine exists" but e.g. "quantity of order line changed" |
In reply to this post by chris snow
Chris that was my first impression of Guvnor as I skimmed it.
but as with Drool I see the integration into the ofbiz model as well as the conversion of the None HTML screens to widgets to be a lot of work. I all for taking parts of Drool. I will present a vocabulary soon for Business Basic. I plan to follow the minilangquage for basis, but not in XML format. My reasoning it there is code for the minilanquage for guts of the compiler, just the syntax has to be done. chris snow sent the following on 7/29/2010 6:14 AM: > Hi BJ, I was responding to your comment: > > "I like the design of Drool but think we need to go one step higher > and see this as how to run a business." > > Guvnor has an abstraction on top of drools that is aimed at the > business user. I don't know enough about drools to comment on how it > would be integrated with the business model. I still have a lot more > learning to do around the subject... > > > On Thu, Jul 29, 2010 at 12:32 PM, BJ Freeman<[hidden email]> wrote: >> so how would that integrate with the ofbiz data model? >> >> [hidden email] sent the following on 7/29/2010 4:09 AM: >>> >>> BJ - take a look at Guvnor to see a more business end user oriented >>> environment for drools. >>> >>> On Jul 29, 2010 7:15am, BJ Freeman<[hidden email]> wrote: >>>> >>>> not to water down the Drool initiative this is something I have >>>> pondered on.. >>> >>>> if you are familiar with Excel or Spreadsheet they have a programming >>>> interface for their macro code. >>> >>>> the interface includes a function list you can select functions to add >>>> to your macro. >>> >>>> The Artifact(webtools) lends it self to the idea of that concept. >>> >>>> Html allows selection of from a list similar to Excel, spreadsheet. >>> >>>> I selected "BASIC"since that is what business men are use to. >>> >>>> If you present to a business man, some thing like Shark, BIRT, Drool >>>> they will not use it, but get someone in their organization to do it. >>> >>>> Some even freak at Basic. >>> >>> >>> >>>> So how can ofbiz beat the competition. Make the interface the way a >>>> business man uses tools today. >>> >>> >>> >>>> some years back I was commissioned to write an interface to excel that >>>> handled Data Warehouse information and make a Cross tab presentation >>>> in excel. Then provide Templates for different Departments. >>> >>> >>> >>>> I see that same possibility in Ofbiz and programing a openoffice >>>> spreadsheet from Ofbiz. the Business man wold, in ofbiz build his >>>> application then it would be exported to openoffice like we build pdf >>>> now. the business person would still be hooked up to live data through >>>> the ofbiz to openoffice interface. >>> >>> >>> >>>> The Data model of ofbiz has Budgeting and Budget Scenario that can >>>> also be leverage this way. >>> >>> >>> >>>> I like the design of Drool but think we need to go one step higher and >>>> see this as how to run a business. >>> >>> >>> >>> >>> >>> >>> >>> >>> >>>> ========================= >>> >>>> BJ Freeman http://bjfreeman.elance.com> >>> >>>> Strategic Power Office with Supplier Automation >>>> http://www.businessesnetwork.com/automation/viewforum.php?f=52> >>> >>>> Specialtymarket.com http://www.specialtymarket.com/> >>> >>>> Systems Integrator-- Glad to Assist >>> >>> >>> >>>> Chat Y! messenger: bjfr33man >>> >>> >>> >>> >> > |
In reply to this post by Marek Mosiewicz-2
Thanks that looks like beanshell or Groovy type of code.
this goes along with the openoffice macro code flexibility. At a business level would like to follow that macro type of formulation but expose ofbiz services like the Artifacts (webtools) At this point I am aiming this for business person that has little or no programming knowlege. I will use you supplied example to show how the Business Macros will work. Marek Mosiewicz sent the following on 7/29/2010 7:10 AM: > W dniu 2010-07-29 15:14, chris snow pisze: >> Hi BJ, I was responding to your comment: >> >> "I like the design of Drool but think we need to go one step higher >> and see this as how to run a business." >> >> Guvnor has an abstraction on top of drools that is aimed at the >> business user. I don't know enough about drools to comment on how it >> would be integrated with the business model. I still have a lot more >> learning to do around the subject... >> >> > I made some attempts with Drools as engine for future (probably open > source) ERP. But it not like excel. You can write calculation rules but > Drools would not order them automatically based on dependencies. (e.g. > calc line total before sum of order). But in many ways it is very > powerful tool. > > > There are example rules for simple Order (I could send whole project): > > package com.sample > > import com.sample.Order; > import com.sample.OrderItem > import com.sample.OrderTaxLine; > import com.sample.OrderTaxSummary; > import com.sample.OrderDiscount; > import com.sample.Product; > import com.sample.Tax; > import com.sample.TaxCalculator; > import com.sample.Discount; > import com.sample.DiscountCalculator; > > dialect "java" > > function Tax calcTax(int customerId,int productId) { > return TaxCalculator.calculateTax(customerId,productId); > } > > rule "order item price" > dialect "mvel" > agenda-group "Items" > lock-on-active true > salience 9 > when > $item : OrderItem(); > then > modify($item){ > setPrice($item.product.price); > } > end > > rule "order item amountNetto" > dialect "mvel" > lock-on-active true > agenda-group "Items" > salience 8 > when > $item : OrderItem(); > then > modify($item){ > setAmountNetto($item.price * $item.quantity); > } > end > > rule "order item tax" > dialect "mvel" > lock-on-active true > agenda-group "Items" > salience 7 > when > $item : OrderItem(); > then > modify($item){ > setTaxes(calcTax($item.order.partyDelivery.partyId.intValue(),$item.product.productId.intValue())); > > } > end > > rule "order item amountTax" > dialect "mvel" > lock-on-active true > agenda-group "Items" > salience 6 > when > $item : OrderItem(); > then > modify($item){ > setAmountTax($item.tax.rateTax * $item.amountNetto); > } > end > > rule "order item amountBrutto" > dialect "mvel" > lock-on-active true > agenda-group "Items" > salience 5 > when > $item : OrderItem(); > then > modify($item){ > setAmountBrutto($item.amountNetto + $item.amountTax); > } > end > > rule "Switch to Order" > dialect "mvel" > lock-on-active true > agenda-group "Items" > salience -100000 > when > $item : OrderItem(); > then > drools.setFocus("Order"); > end > > rule "order calucations" > dialect "mvel" > lock-on-active true > agenda-group "Order" > salience 4 > when > $order : Order(); > $amountTax : Number() from accumulate (OrderItem( order==$order, > amountTax!=null,$amount:amountTax), sum($amount)); > then > $order.amountTax = $amountTax; > end > > rule "order calucations 2" > dialect "mvel" > lock-on-active true > agenda-group "Order" > salience 3 > when > $order : Order(); > $amountNetto : Number() from accumulate (OrderItem( order==$order, > amountNetto!=null, $amount:amountNetto), sum($amount)); > then > $order.amountNetto = $amountNetto; > end > > > rule "order calucations 3" > dialect "mvel" > lock-on-active true > agenda-group "Order" > salience 2 > when > $order : Order(amountTax !=null,amountNetto!=null); > then > $order.amountBrutto = ($order.amountTax + $order.amountNetto); > end > > > > Maybe facts assertions should not be like above "OrderLine exists" but > e.g. "quantity of order line changed" > > > > |
W dniu 2010-07-29 20:18, BJ Freeman pisze: > Thanks that looks like beanshell or Groovy type of code. > this goes along with the openoffice macro code flexibility. It has a little different usage. Each rule is fired only when assertions for rule are true. That means that facts can be fired incrementally when new facts appear. But it also means that you have to supply facts. Drools does not opperate on data model but on facts. Each statement (e.g. OrderLine) must be inserted into so called working memory as a fact. In example blow the only facts are entities (fact that they exists), but in more advanced scenario fact can be that some field changed. That would make possible to fire some expensive rules only when given field change, but it makes rules definitions more complicated. It would need braimstorming, probably with appropriate people in field what is better: RETE rule engine(aka drools) or functional reactive programming (FRP) (something like this http://lambda-the-ultimate.org/node/1918 or this http://www.flapjax-lang.org/tutorial/ ). Functional reactive programming seems to be more declarative way of things for me. . > At a business level would like to follow that macro type of > formulation but expose ofbiz services like the Artifacts (webtools) OfBiz services are stateless. What I think is possible is (optional) stateful services. I think it is possible to have "live" documents. For example when we create order we do not go with services to database, but operate only in memory. Drools or FRP would recalculate document on change of facts. What is good is that you can have temporary facts (e.g. line X is discount for line Y). Facts can also retract (be removed) when condition is no longer valid, so discount line probably could be removed if condition for it is no longer valid. Live documets would have folowing advantages: no problems with temporary documents between saves much imporved scalabilty (go to database only when save whole document) possiblity to have one logic to serve UI and for batch/webservices mode ? > At this point I am aiming this for business person that has little or > no programming knowlege. Curent DSL for Drools would genereate some noise, I think. There is a lot of tricks. One I said before, that you must order rules manualy. Another thing is you have to divide logic into agenda groups (In case below one agenda group caulcates item and another order summary). Yet another thing is that you have to say that fact was modified with modify() statement. > I will use you supplied example to show how the Business Macros will > work. You are welcome. > Marek Mosiewicz sent the following on 7/29/2010 7:10 AM: >> W dniu 2010-07-29 15:14, chris snow pisze: >>> Hi BJ, I was responding to your comment: >>> >>> "I like the design of Drool but think we need to go one step higher >>> and see this as how to run a business." >>> >>> Guvnor has an abstraction on top of drools that is aimed at the >>> business user. I don't know enough about drools to comment on how it >>> would be integrated with the business model. I still have a lot more >>> learning to do around the subject... >>> >>> >> I made some attempts with Drools as engine for future (probably open >> source) ERP. But it not like excel. You can write calculation rules but >> Drools would not order them automatically based on dependencies. (e.g. >> calc line total before sum of order). But in many ways it is very >> powerful tool. >> >> >> There are example rules for simple Order (I could send whole project): >> >> package com.sample >> >> import com.sample.Order; >> import com.sample.OrderItem >> import com.sample.OrderTaxLine; >> import com.sample.OrderTaxSummary; >> import com.sample.OrderDiscount; >> import com.sample.Product; >> import com.sample.Tax; >> import com.sample.TaxCalculator; >> import com.sample.Discount; >> import com.sample.DiscountCalculator; >> >> dialect "java" >> >> function Tax calcTax(int customerId,int productId) { >> return TaxCalculator.calculateTax(customerId,productId); >> } >> >> rule "order item price" >> dialect "mvel" >> agenda-group "Items" >> lock-on-active true >> salience 9 >> when >> $item : OrderItem(); >> then >> modify($item){ >> setPrice($item.product.price); >> } >> end >> >> rule "order item amountNetto" >> dialect "mvel" >> lock-on-active true >> agenda-group "Items" >> salience 8 >> when >> $item : OrderItem(); >> then >> modify($item){ >> setAmountNetto($item.price * $item.quantity); >> } >> end >> >> rule "order item tax" >> dialect "mvel" >> lock-on-active true >> agenda-group "Items" >> salience 7 >> when >> $item : OrderItem(); >> then >> modify($item){ >> setTaxes(calcTax($item.order.partyDelivery.partyId.intValue(),$item.product.productId.intValue())); >> >> >> } >> end >> >> rule "order item amountTax" >> dialect "mvel" >> lock-on-active true >> agenda-group "Items" >> salience 6 >> when >> $item : OrderItem(); >> then >> modify($item){ >> setAmountTax($item.tax.rateTax * $item.amountNetto); >> } >> end >> >> rule "order item amountBrutto" >> dialect "mvel" >> lock-on-active true >> agenda-group "Items" >> salience 5 >> when >> $item : OrderItem(); >> then >> modify($item){ >> setAmountBrutto($item.amountNetto + $item.amountTax); >> } >> end >> >> rule "Switch to Order" >> dialect "mvel" >> lock-on-active true >> agenda-group "Items" >> salience -100000 >> when >> $item : OrderItem(); >> then >> drools.setFocus("Order"); >> end >> >> rule "order calucations" >> dialect "mvel" >> lock-on-active true >> agenda-group "Order" >> salience 4 >> when >> $order : Order(); >> $amountTax : Number() from accumulate (OrderItem( order==$order, >> amountTax!=null,$amount:amountTax), sum($amount)); >> then >> $order.amountTax = $amountTax; >> end >> >> rule "order calucations 2" >> dialect "mvel" >> lock-on-active true >> agenda-group "Order" >> salience 3 >> when >> $order : Order(); >> $amountNetto : Number() from accumulate (OrderItem( order==$order, >> amountNetto!=null, $amount:amountNetto), sum($amount)); >> then >> $order.amountNetto = $amountNetto; >> end >> >> >> rule "order calucations 3" >> dialect "mvel" >> lock-on-active true >> agenda-group "Order" >> salience 2 >> when >> $order : Order(amountTax !=null,amountNetto!=null); >> then >> $order.amountBrutto = ($order.amountTax + $order.amountNetto); >> end >> >> >> >> Maybe facts assertions should not be like above "OrderLine exists" but >> e.g. "quantity of order line changed" >> >> >> >> > > |
you are correct that service is stateless.
however the ECA would be the equivalent of a Fact where a SE#CA would be equivalent of an event based on process and fact. this these though are3 not present to the business user but crated by the code they write. so a statement like: rule name reccalorderTotal begin when an order has a item added recalculate the total price. end this wold create and ECA on orderitem entity that would call a service to calc all the orderitmes and put the sum in the orderheader entity. another rule: rule name checkNewperson begin When a New Person is added, check for the address and phone number. end this would Create and SECA on createpersion Service that contact mech for type address and type phone number were filled in for the partyy with type person. when a new rule is written all the rules that effect that rule will be shown so the business person could see the progressing of the rules. that was whatI meant by learaging the Artifact code in webtools which list all the artifacts thar effec an enity, service, widget or controller. if a rule became a process Rule name SendOrderEmailToCustomer begin end this would create the equivalent minilanq code and a SECA based on the condition specified in the rule. the objective is to make the business Basic so the business man can sit down and start in just a few hours to write these with minimum instruction and no developer. The building of the code is done by selecting drop downs like for a service (process) or field (fact) and inputting the actual fact they are wanting to use. Marek Mosiewicz sent the following on 7/30/2010 12:50 AM: > > W dniu 2010-07-29 20:18, BJ Freeman pisze: >> Thanks that looks like beanshell or Groovy type of code. >> this goes along with the openoffice macro code flexibility. > It has a little different usage. Each rule is fired only when assertions > for rule are true. That means that facts can be fired incrementally when > new facts appear. But it also means that you have to supply facts. > Drools does not opperate on data model but on facts. > Each statement (e.g. OrderLine) must be inserted into so called working > memory as a fact. In example blow the only facts are entities (fact that > they exists), but in more advanced scenario fact can be that some field > changed. That would make possible to > fire some expensive rules only when given field change, but it makes > rules definitions more complicated. It would need braimstorming, > probably with appropriate people in field what is better: RETE rule > engine(aka drools) or functional reactive programming (FRP) > (something like this http://lambda-the-ultimate.org/node/1918 or this > http://www.flapjax-lang.org/tutorial/ ). Functional reactive programming > seems to be more declarative way of things for me. > . >> At a business level would like to follow that macro type of >> formulation but expose ofbiz services like the Artifacts (webtools) > OfBiz services are stateless. What I think is possible is (optional) > stateful services. I think it is possible to have "live" documents. For > example when we create order we do not go with services to database, but > operate only in memory. Drools or FRP would recalculate document on > change of facts. What is good is that you can have temporary facts (e.g. > line X is discount for line Y). Facts can also retract (be removed) when > condition is no longer valid, so discount line probably could be removed > if condition for it is no longer valid. > Live documets would have folowing advantages: > no problems with temporary documents between saves > much imporved scalabilty (go to database only when save whole document) > possiblity to have one logic to serve UI and for batch/webservices mode ? > >> At this point I am aiming this for business person that has little or >> no programming knowlege. > Curent DSL for Drools would genereate some noise, I think. There is a > lot of tricks. One I said before, that you must order rules manualy. > Another thing is you have to divide logic into agenda groups (In case > below one agenda group caulcates item and another order summary). Yet > another thing is that you have to say that fact was modified with > modify() statement. >> I will use you supplied example to show how the Business Macros will >> work. > You are welcome. >> Marek Mosiewicz sent the following on 7/29/2010 7:10 AM: >>> W dniu 2010-07-29 15:14, chris snow pisze: >>>> Hi BJ, I was responding to your comment: >>>> >>>> "I like the design of Drool but think we need to go one step higher >>>> and see this as how to run a business." >>>> >>>> Guvnor has an abstraction on top of drools that is aimed at the >>>> business user. I don't know enough about drools to comment on how it >>>> would be integrated with the business model. I still have a lot more >>>> learning to do around the subject... >>>> >>>> >>> I made some attempts with Drools as engine for future (probably open >>> source) ERP. But it not like excel. You can write calculation rules but >>> Drools would not order them automatically based on dependencies. (e.g. >>> calc line total before sum of order). But in many ways it is very >>> powerful tool. >>> >>> >>> There are example rules for simple Order (I could send whole project): >>> >>> package com.sample >>> >>> import com.sample.Order; >>> import com.sample.OrderItem >>> import com.sample.OrderTaxLine; >>> import com.sample.OrderTaxSummary; >>> import com.sample.OrderDiscount; >>> import com.sample.Product; >>> import com.sample.Tax; >>> import com.sample.TaxCalculator; >>> import com.sample.Discount; >>> import com.sample.DiscountCalculator; >>> >>> dialect "java" >>> >>> function Tax calcTax(int customerId,int productId) { >>> return TaxCalculator.calculateTax(customerId,productId); >>> } >>> >>> rule "order item price" >>> dialect "mvel" >>> agenda-group "Items" >>> lock-on-active true >>> salience 9 >>> when >>> $item : OrderItem(); >>> then >>> modify($item){ >>> setPrice($item.product.price); >>> } >>> end >>> >>> rule "order item amountNetto" >>> dialect "mvel" >>> lock-on-active true >>> agenda-group "Items" >>> salience 8 >>> when >>> $item : OrderItem(); >>> then >>> modify($item){ >>> setAmountNetto($item.price * $item.quantity); >>> } >>> end >>> >>> rule "order item tax" >>> dialect "mvel" >>> lock-on-active true >>> agenda-group "Items" >>> salience 7 >>> when >>> $item : OrderItem(); >>> then >>> modify($item){ >>> setTaxes(calcTax($item.order.partyDelivery.partyId.intValue(),$item.product.productId.intValue())); >>> >>> >>> } >>> end >>> >>> rule "order item amountTax" >>> dialect "mvel" >>> lock-on-active true >>> agenda-group "Items" >>> salience 6 >>> when >>> $item : OrderItem(); >>> then >>> modify($item){ >>> setAmountTax($item.tax.rateTax * $item.amountNetto); >>> } >>> end >>> >>> rule "order item amountBrutto" >>> dialect "mvel" >>> lock-on-active true >>> agenda-group "Items" >>> salience 5 >>> when >>> $item : OrderItem(); >>> then >>> modify($item){ >>> setAmountBrutto($item.amountNetto + $item.amountTax); >>> } >>> end >>> >>> rule "Switch to Order" >>> dialect "mvel" >>> lock-on-active true >>> agenda-group "Items" >>> salience -100000 >>> when >>> $item : OrderItem(); >>> then >>> drools.setFocus("Order"); >>> end >>> >>> rule "order calucations" >>> dialect "mvel" >>> lock-on-active true >>> agenda-group "Order" >>> salience 4 >>> when >>> $order : Order(); >>> $amountTax : Number() from accumulate (OrderItem( order==$order, >>> amountTax!=null,$amount:amountTax), sum($amount)); >>> then >>> $order.amountTax = $amountTax; >>> end >>> >>> rule "order calucations 2" >>> dialect "mvel" >>> lock-on-active true >>> agenda-group "Order" >>> salience 3 >>> when >>> $order : Order(); >>> $amountNetto : Number() from accumulate (OrderItem( order==$order, >>> amountNetto!=null, $amount:amountNetto), sum($amount)); >>> then >>> $order.amountNetto = $amountNetto; >>> end >>> >>> >>> rule "order calucations 3" >>> dialect "mvel" >>> lock-on-active true >>> agenda-group "Order" >>> salience 2 >>> when >>> $order : Order(amountTax !=null,amountNetto!=null); >>> then >>> $order.amountBrutto = ($order.amountTax + $order.amountNetto); >>> end >>> >>> >>> >>> Maybe facts assertions should not be like above "OrderLine exists" but >>> e.g. "quantity of order line changed" >>> >>> >>> >>> >> >> > > |
In reply to this post by Marek Mosiewicz-2
I a sorry I have not explained myself well.
I have assumed you have seen how VBA of excel works. however make work in the current environment of ofbiz. the Business user will not know about minilang, ECA, SECA, and Services as ofbiz implements them but will have a free flow language that they can talk in a comfortable terms. I have a rough proof of concept I will try to put on my demo server shortly that will show more what I am talking about. Marek Mosiewicz sent the following on 8/2/2010 1:10 AM: > I'do not think ECA implementation would work in way is needed. > When we operate on macros (documents), what is important is dependency > graph and > old values tracking. > we can have conditions like this in pseudo code: > > on Order o > when > grandTotal>$200 and o.noPromotionsAdded > then > invoke addSomePromotion(o) > > on > OrderItem oi > when > changed(oi.quantity) or > changed(oi.price) > then > invoke recalulateLineTotal(oi) > > on > Order o > when > changed or added or deleted (o.items[].lineTotal) > then > invoke recalculateGrandTotal(o) > > Now if we order >200 then we add some stuff and recalulate line total > and later need to fire rule which > will recaulate Order grand total. It must be like speadsheet where you can > show what depends on what. Of course we can always do calcuations in > services to avoid these kind of problems > but it will not be flexible or manually know (as in your ECA example) > that e.g. service updateOrderItems changes > line total so we need to invoke reset grand total. But there are many > services which change line total (adding, deleteing, updating item) > and we will need to always say it manually, so saying that ECA depends > on field is much more useful. > > Of course the best thing would be to have triggers for complicated stuff > but also > calculation rules for simpler things like GrandTotal. For rules it can > be automatically determined what they are depend on , we just say: > grandTotal =from items select sum(lineTotal) > > There are several problems with more advanced appoach: > need for change notification mechanism to know what to fire next (let > imagine rule which operates on order but changes order line - in case of > db services we have no way to detect that line has changed - and we need > another rule to fire) > probably need in memory macros for performance reasons. In memory macros > can be much more faster (e.g. recalulation of grand total after change > of line total) and futher optimized (can be in "invalid" status until > acctually required or stored in db e.g. no need to recaulate grand total > after adding new line) > rules would need some kind of language > > > > W dniu 2010-07-31 23:34, BJ Freeman pisze: >> in line >> >> >> Marek Mosiewicz sent the following on 7/30/2010 12:50 AM: >>> >>> W dniu 2010-07-29 20:18, BJ Freeman pisze: >>>> Thanks that looks like beanshell or Groovy type of code. >>>> this goes along with the openoffice macro code flexibility. >>> It has a little different usage. Each rule is fired only when assertions >>> for rule are true. That means that facts can be fired incrementally when >>> new facts appear. But it also means that you have to supply facts. >>> Drools does not opperate on data model but on facts. >>> Each statement (e.g. OrderLine) must be inserted into so called working >>> memory as a fact. In example blow the only facts are entities (fact that >>> they exists), but in more advanced scenario fact can be that some field >>> changed. That would make possible to >>> fire some expensive rules only when given field change, but it makes >>> rules definitions more complicated. It would need braimstorming, >>> probably with appropriate people in field what is better: RETE rule >>> engine(aka drools) or functional reactive programming (FRP) >>> (something like this http://lambda-the-ultimate.org/node/1918 or this >>> http://www.flapjax-lang.org/tutorial/ ). Functional reactive programming >>> seems to be more declarative way of things for me. >> >> and ECA works this way. >> <eca service="updateOrderItems" event="commit"> >> <action service="resetGrandTotal" mode="sync"/> >> <action service="sendOrderChangeNotification" mode="async" >> persist="true"/> >> </eca> >> OR >> <eca service="changeOrderStatus" event="commit" run-on-error="false"> >> <condition field-name="statusId" operator="equals" >> value="ORDER_APPROVED"/> >> <condition field-name="orderTypeId" operator="equals" >> value="SALES_ORDER"/> >> <condition-field field-name="statusId" operator="not-equals" >> to-field-name="oldStatusId"/> >> <action service="updateContentSubscriptionByOrder" mode="sync"/> >> <action service="processExtendSubscriptionByOrder" mode="sync"/> >> </eca> >> >> >>> . >>>> At a business level would like to follow that macro type of >>>> formulation but expose ofbiz services like the Artifacts (webtools) >>> OfBiz services are stateless. What I think is possible is (optional) >>> stateful services. I think it is possible to have "live" documents. For >>> example when we create order we do not go with services to database, but >>> operate only in memory. Drools or FRP would recalculate document on >>> change of facts. What is good is that you can have temporary facts (e.g. >>> line X is discount for line Y). Facts can also retract (be removed) when >>> condition is no longer valid, so discount line probably could be removed >>> if condition for it is no longer valid. >>> Live documets would have folowing advantages: >>> no problems with temporary documents between saves >>> much imporved scalabilty (go to database only when save whole document) >>> possiblity to have one logic to serve UI and for batch/webservices >>> mode ? >> >> in the macro mode the business man can use predfined macro(services) >> once a macro the new macro is define it can be called but another macro. >> Part of my spec, pulls all the current services and SECA into this >> Macro enviorment. Then the business man has access to them. >> from what you describe the Macro is a Document. >> >>> >>>> At this point I am aiming this for business person that has little or >>>> no programming knowlege. >>> Curent DSL for Drools would genereate some noise, I think. There is a >>> lot of tricks. One I said before, that you must order rules manualy. >>> Another thing is you have to divide logic into agenda groups (In case >>> below one agenda group caulcates item and another order summary). Yet >>> another thing is that you have to say that fact was modified with >>> modify() statement. >> >> I believe macro environment I am describing will fill those >> requirements but be native to ofbiz. >> I related Agenda Group as components in ofbiz. >> >>>> I will use you supplied example to show how the Business Macros will >>>> work. >>> You are welcome. >>>> Marek Mosiewicz sent the following on 7/29/2010 7:10 AM: >>>>> W dniu 2010-07-29 15:14, chris snow pisze: >>>>>> Hi BJ, I was responding to your comment: >>>>>> >>>>>> "I like the design of Drool but think we need to go one step higher >>>>>> and see this as how to run a business." >>>>>> >>>>>> Guvnor has an abstraction on top of drools that is aimed at the >>>>>> business user. I don't know enough about drools to comment on how it >>>>>> would be integrated with the business model. I still have a lot more >>>>>> learning to do around the subject... >>>>>> >>>>>> >>>>> I made some attempts with Drools as engine for future (probably open >>>>> source) ERP. But it not like excel. You can write calculation rules >>>>> but >>>>> Drools would not order them automatically based on dependencies. (e.g. >>>>> calc line total before sum of order). But in many ways it is very >>>>> powerful tool. >>>>> >>>>> >>>>> There are example rules for simple Order (I could send whole project): >>>>> >>>>> package com.sample >>>>> >>>>> import com.sample.Order; >>>>> import com.sample.OrderItem >>>>> import com.sample.OrderTaxLine; >>>>> import com.sample.OrderTaxSummary; >>>>> import com.sample.OrderDiscount; >>>>> import com.sample.Product; >>>>> import com.sample.Tax; >>>>> import com.sample.TaxCalculator; >>>>> import com.sample.Discount; >>>>> import com.sample.DiscountCalculator; >>>>> >>>>> dialect "java" >>>>> >>>>> function Tax calcTax(int customerId,int productId) { >>>>> return TaxCalculator.calculateTax(customerId,productId); >>>>> } >>>>> >>>>> rule "order item price" >>>>> dialect "mvel" >>>>> agenda-group "Items" >>>>> lock-on-active true >>>>> salience 9 >>>>> when >>>>> $item : OrderItem(); >>>>> then >>>>> modify($item){ >>>>> setPrice($item.product.price); >>>>> } >>>>> end >>>>> >>>>> rule "order item amountNetto" >>>>> dialect "mvel" >>>>> lock-on-active true >>>>> agenda-group "Items" >>>>> salience 8 >>>>> when >>>>> $item : OrderItem(); >>>>> then >>>>> modify($item){ >>>>> setAmountNetto($item.price * $item.quantity); >>>>> } >>>>> end >>>>> >>>>> rule "order item tax" >>>>> dialect "mvel" >>>>> lock-on-active true >>>>> agenda-group "Items" >>>>> salience 7 >>>>> when >>>>> $item : OrderItem(); >>>>> then >>>>> modify($item){ >>>>> setTaxes(calcTax($item.order.partyDelivery.partyId.intValue(),$item.product.productId.intValue())); >>>>> >>>>> >>>>> >>>>> } >>>>> end >>>>> >>>>> rule "order item amountTax" >>>>> dialect "mvel" >>>>> lock-on-active true >>>>> agenda-group "Items" >>>>> salience 6 >>>>> when >>>>> $item : OrderItem(); >>>>> then >>>>> modify($item){ >>>>> setAmountTax($item.tax.rateTax * $item.amountNetto); >>>>> } >>>>> end >>>>> >>>>> rule "order item amountBrutto" >>>>> dialect "mvel" >>>>> lock-on-active true >>>>> agenda-group "Items" >>>>> salience 5 >>>>> when >>>>> $item : OrderItem(); >>>>> then >>>>> modify($item){ >>>>> setAmountBrutto($item.amountNetto + $item.amountTax); >>>>> } >>>>> end >>>>> >>>>> rule "Switch to Order" >>>>> dialect "mvel" >>>>> lock-on-active true >>>>> agenda-group "Items" >>>>> salience -100000 >>>>> when >>>>> $item : OrderItem(); >>>>> then >>>>> drools.setFocus("Order"); >>>>> end >>>>> >>>>> rule "order calucations" >>>>> dialect "mvel" >>>>> lock-on-active true >>>>> agenda-group "Order" >>>>> salience 4 >>>>> when >>>>> $order : Order(); >>>>> $amountTax : Number() from accumulate (OrderItem( order==$order, >>>>> amountTax!=null,$amount:amountTax), sum($amount)); >>>>> then >>>>> $order.amountTax = $amountTax; >>>>> end >>>>> >>>>> rule "order calucations 2" >>>>> dialect "mvel" >>>>> lock-on-active true >>>>> agenda-group "Order" >>>>> salience 3 >>>>> when >>>>> $order : Order(); >>>>> $amountNetto : Number() from accumulate (OrderItem( order==$order, >>>>> amountNetto!=null, $amount:amountNetto), sum($amount)); >>>>> then >>>>> $order.amountNetto = $amountNetto; >>>>> end >>>>> >>>>> >>>>> rule "order calucations 3" >>>>> dialect "mvel" >>>>> lock-on-active true >>>>> agenda-group "Order" >>>>> salience 2 >>>>> when >>>>> $order : Order(amountTax !=null,amountNetto!=null); >>>>> then >>>>> $order.amountBrutto = ($order.amountTax + $order.amountNetto); >>>>> end >>>>> >>>>> >>>>> >>>>> Maybe facts assertions should not be like above "OrderLine exists" but >>>>> e.g. "quantity of order line changed" >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > |
Free forum by Nabble | Edit this page |