woensdag 10 mei 2017

Oracle Process Cloud Service - Decision Model Notation part 2


In my previous blog, I showed how to get started with Decision Model Notation (DMN) in Oracle Process Cloud Service and how to create a simple Decision Table. Picking up from there, we will now look into creating If-Then-Else rules, which should also be familiar to people who know Oracle's old Business Rules. We will also create a service and call it from a process.

Creating an If Then Else Decision

As Input, I have created a TotalAmount object, which is the total amount of a Sales Order. Based on this TotalAmount, we are going to calculate a Discount Price, for which I have created a DiscountPrice type to make the service interface a bit prettier than just 'output'. To create an If-Then-Else rule, just click the + button next to Decisions, enter a name and set the output type to string, number or any other type, in this case DiscountPrice.


Now, Oracle will have created a rule for you, in which you only need to fill in the "if", "then" and "else". Since you've already decided your output object, we will not use that one in the expression, which is different from the old Oracle Business Rules. So just enter the value that you want for this object and you'll be fine. You can also create nested expressions, as shown below:

One thing that I don't like, is that all the nesting needs to be done in the "else" part. I hope for Oracle to acknowledge this and create a new "if" section (for example with indent), where I can happily nest away in a more user-friendly manner. However, it works (use the Test feature to verify) and if you don't make things too complicated, it's mainly a minor display issue.

Calling an If Then Else Decision

Calling any Decision from a process is super easy. Just make sure to have a service created for your Decision and deploy it, so the process can find it. In Oracle Process Cloud's Process Composer, you can then select "Decision" as a system task, select the Decision Model that you want to use and the service within that Decision Model that you want to call:


From here, you can make your data associations and you're done. Obviously, a process is generally not as simple as this one, but using Decisions within processes is.

So that's the second part of this blog series. The third part will be an overview of other DMN functionality: Expression, Relation, List, Function and Context. I still think that we will mostly be using If/Then/Else and Decision Tables though, so for most use cases, the information in this blog and the previous one should provide you with a nice kickstart.

maandag 8 mei 2017

Oracle Process Cloud Service - Decision Model Notation part 1


Recently, Oracle Process Cloud Service (PCS) has made another major step forward through the addition of a whole new way of dealing with business rules. This brand new Decision Model Notation (DMN) feature is developed seperate from the actual processes and deployed as a microservice, so your decision models can be reused and everything is nicely loosely coupled. I like it.

What I also like about DMN is that it's much more (business) user friendly than the rule engine from Oracle SOA Suite, which was used until now. While it was performing well and somewhat agreeable for technical users, business users were often lost and leaving the business rule modelling to developers. With this new DMN feature, this is no longer necessary. Business users will be able to do much more, if not everything, themselves and actually enjoy the experience!

I've decided to write a series of blogs about the different types of decision models that can be created and how to use them. But first we need to turn it on.

Getting Started

When you're in the home screen, click on your login name in the top-right corner and choose 'Administration'. On the Admin page, go to 'UI Customization' and tick 'Enable DMN in Composer', then Save.

Now you're ready to go! You can go back to the home page now, click 'Develop Processes' and then under Create, you will have the option to create a New Decision Model. As you can see, these Decision Models are seperate from your normal PCS applications, but you can call them from your processes. Once you have created your Decision Model, your interface will show you Services on the left, Input Data on the right and Decision Models in the middle.

Input Data

The objects and the left and right can be expanded. Here's a brief explanation of what they contain, starting with the right: Input Data. When you expand it, you can see two options: Input Data and Type Definition. In Type Definitions, you can setup complex types for your input data, like lists or elements that contain attributes. Types can also refer to other types and so on and so on. It's pretty much a declarative way to make an XSD.


In Input Data, you can then refer to these Types, but also create strings, numbers and other basic stuff. In this case, I choose to make a SalesOrder, referring to the SalesOrderType I've created. This Input Data is obviously very important, because it will be the facts in your Decision Model and defining the interface of your Service.

Decision Table

So, now we know how to turn on DMN and how to create Input Data. Now let's create a simple Decision Table to make it work. Just click on the Blue + next to Decisions and choose Decision Table on the right. Since my Decision Table will decide the approval level needed for the Sales Order, the output will be a simple string value.

Once the Decision Table has been created, you obviously need to fill it. You start with Enter Expression on the left and just type the first letters of your Input Data object. DMN will suggest automatically what you want and you can just select it. In this case, I wanted to have SalesOrder.TotalAmount as input, but oops... I forgot to add it to the Type! No problem, you can always modify your Types later and the changes can be used immediately. Now we can enter our rules, which is also very nice and declarative. It could look something like this:

Absolutely no coding is necessary! To test it, you can use the test button in the top-right corner (the blue play button) and the test interface is very easy to use. Once you're satisfied, save your work.

Creating a Service

Believe it or not, creating a Service is even easier. Expand the menu on the left, create a Service, give it a name and drag the Input Data and Decision on the Input and Output fields. It will generate a REST Service and will give you the URL, as well as request and response payload when you click on Payload. Obviously, you'll have to fill in the data yourself, but all the types are described, so it will be very easy to use. Now you're ready to deploy, but the runtime aspects and calling the Decision Model from a process we will save for a later blog.

Conclusion

Oracle has created a significant improvement in Decision Modelling with their DMN-based feature. It's easy to use, business friendly and allows for fast development. Further blogs will get into more complex rules, different types of rules, calling decision services from processes and the runtime environment.