A data management function source code generation method based on template injection

By abstracting single-table and master-detail table data management models in client application development and using rule base to inject code file templates to generate data management source code, the problem of repetitive development and maintenance difficulties in existing technologies is solved, and efficient and standardized software development and maintenance are achieved.

CN116974528BActive Publication Date: 2026-11-20SHENYANG INST OF AUTOMATION - CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210433485.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-24
Publication Date
2026-11-20
Estimated Expiration
2042-04-24

AI Technical Summary

Technical Problem

Existing technologies in client application development lack abstraction of business logic, resulting in repetitive development work, long development cycles, messy code, difficult maintenance, low software quality, numerous testing problems, poor user experience, and high development and maintenance costs.

Method used

By abstracting single-table and master-detail table data management models, and using rule base to inject code file templates, data management source code is generated, realizing the automatic generation of UI and backend logic control layers, including view configuration layer, parser, source code template and export layer, supporting visual configuration and standardized code generation.

Benefits of technology

It shortens the software development cycle, improves development and maintenance efficiency, reduces costs, standardizes code quality, simplifies testing workload, and enhances user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116974528B_ABST
    Figure CN116974528B_ABST
Patent Text Reader

Abstract

The application discloses a data management function source code generation method based on a template injection mode, and realizes the basic functions of data new creation, copying, editing, deletion and query through the mapping relationship between entities and database tables, the normalized configuration of the visual configuration method and management mode of attributes, and the source code conversion of rules by a code container, the editing requirements of the attributes are configured according to the rules through the visual configuration of the attributes, the interface of the configured data management rules is exported as management source code through the analysis of the management rules, and the management interface can be loaded after the management source code is added to a solution, meanwhile, the secondary development of the program can be realized by adjusting the automatically generated source code by a developer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of client and service application development, and specifically to the business document management interface for single-table management and master-detail tables, implementing automatic generation of source code for the UI and backend logic control layer. Background Technology

[0002] In client application development, many application frameworks adopt MVVM and MVC, which are widely used. This approach separates business logic development from front-end presentation, improving efficiency by separating front-end and back-end development. However, in the front-end business development process, the lack of abstraction and extraction of relevant business management interfaces, leaving developers to freely develop functions based on business needs or referencing existing source code, leads to low development efficiency, non-standardized code, long development cycles, low efficiency, messy code, difficulties in subsequent maintenance, difficulty in controlling software quality, a large amount of redundant work, and low code quality, resulting in unstable software system operation, numerous testing problems, long software release iteration cycles, and poor user experience. Furthermore, it overburdens software engineers with dealing with problems during software operation, increases the investment of development and maintenance personnel, and drives up project development and maintenance costs.

[0003] Current typical application development methods and corresponding development processes Figure 1 As shown, the service uses an entity framework to connect the database and entities, and develops related services at the business layer to provide business data for the UI model.

[0004] The UI employs the common MVVM approach to connect the data and presentation layers. This typical client-server framework achieves separation between the server and the front-end UI, while the MVVM approach in the UI separates the view from the business logic.

[0005] The drawback of this approach is that it does not abstract the business logic. Every new business requires the development of related front-end and back-end programs. In actual business, many businesses have a lot of similarities, which leads to a lot of repetitive development work. Summary of the Invention

[0006] To address the shortcomings of current technologies, this invention categorizes the code files involved by developers, abstracting two data management models: a single-table data management model and a master-detail table mutual data management model. Through a rule base, the differences are injected into the code file templates of both models, forming the data management source code for the single-table and master-detail table models. This source code is then exported to the local disk via the front-end. Developers can quickly obtain the source code for relevant interface business management operations (query, create, copy, modify, delete). This approach not only shortens the software development cycle but also establishes a unified and standardized program development method by reviewing existing source code, making the software system easier for subsequent developers to maintain, improving software development and maintenance efficiency, and reducing application system development and maintenance costs.

[0007] The technical solution adopted by this invention to achieve the above objectives is: a data management function source code generation system based on template injection, comprising:

[0008] The view configuration layer is used for user-abstracted entities and custom-developed services. According to the rules in the page rule base, it configures the rule information used by the page in a visual way and stores it in the rule instance table of the database. The front-end interface functions read the data in the rule instance table, and the parser parses the rule instances to export the interface source code.

[0009] The parser is used to inject the rule instance data configured in the view configuration layer into the source code template to form the source code for business data management, and output the source code to a disk file through the source code export service;

[0010] Source code templates are source code templates of different types represented by entities.

[0011] The parser includes:

[0012] The entity mapping parsing layer is used to load the mapping relationship between entities and the rule instance data configured in the view configuration layer, and to provide injected data support for injecting business data management tables for page management operations;

[0013] The template loading layer is used to load source code templates based on the business data management table in the rule instance.

[0014] The rule injection layer is used to inject rule instance data into each file of the source code template to form the source code for business data management.

[0015] The source code export layer is used to output all the source code generated by the rule injection layer to a disk file for secondary development.

[0016] The entity configuration includes a mapping relationship between the entity and the business data management table, which includes the correspondence between the main table and the subsidiary table of business data management, the mapping relationship between the foreign key association of the business data management table and the basic information table, and the attributes associated with the foreign key.

[0017] The source code templates include single-table templates and master-slave table templates.

[0018] The rule base includes query rules and editing rules, which are used by the view configuration layer to configure rule instances for the business data management table.

[0019] The front-end interface functions include:

[0020] Configuration attributes include the main table entity, the slave table entity, the reserved conditions (i.e., the initial filtering conditions for the data queried on this page), the loading status, and the sorting function settings for the corresponding function page.

[0021] Pop-up configuration is used to configure foreign key data for business data management as a pop-up selection dialog box, and to specify the unique identifier of the pop-up dialog box, the query conditions for foreign key data, and the relevant data attributes loaded in the dialog box;

[0022] The query attribute configuration is used to configure query conditions in the business data management page. That is, to specify filter conditions based on the reserved conditions in the configuration attributes. If it is foreign key data, the display attribute is associated through the foreign key. The default is drop-down list data. When the data volume exceeds the threshold, it is configured to pop up a dialog box and configured with the same pop-up dialog box identifier as in the pop-up box configuration.

[0023] The edit attribute configuration is used to configure all fields of a business entity through reflection. This means that database fields need to be edited, and default values ​​can be set for fields when configuring them. Required fields can be specified, and the underlying data table data for related foreign keys can be filtered. The configuration also allows setting whether the related foreign key is a pop-up dialog box. By default, the underlying data table data for the foreign key is a dropdown list. When the data volume exceeds a threshold, a pop-up window is configured when editing the foreign key association attribute. The pop-up window is identified by a pop-up identifier.

[0024] A method for generating source code for a data management function based on template injection includes the following steps:

[0025] The view configuration layer targets user-abstracted entities and custom-developed services. According to the rules in the page rule base, it configures and stores the rule information used by the page in a visual way into the rule instance table of the database. The front-end interface functions read the data in the rule instance table, and the parser parses the rule instances to export the interface source code.

[0026] The parser injects the rule instance data configured in the view configuration layer into the source code template to form the source code for business data management, and outputs the source code to a disk file through the source code export service; the source code template is a source code template of different types represented by entities.

[0027] The parser performs the following steps:

[0028] The entity mapping parsing layer loads the mapping relationship between entities and the rule instance data configured in the view configuration layer, providing injected data support for injecting business data management tables for page management operations;

[0029] The template loading layer loads the source code template based on the business data management table in the rule instance;

[0030] The rule injection layer injects each rule of the rule instance data into the various files of the source code template to form the source code for business data management;

[0031] The source code export layer outputs all the source code generated by the rule injection layer to a disk file to provide secondary development opportunities.

[0032] The present invention has the following beneficial effects and advantages:

[0033] 1. This invention implements a visual configuration of the business data management rule base based on an ORM framework. It can handle application development scenarios involving single-table and master-detail table business data management in application systems. By configuring data management rules, the source code of business data management can be quickly exported. Developers can add the source code to the solution and run the business management interface. Secondary development and adjustments can be made for specific business needs, which can quickly realize customer business requirements, reduce the time developers spend responding to customer needs, greatly shorten the software development cycle for customer needs, and improve customer satisfaction.

[0034] 2. This invention abstracts and categorizes the business management interface according to data characteristics. For general business operations such as creating, copying, modifying, deleting, and querying, developers create entities and add them to the solution. Based on the configuration rule base, standardized program code is generated, which reduces the development difficulty of the system. At the same time, the standardized code development specifications accelerate the system iteration speed, reduce the development difficulty for software developers, make the system easier to maintain, and reduce the system development cost.

[0035] 3. By using this business data management source code generation method, the functional pages of business data management, from the design of business tables to the development of front-end management and business data service acquisition, can be implemented in one go, shortening the development path of business management.

[0036] 4. By exporting the source code from the business data management page, standardized code can be generated, enabling testers to conduct standardized testing. This not only reduces the workload of testing but also improves the quality of software code.

[0037] 5. This method not only enables rapid development of single-table business data models and master-detail table business data models, but also allows developers to decompose complex applications by breaking down related business processes into single-table and master-detail table data model management, thus completing the rapid development of most business functions and reducing development difficulty. Attached Figure Description

[0038] Figure 1 This diagram illustrates the typical application development methods and corresponding development processes.

[0039] Figure 2 This is a flowchart illustrating the program implementation framework of the present invention;

[0040] Figure 3 Diagram of source code file composition;

[0041] Figure 4 This is a diagram illustrating the specific implementation steps of the source code generation method.

[0042] Figure 5 Flowchart for source code analysis;

[0043] Figure 6 Supported entity attribute type graph;

[0044] Figure 7 Example diagram of a single-table data model;

[0045] Figure 8 Example diagram of a master-detail table data model;

[0046] Figure 9 Example diagram of basic information table data. Detailed Implementation

[0047] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.

[0048] This invention discloses a method for generating source code for data management functions based on template injection. This invention is developed using an object-oriented language and can directly export the source code of single-table and master-detail table data management functions through entity configuration, data mapping, front-end configuration, function parsing, and source code classification analysis. The method for exporting the source code of this management interface includes the following steps:

[0049] 1. Entity Creation and Mapping Configuration. This section is used to connect the front-end entities with the underlying database. It manages field entities and related foreign key attribute mappings.

[0050] 2. Front-end configuration: This part uses a visual approach to connect the application entity layer and the data table management interface. It allows for the functional planning of the management interface through front-end client operations. Custom configurations are made for the required data management functions according to fixed rules. The content that can be used for business management function design includes:

[0051] a) Dialog box configuration (optional configuration; when the management interface needs to pop up a dialog box to search for data, the relevant properties of the pop-up dialog box and the dialog box identifier need to be configured. The management interface can directly call this part to load the data selection box).

[0052] b) Configure editing attributes (supports text boxes, time boxes, dropdown lists, and pop-ups)

[0053] c) Configuring query attributes (supports text boxes, time boxes, dropdown lists, and pop-ups)

[0054] d) Page state settings (data filtering conditions, whether to load data initially, etc.)

[0055] 3. Exporting Management Interface Code: This section exports the code for the designed interface management functions to a specified location on the disk. Developers can then load this code into the project to load the relevant data management interface. Furthermore, the exported code can be further developed according to specific business needs.

[0056] This method can reduce the application development cycle, standardize software code implementation, and enable developers to use unified and standardized code to quickly understand the code implementation of business functions and quickly develop business functions. This invention is mainly applied to the front-end and server-side development based on the ORM software framework.

[0057] A method for generating source code for data management functions based on template injection is proposed. This method utilizes the mapping relationship between entities and database tables, standardizes the configuration of attributes through visual configuration and management methods, and then transforms the rules into source code using a code container. This enables basic functions such as creating, copying, editing, deleting, and querying data. Visual configuration of attributes allows for the configuration of attribute editing requirements according to rules. The configured data management rule interface is then exported as management source code through rule parsing. After being added to the solution, the relevant management interface can be loaded. Furthermore, developers can adjust the automatically generated source code to achieve secondary development of the program.

[0058] The basis of this method is the relevant business entities, which are data tables abstracted from actual business needs. This invention is for business data management of single tables and master-detail tables, including business tables and basic information tables corresponding to their associated foreign keys. The created entities need to add mapping associations with the corresponding fields in the database on each attribute. Foreign key fields need to add the table of object foreign key association and the basic data table fields of association that may be used in the business table on the mapping.

[0059] The business tables and related foreign key tables are created in the database, and the relevant entities are added to the application solution. The solution is then compiled and run using this framework. By configuring the rule base and combining it with visual configuration functions, the business data management functions are planned. Simultaneously, based on the parsing of the rule base, the business data management functions are implemented, and the management source code is exported. The specific implementation steps are as follows:

[0060] A. Page main configuration, the relevant attributes of which include: the main table entity corresponding to the functional page, the subordinate table entity (not available when there is only one table), the reserved conditions, i.e. the initial filtering conditions for the data queried on this page, the loading status (whether to load data when the interface is opened), and the sorting function settings.

[0061] B. Pop-up configuration: For foreign key data in business data management, when the data volume is large, a drop-down list box cannot be directly loaded. In this case, the foreign key management data can be configured as a pop-up selection dialog box. A unique identifier for the pop-up dialog box needs to be configured. When configuring the pop-up dialog box, you need to specify the unique identifier of the pop-up dialog box, the query conditions for the foreign key data, and the relevant data attributes loaded by the dialog box.

[0062] C. Configure the relevant query attributes. Configure the relevant query conditions on the business data management page. That is, specify the relevant filter conditions based on the reserved conditions in A. If it is foreign key data, display the attributes through foreign key association (such as displaying code, name, etc. if the foreign key is **ID). The default is drop-down list data. When the data volume is large, it can be configured to pop up a dialog box. Then you need to configure the dialog box identifier (the dialog box identifier configured in step B).

[0063] D. Edit attribute configuration: Configure all fields of the business entity through reflection, i.e., which database fields need to be edited. When configuring and editing fields, you can set default values ​​for fields; set whether fields are required; filter the data of the base information table of related foreign keys (achieved by writing SQL statements directly); set whether the related foreign keys are pop-up dialog boxes. By default, the base data of the foreign key association is drop-down data. When the data volume is large and related foreign key association attributes need to be edited, a pop-up window can be configured. The pop-up window is identified by a pop-up identifier.

[0064] E. Exporting the code for the program management page: Each rule of the data management configuration for A, B, C, and D is parsed, and the relevant page code is converted to generate the source code for the management interface. This source code is exported to a disk file, which developers can add to the solution to form the source code for data management. This source code includes program files for querying, creating, modifying, deleting, and sorting (optional). Running the solution will allow you to view the relevant management pages. Developers can also adjust the source code according to specific business functions.

[0065] like Figure 3 As shown, this source code needs to run under a custom-implemented ORM solution framework. If it is ported to other solutions, the data acquisition and update services need to be adjusted before it can run.

[0066] like Figure 2 The diagram shown illustrates the implementation framework of this source code generation method. This method abstracts various attributes and areas of the interface into a visual interface configuration rule library using a rule base. During interface export, the configuration rules and page management rules are injected into the specified business data management template, along with the source code for the industry business data management function (interface source code, data binding source code, and data retrieval code). For the configuration of each interface rule library, a view configuration layer is used to implement the visual configuration of page rules. Specific implementation details are provided below. Figure 4 , Figure 5 As shown.

[0067] The implementation steps are as follows:

[0068] I. Entity Definition

[0069] Business personnel abstract specific business entity attributes. The entity definition implementation includes the mapping relationship between the entity and the database table, the correspondence between the master table and the slave table, the mapping relationship of foreign key fields, and the attributes associated with the foreign keys.

[0070] II. Rule Base Definition

[0071] This section is a mapping syntax library that defines the relationship between business entity configuration rules and the management page. It specifies the relationships between related attributes and the actual user interface, as well as the syntax for defining each field.

[0072] The definitions included are:

[0073] 1) Supported types: Supports single table and master-detail table relationships.

[0074] 2) Page identifier definition: This is a rule set to distinguish different pages implemented by the same entity. It can be defined using a serial number to ensure uniqueness.

[0075] 3) Reserved sorting rules: This part sorts the data in the main table according to the user's custom rules. By configuring the sorting field in the exported source code, the function of sorting data rows across pages can be realized.

[0076] 4) Field attribute configuration rules: This includes configuration rules for query attributes and configuration rules for edit attributes.

[0077] The query attribute rules are the basic business of business document management. Configure the query attributes of the main interface for document management. Multiple query attributes can be specified. Foreign key data can be managed at the same time. Depending on the characteristics of different foreign key data, it can be set to drop-down or pop-up mode. When the data volume is small, it can be set to drop-down to select query conditions. When the data volume is large, the query conditions need to be set to pop-up box. Before configuring this interface, you need to configure the relevant attributes of the loaded dialog box and set the unique identifier of the pop-up dialog box. Here, you only need to configure the unique identifier of the dialog box.

[0078] Edit attribute rules, specifying which fields in the master and detail tables of business documents can be edited, and classifying edit attributes as follows: Figure 6 As shown.

[0079] Document number rules: The document number is a unique identifier used to represent the document. Users can enter it manually, or they can set a certain field to automatically generate the document number according to a reserved rule.

[0080] Reserved value rules: When editing a field, you can specify a reserved value. This part simply involves setting the field as a reserved value.

[0081] Reserved field rules: For some editable fields that do not need to be edited when creating a new field, the field is set as a reserved field. Whether or not there is a reserved value can be configured according to the reserved value rules above.

[0082] Foreign key configuration rules: Foreign keys in the master or slave table support a maximum of three fields. One or two fields can be displayed. For larger datasets, manual modifications can be made after exporting the source code. For small amounts of related foreign key data, a dropdown menu can be used to select data. For large amounts of related foreign key data, a pop-up dialog box can be used for data selection. The configuration rules for the dialog box are the same as those for master and slave tables.

[0083] III. Template Library

[0084] This section comprises two types of source code model libraries implemented in the application background by the source code generation method: single-table templates and master-detail table templates. It also includes a rule injection interface, generating different data management source code for different rules.

[0085] IV. Rule Configuration Layer

[0086] This section targets user-abstracted entities and custom-developed services. Following the principles of the rule base, it configures the information of the interface rule base into the database rule base table in a visual manner. The front-end interface function rules are configured to form rule base data, providing a rule base data source for the parser to export the interface source code. See the attached figure for the specific implementation.

[0087] V. Parser

[0088] This part combines the rule base configured through "four" from the backend rule base data table into the application with the template library implemented through "three". The parser injects the rule base into the template to form the source code of business data management, and outputs the source code to a disk file through the source code export service.

[0089] Entity mapping parsing layer: Loads the mapping relationship between entities and the database into the parser cache, providing injected data support for subsequent page management operations such as data querying, editing, modification, copying, and deletion, and injecting business data management model.

[0090] Template loading layer: Loads source code management template library files based on the business data management type in the rule base.

[0091] Rule injection layer: Injects each rule into the various files of the template to form the source code for business data management functions.

[0092] Source code export layer: Outputs all source code generated by the rule injection layer to a disk file, providing it to program developers for secondary development. See the specific implementation details below. Figure 7 , Figure 8 , Figure 9 This is a table containing relevant basic information.

Claims

1. A data management function source code generation system based on template injection, characterized in that, include: The view configuration layer is used for user-abstracted entities and custom-developed services. According to the rules in the page rule base, it configures the rule information used by the page in a visual way and stores it in the rule instance table of the database. The front-end interface functions read the data in the rule instance table, and the parser parses the rule instances to export the interface source code. The parser is used to inject the rule instance data configured in the view configuration layer into the source code template to form the source code for business data management, and output the source code to a disk file through the source code export service; Source code templates are source code templates of different types represented by entities; The parser includes: The entity mapping parsing layer is used to load the mapping relationship between entities and the rule instance data configured in the view configuration layer, and to provide injected data support for injecting business data management tables for page management operations; The template loading layer is used to load source code templates based on the business data management table in the rule instance. The rule injection layer is used to inject rule instance data into each file of the source code template to form the source code for business data management. The source code export layer is used to output all the source code generated by the rule injection layer to a disk file for secondary development. The source code templates include single-table templates and master-slave table templates.

2. The data management function source code generation system based on template injection according to claim 1, characterized in that, The entity configuration includes a mapping relationship between the entity and the business data management table, which includes the correspondence between the main table and the subsidiary table of business data management, the mapping relationship between the foreign key association of the business data management table and the basic information table, and the attributes associated with the foreign key.

3. The data management function source code generation system based on template injection according to claim 1, characterized in that, The rule base includes query rules and editing rules, which are used by the view configuration layer to configure rule instances for the business data management table.

4. The data management function source code generation system based on template injection according to claim 1, characterized in that, The front-end interface functions include: Configuration attributes include the main table entity, the slave table entity, the reserved conditions (i.e., the initial filtering conditions for the data queried on this page), the loading status, and the sorting function settings for the corresponding function page. Pop-up configuration is used to configure foreign key data for business data management as a pop-up selection dialog box, and to specify the unique identifier of the pop-up dialog box, the query conditions for foreign key data, and the relevant data attributes loaded in the dialog box; The query attribute configuration is used to configure query conditions in the business data management page. That is, to specify filter conditions based on the reserved conditions in the configuration attributes. If it is foreign key data, the display attribute is associated through the foreign key. The default is drop-down list data. When the data volume exceeds the threshold, it is configured to pop up a dialog box and configured with the same pop-up dialog box identifier as in the pop-up box configuration. The edit attribute configuration is used to configure all fields of a business entity through reflection. This means that database fields need to be edited, and default values ​​can be set for fields when configuring them. Required fields can be specified, and the underlying data table data for related foreign keys can be filtered. The configuration also allows setting whether the related foreign key is a pop-up dialog box. By default, the underlying data table data for the foreign key is a dropdown list. When the data volume exceeds a threshold, a pop-up window is configured when editing the foreign key association attribute. The pop-up window is identified by a pop-up identifier.

5. A method for generating source code for a data management function based on template injection, wherein the method is applied to the source code generation system for a data management function based on template injection as described in claim 1, characterized in that, Includes the following steps: The view configuration layer targets user-abstracted entities and custom-developed services. According to the rules in the page rule base, it configures and stores the rule information used by the page in a visual way into the rule instance table of the database. The front-end interface functions read the data in the rule instance table, and the parser parses the rule instances to export the interface source code. The parser injects the rule instance data configured in the view configuration layer into the source code template to form the source code for business data management, and outputs the source code to a disk file through the source code export service; the source code template is a source code template of different types represented by entities.

6. The method for generating source code for data management functions based on template injection according to claim 5, characterized in that, The parser performs the following steps: The entity mapping parsing layer loads the mapping relationship between entities and the rule instance data configured in the view configuration layer, providing injected data support for injecting business data management tables for page management operations; The template loading layer loads the source code template based on the business data management table in the rule instance; The rule injection layer injects each rule of the rule instance data into the various files of the source code template to form the source code for business data management; The source code export layer outputs all the source code generated by the rule injection layer to a disk file to provide secondary development opportunities.

Citation Information

Patent Citations

  • Two-level data management interface visual development configuration method based on dynamic loading

    CN113010154A

  • Computer Source Code Generator for Building Software Applications

    US20160041815A1