The method according to an embodiment of the present invention will be further described hereinafter with reference to the accompanying drawings.
According to some embodiments of the present invention, an application system has already defined a data model. When a rule in a BRMS changes, automatic adaptation of a DOM to the changed rule may be realized without modifying the application system as much as possible, via integrated application of DOM and Extensible Markup Language (XML) model.
Therefore, an embodiment of the present invention proposes a method for realizing automatic adaptation of a data object model as illustrated in
Block A1: A business rule management system generates a first data object model according to a second data object model. The first data object model is a data object model for use with a rule, and the second data object model is a data object model provided by an application system. The first data object model and the second data object model are the same, which includes their element names, element numbers, and element types being the same. In other embodiment, there may be a process before block A1: the application system obtains a XML model from the business rule management system and stores the XML model.
Block A2: The business rule management system analyzes the first data object model, and generates an XML model according to a rule identifier provided by the application system and the first data object model. Elements in the XML model are a subset of the first data object model. A particular method of generating the XML model is as illustrated in
Block A3: The application system determines that a rule of the business rule management system changes according to the rule identifier, obtains the XML model from the business rule management system, and updates a local XML model according to the obtained XML model. Otherwise, the application system does not update the local XML model.
Block A4: The application system generates an XML file complying with the rule by using the local XML model, and transfers the XML file and the identifier of the rule to the business rule management system. A particular method of generating the XML file will be described in detail later.
Block A5: The business rule management system generates a data object model instance by using the XML file, and transfers the data object model instance to the rule engine to trigger the rule. A particular method of generating a DOM instance is as shown in
A schematic diagram of function modules according to an embodiment of the present invention is as shown in
In the block A2, the process of generating the XML Schema (XML model, also called XDOM) by the BRMS includes the following blocks: The business rule management system obtains particular rule information from the rule base according to the rule identifier of the application system, and restores the rule information as an XML text; The business rule management system generates an empty XML model file according to data object model elements of the XML text; The business rule management system reads elements used by a condition of the XML text circularly and adds the elements to the XML model file, until all the elements of the XML text have been added. Of course, the business rule management system may also read the elements used by the condition of the XML file in a certain order, and there could be some other reading methods particularly as long as the adding of all the elements of the XML text can be completed. As shown in
Block 401: The BRMS obtains particular rule information from the rule base according to the rule identifier transferred by the application system, and restores the rule information as an XML text because the rules are stored in binary in the rule base;
Block 402: The XML text of the rule is analyzed and the name of an element DOM, e.g. Customer, is obtained;
Block 403: An empty XML file named after DOM, e.g. Customer.xsd, is generated;
Block 404: Elements used by the condition in the XML text of the rule, e.g. iGender, are read sequentially;
Block 405: The element iGender is added to the Customer.xsd; and
Block 406: The blocks 404 and 405 are repeated until all the elements used by the condition in the XML text of the rule are added to the Customer.xsd to generate a XDOM similar to the following one:
Block 501: The BRMS analyzes the XML data and obtains a DOM object used in the XML data; and the DOM object is a JavaBean object, e.g. Customer;
Block 502: A DOM instance is generated by using reflection mechanism of Java, e.g. new Customer( ); and
Block 503: A method of the Customer instance is invoked to load the XML data into the Customer instance, e.g., Customer.loadXML(Customer.xml). In the method .loadXML, the conversion from XML to DOM object instance is realized.
A general flow of triggering a rule by the application system is described in detail hereinafter, and it is particularly illustrated in
With respect to the triggering procedure of a certain rule, the flow mainly includes the following blocks:
Block 601: The application system obtains a local XDOM;
Block 602: The application system compares the local XDOM and a corresponding rule version in the BRMS to determine whether they are consistent with each other, if not, the flow proceeds to the block 603. Otherwise, the flow jumps to block 604;
Block 603: The XDOM is downloaded locally from the BRMS by referring to the processing flow in
Block 604: The XDOM obtained from the BRMS, e.g. Customer.xsd, is analyzed, and the values of the elements in the XDOM are obtained from the database. For example, age and gender of a certain customer are obtained from the database. A Customer.xml file is generated according to the XDOM to add the age and gender values of the customer to Customer.xml;
Block 605: The Customer.xml and a corresponding rule identifier are transferred to the BRMS;
Block 606: The DOM module analyzes the file Customer.xml (refer to
Block 607: The DOM instance Customer is transferred to the rule engine to trigger the rule;
Block 608: The rule engine feeds back the result of executing the rule to the application system; and
Block 609: The application system processes the triggering result.
In a practical application, for example, Partner in the database is defined as follows:
According to an embodiment, the BRMS creates a rule according to the definition of the Partner. It is assumed that there is a rule: if the status of a Partner is active and his/her credit level is more than 100, then the grade of Partner is set as VIP. The application system analyzes an XDOM obtained from the BRMS, e.g. Partner.xsd, obtains the values of the elements in the XDOM from the database, for example, obtains the values of status and creditGrade from the database, generates a Partner.xml file according to the XDOM, adds the values of the status and creditGrade to the Partner.xml, and transfers the Partner.xml and a corresponding rule identifier to the BRMS. The DOM module analyzes the file Partner.xml (refer to
An embodiment of the present invention also provides a system for realizing automatic adaptation of a data object model, including a business rule management subsystem and an application subsystem. The business rule management subsystem being configured with a data object model module and an XML model module. The data object model module generates a first data object model according to a second data object model. The first data object model is a data object model for use with a rule, and the second data object model is a data object model provided by the application subsystem. The XML model module extracts a rule from a rule base according to a rule identifier provided by the application subsystem, and generates an XML model according to the rule and the first data object model. The data object model module is adapted for generating the first data object model, reading data of the second data object model, and writing the first data object model so that the second data object model and the first data object model are the same. The XML model module is adapted for obtaining particular rule information from the rule base and restoring the rule information into an XML text; generating an empty XML model file according to data object model elements of the XML text; and reading all the elements used by a condition of the XML text and adding the elements to the XML model file. The particular implementation method is as described above and as illustrated in
It shall be understood that the above descriptions of the particular embodiments according to the present invention are relative specific and can not be construed as limiting the protection scope of the present invention, and the protection scope of the present invention shall be based on the appended claims.
| Number | Date | Country | Kind |
|---|---|---|---|
| 200610062258.X | Aug 2006 | CN | national |