Implementing Formula Management with BeanShell

Source: Internet
Author: User

Building a powerful and flexible formula management system with Java scripts

In many large and medium applications, such as SCM (supply chain Management), CRM (Customer relationship Management) and ERP (Enterprise resource planning) and so on, users often need to according to their own needs, the flexibility of a number of parameters to change, so that according to a fixed formula calculated results in line with the current situation. If the discount rate of the commodity price in different period needs to adjust according to the actual situation, or the employee's bonus percentage depends on the company's performance. This requires a strong formula management mechanism to flexibly adjust some of the parameters.

Objective

The needs of our customers are constantly changing. While they say the employee bonuses for their company are supposed to be based on that formula, they'll tell you in a couple of months that the formula is not very reasonable and that you need to add some parameters. You might say, no problem, we can change the procedure. But when such changes do not occur one at a time, but frequently and in large numbers, you may be thinking that there should be a formula management system to accomplish these trivial but important changes. Yes, it has been done in many systems. This paper introduces a simple and extensible formula Management system, which adopts simple and flexible BeanShell scripting mechanism, and combines jdom technology to realize it. Before reading this article, you need to know something about BeanShell and jdom.

BeanShell Introduction

BeanShell is a Java interpreter that contains scripting languages that are basically compatible with the Java language and are small, simple, and Java-style. Instead of introducing the syntax and usage of BeanShell, this article simplifies the programming of Java programmers by implementing a Formula manager based on the BeanShell script to illustrate the powerful scripting features of BeanShell. Giving them a deeper understanding of when using BeanShell technology will make the system more flexible. You can read the resources to learn more about BeanShell. Similar Java scripting techniques and DYNAMICJ, for more information about them, refer to later references. (Note: The Java script here is not JavaScript.) )

Jdom Introduction

Jdom makes it easier to manipulate XML files in Java. Here, the XML file format is used to store the user's custom formula library, which is simple and easy to manage. Using Jdom technology, can complete this task simply and quickly. If you would like to know more about Jdom, please refer to the resources later in this article.

The goal of the Formula management system

The main goal of the formula Management system is that the user can customize the formula according to their own needs, including adding, modifying and deleting the formula or the parameters contained in the formula, and providing the interface so that the user or other system can use the formula in the formula Library to calculate the evaluation. From the main functions of the above system, you can know that the system mainly contains two use cases: custom formulas and calculation expressions. A custom formula is one in which the user defines the parameters (including parameter names, parameter types, and so on) that a formula contains, and then uses the operators to combine them into the desired formula by a certain law. When the formula is defined, it is saved to the formula Library for later calls when the user or other system evaluates. This is the system function that the manager flexibly changes the parameters contained in the formula or formula according to his own needs. The evaluation expression is evaluated by the user assigning the corresponding parameter and then specifying the formula to follow. This is the external interface that the system provides to the consumer. In general, the user can invoke the interface for calculation only by providing the formula ID to be followed and the associated parameter value. The use case diagram for the system is as follows:

Figure 1. Formula Management system use case diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.