Model framework code generation system and method
Through the model framework code generation system, the visual interface is used to automatically generate the framework code of the data model, which solves the problems of high workload and high error rate in manual writing of data models, and improves the data quality and code generation efficiency.
Patent Information
- Application Number
- CN202011464734.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-14
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2040-12-14
AI Technical Summary
The existing data model is written manually, and has problems such as large workload, long cycle, high cost, high error rate, and low code reuse rate. It is difficult to hand over code when people move.
Provide a model framework code generation system, including model database module, visual interface module, model construction layer module and model publishing layer module, automatically generate framework code through the visual interface to reduce manual writing.
It reduces manpower workload, repetitive work and human errors, and improves the data quality of the model and the generation speed, standardization and stability of codes.
Smart Images

Figure CN114625353B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud service technology, and in particular to a model framework code generation system and method. Background Art
[0002] A data model is an abstraction of the characteristics of real-world data. It is used to describe the concepts and definitions of a set of data and is the basis for data asset management and data governance. A high-quality data model helps improve the quality of business system data.
[0003] The existing data model is manually defined and developed offline. However, in the information system construction and development stage, there are problems that cannot be fundamentally solved by manually writing code: first, the workload of manually writing code is large, the cycle is long, and the cost is high; second, it has high requirements for R&D personnel, and some errors are repeated in the codes of different personnel and different positions of the same personnel. Improving personal ability can only reduce the error rate, but cannot fundamentally avoid these errors; third, although there are public coding standards, different personnel have different learning levels and understanding directions of code standards. In the coding process, they have more or less personal bad habits. When personnel turnover occurs, the difficulty of code handover increases; fourth, the reuse rate of manually written code is low and the reuse difficulty is high. A large number of codes with similar logic are easily missed during transplantation and modification, which can easily lead to a series of serious errors. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a framework code generation system and method to improve the data quality of the model.
[0005] In order to achieve the above object, the present invention adopts the following scheme:
[0006] According to one aspect of an embodiment of the present invention, a model framework code generation system is provided, comprising:
[0007] A model database module, used to store at least one of a data element, a data object model, and a service description model pre-constructed according to a set business system, and a service description language defined for the business domain of the set business system;
[0008] A visualization interface module, configured to display the visualization identifiers of the stored data elements, data object models, and service description models, receive an orchestration operation instruction, and select at least one of the visualization identifiers of the data elements, data object models, and service description models according to the orchestration operation instruction;
[0009] A model building layer module, used to obtain at least one of the corresponding stored data elements, data object models, and service description models according to the selected visual identifier, so as to construct a new model; wherein the new model is a new data object model or a new service description model;
[0010] The model publishing layer module is used to publish the new model according to the stored service description language, and generate the framework code and corresponding environment library files for running the new model in the set business system.
[0011] In some embodiments, the model framework code generation system further includes:
[0012] The model testing layer module is used to verify and analyze the framework code and corresponding environment library files of the new model to perform client and server contract testing.
[0013] In some embodiments, the model publishing layer module is further used to record the new model related information; wherein the new model related information includes at least one of publishing time information, publishing description information, publishing version information, publishing field information, and publishing organization information;
[0014] The model database module is also used to import and store the framework code and corresponding environment library files of the new model, as well as the relevant information of the new model.
[0015] In some embodiments, the storage structure of at least one of the stored data elements, data object models, and service description models is a tree structure.
[0016] In some embodiments, the arrangement operation instruction includes a drag operation instruction and / or an association operation instruction.
[0017] In some embodiments, the service description language includes the structure of the data object model and its meaning, data elements and their meaning, the function interface model and its meaning, function types, and containers, as well as the required inheritance relationships, composition relationships, and aggregation associations between them.
[0018] In some embodiments, the model publishing layer module includes:
[0019] The lexical analysis and verification module is used to scan the description file of the new model in units of characters. When a word in the scanned new model is a keyword in the service description language, the attribute code corresponding to the word is returned. When a word in the scanned new model is an invalid character, the invalid character is skipped. When a word in the scanned new model is not a keyword in the service description language and is not an invalid character, the string information of the corresponding word is retained, so as to obtain the lexical analysis and verification results of the new model after scanning the description file of the new model;
[0020] The framework code generation module is used to parse the description file of the new model according to the lexical analysis and verification results of the new model to execute the corresponding functions, initialize global variables, call the set code generation function, parse the language type, and generate the corresponding framework code according to the language type;
[0021] The packaging module is used to copy the framework code to the source code path of the programming language project, and copy the service framework environment library file that the programming language project depends on to the environment library path, and package and compress the framework code and environment library path and service framework environment library file under the source code path to obtain a compressed package of the framework code of the new model and the corresponding environment library file.
[0022] In some embodiments, the model testing layer module includes:
[0023] The server-side service instance MockServer generation module is used to simulate the function interface return parameter value and generate the server-side service instance MockServer according to the framework code of the new model and the description file of the service description model used for testing;
[0024] The client capability test MockClient generation module is used to load the interface using the Java parent class loader according to the framework code of the server service instance to obtain the class object instance by using the reflection mechanism, collect the interface method array information of the service description model used for testing through the reflection mechanism, obtain the instance class required to create the client through the reflection mechanism according to the obtained class object instance and interface method data information, create the client object through the instance class and obtain the member variables and corresponding calling methods to form the client capability test MockClient;
[0025] The xml template generation module is used to test MockClient using client capabilities, obtain the input parameter type, output parameter type and method name of the interface function according to the obtained member variables, and generate an xml template according to the input parameter type, output parameter type and method name;
[0026] The contract test module is used to fill in the parameter values of the corresponding types of the input test parameters using the generated xml template, and pass the input parameter values into the invoke method of the client object through the reflection mechanism, so as to use the calling method to remotely call the server service instance MockServer.
[0027] According to another aspect of an embodiment of the present invention, a model framework code generation method is also provided, comprising:
[0028] Acquire at least one of a stored data element, a data object model, and a service description model that are pre-constructed according to a set business system, and a service description language defined for a business domain where the set business system is located;
[0029] Displaying the visual identification of the stored data elements, data object models, and service description models, receiving an orchestration operation instruction, and selecting at least one of the visual identification of the data elements, data object models, and service description models according to the orchestration operation instruction;
[0030] According to the selected visualization identifier, obtaining at least one of the corresponding stored data elements, data object models, and service description models to construct a new model; wherein the new model is a new data object model or a new service description model;
[0031] The new model is published according to the stored service description language, and a framework code and a corresponding environment library file for running the new model in the set business system are generated.
[0032] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the steps of the method described in the above embodiment are implemented.
[0033] The model framework code generation system, model framework code generation method and computer-readable storage medium of the embodiments of the present invention can assist users in model compilation, reduce manual workload, repetitive work, human errors, etc., and improve the data quality of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0035] Figure 1 It is a schematic diagram of the structure of a model framework code generation system according to an embodiment of the present invention;
[0036] Figure 2 is a schematic diagram of the structure of a model framework code generation system according to another embodiment of the present invention;
[0037] Figure 3 It is a flowchart of a model framework code generation method according to an embodiment of the present invention;
[0038] Figure 4is a schematic diagram of a data object model application mode in one embodiment of the present invention;
[0039] Figure 5 It is a schematic diagram of an exchange model application mode in one embodiment of the present invention. DETAILED DESCRIPTION
[0040] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0041] It should be noted in advance that the description of the following embodiments or examples or the features mentioned therein can be combined with the features in other embodiments or examples in the same or similar manner, or replace the features in other embodiments or examples to form possible implementation methods. In addition, the term "include / comprise" used herein refers to the presence of features, elements, steps or components, but does not exclude the presence of one or more other features, elements, steps or components.
[0042] In order to reduce various problems existing in manually written codes, an embodiment of the present invention provides a model code auxiliary generation tool to automatically generate source code using a visual interface, thereby improving the generation speed, standardization and stability of the code.
[0043] Figure 1 is a schematic diagram of the structure of a model framework code generation system according to an embodiment of the present invention. Figure 1 As shown, the model framework code generation system of this embodiment may include: a model database module 110 , a visualization interface module 120 , a model construction layer module 130 and a model publishing layer module 140 .
[0044] The model database module 110 is used to store at least one of the data elements, data object models, and service description models that are pre-built according to the set business system, and the service description language defined for the business field where the set business system is located. The data elements are standard data elements and can be obtained by importing or manually adding. The data elements and data object models can be used to build new data object models. The data elements, data object models, and service description models can be used to build new service description models. Among them, the service description model is, for example, a business system service provided to users using a cloud service platform.
[0045] The storage structure of at least one of the stored data elements, data object models, and service description models may be a tree structure, so that the data elements, data object models, and service description models can be easily searched.
[0046] The service description language may include the structure of the data object model and its meaning, data elements and their meaning, function interface model and its meaning, function type, and container, as well as the inheritance relationship, composition relationship and aggregation relationship required therebetween. The service description language may be obtained by summarizing and standardizing according to the business system.
[0047] The visualization interface module 120 is used to display the stored visualization identifiers of the data elements, data object models, and service description models, receive an arrangement operation instruction, and select at least one of the visualization identifiers of the data elements, data object models, and service description models according to the arrangement operation instruction. The arrangement operation instruction may include a drag operation instruction and / or an association operation instruction.
[0048] The model building layer module 130 is used to obtain at least one of the corresponding stored data elements, data object models, and service description models according to the selected visualization identifier to construct a new model; wherein the new model is a new data object model or a new service description model. The visualization interface module 120 may be a part of the model building layer module 130. Different identifiers may be used to represent data elements, data object models, service description models, etc. on the visualization interface, and these identifiers may be associated with the background model library. For example, when dragging an identifier, a corresponding part of the model library may be selected.
[0049] The model publishing layer module 140 is used to publish the new model according to the stored service description language, and generate a framework code and a corresponding environment library file for running the new model in the set business system.
[0050] In specific implementation, the model publishing layer module 140 may include: a lexical analysis and verification module, a framework code generation module and a packaging module.
[0051] The lexical analysis and verification module is used to scan the description file of the new model in units of characters. When the word in the scanned new model is a keyword in the service description language, the attribute code corresponding to the word is returned. When the word in the scanned new model is an invalid character, the invalid character is skipped. When the word in the scanned new model is not a keyword in the service description language and is not an invalid character, the string information of the corresponding word is retained, so as to obtain the lexical analysis and verification results of the new model after scanning the description file of the new model. The description file is, for example, an IDL (Interactive Data Language) description file.
[0052] The framework code generation module is used to parse the description file of the new model according to the lexical analysis and verification results of the new model to execute the corresponding functions, initialize global variables, call the set code generation function, parse the language type, and generate the corresponding framework code according to the language type. Among them, the correspondence between the lexical and attribute encoding in the compiler can be pre-built, so the compiler can be used to execute the parsed file and generate code. The compiler can be an improved compiler.
[0053] The packaging module is used to copy the framework code to the source code path of the programming language project, and copy the service framework environment library file that the programming language project depends on to the environment library path, and package and compress the framework code and environment library path and service framework environment library file under the source code path to obtain a compressed package of the framework code of the new model and the corresponding environment library file.
[0054] In a further embodiment, the model publishing layer module 140 can also be used to record the new model related information; wherein the new model related information includes at least one of the release time information, release description information, release version information, release field information, and release organization information. The model database module 110 can also be used to import and store the framework code and corresponding environment library files of the new model, as well as the new model related information. In this embodiment, the generated new model can be stored in the model library for use in the next model arrangement.
[0055] Figure 2 is a schematic diagram of the structure of a model framework code generation system according to another embodiment of the present invention. Figure 2 As shown, Figure 1 The model framework code generation system shown may also include a model test layer module 150. The model test layer module 150 is used to verify and analyze the framework code of the new model and the corresponding environment library files to perform client and server contract testing. The test can ensure that the generated new model can be used.
[0056] Specifically, the model test layer module 150 may include: a server service instance MockServer generation module, a client capability test MockClient generation module, an xml template generation module, and a contract test module.
[0057] The server-side service instance MockServer generation module is used to generate the server-side service instance MockServer based on the framework code of the new model and the description file of the service description model used for testing, to simulate the function interface return parameter value. If the service description model is tested, the description file of the service description model to be tested (such as an IDL file) can be used as the description file of the service description model used for testing; if the data object model is tested, the description file of the service description model used for testing can be the description file of any given service description model, as long as it can describe the data object model.
[0058] The client capability test MockClient generation module is used to load the interface using the Java parent class loader according to the framework code of the server service instance to obtain the class object instance using the reflection mechanism, collect the interface method array information of the service description model used for testing through the reflection mechanism, obtain the instance class required to create the client through the reflection mechanism according to the obtained class object instance and interface method data information, create the client object through the instance class and obtain member variables and corresponding calling methods to form the client capability test MockClient.
[0059] The xml template generation module is used to test MockClient using client capabilities, obtain the input parameter type, output parameter type and method name of the interface function according to the obtained member variables, and generate an xml template (Extensible Markup Language template) according to the input parameter type, output parameter type and method name.
[0060] The contract test module is used to fill in the parameter values of the corresponding types of the input test parameters using the generated xml template, and pass the input parameter values into the invoke method of the client object through the reflection mechanism, so as to use the calling method to remotely call the server service instance MockServer.
[0061] In this embodiment, by using Java language to perform model testing, test results of various function interfaces, etc. can be obtained during the test process. Moreover, since the initial description file is independent of the programming language, the model test can be performed using Java language regardless of whether it is used for Java language or C / C++ language.
[0062] Based on Figure 1 The same inventive concept as the model framework code generation system shown in the figure, the embodiment of the present application also provides a model framework code generation method, as described in the following embodiment. Since the principle of solving the problem by the model framework code generation method is similar to that of the model framework code generation system, the implementation of the model framework code generation method can refer to the implementation of the model framework code generation system, and the repeated parts will not be repeated.
[0063] Figure 3 is a flow chart of a model framework code generation method according to an embodiment of the present invention. Figure 3 As shown, the model framework code generation method of this embodiment may include:
[0064] Step S210: acquiring at least one of a stored data element, a data object model, and a service description model that are pre-constructed according to a set business system, and a service description language defined for the business domain where the set business system is located;
[0065] Step S220: Displaying the stored visual identifiers of the data element, data object model, and service description model, receiving an orchestration operation instruction, and selecting at least one of the visual identifiers of the data element, data object model, and service description model according to the orchestration operation instruction;
[0066] Step S230: according to the selected visualization identifier, obtaining at least one of the corresponding stored data elements, data object models, and service description models to construct a new model; wherein the new model is a new data object model or a new service description model;
[0067] Step S240: Publish the new model according to the stored service description language, and generate a framework code and a corresponding environment library file for running the new model in the set business system.
[0068] In some embodiments, Figure 3 The method shown may also include the step: S250, verifying and analyzing the framework code of the new model and the corresponding environment library files to perform client and server contract testing.
[0069] In some embodiments, Figure 3 The method shown may also include the steps of: S260, recording information related to the new model; wherein the information related to the new model includes at least one of release time information, release description information, release version information, release field information, and release organization information; S270, importing and storing the framework code and corresponding environment library files of the new model, as well as the information related to the new model.
[0070] In some embodiments, the storage structure of at least one of the stored data elements, data object models, and service description models is a tree structure.
[0071] In some embodiments, the arrangement operation instruction includes a drag operation instruction and / or an association operation instruction.
[0072] In some embodiments, the service description language includes the structure of the data object model and its meaning, data elements and their meaning, the function interface model and its meaning, function types, and containers, as well as the required inheritance relationships, composition relationships, and aggregation associations between them.
[0073] In specific implementation, the above step S240, that is, publishing the new model according to the stored service description language, generating a framework code and a corresponding environment library file for running the new model in the set business system, may specifically include the following steps: S241, scanning the description file of the new model in units of characters, returning the attribute code corresponding to the word when the scanned word in the new model is a keyword in the service description language, skipping the invalid character when the scanned word in the new model is an invalid character, retaining the string information of the corresponding word when the scanned word in the new model is not a keyword in the service description language and is not an invalid character, so as to obtain the attribute code corresponding to the word after scanning the new model. After obtaining the lexical analysis and verification results of the new model, S242, the description file of the new model is parsed according to the lexical analysis and verification results of the new model to execute the corresponding functions, initialize global variables, call the setting code generation function, parse the language type, and generate the corresponding framework code according to the language type; S243, copy the framework code to the source code path of the programming language project, and copy the service framework environment library file that the programming language project depends on to the environment library path, and package and compress the framework code and environment library path and service framework environment library file under the source code path to obtain a compressed package of the framework code of the new model and the corresponding environment library file.
[0074] In specific implementation, the above step S250, that is, verifying and analyzing the framework code of the new model and the corresponding environment library files to perform client and server contract testing, may specifically include the following steps: S251, according to the framework code of the new model, using the description file of the service description model used for testing, simulating the function interface return parameter value, and generating a server-side service instance MockServer; S252, according to the framework code of the server-side service instance, using the Java parent class loader to load the interface to obtain the class object instance using the reflection mechanism, collecting the interface method array information of the service description model used for testing through the reflection mechanism, and obtaining the class object instance and interface method data information through the reflection mechanism. To create the instance class required by the client, create the client object through the instance class and obtain the member variables and the corresponding calling method to form the client capability test MockClient; S253, use the client capability test MockClient to obtain the input parameter type, output parameter type and method name of the interface function according to the obtained member variables, and generate an xml template according to the input parameter type, output parameter type and method name; S254, use the generated xml template to fill in the parameter value of the corresponding type of the input test parameter, and pass the input parameter value into the invoke method of the client object through the reflection mechanism, so as to use the calling method to remotely call the server service instance MockServer.
[0075] In addition, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method described in the above embodiment are implemented.
[0076] The above method is described below in conjunction with a specific embodiment. However, it should be noted that this specific embodiment is only for better illustrating the present application and does not constitute an improper limitation on the present application.
[0077] Figure 4 is a schematic diagram of a data object model application mode in an embodiment of the present invention, see Figure 4 The model management service of the framework code generation tool based on model orchestration can include five functional modules: model database, model building layer, model testing layer, and model publishing layer.
[0078] Among them, the model database can be used to store the defined models, including standard data element storage, entity data model storage, and service description model storage. The standard data element storage can be a set of common attributes of data objects in a specific business field. Standard data elements, entity data models, and service description models can all be in a tree structure, and can be stored in the database with unified field attributes and precision, which can provide consistent specifications and definitions of basic data elements of the business system, and is the basis for the establishment of all models. The entity data subject model (data object model) is stored as a wide table of data objects for a specific business system (a wide table literally means a database table with more fields. It usually refers to a database table in which indicators, dimensions, and attributes related to business themes are associated together) entity data model refers to a model in which the attributes and operation attributes of data resources are encapsulated in a structure called an object class, which is essentially an abstract description of business data resources; the service description model is stored as an interface description file for the interface interaction between various business systems defined in a specific business field system, and the input and output parameters of the interface are sourced from standard data elements or complex entity data models.
[0079] The model building layer can be responsible for the construction of standard data elements (which can be obtained by importing or manually adding), entity data models (involving interactive modes), and service description models, providing a visual interface, using drag and drop and association modes to build new data models or service description models, and supporting two methods of building data objects based on existing model aggregation and creating new data models. Function interface models, basic types of functions, containers, etc. can be selected on the interface, such as by checking the selection.
[0080] The model testing layer can be responsible for customizing the verification rules for specific fields in the data model or specific interfaces of the service description model (which can be business system summary or language specification), forming two test piles: producer service contract test and consumer contract test;
[0081] The model publishing layer may include data model publishing and service description model publishing. The data model publishing generates entity classes corresponding to java and C++ languages (mainly as categories existing at the data management and business logic processing levels) and proto files (files and codes) constructed based on model orchestration from the data model that has passed the construction test. The service model publishing generates framework codes corresponding to java (packaged) or C++ languages and dependent environment library file resources for publishing and registering in the data directory. Business developers can download the published and registered data object models and service description models on demand. The model publishing layer records the historical time information, publishing description information, publishing version information, publishing field information, and publishing agency information of the publishing, and publishes the model as a service in the data directory, realizing the cloud service model. The model publishing layer supports importing proto files to form data object models and service description files to form service description models and persistently storing them in the model database. The release generation result can be a compressed package of both code (framework code) and files (environment library files).
[0082] In the model publishing layer, you can publish the data model by following the steps below:
[0083] (S11) defining a description language for a service description model for a specific business domain, wherein the service description language includes a data entity object model structure and its Chinese meaning, standard elements and their Chinese meaning, a function interface model and its Chinese meaning, basic types of functions (such as int), containers, and inheritance, combination, and aggregation relationships among them, provided by a model database; the data entity object model (data object model) is a complex data type, describing an object model for a specific business domain, including members and methods (if nested, in affix format); the function interface model describes a function interface of a system call, including input and output parameters and interface name definitions;
[0084] (S12) performing lexical analysis and verification on the text file generated by the data entity object model and the function interface model described in the language described in step (S11), scanning the constructed description file in units of characters, skipping blank symbols, line feed symbols and comment parts, and returning the attribute code corresponding to the reserved word (such as type, structure, function, number of parameters, data object, etc., such as int type, which will be changed to i32) if the scanned word is a keyword of the description language, otherwise directly returning the string information of the word, until the end of the description file is scanned, completing the lexical analysis and verification of the description file;
[0085] (S13) according to the result of the lexical analysis in step (S12), the description file (i.e., the IDL description file) is parsed (a file recognizable by the compiler), and according to the corresponding function, the global variable is initialized and the code generation function is called to generate the code, the language type is parsed, and the corresponding class object is generated according to the language type, and then the program generation function is called to generate the corresponding program code; there can be a corresponding table of attribute codes and corresponding contents, and the obtained attribute codes can be parsed into a file recognizable by the compiler, and the compiler is also a compiler adjusted appropriately;
[0086] (S14) According to the framework code (generated program code) generated in step (S13), copy the framework code to the source code path (path corresponding to the model) of the template C++VS2010 project and the template java project (Jar package), copy the service framework environment library file that the project depends on to the environment library path, compress and package it with the model name, and download and publish its resources (compressed package of code and environment library files) to the data directory;
[0087] (S15) According to the model resources released in step (S14), the data directory management personnel review the released model resources, and the model resources that meet the rules are reviewed and approved. Users can access the data directory through a browser to download and use the model resources.
[0088] In the model testing layer, the following steps can be used for testing:
[0089] (S21) According to the framework code generated by the model publishing layer, in the model management background, according to the IDL description file of the defined service description model (the description file does not yet involve the language type, no matter which language the data model is in, it can be tested in Java, and the Java method can be used to test on the client), simulate the function interface return parameter value, and generate the test server service instance MockServer (server program); a normal function return parameter requires a lot of processing (such as calculation, conversion, call), while this embodiment only needs a simple function return here;
[0090] (S22) According to the framework code generated in step (S21), the interface implementation class is loaded using the parent class loader of Java, and the Class object instance (file, object, interface of the running thing) is obtained by the reflection mechanism. All interface method array information defined in the service description model (interface in the service description file) is collected through the reflection mechanism, and the client factory instance and the client create instance. After all the instance Class required to create the client are obtained through the reflection mechanism (based on the obtained Class object instance and interface method array information), the client object is created through the instance Class and the member variables and calling methods (the content corresponding to the interface) are obtained to form a capability test MockClient (client program).
[0091] (S23) According to the member variables obtained by the reflection mechanism in step (S22), the input and output parameter types and method name (such as calculation method) of the defined interface function are obtained, and an XML template is generated according to the method name and parameter type.
[0092] (S24) Fill in the value of the corresponding type of the test parameter according to the XML template generated in step (S23), and pass the value of the input (invaded) parameter into the invoke method held by the instance object generated by the reflection mechanism through the reflection mechanism to remotely call the method of the service instance generated in step (S21).
[0093] The model database can be constructed by following the steps below:
[0094] The first step is to create a data object model library template
[0095] The namespace of entity classes in the existing business system is reasonably classified and layered according to the package path name, and the data object tree list structure is constructed step by step according to the classification and layering structure, so as to facilitate the rapid construction of new data object models using existing model library templates and to facilitate the unified modification of the public attributes of a basic data object in the later stage;
[0096] Step 2: Create data objects and standard elements
[0097] Summarize and summarize the existing database tables and business systems to form a tree list of standard elements, and classify and layer the standard elements according to business domain categories to facilitate the creation of data models for repeated reference; provide a basic data object model to facilitate the aggregation and repeated reference of complex data object models;
[0098] Step 3: Create data object associations
[0099] When creating a complex data model, select data objects with associated relationships from the data model tree list and set the association relationship with each data object. After the setting is completed, a network of association relationships of all data objects is formed, providing an interface for viewing the association relationship globally and locally, providing strong support for the subsequent maintenance of the business integrity of the data model.
[0100] This embodiment can address the problems of inconsistent data description, non-standard manual coding, and cumbersome and complex secondary development processes in business information systems in specific fields. From the perspective of integrated design, development, and operation and maintenance, a visual orchestration model generation tool and framework code generation method are proposed, including a model database, a model construction layer, a model testing layer, a model publishing layer, a data capability model, and a service capability model. The model database is responsible for storing data object models and service description models that have been built online, and supports the import and export of business subject service data objects, operators, and service description files based on standard formats; the model construction layer provides a visual interface, uses drag-and-drop and association modes to build new data object models and service description models, and supports two methods: building based on existing models and creating new models. At the same time, the model construction layer has built-in standard data elements and general data object models that are commonly used in the business system field to describe entities. It can be aggregated and constructed based on the standard data elements and general data object models, and supports the selection of several data models to generate data objects according to the association relationship to achieve further integration of data. The aggregated and associated data object models can be directly used and stored; in the model testing layer, users can customize verification rules for specific fields of the data model, provide an online test interface to test whether the data model complies with the specifications, support online generation of test reports, and form two test piles for producer service contract testing and consumer contract testing; the model publishing layer, including data model publishing and service description model publishing, business developers can download the published and registered data object model and service description model on demand, the model publishing layer records the historical time information, publishing description information, publishing version information, publishing field information, and publishing agency information of the publishing, and publishes the model as a service in the data directory, realizing the cloud service model; the model publishing layer supports the import of proto files to form data object models and service description files to form service description models and persistently stores them in the model database. The data capability model generates entity classes corresponding to Java and C++ languages and proto files based on model arrangement and construction from the data model that has passed the test based on the ProtoBuf binary serialization protocol. The service capability model generates framework codes corresponding to Java and C++ languages and dependent environment library file resources from the service description model interface description, and packages and publishes them to the data directory.
[0101] The model generation tool service refers to the business model, uses standardized terms, words and other data to design and constrain the data and service models in the business system, and in the process of business system construction and operation and maintenance, strictly follows the standards and contract terms established by model management to review and manage the newly added data models. Standardized management and unified control of data models are conducive to the integration of data assets and improve the data quality of business systems.
[0102] Figure 5 Schematic diagram of the application mode of the exchange model in one embodiment of the present invention. Figure 5 As shown, the framework code generation method based on model arrangement includes the following steps:
[0103] S1, standardize the naming, identification, and type information of database fields in standard data elements according to basic data, business database, comprehensive, and aggregate classification. The standard data elements constructed in step 1 are the basis for data model construction and exchange model;
[0104] S2, constructs a data model for the business domain based on the data standard elements constructed in S1 and the existing data models in the model database. The standard data elements serve as fields of the complex data model, and a drag-and-drop editing method is provided on the model construction page to edit and construct the complex data object model.
[0105] S3, based on the complex data model built in S2 as the input and output parameters of the system exchange data interface in the exchange model, name and identify the exchange data method of the exchange model on the model building page, and improve the list of designed exchange data interfaces. The exchange model definition can support the use of the existing exchange model interface in the model interface database table;
[0106] S4, publish resources for the data model and exchange model constructed in S2 and S3, the model publishing tool calls the model built-in framework code generator to generate proto source files, Java and Cpp source files for the data model, calls the model built-in service code compiler to generate JAVA and cpp framework codes for the exchange model of S3, and packages and compresses the operating environment library that the exchange model depends on, and uniformly publishes the resource download address to the data directory;
[0107] S5, the model user logs in to the data catalog portal and downloads the data model and service model resources.
[0108] A visual orchestration model generation tool and a framework code generation method, wherein the model generation tool comprises a model database module, a model construction layer module, a model test layer module, a model publishing layer module, a data capability model, and a service capability model; the model generation tool refers to the business model, uses standardized user, word and other data to design and constrain the data and service models in the business system, and during the construction and operation and maintenance of the business system, strictly follows the standards and contract terms formulated by the model management, reviews and manages the newly added data capability models and service capability models, completes the transformation and automatic generation of the data object model from graphical construction to the generation of description language text files to the framework code in the standard C++ syntax format and the framework code in the Java and syntax formats, and the standardized management and unified control of the data model are conducive to the integration of data assets and improving the data quality of the business system.
[0109] In this embodiment, a model management tool is provided to construct standard elements, data models, and exchange models, and a set of standardized processes are constructed to abstractly describe the characteristics of real-world data. The data model is constructed through a model publishing tool, and the verification rules of specific fields in the data model are customized. The data subject service client test code is generated to test the add, delete, modify and query interfaces provided by the data object in reality. After the test is successful, the passed data model is registered in the data directory. The exchange model is constructed through the model publishing tool, and the function name and function description information are set, and the parameter and return value type of the function interface are set by using the data object model in the data object model pool to create a function object interface. By combining the existing function models and providing detailed information of the service to generate a capability model, the background generates the rtp description file of the service according to the model interface. After the rtp file format is verified by the compiler, the exchange model can be generated and saved to the exchange model pool, and the exchange model capability verification function is provided. Based on the code generated by the rtp file, the exchange model server online program and the client online program are created. The service call test is successful, the service capability verification is passed, and the exchange model resources are published in the data directory. However, in the prior art, the definition of data models and exchange models has not formed a unique standardized process, and manual offline definition development has high communication costs and long testing and troubleshooting costs. Therefore, compared with the prior art, the present invention designs a model arrangement and publishing tool, which transfers the previous process of manually designing data object models and exchange service files to provide online design tools and reference model resource pools to guide and assist data subject and service design developers in design and development. The development efficiency of data services and exchange services is improved, and a model resource pool is provided to quickly develop new data models and exchange models.
[0110] The model framework code generation system, model framework code generation method and computer-readable storage medium of the embodiments of the present invention can assist users in model compilation, reduce manual workload, repetitive work, human errors, etc., and improve the data quality of the model.
[0111] In the description of this specification, the description with reference to the terms "one embodiment", "a specific embodiment", "some embodiments", "for example", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. The order of steps involved in each embodiment is used to schematically illustrate the implementation of the present invention, and the order of steps is not limited and can be appropriately adjusted as needed.
[0112] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0113] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0114] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0115] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0116] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A model framework code generation system, characterized in that: include: A model database module, used to store at least one of a data element, a data object model, and a service description model pre-constructed according to a set business system, and a service description language defined for the business domain of the set business system; A visualization interface module, configured to display the visualization identifiers of the stored data elements, data object models, and service description models, receive an orchestration operation instruction, and select at least one of the visualization identifiers of the data elements, data object models, and service description models according to the orchestration operation instruction; A model building layer module, used to obtain at least one of the corresponding stored data elements, data object models, and service description models according to the selected visual identifier, so as to construct a new model; wherein the new model is a new data object model or a new service description model; A model publishing layer module is used to publish the new model according to the stored service description language, and generate a framework code and a corresponding environment library file for running the new model in the set business system; The model testing layer module is used to verify and analyze the framework code of the new model and the corresponding environment library files to perform client and server contract testing; Among them, the model testing layer module includes: The server-side service instance MockServer generation module is used to simulate the function interface return parameter value and generate the server-side service instance MockServer according to the framework code of the new model and the description file of the service description model used for testing; The client capability test MockClient generation module is used to load the interface using the Java parent class loader according to the framework code of the server service instance to obtain the class object instance by using the reflection mechanism, collect the interface method array information of the service description model used for testing through the reflection mechanism, obtain the instance class required to create the client through the reflection mechanism according to the obtained class object instance and interface method data information, create the client object through the instance class and obtain the member variables and corresponding calling methods to form the client capability test MockClient; The xml template generation module is used to test MockClient using client capabilities, obtain the input parameter type, output parameter type and method name of the interface function according to the obtained member variables, and generate an xml template according to the input parameter type, output parameter type and method name; The contract test module is used to fill in the parameter values of the corresponding types of the input test parameters using the generated xml template, and pass the input parameter values into the invoke method of the client object through the reflection mechanism, so as to use the calling method to remotely call the server service instance MockServer.
2. The model framework code generation system according to claim 1, characterized in that: The model publishing layer module is further used to record the new model related information; wherein the new model related information includes at least one of the release time information, release description information, release version information, release field information, and release organization information; The model database module is also used to import and store the framework code and corresponding environment library files of the new model, as well as the relevant information of the new model.
3. The model framework code generation system according to claim 1, characterized in that: The storage structure of at least one of the stored data elements, data object models, and service description models is a tree structure.
4. The model framework code generation system according to claim 1, characterized in that: The arrangement operation instruction includes a drag operation instruction and / or an association operation instruction.
5. The model framework code generation system according to claim 1, characterized in that: The service description language includes the structure of the data object model and its meaning, data elements and their meaning, the function interface model and its meaning, function types, and containers, as well as the inheritance relationship, combination relationship and aggregation association required between them.
6. The model framework code generation system according to claim 1, characterized in that: Model publishing layer module, including: The lexical analysis and verification module is used to scan the description file of the new model in units of characters. When a word in the scanned new model is a keyword in the service description language, the attribute code corresponding to the word is returned. When a word in the scanned new model is an invalid character, the invalid character is skipped. When a word in the scanned new model is not a keyword in the service description language and is not an invalid character, the string information of the corresponding word is retained, so as to obtain the lexical analysis and verification results of the new model after scanning the description file of the new model; The framework code generation module is used to parse the description file of the new model according to the lexical analysis and verification results of the new model to execute the corresponding functions, initialize global variables, call the set code generation function, parse the language type, and generate the corresponding framework code according to the language type; The packaging module is used to copy the framework code to the source code path of the programming language project, and copy the service framework environment library file that the programming language project depends on to the environment library path, and package and compress the framework code and environment library path and service framework environment library file under the source code path to obtain a compressed package of the framework code of the new model and the corresponding environment library file.
7. A model framework code generation method, characterized in that: include: Acquire at least one of a stored data element, a data object model, and a service description model that are pre-constructed according to a set business system, and a service description language defined for a business domain where the set business system is located; Displaying the visual identification of the stored data elements, data object models, and service description models, receiving an orchestration operation instruction, and selecting at least one of the visual identification of the data elements, data object models, and service description models according to the orchestration operation instruction; According to the selected visualization identifier, obtaining at least one of the corresponding stored data elements, data object models, and service description models to construct a new model; wherein the new model is a new data object model or a new service description model; Publishing the new model according to the stored service description language, generating a framework code and a corresponding environment library file for running the new model in the set business system; Verify and analyze the framework code of the new model and the corresponding environment library files to perform client and server contract testing; The verification and analysis of the framework code and the corresponding environment library files of the new model to perform client and server contract testing includes: According to the framework code of the new model, use the description file of the service description model used for testing to simulate the parameter value returned by the function interface and generate the server-side service instance MockServer; According to the framework code of the server-side service instance, use the Java parent class loader to load the interface to obtain the class object instance using the reflection mechanism, collect the interface method array information of the service description model used for testing through the reflection mechanism, and obtain the instance class required to create the client through the reflection mechanism according to the obtained class object instance and interface method data information. Create the client object through the instance class and obtain the member variables and corresponding calling methods to form the client capability test MockClient; Use the client capability to test MockClient, get the input parameter type, output parameter type and method name of the interface function according to the obtained member variables, and generate an xml template according to the input parameter type, output parameter type and method name; The generated xml template is used to fill in the parameter values of the corresponding types of the input test parameters, and the input parameter values are passed into the invoke method of the client object through the reflection mechanism, so as to use the calling method to remotely call the server service instance MockServer.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method as claimed in claim 7 are implemented.
Citation Information
Patent Citations
Frame code automatic generating method of virtual test distributed type object model
CN102929681A
Visual service development method and system
CN104360859A