CN101169713A - Model Transformation Framework and Method Supporting Separation of Transformation Engine and Mapping Rules - Google Patents
Model Transformation Framework and Method Supporting Separation of Transformation Engine and Mapping Rules Download PDFInfo
- Publication number
- CN101169713A CN101169713A CNA2006101426257A CN200610142625A CN101169713A CN 101169713 A CN101169713 A CN 101169713A CN A2006101426257 A CNA2006101426257 A CN A2006101426257A CN 200610142625 A CN200610142625 A CN 200610142625A CN 101169713 A CN101169713 A CN 101169713A
- Authority
- CN
- China
- Prior art keywords
- model
- mapping ruler
- rule
- engine
- mapping
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000013507 mapping Methods 0.000 title claims abstract description 208
- 238000000034 method Methods 0.000 title claims abstract description 27
- 230000009466 transformation Effects 0.000 title abstract description 25
- 238000000926 separation method Methods 0.000 title abstract description 18
- 238000006243 chemical reaction Methods 0.000 claims abstract description 101
- 238000013515 script Methods 0.000 claims abstract description 70
- 238000012545 processing Methods 0.000 claims abstract description 15
- 238000011156 evaluation Methods 0.000 claims description 24
- 230000008569 process Effects 0.000 claims description 7
- 230000008676 import Effects 0.000 claims description 3
- 230000000007 visual effect Effects 0.000 claims description 3
- 238000012360 testing method Methods 0.000 claims 7
- 238000000605 extraction Methods 0.000 claims 5
- 238000005516 engineering process Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 5
- 230000007246 mechanism Effects 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 239000000284 extract Substances 0.000 description 3
- 230000003068 static effect Effects 0.000 description 3
- 238000000844 transformation Methods 0.000 description 3
- 238000004422 calculation algorithm Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000007670 refining Methods 0.000 description 2
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 230000008571 general function Effects 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
本发明公开了一种支持转换引擎与映射规则相分离的模型转换框架及其方法,该框架包括模型提取器,还包括:目标平台管理器、代理规则管理器、映射规则查询引擎、映射规则库、映射规则编辑器、映射规则执行引擎、脚本合并器、脚本解释器及公共数据区;代理规则将模型元素传给映射规则查询引擎,映射规则查询引擎根据模型元素查询映射规则库得到与模型元素对应的映射规则,代理规则再将模型元素和映射规则交给映射规则执行引擎进行处理;映射规则执行引擎将处理得到的目标脚本文件送至脚本合并器进行合并处理,生成一个目标脚本文件;脚本解释器对目标脚本文件进行解释生成目标模型或代码。采用本发明实现了模型转换引擎与映射规则的分离。
The invention discloses a model conversion framework and method supporting the separation of conversion engine and mapping rules. The framework includes a model extractor, and further includes: a target platform manager, an agent rule manager, a mapping rule query engine, and a mapping rule library , mapping rule editor, mapping rule execution engine, script combiner, script interpreter and public data area; proxy rules pass model elements to the mapping rule query engine, and the mapping rule query engine queries the mapping rule base according to the model elements to obtain the model elements The corresponding mapping rules and proxy rules will then hand over the model elements and mapping rules to the mapping rule execution engine for processing; the mapping rule execution engine will send the processed target script file to the script combiner for merge processing to generate a target script file; script The interpreter interprets the target script file to generate the target model or code. The invention realizes the separation of the model transformation engine and the mapping rules.
Description
技术领域 technical field
本发明涉及计算机软件开发技术领域,特别是涉及一种基于模型驱动架构MDA(Model Driven Architecture)的支持转换引擎与映射规则相分离的模型转换框架和方法。The invention relates to the technical field of computer software development, in particular to a model conversion framework and method based on a Model Driven Architecture (MDA) that supports the separation of a conversion engine and a mapping rule.
背景技术 Background technique
对象管理组织(Object Management Group,OMG)于2002年底提出了新的系统软件开发方法学-模型驱动架构MDA。该架构的核心思想是将系统的业务功能逻辑与实现平台技术相分离,避免造成业务逻辑和实现技术的紧耦合,同时,MDA通过模型转换技术可以将平台独立的系统功能模型映射到不同的实现平台模型上,最终实现到具体代码的转换。从而使软件系统的移植性、互操作性和可重用性都可以长期保持,能够应对未来的技术变化,延长了软件的生命期。目前,基于MDA的软件开发-MDD(Model Driven Development,模型驱动开发)已经引起了学术界和工业界的高度关注和重视。Object Management Group (OMG) proposed a new system software development methodology - Model Driven Architecture (MDA) at the end of 2002. The core idea of this architecture is to separate the business function logic of the system from the implementation platform technology to avoid tight coupling between business logic and implementation technology. At the same time, MDA can map the platform-independent system function model to different implementations through model conversion technology. On the platform model, the conversion to specific code is finally realized. So that the portability, interoperability and reusability of the software system can be maintained for a long time, it can cope with future technological changes, and prolong the life cycle of the software. At present, MDA-based software development - MDD (Model Driven Development, Model Driven Development) has attracted great attention and attention from academia and industry.
模型转换技术是基于MDA的软件开发的关键技术之一,它是保持MDA中不同抽象层次模型间联系的纽带。利用模型转换技术,可以实现平台独立模型(Platform Independent Model,PIM)到平台相关模型(Platform SpecificModel,PSM)的转换,以及平台相关模型PSM到实现代码的转换。OMG为了成功推广MDA,正力图使模型转换规范化,于2002年3月发布一个名为QVT(MOF Queries,Views and Transformations)的意见征求稿,其中MOF(Meta Object Facility)为元对象设施。于2005年11月,确定了最终版本的规范提案,目前正处于最后的表决阶段。Model conversion technology is one of the key technologies of MDA-based software development, and it is the link to maintain the connection between models of different abstract levels in MDA. Using the model conversion technology, it is possible to realize the conversion from the platform independent model (Platform Independent Model, PIM) to the platform specific model (Platform Specific Model, PSM), and the conversion from the platform dependent model PSM to the implementation code. In order to successfully promote MDA, OMG is trying to standardize model transformation. In March 2002, it released a draft called QVT (MOF Queries, Views and Transformations), where MOF (Meta Object Facility) is a meta object facility. In November 2005, the final version of the specification proposal was finalized and is currently in the final voting stage.
由于模型转换还没有形成一套规范的方法,缺乏规范来支持模型转换的标准化,导致模型转换的技术都依赖于具体厂商的MDA工具。大多数的现有MDA工具对模型转换的支持程度都不完善,仍有许多技术问题需要解决。Since model conversion has not yet formed a set of standardized methods, there is a lack of specifications to support the standardization of model conversion, resulting in the technology of model conversion relying on the MDA tools of specific manufacturers. Most of the existing MDA tools do not support model transformation perfectly, and there are still many technical problems to be solved.
目前的MDA工具提供的转换引擎(实现模型转换的功能)大多实现了源模型提取器,支持对模型的扫描和访问;也定义了一些通用的转换规则机制来支持特定模型间的转换。但对特定领域相关的模型的转换,支持力度不够或没有提供支持。在特定领域中,UML(Unified Modeling Language,统一建模语言)的语义往往不能完整表达需求,所以需要对UML进行扩展,一般利用UML的Profile(扩展集)机制,采用版类(Stereotype)、标签值(TaggedValue)和约束(Constraint)的方式来扩展已有的UML元素,引入新的模型元素。利用UML的Profile扩展机制,用户可以自定义一些领域相关的建模元素,来表达特定领域中的某种确切语义。如果源模型含有UML Profile中定义的新的扩展建模元素,则需要对每种新模型元素进行相应的转换。在现有的MDA工具的转换机制下,则需要加入新的转换规则或修改已有的转换规则来实现对新模型元素的转换。因此,针对具体的或领域相关的软件开发活动,经常需要对已有的转换引擎进行扩展,加上特定的转换规则来完成相应的模型转换。Most of the conversion engines provided by current MDA tools (implementing the function of model conversion) implement source model extractors to support scanning and accessing models; some general conversion rule mechanisms are also defined to support conversion between specific models. However, there is insufficient support or no support for the conversion of models related to specific domains. In a specific field, the semantics of UML (Unified Modeling Language, Unified Modeling Language) often cannot fully express the requirements, so UML needs to be extended. Generally, the Profile (extension set) mechanism of UML is used, and the stereotype (Stereotype), label Value (TaggedValue) and constraint (Constraint) to extend existing UML elements and introduce new model elements. Using UML's Profile extension mechanism, users can customize some domain-related modeling elements to express certain exact semantics in a specific domain. If the source model contains new extended modeling elements defined in the UML Profile, a corresponding transformation is required for each new model element. Under the conversion mechanism of the existing MDA tool, it is necessary to add new conversion rules or modify existing conversion rules to realize the conversion of new model elements. Therefore, for specific or domain-related software development activities, it is often necessary to extend the existing conversion engine and add specific conversion rules to complete the corresponding model conversion.
目前的转换引擎在不同程度上提供了对扩展的支持。但转换引擎与转换规则通常是绑定在一起的,一个转换引擎通常只有一种同一规则集,即所有的转换规则都是处理相同的源元模型和相同的目标元模型。如果新加的规则和转换引擎中的规则同属于一个规则集,则可以比较方便的对转换引擎进行扩展。如果不属于同一个规则集,则往往需要开发一个新的转换引擎。这种模式不仅增加了模型转换引擎开发的技术难度和成本,而且大大降低了模型转换引擎中大部分通用功能的重用性,阻碍了MDA在具体的或领域相关的软件开发活动中的应用和推广。Current transformation engines provide support for extensions to varying degrees. However, the transformation engine and the transformation rules are usually bound together, and a transformation engine usually has only one same rule set, that is, all transformation rules deal with the same source metamodel and the same target metamodel. If the newly added rules and the rules in the conversion engine belong to the same rule set, the conversion engine can be extended more conveniently. If they do not belong to the same ruleset, a new transformation engine will often need to be developed. This mode not only increases the technical difficulty and cost of model transformation engine development, but also greatly reduces the reusability of most general functions in model transformation engines, hindering the application and promotion of MDA in specific or domain-related software development activities .
相关的现有技术包括:2006年6月15日公开的公开号为US2006/0130011A1的美国专利“Extending Existing Model-To-Model Transformations”(扩展现有的模型到模型的转换)和2006年6月15日公开的公开号为US2006/0130008 A1的美国专利“Model-To-Model Transformation By Kind”(基于模型元素类型的模型到模型的转换),以及2006年6月15日公开的公开号为US2006/0130009 A1的美国专利“Dynamically ConfigurableModel-To-Model Transformation Engine”(动态可配置的模型到模型转换引擎)。The relevant prior art includes: the U.S. patent "Extending Existing Model-To-Model Transformations" published on June 15, 2006 with the publication number US2006/0130011A1 (extending existing models to model transformations) and June 2006 The US patent "Model-To-Model Transformation By Kind" published on the 15th with the publication number US2006/0130008 A1 (model-to-model transformation based on the model element type), and the publication number US2006 published on June 15, 2006 /0130009 A1's US patent "Dynamically Configurable Model-To-Model Transformation Engine" (dynamically configurable model-to-model transformation engine).
第0130011、0130009、0130008号美国专利存在以下不足:这三个专利都是针对同一种转换引擎的不同技术方面的说明,其主要的不足是转换引擎与转换规则是绑定在一起的,该模型转换技术只实现了同一规则集(即一个转换引擎中所有的转换规则都是处理相同的源元模型和相同的目标元模型)上的重用,而要将基于相同的元模型的源模型转换为基于不同元模型的目标模型时,则必须重新开发一个新的转换引擎和相应的转换规则。No. 0130011, 0130009, and 0130008 U.S. patents have the following disadvantages: these three patents are all aimed at different technical aspects of the same conversion engine, and their main disadvantage is that the conversion engine and conversion rules are bound together. The conversion technology only realizes the reuse on the same rule set (that is, all the conversion rules in a conversion engine process the same source meta-model and the same target meta-model), and the source model based on the same meta-model should be converted into When the target model is based on a different meta-model, a new transformation engine and corresponding transformation rules must be redeveloped.
发明内容 Contents of the invention
本发明所要解决的技术问题在于提供一种支持转换引擎与映射规则相分离的模型转换框架和方法,用于实现模型转换引擎与映射规则的分离。The technical problem to be solved by the present invention is to provide a model conversion framework and method that support the separation of the conversion engine and the mapping rules, so as to realize the separation of the model conversion engine and the mapping rules.
为了实现上述目的,本发明提供了一种支持转换引擎与映射规则相分离的模型转换框架,包括模型提取器,用于提取源模型中的模型元素,其特征在于,还包括:一目标平台管理器、一代理规则管理器、一映射规则查询引擎、一映射规则库、一映射规则编辑器、一映射规则执行引擎、一脚本合并器、一脚本解释器及一公共数据区;In order to achieve the above object, the present invention provides a model conversion framework that supports the separation of the conversion engine and the mapping rules, including a model extractor for extracting model elements in the source model, characterized in that it also includes: a target platform management device, a proxy rule manager, a mapping rule query engine, a mapping rule library, a mapping rule editor, a mapping rule execution engine, a script merger, a script interpreter and a public data area;
所述目标平台管理器处理代理规则与同一目标平台的映射规则之间的关系;所述代理规则管理器根据所述模型元素的类型查找与所述模型元素对应的代理规则;所述映射规则编辑器通过一可视化方式编辑生成映射规则,并存放于所述映射规则库;所述公共数据区用于存放模型转换所需数据;The target platform manager processes the relationship between the proxy rule and the mapping rule of the same target platform; the proxy rule manager searches for the proxy rule corresponding to the model element according to the type of the model element; the mapping rule editor The mapper is edited in a visual way to generate mapping rules, and stored in the mapping rule base; the public data area is used to store the data required for model conversion;
所述代理规则将所述模型元素传给所述映射规则查询引擎,所述映射规则查询引擎根据所述模型元素查询所述映射规则库得到与所述模型元素对应的映射规则,所述代理规则再将所述模型元素和所述映射规则交给所述映射规则执行引擎进行处理;The proxy rule transmits the model element to the mapping rule query engine, and the mapping rule query engine queries the mapping rule library according to the model element to obtain a mapping rule corresponding to the model element, and the proxy rule Then hand over the model element and the mapping rule to the mapping rule execution engine for processing;
所述映射规则执行引擎将处理得到的目标脚本文件送至所述脚本合并器进行合并处理,生成一个目标脚本文件;所述脚本解释器对所述目标脚本文件进行解释生成目标模型或代码。The mapping rule execution engine sends the processed target script file to the script combiner for merging processing to generate a target script file; the script interpreter interprets the target script file to generate a target model or code.
所述的支持转换引擎与映射规则相分离的模型转换框架,其中,所述映射规则库又分为:版类包、评测包、语句包及规则包。In the model conversion framework that supports the separation of the conversion engine and the mapping rules, the mapping rule base is further divided into: a version class package, an evaluation package, a statement package, and a rule package.
所述的支持转换引擎与映射规则相分离的模型转换框架,其中,所述映射规则又包括:版类结点、评测结点、分支及语句结点;其中,所述版类结点是对版类的引用,所述评测结点是对评测的引用,所述语句结点是对语句的引用,所述分支用于连接所述评测结点与所述语句结点。The model conversion framework that supports the separation of the conversion engine and the mapping rules, wherein the mapping rules further include: version class nodes, evaluation nodes, branches, and statement nodes; wherein the version class nodes are for A reference to a version class, the evaluation node is a reference to an evaluation, the statement node is a reference to a statement, and the branch is used to connect the evaluation node and the statement node.
所述的支持转换引擎与映射规则相分离的模型转换框架,其中,所述映射规则中,所述版类结点、所述评测结点的个数为一个,所述分支结点、所述语句结点的个数为一个或多个。The model conversion framework that supports the separation of the conversion engine and the mapping rules, wherein, in the mapping rules, the number of the version node and the evaluation node is one, and the branch node, the The number of statement nodes is one or more.
所述的支持转换引擎与映射规则相分离的模型转换框架,其中,同一个所述版类、所述评测或所述语句包含于多个所述映射规则中,一个所述分支仅包含于一个所述映射规则中。The model conversion framework that supports the separation of the conversion engine and the mapping rules, wherein the same type, evaluation or statement is included in multiple mapping rules, and one branch is only included in one in the mapping rules.
所述的支持转换引擎与映射规则相分离的模型转换框架,其中,所述映射规则查询引擎还包括:The model conversion framework that supports the separation of the conversion engine and the mapping rules, wherein the mapping rule query engine further includes:
一特征字符串查询模块,用于将所述代理规则传入的一特征字符串与所述映射规则中的另一特征字符串进行匹配并在两者相同时返回所述映射规则;或A feature string query module, configured to match a feature string input by the proxy rule with another feature string in the mapping rule and return the mapping rule when the two are the same; or
一元模型查询模块,用于将所述代理规则传入的一元模型与所述映射规则中的另一元模型进行匹配并在两者相同时返回所述映射规则。The unary model query module is configured to match the unary model passed in by the proxy rule with another metamodel in the mapping rule and return the mapping rule when the two are the same.
为了实现上述目的,本发明还提供了一种利用所述模型转换框架实现转换引擎与映射规则相分离的模型转换方法,其特征在于,包括:In order to achieve the above object, the present invention also provides a model conversion method using the model conversion framework to separate the conversion engine from the mapping rules, which is characterized in that it includes:
步骤71,通过所述模型提取器提取源模型中的模型元素,并传给所述代理规则管理器,所述代理规则管理器根据所述模型元素的类型得到与所述模型元素对应的代理规则;Step 71, extract the model elements in the source model through the model extractor, and pass it to the proxy rule manager, and the proxy rule manager obtains the proxy rule corresponding to the model element according to the type of the model element ;
步骤72,所述代理规则将所述模型元素传给所述映射规则查询引擎,所述映射规则查询引擎根据所述模型元素查询所述映射规则库得到与所述模型元素对应的映射规则,所述代理规则再将所述模型元素和所述映射规则传给所述映射规则执行引擎进行处理;及Step 72, the proxy rule transmits the model element to the mapping rule query engine, and the mapping rule query engine queries the mapping rule library according to the model element to obtain a mapping rule corresponding to the model element, so The proxy rules then pass the model elements and the mapping rules to the mapping rule execution engine for processing; and
步骤73,通过所述脚本合并器对所述映射规则执行引擎处理得到的目标脚本文件进行合并处理生成一个目标脚本文件,再通过所述脚本解释器解释所述目标脚本文件生成目标模型或代码。Step 73: Merge the target script files processed by the mapping rule execution engine through the script combiner to generate an target script file, and then interpret the target script file through the script interpreter to generate target models or codes.
所述的支持转换引擎与映射规则相分离的模型转换方法,其中,所述步骤72中,还包括:当所述模型元素未附加元模型时,由所述映射规则查询引擎以一特征字符串查询方式查询映射规则的步骤,具体为:所述映射规则查询引擎将所述代理规则传入的一特征字符串与所述映射规则中的另一特征字符串进行匹配并在两者相同时返回所述映射规则。The model conversion method that supports the separation of the conversion engine and the mapping rules, wherein, in the step 72, it also includes: when the model element does not have a meta-model attached, the mapping rule query engine uses a characteristic string The step of querying the mapping rules in query mode is specifically: the mapping rule query engine matches a characteristic string passed in by the proxy rule with another characteristic string in the mapping rule and returns when the two are the same. The mapping rules.
所述的支持转换引擎与映射规则相分离的模型转换方法,其中,所述步骤72中,还包括:当所述模型元素已附加元模型时,由所述映射规则查询引擎以一元模型查询方式查询映射规则的步骤,具体为:所述映射规则查询引擎将所述代理规则传入的一元模型与所述映射规则中的另一元模型进行匹配并在两者相同时返回所述映射规则。The model conversion method that supports the separation of the conversion engine and the mapping rule, wherein, in the step 72, it also includes: when the model element has a meta-model attached, the mapping rule query engine uses a meta-model query The step of querying the mapping rules specifically includes: the mapping rule query engine matches the unary model passed in by the proxy rule with another meta model in the mapping rule and returns the mapping rule when the two are the same.
所述的支持转换引擎与映射规则相分离的模型转换方法,其中,所述步骤72中,还包括一由所述模型提取器判断当前模型元素是否包含子元素的步骤,若含有,则返回至所述步骤71执行,否则,继续所述步骤73。The model conversion method that supports the separation of the conversion engine and the mapping rules, wherein, in the step 72, it also includes a step of judging whether the current model element contains sub-elements by the model extractor, and if so, returns to The step 71 is executed, otherwise, the step 73 is continued.
与现有技术相比较,本发明通过将模型转换规则细化为代理规则和映射规则,实现了模型转换引擎与映射规则的分离,增强了转换引擎中一些通用模块的重用性,大大简化了模型转换的工作量和技术难度。利用该发明提出的模型转换方法,在实现基于相同元模型的源模型到基于不同元模型的各种目标模型转换时,无需再重新开发一个模型转换引擎,只需通过映射规则编辑器,构建新的基于源元模型到各种目标元模型的映射规则,将其加入映射规则库中即可。这种模型转换方式也大大提高了映射规则的可重用性。Compared with the prior art, the present invention realizes the separation of the model conversion engine and the mapping rules by refining the model conversion rules into proxy rules and mapping rules, enhances the reusability of some common modules in the conversion engine, and greatly simplifies the model The workload and technical difficulty of the conversion. Utilizing the model conversion method proposed in this invention, when realizing the conversion from the source model based on the same meta-model to various target models based on different meta-models, there is no need to re-develop a model conversion engine, and only need to build a new model through the mapping rule editor The mapping rules based on the source metamodel to various target metamodels can be added to the mapping rule base. This model conversion method also greatly improves the reusability of mapping rules.
另外,本发明支持转换引擎与映射规则相分离的模型转换方法同时适用于模型到模型、模型到代码的转换。在模型到模型的转换中,脚本解释器将生成目标模型;在模型到代码的转换中,将代码也抽象为模型来表示,然后只要改动脚本解释器的功能,脚本解释器就可以将模型对应的代码生成出来。In addition, the present invention supports a model conversion method in which the conversion engine and the mapping rules are separated, and is applicable to both model-to-model and model-to-code conversions. In the conversion from model to model, the script interpreter will generate the target model; in the conversion from model to code, the code is also abstracted into a model to represent, and then as long as the function of the script interpreter is changed, the script interpreter can correspond to the model code is generated.
以下结合附图和具体实施例对本发明进行详细描述,但不作为对本发明的限定。The present invention will be described in detail below in conjunction with the accompanying drawings and specific embodiments, but not as a limitation of the present invention.
附图说明 Description of drawings
图1是本发明模型转换框架模块结构图;Fig. 1 is a structural diagram of a model conversion framework module of the present invention;
图2是本发明代理规则管理器结构图;Fig. 2 is a structural diagram of the proxy rule manager of the present invention;
图3是本发明代理规则使用关键字方式进行查询流程图;Fig. 3 is that the agent rule of the present invention uses keyword mode to carry out query flowchart;
图4是本发明代理规则使用元模型方式进行查询流程图;Fig. 4 is a flow chart of querying the agent rules of the present invention using the meta-model mode;
图5是本发明映射规则结构图;Fig. 5 is a structural diagram of mapping rules of the present invention;
图6是本发明模型转换流程图。Fig. 6 is a flow chart of model conversion in the present invention.
具体实施方式 Detailed ways
下面结合附图对本发明支持转换引擎与映射规则相分离的模型转换框架及模型转换方法作进一步的详细描述:The following is a further detailed description of the model conversion framework and model conversion method of the present invention that supports the separation of the conversion engine and the mapping rules in conjunction with the accompanying drawings:
如图1所示,是本发明模型转换框架模块结构图,图2是本发明代理规则管理器结构图,并结合图3、4、5所示;该模型转换框架由转换引擎和映射规则库系统构成,具体包括:As shown in Figure 1, it is a structural diagram of the model conversion framework module of the present invention, and Figure 2 is a structural diagram of the proxy rule manager of the present invention, and shown in conjunction with Figures 3, 4, and 5; the model conversion framework consists of a conversion engine and a mapping rule base System composition, including:
模型提取器101,用于负责提取源模型中的模型元素。采用逐层扫描的方式来提取模型元素,即先提取源模型中的根元素,将其交给代理规则管理器103处理,根元素处理完后,再提取根元素的子元素交给代理规则管理器103处理。The
目标平台管理器102,针对同一个代理规则105,可能有到多个目标平台的映射规则与之相对应,目标平台管理器102负责管理代理规则105与同一目标平台的映射规则之间的关系,确保在针对特定平台的转换时,代理规则105只调用与该平台相关的映射规则。The
映射规则属于静态映射规则,是一种静态的表示源模型元素和目标模型元素映射关系的规则;代理规则105不属于静态映射规则,它由代理规则管理器103查询得到,主要用于根据模型提取器101提取的模型元素,通过映射规则查询引擎104查询映射规则库106得到映射规则。The mapping rule belongs to the static mapping rule, which is a static rule representing the mapping relationship between the source model element and the target model element; the proxy rule 105 does not belong to the static mapping rule, it is obtained by querying the proxy rule manager 103, and is mainly used to extract The model elements extracted by the
代理规则管理器103,用于根据模型提取器101提取的模型元素的类型,找到与之相对应的代理规则105;一个代理规则管理器103可以同时管理多条代理规则105。The proxy rule manager 103 is used to find the corresponding proxy rule 105 according to the type of the model element extracted by the
如图2所示,代理规则管理器103维护一个模型元素类型201和代理规则105的映射表,对每一个模型元素类型201,都有一个代理规则105与之相对应。当输入一个模型元素时,代理规则管理器103会检查该模型元素的类型,返回相应的代理规则105,并将该模型元素交给该代理规则105进行处理。As shown in FIG. 2 , the proxy rule manager 103 maintains a mapping table of model element types 201 and proxy rules 105 , and for each model element type 201 , there is a proxy rule 105 corresponding to it. When a model element is input, the proxy rule manager 103 will check the type of the model element, return the corresponding proxy rule 105, and hand over the model element to the proxy rule 105 for processing.
映射规则查询引擎104,用于支持模型映射规则的查询,其又包括:特征字符串查询模块1041、元模型查询模块1042,分别支持特征字符串查询方式、元模型查询方式进行映射规则查询:The mapping rule query engine 104 is used to support the query of model mapping rules, and it also includes: a feature
(1)特征字符串查询方式:代理规则105传入一个特征字符串来查询映射规则,特征字符串查询模块1041将该特征字符串与映射规则中的特征字符串进行匹配,如果相同,则返回该规则,如图3所示;(1) Feature string query mode: proxy rule 105 passes in a feature string to query the mapping rule, and the feature
(2)元模型查询方式:代理规则105传入元模型来查询映射规则,元模型查询模块1042将元模型与映射规则中的元模型进行匹配,如果相同,则返回该规则,如图4所示。(2) Metamodel query mode: the proxy rule 105 imports the metamodel to query the mapping rules, and the metamodel query module 1042 matches the metamodel with the metamodel in the mapping rules, and if they are the same, returns the rule, as shown in Figure 4 Show.
映射规则查询引擎104查询的结果为一个映射规则列表,映射规则查询引擎104将该列表返回给代理规则105。The query result of the mapping rule query engine 104 is a mapping rule list, and the mapping rule query engine 104 returns the list to the proxy rule 105 .
代理规则105,用于根据模型提取器101提取的模型元素,通过映射规则查询引擎104查询映射规则库106,得到与模型元素相对应的映射规则,并将模型元素和查询得到的映射规则一起交给映射规则执行引擎108进行处理。The proxy rule 105 is used for querying the
映射规则库106,主要作用是存放映射规则,供转换引擎查询。为了实现版类、评测及语句模块的重用,将映射规则库106划分为四个包:The
版类包:版类是从Profile(版类的容器)导入的,包括一些版类的基本信息;Profile package: profiles are imported from Profile (container of profiles), including some basic information of profiles;
评测包:评测是映射规则的主体,用来对元模型的属性或其他信息进行检查;Evaluation package: Evaluation is the main body of mapping rules, which is used to check the attributes or other information of the metamodel;
语句包:语句是用目标脚本编写的,所以语句本身也是一个目标脚本文件;Statement package: the statement is written in the target script, so the statement itself is also a target script file;
规则包:映射规则的集合构成了规则包。Rule Package: A collection of mapping rules constitutes a rule package.
基础规则包:通用的或可重用性非常高的映射规则称为基础规则,它的集合构成基础规则包。基础规则包一般由转换引擎提供者提供。Basic rule package: general or highly reusable mapping rules are called basic rules, and its collection constitutes a basic rule package. The basic rule package is generally provided by the transformation engine provider.
规则包、基础规则包和规则库是松耦合的,只需要在初始化时指定规则包和基础规则包的路径,规则库可以动态加载规则包和基础规则包。The rule package, the basic rule package and the rule library are loosely coupled. You only need to specify the path of the rule package and the basic rule package during initialization, and the rule library can dynamically load the rule package and the basic rule package.
如图5所示,映射规则结构包括四部分:版类(Stereotype)结点501、评测结点502、分支(Branch)503、语句结点504。版类结点501是对版类的引用,同样地,评测结点502和语句结点504分别是对评测和语句的引用。As shown in FIG. 5 , the mapping rule structure includes four parts: Stereotype node 501 , evaluation node 502 , branch (Branch) 503 , and sentence node 504 . Version node 501 is a reference to version, similarly, evaluation node 502 and sentence node 504 are references to evaluation and sentence respectively.
分支503用来连接评测结点502和语句结点504。一个映射规则中只能包含一个版类结点501和评测结点502,但可以包含多个分支结点503和语句结点504。同样地,一个版类、评测或语句也可以被多个映射规则引用,但分支503只能包含在一个映射规则中。Branch 503 is used to connect evaluation node 502 and statement node 504 . A mapping rule can only contain one version node 501 and evaluation node 502 , but can contain multiple branch nodes 503 and statement nodes 504 . Similarly, a category, comment or statement can also be referenced by multiple mapping rules, but branch 503 can only be included in one mapping rule.
映射规则编辑器107,用于通过可视化的方式编辑生成映射规则。将映射规则各部分之间关系用Eclipse平台上的EMF(Eclipse Modeling Framework,Eclipse建模框架)模型表示出来,生成映射规则编辑器107,并加入映射规则解释器,使映射规则编辑器107生成的映射规则能通过该解释器生成Java代码。The mapping rule editor 107 is configured to edit and generate mapping rules in a visual manner. Express the relationship between each part of the mapping rule with the EMF (Eclipse Modeling Framework, Eclipse Modeling Framework) model on the Eclipse platform, generate a mapping rule editor 107, and add a mapping rule interpreter, so that the mapping rule editor 107 generates Mapping rules can generate Java code through the interpreter.
映射规则执行引擎108,用于依次加载并执行传入的映射规则列表,返回一个或多个目标脚本文件。The mapping rule execution engine 108 is configured to sequentially load and execute the incoming mapping rule list, and return one or more target script files.
映射规则执行引擎108在收到代理规则105传来的映射规则和模型元素后,执行映射规则的过程具体如下:After the mapping rule execution engine 108 receives the mapping rules and model elements from the proxy rule 105, the process of executing the mapping rules is specifically as follows:
取得当前映射规则所对应的分支503,对每个分支503进行初始化,然后将该分支503的值传入到评测结点502中,评测结点502对传入的分支503的值和模型元素按一定的算法(该算法是定义映射规则时定义的)进行运算,运算结果为一个布尔值。当该值为真时,映射规则执行引擎108再把该分支503所对应的语句(语句本身是一个目标脚本文件)加入到目标脚本列表中。当所有分支都处理完毕后,该映射规则执行完毕。Obtain the branch 503 corresponding to the current mapping rule, initialize each branch 503, and then transfer the value of the branch 503 to the evaluation node 502, and the evaluation node 502 performs the input of the value of the branch 503 and the model element according to A certain algorithm (the algorithm is defined when defining the mapping rule) performs the operation, and the result of the operation is a Boolean value. When the value is true, the mapping rule execution engine 108 adds the statement corresponding to the branch 503 (the statement itself is a target script file) into the target script list. When all branches are processed, the mapping rule is executed.
当所有映射规则都处理完后,映射规则执行引擎108将目标脚本列表交给脚本合并器109进行合并。After all the mapping rules are processed, the mapping rule execution engine 108 sends the target script list to the script combiner 109 for merging.
脚本合并器109,用于将多个目标脚本文件合并成一个目标脚本文件。对每种目标模型,都定义了一套基于XML的脚本对该目标模型进行描述,称该脚本为目标脚本(ObjectScript)。利用目标脚本描述的包含有目标模型信息的脚本文件,称之为目标脚本文件。Script combiner 109, used to combine multiple target script files into one target script file. For each object model, a set of XML-based scripts is defined to describe the object model, which is called object script (ObjectScript). The script file containing the target model information described by the target script is called the target script file.
为了描述目标模型中的各种模型元素,在目标脚本中也要定义相应的结点,所以每个目标脚本文件中可能包括了多种结点,脚本合并器109将多个目标脚本中相同的类型的结点进行合并,最后生成一个目标脚本文件。In order to describe various model elements in the target model, corresponding nodes are also defined in the target script, so each target script file may include multiple nodes, and the script combiner 109 combines the same nodes in multiple target scripts. Types of nodes are merged, and finally an object script file is generated.
脚本解释器110,用于在模型到模型的转换中,将目标脚本文件进行解释,生成目标模型;在模型到代码的转换中,对目标文件进行解释,生成相应的代码;The
公共数据区111,主要存放模型转换过程中的一些全局数据,如扫描的模型元素的信息、目标脚本文件相关的数据以及用户自定义的数据,用于支持代理规则105之间及映射规则之间数据的共享。The
如图6所示,是本发明模型转换流程图。结合图1、3、4,该模型转换的处理步骤如下:As shown in Fig. 6, it is a flow chart of model conversion in the present invention. Combined with Figures 1, 3, and 4, the processing steps of the model conversion are as follows:
步骤601,模型提取器101提取源模型中的模型元素,并传给代理规则管理器103;
在该步骤之前,使用映射规则编辑器107生成源元模型与目标元模型之间的映射规则,并将其保存到映射规则库106中;Before this step, use the mapping rule editor 107 to generate the mapping rule between the source metamodel and the target metamodel, and save it in the
步骤602,代理规则管理器103根据模型元素的类型查询模型元素所对应的代理规则105,并把模型元素交给代理规则105进行处理;
步骤603,代理规则105将模型元素传给映射规则查询引擎104,映射规则查询引擎104根据模型元素查询映射规则库106得到与该模型元素对应的映射规则;映射规则查询引擎104将查询得到的映射规则返回给代理规则105进行处理;
如果模型元素上没有附加元模型(即版类),只采用特征字符串查询,查询的过程如图3所示,每个代理规则105都有一个查询关键字SearchKey,并将该SearchKey作为特征字符串交给映射规则查询引擎104的特征字符串查询模块1041,特征字符串查询模块1041返回所有关键字Key为特征字符串的映射规则;If there is no additional meta-model (that is, version class) on the model element, only the feature string query is used. The query process is shown in Figure 3. Each proxy rule 105 has a query keyword SearchKey, and the SearchKey is used as the feature character The string is given to the feature
如果模型元素上附加了元模型(即版类),则采用元模型查询方式,如图4所示,代理规则105将从模型元素中提取的元模型交给映射规则查询引擎104的元模型查询模块1042,元模型查询模块1042返回所有包含有该元模型的映射规则;If a meta-model (i.e. version class) is attached to the model element, the meta-model query method is adopted, as shown in Figure 4, the proxy rule 105 hands over the meta-model extracted from the model element to the meta-model query of the mapping rule query engine 104 Module 1042, the metamodel query module 1042 returns all mapping rules that include the metamodel;
步骤604,代理规则105将模型元素的信息和映射规则一起提交给映射规则执行引擎108;映射规则执行引擎108对模型元素和映射规则进行处理,得到一个或多个目标脚本文件,并交给脚本合并器109进行合并处理;
该步骤中,映射规则执行引擎108依次读入并执行列表中的映射规则,每个映射规则返回一个目标脚本文件;将返回的所有目标脚本文件在公共数据区111缓存起来;In this step, the mapping rule execution engine 108 sequentially reads and executes the mapping rules in the list, and each mapping rule returns a target script file; all target script files returned are cached in the
步骤605,模型提取器101判断当前模型元素是否包含子元素,若含有,则返回至步骤601开始执行,即提取该模型元素的子元素,否则,跳到步骤606,进行目标脚本文件的合并;
步骤606,在所有的模型元素扫描完毕且都进行了处理,返回的所有目标脚本文件也保存在公共数据区111;脚本合并器109将对公共数据区111缓存的所有目标脚本文件进行合并,最后生成一个目标脚本文件,并由脚本解释器110进行解释;
步骤607,脚本解释器110解释目标脚本文件,生成目标模型或代码。In
该步骤中,同时适用于模型到代码的转换,将代码也抽象为用模型来表示,然后只要改动脚本解释器110的功能,就可以将模型转换为对应的代码。In this step, it is also applicable to the transformation from the model to the code, and the code is also abstracted to be represented by the model, and then the model can be converted into the corresponding code only by changing the function of the
本发明通过将模型转换规则细化为代理规则和映射规则,实现了模型转换引擎与映射规则的分离,增强了转换引擎中一些通用模块的重用性,大大简化了模型转换的工作量和技术难度。The invention realizes the separation of the model conversion engine and the mapping rules by refining the model conversion rules into proxy rules and mapping rules, enhances the reusability of some common modules in the conversion engine, and greatly simplifies the workload and technical difficulty of model conversion .
当然,本发明还可有其他多种实施例,在不背离本发明精神及其实质的情况下,熟悉本领域的技术人员当可根据本发明作出各种相应的改变和变形,但这些相应的改变和变形都应属于本发明所附的权利要求的保护范围。Of course, the present invention can also have other various embodiments, and those skilled in the art can make various corresponding changes and deformations according to the present invention without departing from the spirit and essence of the present invention, but these corresponding Changes and deformations should belong to the scope of protection of the appended claims of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2006101426257A CN100517222C (en) | 2006-10-25 | 2006-10-25 | Model Transformation Device and Method Supporting Separation of Transformation Engine and Mapping Rules |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2006101426257A CN100517222C (en) | 2006-10-25 | 2006-10-25 | Model Transformation Device and Method Supporting Separation of Transformation Engine and Mapping Rules |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101169713A true CN101169713A (en) | 2008-04-30 |
CN100517222C CN100517222C (en) | 2009-07-22 |
Family
ID=39390353
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2006101426257A Expired - Fee Related CN100517222C (en) | 2006-10-25 | 2006-10-25 | Model Transformation Device and Method Supporting Separation of Transformation Engine and Mapping Rules |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100517222C (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101763261B (en) * | 2009-12-28 | 2013-01-23 | 山东中创软件商用中间件股份有限公司 | Method and system for extracting, converting and loading data |
CN103377044A (en) * | 2012-04-24 | 2013-10-30 | 中兴通讯股份有限公司 | Rule generation system, intelligent platform management controller (IPMC) network device and rule generation method |
CN103425469A (en) * | 2012-05-17 | 2013-12-04 | 上海闻泰电子科技有限公司 | Method for generating mobile game codes based on MDA technology |
CN106919434A (en) * | 2017-03-22 | 2017-07-04 | 恒生电子股份有限公司 | A kind of code generating method and device |
CN109194611A (en) * | 2018-07-24 | 2019-01-11 | 北京邮电大学 | A kind of internetworking safety control strategy rule mapping method |
CN110533162A (en) * | 2019-07-25 | 2019-12-03 | 中国科学院计算技术研究所 | It is a kind of to automatically generate the method and system that mapping is operated between deep learning frame |
CN110750683A (en) * | 2019-09-20 | 2020-02-04 | 平安普惠企业管理有限公司 | Data modification method and device, computer equipment and storage medium |
CN112052012A (en) * | 2020-08-31 | 2020-12-08 | 烽火通信科技股份有限公司 | XSLT and XSD-based code automatic generation method and equipment |
CN112348458A (en) * | 2020-10-19 | 2021-02-09 | 湖南大唐先一科技有限公司 | Process model matching method and system based on business rules |
-
2006
- 2006-10-25 CN CNB2006101426257A patent/CN100517222C/en not_active Expired - Fee Related
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101763261B (en) * | 2009-12-28 | 2013-01-23 | 山东中创软件商用中间件股份有限公司 | Method and system for extracting, converting and loading data |
CN103377044A (en) * | 2012-04-24 | 2013-10-30 | 中兴通讯股份有限公司 | Rule generation system, intelligent platform management controller (IPMC) network device and rule generation method |
CN103377044B (en) * | 2012-04-24 | 2017-06-16 | 南京中兴新软件有限责任公司 | A kind of regular generation system, the IPMC network equipments and rule generating method |
CN103425469A (en) * | 2012-05-17 | 2013-12-04 | 上海闻泰电子科技有限公司 | Method for generating mobile game codes based on MDA technology |
CN106919434A (en) * | 2017-03-22 | 2017-07-04 | 恒生电子股份有限公司 | A kind of code generating method and device |
CN109194611A (en) * | 2018-07-24 | 2019-01-11 | 北京邮电大学 | A kind of internetworking safety control strategy rule mapping method |
CN110533162A (en) * | 2019-07-25 | 2019-12-03 | 中国科学院计算技术研究所 | It is a kind of to automatically generate the method and system that mapping is operated between deep learning frame |
CN110533162B (en) * | 2019-07-25 | 2022-01-07 | 中国科学院计算技术研究所 | Method and system for automatically generating operation mapping between deep learning frames |
CN110750683A (en) * | 2019-09-20 | 2020-02-04 | 平安普惠企业管理有限公司 | Data modification method and device, computer equipment and storage medium |
CN112052012A (en) * | 2020-08-31 | 2020-12-08 | 烽火通信科技股份有限公司 | XSLT and XSD-based code automatic generation method and equipment |
CN112052012B (en) * | 2020-08-31 | 2022-11-11 | 烽火通信科技股份有限公司 | XSLT and XSD-based code automatic generation method and equipment |
CN112348458A (en) * | 2020-10-19 | 2021-02-09 | 湖南大唐先一科技有限公司 | Process model matching method and system based on business rules |
Also Published As
Publication number | Publication date |
---|---|
CN100517222C (en) | 2009-07-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Kelly et al. | Metaedit+ a fully configurable multi-user and multi-tool case and came environment | |
Pérez-Castillo et al. | Knowledge Discovery Metamodel-ISO/IEC 19506: A standard to modernize legacy systems | |
El Akkaoui et al. | A model-driven framework for ETL process development | |
US7739267B2 (en) | Classification and sequencing of mixed data flows | |
US7689582B2 (en) | Data flow system and method for heterogeneous data integration environments | |
CN101169713A (en) | Model Transformation Framework and Method Supporting Separation of Transformation Engine and Mapping Rules | |
CA2641941C (en) | Legacy software modernization system | |
Syme et al. | Expert F♯ | |
CN101887365B (en) | Method and system for constructing executable code for component-based applications | |
Ebert et al. | Graph based modeling and implementation with EER/GRAL | |
US20080071802A1 (en) | Tranformation of modular finite state transducers | |
US20080071801A1 (en) | Transformation of modular finite state transducers | |
de Boer et al. | Enterprise architecture analysis with xml | |
Cartright et al. | Galago: A Modular Distributed Processing and Retrieval System. | |
Kolovos et al. | The epsilon pattern language | |
CN105335161B (en) | It is a kind of from TASM time abstractions state machine to extension NTA automatic machines conversion method | |
Irwin et al. | Object oriented metrics: Precision tools and configurable visualisations | |
Syme et al. | Expert F♯ 2.0 | |
CN113687827B (en) | Data list generation method, device and equipment based on widget and storage medium | |
US7657869B2 (en) | Integration of external tools into an existing design environment | |
Kongdenfha et al. | Web service adaptation: Mismatch patterns and semi-automated approach to mismatch identification and adapter development | |
Ilk et al. | Semantic enrichment process: an approach to software component reuse in modernizing enterprise systems | |
Basciani et al. | Exploring model repositories by means of megamodel-aware search operators. | |
Bézivin et al. | Applying the basic principles of model engineering to the field of process engineering | |
Kalinichenko et al. | Constructing of Mappings of Heterogeneous Information Models into the Canonical Models of Integrated Information Systems. |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20090722 Termination date: 20151025 |
|
EXPY | Termination of patent right or utility model |