CN112860314B - Code modeling method and device - Google Patents

Code modeling method and device Download PDF

Info

Publication number
CN112860314B
CN112860314B CN202110345545.6A CN202110345545A CN112860314B CN 112860314 B CN112860314 B CN 112860314B CN 202110345545 A CN202110345545 A CN 202110345545A CN 112860314 B CN112860314 B CN 112860314B
Authority
CN
China
Prior art keywords
model
meta
information
code
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110345545.6A
Other languages
Chinese (zh)
Other versions
CN112860314A (en
Inventor
谢荣良
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202110345545.6A priority Critical patent/CN112860314B/en
Publication of CN112860314A publication Critical patent/CN112860314A/en
Application granted granted Critical
Publication of CN112860314B publication Critical patent/CN112860314B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a code modeling method and a code modeling device, which can be used in the financial field or other fields. The method comprises the following steps: receiving and analyzing a meta model file input by a user to obtain basic model attribute information and a technical meta model name corresponding to the meta model file; according to the technical meta model name, obtaining a technical meta model corresponding to the meta model file from a database, and analyzing the technical meta model to obtain extended model attribute information; modeling code information input by a user is received, and a preset public template is configured according to the modeling code information, the basic model attribute information and the extended model attribute information, so that a modeling code file is generated and output. The invention carries out code modeling based on the meta model and the technical meta model, improves the efficiency of code modeling development when the meta model is newly added and the meta model is modified, saves a great amount of time to realize service functions, normalizes the code, reduces the code error rate in the development stage, and greatly improves the development efficiency.

Description

Code modeling method and device
Technical Field
The invention relates to the technical field of java backend, in particular to a code modeling method and device.
Background
With the development of digital banking informatization, the system is improved, more and more assets are managed in the system, the new addition of the assets and the adjustment and variation of the assets are more and more frequent, and a rapid and stable code modeling method is required to cope with the situation.
At present, corresponding development is carried out on the configuration modification of the meta-model and the technical meta-model, and code logic corresponding to the corresponding field of the asset is added on related codes. At present, the method has the following defects:
1. the new and adjusted asset requirements are inefficient, requiring time and cost to develop to write some inefficient repeating logic, and supporting automated test cases (utdd).
2. Because the meta-model is matched with the technical meta-model, one function of the code is coupled with one method, a large number of if and else branches respectively process different assets, and even one if branch of several types of assets, so that development cost and a large number of regression testing cost are required for modifying the code.
3. The requirements on developers are high, the function differences developed by different developers are too large, and the code maintenance cost is high.
Disclosure of Invention
Aiming at the problems existing in the prior art, the main purpose of the embodiment of the invention is to provide a code modeling method and a device, which can be suitable for model addition and adjustment and data model change of meta-models and technical meta-models.
To achieve the above object, an embodiment of the present invention provides a code modeling method, including:
receiving and analyzing a meta model file input by a user to obtain basic model attribute information and a technical meta model name corresponding to the meta model file;
according to the technical meta-model name, obtaining a technical meta-model corresponding to the meta-model file from a database, and analyzing the technical meta-model to obtain extended model attribute information;
modeling code information input by a user is received, and a preset public template is configured according to the modeling code information, the basic model attribute information and the extended model attribute information, so that a modeling code file is generated and output.
Optionally, in an embodiment of the present invention, the parsing the meta model file input by the user to obtain the basic model attribute information and the technical meta model name corresponding to the meta model file includes:
analyzing a meta model file input by a user to obtain basic model attribute information; the basic model attribute information comprises a model type identifier, a model attribute type, a model attribute default value, a model attribute name and an inheritance model name;
and determining the technical meta-model name corresponding to the meta-model file according to the model type identifier and the model attribute name.
Optionally, in an embodiment of the present invention, the extended model attribute information includes model attribute details, a detail sorting priority of the model attributes, a presentation sorting priority of the model attributes, dictionary values of the model attributes, rules of the model attributes, and length control information of the model attributes.
Optionally, in an embodiment of the present invention, the receiving modeling code information input by a user, configuring a preset common template according to the modeling code information, the basic model attribute information and the extended model attribute information, and generating and outputting a modeling code file includes:
receiving modeling code information input by a user; the modeling code information comprises a template type, variable information and storage path information;
configuring a preset public template according to the template type, the basic model attribute information and the extended model attribute information to obtain a configured code template;
and writing the variable information into the configured code template, generating the modeling code file, and outputting the modeling code file by utilizing the storage path information.
The embodiment of the invention also provides a code modeling device, which comprises:
the meta model file module is used for receiving and analyzing a meta model file input by a user to obtain basic model attribute information and a technical meta model name corresponding to the meta model file;
the technical meta model module is used for acquiring a technical meta model corresponding to the meta model file from a database according to the technical meta model name, and analyzing the technical meta model to obtain the attribute information of the expansion model;
the modeling code file module is used for receiving modeling code information input by a user, configuring a preset public template according to the modeling code information, the basic model attribute information and the extended model attribute information, and generating and outputting a modeling code file.
Optionally, in an embodiment of the present invention, the meta model file module further includes:
the basic attribute unit is used for analyzing the meta-model file input by the user to obtain basic model attribute information; the basic model attribute information comprises a model type identifier, a model attribute type, a model attribute default value, a model attribute name and an inheritance model name;
and the technical meta-model unit is used for determining the technical meta-model name corresponding to the meta-model file according to the model type identifier and the model attribute name.
Optionally, in an embodiment of the present invention, the extended model attribute information includes model attribute details, a detail sorting priority of the model attributes, a presentation sorting priority of the model attributes, dictionary values of the model attributes, rules of the model attributes, and length control information of the model attributes.
Optionally, in an embodiment of the present invention, the modeling code file module includes:
the modeling code information unit is used for receiving modeling code information input by a user; the modeling code information comprises a template type, variable information and storage path information;
the template configuration unit is used for configuring a preset public template according to the template type, the basic model attribute information and the extended model attribute information to obtain a configured code template;
and the modeling code file unit is used for writing the variable information into the configured code template, generating the modeling code file, and outputting the modeling code file by utilizing the storage path information.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above method when executing the program.
The present invention also provides a computer readable storage medium storing a computer program for executing the above method.
The invention carries out code modeling based on the meta model and the technical meta model, improves the efficiency of code modeling development when the meta model is newly added and the meta model is modified, saves a great amount of time to realize service functions, normalizes the code, reduces the code error rate in the development stage, and greatly improves the development efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a code modeling method according to an embodiment of the present invention;
FIG. 2 is a flow chart of meta-model file parsing in an embodiment of the invention;
FIG. 3 is a flow chart of generating and outputting modeling code files in an embodiment of the present invention;
FIG. 4 is a flow chart of code modeling in an embodiment of the invention;
FIG. 5 is a schematic diagram of a model adaptation model in an embodiment of the present invention;
FIG. 6 is a flowchart illustrating code modeling in accordance with an embodiment of the present invention;
FIG. 7 is a schematic diagram of a code modeling apparatus according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a meta-model file module according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of a modeling code file module according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the invention.
Detailed Description
The embodiment of the invention provides a code modeling method and a device, which can be used in the financial field or other fields, and the application field of the code modeling method and the device is not limited.
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 is a flowchart of a code modeling method according to an embodiment of the present invention, where an execution subject of the code modeling method provided by the embodiment of the present invention includes, but is not limited to, a computer. The method shown in the figure comprises the following steps:
step S1, receiving and analyzing a meta-model file input by a user to obtain basic model attribute information and a technical meta-model name corresponding to the meta-model file.
The meta-model is a model of a model and is used for initializing and defining the attribute of one model. And receiving the meta-model file uploaded by the user and analyzing the meta-model file to obtain a model type identifier, a model attribute type, a default value of the model attribute and a model attribute name. Specifically, the content of the meta-model is shown in table 1.
TABLE 1
Further, if the model type identification type field is Class, the model attribute name is combined to obtain a corresponding technical meta-model name which is class_name.
And S2, acquiring a technical meta-model corresponding to the meta-model file from a database according to the technical meta-model name, and analyzing the technical meta-model to obtain the attribute information of the extended model.
The technical meta-model is used for technical management of the meta-model, so that the attribute of one model can be expanded to support various business scenes. In addition, the technical meta-model can acquire field attributes of script data aiming at each type of data model through configured sql script data to carry out technical management.
Further, a technical meta-model with the same technical meta-model name as that obtained by analyzing the meta-model file is obtained from the database, and the technical meta-model is analyzed. Analyzing the technical meta-model to obtain extended model attribute information, wherein the extended model attribute information comprises model attribute details, detail sorting priority of model attributes, display sorting priority of model attributes, dictionary values of model attributes, rules of model attributes and length control information of model attributes, as shown in table 2.
TABLE 2
And S3, receiving modeling code information input by a user, configuring a preset public template according to the modeling code information, the basic model attribute information and the extended model attribute information, and generating and outputting a modeling code file.
And receiving modeling code information input by a user, wherein the modeling code information comprises a template type, variable information and storage path information. Specifically, the variable information includes a group name, a project name, a module name, and a package name. And configuring a preset public template according to modeling code information, basic model attribute information and extended model attribute information to obtain a code template with the same type as the template type. And inputting the variable information into a code template, generating a modeling code file, and outputting the modeling code file according to the storage path information, thereby completing code modeling.
As shown in fig. 2, as an embodiment of the present invention, parsing a meta model file input by a user to obtain basic model attribute information and a technical meta model name corresponding to the meta model file includes:
s11, analyzing a meta-model file input by a user to obtain basic model attribute information; the basic model attribute information comprises a model type identifier, a model attribute type, a model attribute default value, a model attribute name and an inheritance model name.
And analyzing the meta-model file to obtain a model type identifier, a model attribute type, a default value of the model attribute and a model attribute name. Specifically, the content of the meta-model is shown in table 1.
And step S12, determining the technical meta-model name corresponding to the meta-model file according to the model type identifier and the model attribute name.
According to the contents of table 1 and table 2, if the model type identifier type field is Class, the corresponding technical meta-model name is obtained by combining the model attribute name and the class_name.
As one embodiment of the present invention, the extended model attribute information includes model attribute details, detail sorting priority of model attributes, presentation sorting priority of model attributes, dictionary values of model attributes, rules of model attributes, and length control information of model attributes.
The analysis technology meta-model obtains extended model attribute information, which includes model attribute details, detail sorting priority of model attributes, display sorting priority of model attributes, dictionary values of model attributes, rules of model attributes and length control information of model attributes, as shown in table 2.
As an embodiment of the present invention, as shown in fig. 3, receiving modeling code information input by a user, configuring a preset common template according to the modeling code information, the basic model attribute information and the extended model attribute information, and generating and outputting a modeling code file includes:
step S31, modeling code information input by a user is received; the modeling code information comprises a template type, variable information and storage path information.
The received modeling code information input by the user comprises a template type, variable information and storage path information. Specifically, the variable information includes a group name, a project name, a module name, and a package name.
And step S32, configuring a preset public template according to the template type, the basic model attribute information and the extended model attribute information to obtain a configured code template.
The method comprises the steps of configuring a preset public template according to modeling code information, basic model attribute information and extended model attribute information to obtain a code template with the same type as the template type, namely the configured code template.
And step S33, writing the variable information into the configured code template, generating the modeling code file, and outputting the modeling code file by utilizing the storage path information.
The variable information is input into a code template, and a modeling code file is generated. Specifically, the variable correspondence in the configured code template is replaced by the group name, the project name, the module name and the package name in the variable information. And outputting a modeling code file according to the storage path information, thereby completing code modeling.
In one embodiment of the present invention, the code modeling process shown in fig. 4 specifically includes: step 1, analyzing the content of a meta-model file; step 2, analyzing a technical meta-model; step 3, configuring a public template according to the analyzed content; step 4, manufacturing a tool interface; and 5, generating a modeling code file.
If the type field under the eClassification label is Class, the Class name stored by taking the name as key and corresponding to the attribute is obtained, if the eClassification label is provided with the eSerTypes label, the attribute corresponding to the inherited Class name is required to be found and integrated, and the basic model attributes such as the assetName of the base Class are stored together. If the type field under the eTrusterFeaturyLabel is Attribute, the model Attribute is stored by taking the name to be classified under the key corresponding to the name, and the fields such as eType (model Attribute type) and defaultValueLiterl (model Attribute default value) are stored. Specifically, the relevant data and description of the meta model file are shown in table 3.
TABLE 3 Table 3
Further, the technical meta-model analysis is performed through the step 2, a class_name of the technical meta-model is obtained, the key of the object is formed by the mark meta-model, the attr_name of the technical meta-model is stored to the attribute below the key, and the basic attribute key established by the prior meta-model is found by the mark. The model attribute information of the detail ordering priority, whether editing is supported, whether the detail ordering priority is visible, dictionary values of attribute binding, rules of the attribute, length control of the attribute, dictionary constraint of the attribute, attribute list display priority and the like of each model attribute is stored completely.
Furthermore, the collection of the basic model attribute information in the step 1 and the storage of the model attribute information expanded by the related technology in the step 2 are complete, so that the data shown in the table 4 can be integrated by a set of meta-model and all data of the technical meta-model, and the data can support expansion as a simple example.
TABLE 4 Table 4
Further, a code template is configured according to the parsed content through step 3, and a template adaptation model structure diagram is shown in fig. 5. The template supports the basic ssm items SpringBoot+SpringMVC+MyBatis of the Spring framework of java, has all relevant rules of the meta-model and the technical meta-model, and integrates functions of adding, deleting, modifying, inquiring the matched UTDD and the like. For example, a new function is added, a code template is established, the code of the current meta-model and the technical meta-model rule is adapted, for example, whether the type of the model attribute is correct can be checked when the function is saved through the type of the model attribute, default values of the model attribute can be assigned by default if the value is not saved, the rule of the model attribute, whether corresponding logic processing is necessary, whether a dictionary involved in saving is correct, and the like. The verification is abstracted to form code templates, from a controller to a service to a model to a mapper, and the like, and a template for adapting an overlay meta-model to an existing scene is formed by using a variant of a className and attr to be generated, a module name, a project name, a group name and a path.
Further, a tool interface is manufactured through the step 4, and a graphical interface can be manufactured by using the JFrame of java, so that meta-model information and a template code to be generated, which is input by a user, can be obtained, and closing is supported in a window. And then the interactive functions required by the tool are manufactured by utilizing the Swing structure. The data entry of the tool interface specifically comprises:
(1) the tool interface comprises an uploading meta-model file frame and is mainly used for analyzing the meta-model.
(2) The tool interface comprises a model type drop-down frame, and if the model type field of the eClassification labels of the real-time analytic meta-model is 'Class' and the name is taken to form a number group, the number group is returned to the interactive page for selection.
(3) The method is mainly used for connecting database types, database port numbers, database accounts and database passwords and is mainly used for connecting a database reading technology meta-model.
(4) After connecting the database, the user can select the option of constructing the template, input the group name, the project name, the module name, the package name and select the storage path by using the tool interface.
Further, a modeling code file is generated in step 5, as shown in fig. 6, and a specific use case is referred to for explanation. Assume that there are two data models, application physical-physical applications, and SubApplication-service groups. The process of generating and outputting the modeling code file includes:
1. and uploading the meta-model file to obtain the existing model type, and generating two options ApplicationPhysical, subApplication in a tool interface drop-down box.
2. When the model type of the application physical is selected, relevant information of the database is input again, and after the relevant information is connected, the relevant information is recorded by inquiring the corresponding technical meta model according to the model type selected by the user. By selecting a construction template, inputting a group name, a project name, a module name, a package name and a storage path.
3. The data shown in Table 5 can be obtained by the operations of 1 and 2 described above.
TABLE 5
/>
(1) When the template is selected as a controller+base+UTDD, as shown in a template adaptation model structure diagram of FIG. 5, the controller+base+UTDD template can obtain logic splicing related to the model rule, and the related code logic is spliced to ensure the logic only related to the model. For example, a new function is added, the model attribute must be input, the model attribute default value, the model attribute dictionary needs dictionary related check logic, etc. And a query function, wherein a model field translates a corresponding dictionary if the dictionary is related, and concatenates ordering logic if the ordering is related.
(2) And acquiring relevant information filled in by the tool page, package names, class names, group names and the like, replacing variables in the previous templates, and splicing the method logic according to the input model attribute. For example, all metamodels have 100 model rules to deal with scenes with technical metamodels, the attributes of the input model are 20, and only the logic of the 20 relevant attributes is spliced. If the existing rule is found to be not in the template code, the error cannot be generated, and the modeling code is generated after the template code is required to be updated.
4. Finally, the java file stream is output to the selected catalogue:
(1) according to the input "projectName": "eam", "modelName":
"eam_web","packageName":
"com.eocs.application physical.controller", "outputPath": "D: \model", src\main\java default splice. The above parameters output the corresponding catalogue:
and D, generating an application physical controller file under the path of \model \ eam _web\src\main\java\com\os\application physical controller, wherein the generated modeling code file has the basic functions and required logic of the application physical model.
(2) And meanwhile, an application physical base.java file is generated under a D \model\ eam _web\src\main\java\com\os\application physical base path, and only some data organizations and data verification methods exist. The file acts on the post expansion service, and the expansion can inherit the class as the subsequent logic.
(3) Meanwhile, the model is generated to generate an application physical/java file under the path of D \model \ eam _web\src\main\java\com\application physical\model, and the model has get and set functions which distribute attributes according to the String, int and the like of the model type.
(4) And meanwhile, the UTDD template is called to generate an application physical control test.java file under the path of D \model \ eam _web\src\test\java\com\application physical\controller, so that the UTDD template has the UTDD automatic test function of a method under the application physical control.java file, and a developer and a tester can change parameter automatic test by entering parameters to simulate fixed parameters.
(5) And meanwhile, an application physical BaseTest.java file is generated under the path of D \model \ eam _web\src\test\java\com\application physical\base, so that the automatic UTDD testing function of the method under the application physical BaseTest.java file is provided, fixed parameters are simulated by the input parameters, and a developer and a tester can replace the parameters for automatic testing.
5. If necessary, resources templates such as pore files can be established, and generation can be realized only by using a substitution placeholder form for the templates.
6. The user can directly complete code modeling by copying to the project or designating the storage path under the project file, so that the sub-division and block processing codes are realized, the codes are not coupled any more, and the regression testing range is reduced.
7. The modeling file is directly and continuously generated by modifying the meta-model or the technical meta-model in the later period, basic modeling can be adopted if the function is not extended in the later period, the controller models to the service, if the follow-up service logic can inherit the file under the base directory, the parent class is called to complete the logic controlled by the meta-model and the technical meta-model, and the related service logic is supplemented to complete the whole development.
The invention provides a code modeling method based on a meta-model and a technical meta-model, which aims to solve the problems existing in the existing modeling development. When the meta model is added and modified, the efficiency of code modeling development is improved, a great amount of time is saved to realize service functions, codes are normalized, the code error rate in the development stage is reduced, the global unified style specification is realized, and sub-division and block processing are performed. The invention has the following specific advantages:
1. the invention can deal with the development cost of frequent model adjustment, and only needs to input a meta model file and a configuration technology meta model, so that modeling codes can be generated by one key, and if the logic is expanded, the modeling code class can be inherited to continue to be expanded and developed without mutual influence.
2. The invention can divide the sub-package blocks to generate the modeling codes, reduce the code coupling degree, unify the global style and reduce the post-code maintenance cost.
3. The invention concentrates the code logic of all the adaptation element models on the tool, and the post-modification rule can be perfectly covered only by adjusting the modeling code of the model related to the regeneration of the codes in the tool.
4. The invention can adapt the generated template code to match with UTDD template, generate Test package and file under corresponding directory, and enable developer and tester to update parameter values for automatic Test.
5. The invention can extend other business functions and even a plurality of public code logics, and can directionally model as long as the template adaptation metamodel and the technical metamodel are provided.
Fig. 7 is a schematic structural diagram of a code modeling apparatus according to an embodiment of the present invention, where the apparatus includes:
the meta model file module 10 is configured to receive and parse a meta model file input by a user, and obtain basic model attribute information and a technical meta model name corresponding to the meta model file.
The meta-model is a model of a model and is used for initializing and defining the attribute of one model. And receiving the meta-model file uploaded by the user and analyzing the meta-model file to obtain a model type identifier, a model attribute type, a default value of the model attribute and a model attribute name.
And the technical meta-model module 20 is configured to obtain a technical meta-model corresponding to the meta-model file from the database according to the technical meta-model name, and parse the technical meta-model to obtain the attribute information of the extended model.
The technical meta-model is used for technical management of the meta-model, so that the attribute of one model can be expanded to support various business scenes. In addition, the technical meta-model can acquire field attributes of script data aiming at each type of data model through configured sql script data to carry out technical management.
Further, a technical meta-model with the same technical meta-model name as that obtained by analyzing the meta-model file is obtained from the database, and the technical meta-model is analyzed. Analyzing the technical meta-model to obtain extended model attribute information, wherein the extended model attribute information comprises model attribute details, detail sorting priority of model attributes, display sorting priority of model attributes, dictionary values of model attributes, rules of model attributes and length control information of model attributes.
The modeling code file module 30 is configured to receive modeling code information input by a user, configure a preset common template according to the modeling code information, the basic model attribute information and the extended model attribute information, and generate and output a modeling code file.
And receiving modeling code information input by a user, wherein the modeling code information comprises a template type, variable information and storage path information. Specifically, the variable information includes a group name, a project name, a module name, and a package name. And configuring a preset public template according to modeling code information, basic model attribute information and extended model attribute information to obtain a code template with the same type as the template type. And inputting the variable information into a code template, generating a modeling code file, and outputting the modeling code file according to the storage path information, thereby completing code modeling.
As shown in fig. 8, the meta model file module 10 further includes:
a basic attribute unit 11, configured to parse the meta model file input by the user to obtain basic model attribute information; the basic model attribute information comprises a model type identifier, a model attribute type, a model attribute default value, a model attribute name and an inheritance model name;
and a technical meta-model unit 12, configured to determine a technical meta-model name corresponding to the meta-model file according to the model type identifier and the model attribute name.
As one embodiment of the present invention, the extended model attribute information includes model attribute details, detail sorting priority of model attributes, presentation sorting priority of model attributes, dictionary values of model attributes, rules of model attributes, and length control information of model attributes.
As shown in fig. 9, as one embodiment of the present invention, the modeling code file module 30 includes:
a modeling code information unit 31 for receiving modeling code information input by a user; the modeling code information comprises a template type, variable information and storage path information;
the template configuration unit 32 is configured to configure a preset common template according to the template type, the basic model attribute information and the extended model attribute information, so as to obtain a configured code template;
and a modeling code file unit 33, configured to write the variable information into the configured code template, generate the modeling code file, and output the modeling code file by using the storage path information.
The invention also provides a code modeling device based on the same application conception as the code modeling method. Since the principle of the code modeling apparatus for solving the problem is similar to that of a code modeling method, the implementation of the code modeling apparatus can refer to the implementation of a code modeling method, and the repetition is omitted.
The invention carries out code modeling based on the meta model and the technical meta model, improves the efficiency of code modeling development when the meta model is newly added and the meta model is modified, saves a great amount of time to realize service functions, normalizes the code, reduces the code error rate in the development stage, and greatly improves the development efficiency.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above method when executing the program.
The present invention also provides a computer readable storage medium storing a computer program for executing the above method.
As shown in fig. 10, the electronic device 600 may further include: a communication module 110, an input unit 120, an audio processing unit 130, a display 160, a power supply 170. It is noted that the electronic device 600 need not include all of the components shown in fig. 10; in addition, the electronic device 600 may further include components not shown in fig. 10, to which reference is made to the related art.
As shown in fig. 10, the central processor 100, sometimes also referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, which central processor 100 receives inputs and controls the operation of the various components of the electronic device 600.
The memory 140 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The information about failure may be stored, and a program for executing the information may be stored. And the central processor 100 can execute the program stored in the memory 140 to realize information storage or processing, etc.
The input unit 120 provides an input to the central processor 100. The input unit 120 is, for example, a key or a touch input device. The power supply 170 is used to provide power to the electronic device 600. The display 160 is used for displaying display objects such as images and characters. The display may be, for example, but not limited to, an LCD display.
The memory 140 may be a solid state memory such as Read Only Memory (ROM), random Access Memory (RAM), SIM card, or the like. But also a memory which holds information even when powered down, can be selectively erased and provided with further data, an example of which is sometimes referred to as EPROM or the like. Memory 140 may also be some other type of device. Memory 140 includes a buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application/function storage 142, the application/function storage 142 for storing application programs and function programs or a flow for executing operations of the electronic device 600 by the central processor 100.
The memory 140 may also include a data store 143, the data store 143 for storing data, such as contacts, digital data, pictures, sounds, and/or any other data used by the electronic device. The driver storage 144 of the memory 140 may include various drivers of the electronic device for communication functions and/or for performing other functions of the electronic device (e.g., messaging applications, address book applications, etc.).
The communication module 110 is a transmitter/receiver 110 that transmits and receives signals via an antenna 111. A communication module (transmitter/receiver) 110 is coupled to the central processor 100 to provide an input signal and receive an output signal, which may be the same as in the case of a conventional mobile communication terminal.
Based on different communication technologies, a plurality of communication modules 110, such as a cellular network module, a bluetooth module, and/or a wireless local area network module, etc., may be provided in the same electronic device. The communication module (transmitter/receiver) 110 is also coupled to a speaker 131 and a microphone 132 via an audio processor 130 to provide audio output via the speaker 131 and to receive audio input from the microphone 132 to implement usual telecommunication functions. The audio processor 130 may include any suitable buffers, decoders, amplifiers and so forth. In addition, the audio processor 130 is also coupled to the central processor 100 so that sound can be recorded locally through the microphone 132 and so that sound stored locally can be played through the speaker 131.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principles and embodiments of the present invention have been described in detail with reference to specific examples, which are provided to facilitate understanding of the method and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (6)

1. A method of modeling code, the method comprising:
receiving and analyzing a meta model file input by a user to obtain basic model attribute information and a technical meta model name corresponding to the meta model file;
according to the technical meta-model name, obtaining a technical meta-model corresponding to the meta-model file from a database, and analyzing the technical meta-model to obtain extended model attribute information;
modeling code information input by a user is received, and a preset public template is configured according to the modeling code information, the basic model attribute information and the extended model attribute information to generate and output a modeling code file;
the analyzing the meta model file input by the user to obtain the basic model attribute information and the technical meta model name corresponding to the meta model file includes:
analyzing a meta model file input by a user to obtain basic model attribute information; the basic model attribute information comprises a model type identifier, a model attribute type, a model attribute default value, a model attribute name and an inheritance model name;
determining a technical meta-model name corresponding to the meta-model file according to the model type identifier and the model attribute name;
the receiving modeling code information input by a user, configuring a preset public template according to the modeling code information, the basic model attribute information and the extended model attribute information, and generating and outputting a modeling code file includes:
receiving modeling code information input by a user; the modeling code information comprises a template type, variable information and storage path information;
configuring a preset public template according to the template type, the basic model attribute information and the extended model attribute information to obtain a configured code template;
and writing the variable information into the configured code template, generating the modeling code file, and outputting the modeling code file by utilizing the storage path information.
2. The method of claim 1, wherein the extended model attribute information comprises model attribute details, detail prioritization priorities of model attributes, presentation prioritization priorities of model attributes, dictionary values of model attributes, rules of model attributes, and length control information of model attributes.
3. A code modeling apparatus, the apparatus comprising:
the meta model file module is used for receiving and analyzing a meta model file input by a user to obtain basic model attribute information and a technical meta model name corresponding to the meta model file;
the technical meta model module is used for acquiring a technical meta model corresponding to the meta model file from a database according to the technical meta model name, and analyzing the technical meta model to obtain the attribute information of the expansion model;
the modeling code file module is used for receiving modeling code information input by a user, configuring a preset public template according to the modeling code information, the basic model attribute information and the extended model attribute information, and generating and outputting a modeling code file;
wherein the meta model file module further comprises:
the basic attribute unit is used for analyzing the meta-model file input by the user to obtain basic model attribute information; the basic model attribute information comprises a model type identifier, a model attribute type, a model attribute default value, a model attribute name and an inheritance model name;
the technical meta model unit is used for determining the technical meta model name corresponding to the meta model file according to the model type identifier and the model attribute name;
wherein the modeling code file module comprises:
the modeling code information unit is used for receiving modeling code information input by a user; the modeling code information comprises a template type, variable information and storage path information;
the template configuration unit is used for configuring a preset public template according to the template type, the basic model attribute information and the extended model attribute information to obtain a configured code template;
and the modeling code file unit is used for writing the variable information into the configured code template, generating the modeling code file, and outputting the modeling code file by utilizing the storage path information.
4. The apparatus of claim 3, wherein the extended model attribute information comprises model attribute details, detail prioritization priorities of model attributes, presentation prioritization priorities of model attributes, dictionary values of model attributes, rules of model attributes, and length control information of model attributes.
5. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of claims 1 to 2 when executing the computer program.
6. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program for executing the method of any one of claims 1 to 2.
CN202110345545.6A 2021-03-31 2021-03-31 Code modeling method and device Active CN112860314B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110345545.6A CN112860314B (en) 2021-03-31 2021-03-31 Code modeling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110345545.6A CN112860314B (en) 2021-03-31 2021-03-31 Code modeling method and device

Publications (2)

Publication Number Publication Date
CN112860314A CN112860314A (en) 2021-05-28
CN112860314B true CN112860314B (en) 2024-02-20

Family

ID=75991906

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110345545.6A Active CN112860314B (en) 2021-03-31 2021-03-31 Code modeling method and device

Country Status (1)

Country Link
CN (1) CN112860314B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104932905A (en) * 2015-07-14 2015-09-23 北京神舟航天软件技术有限公司 Automatic code generation method from AADL to C language
CN110825369A (en) * 2019-11-07 2020-02-21 四川长虹电器股份有限公司 Method for automatically generating codes based on java language

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104932905A (en) * 2015-07-14 2015-09-23 北京神舟航天软件技术有限公司 Automatic code generation method from AADL to C language
CN110825369A (en) * 2019-11-07 2020-02-21 四川长虹电器股份有限公司 Method for automatically generating codes based on java language

Also Published As

Publication number Publication date
CN112860314A (en) 2021-05-28

Similar Documents

Publication Publication Date Title
CN104781785B (en) For application native code is generated from intermediate language code
CN112783793B (en) Automatic interface test system and method
CN111930617B (en) Automatic test method and device based on data objectification
CN112463634B (en) Software testing method and device under micro-service architecture
CN110543301B (en) Method and device for generating jenkins code file
CN110162464A (en) Mcok test method and system, electronic equipment and readable storage medium storing program for executing
CN113051269A (en) Form configuration method and device
CN111897738B (en) Automatic testing method and device based on atomic service
CN111897890A (en) Financial business processing method and device
CN115878092A (en) Code generation method, device and medium based on micro-service architecture
CN116149747A (en) Interface arrangement method, device, electronic equipment and computer readable storage medium
CN112860264B (en) Method and device for reconstructing abstract syntax tree
CN113342330A (en) Front-end engineering generation method and device
CN112860314B (en) Code modeling method and device
CN113297179A (en) Method and device for processing supervision submission data
CN114443039A (en) Input parameter verification method and device, electronic equipment and storage medium
CN106919387A (en) A kind of software delivery system and dissemination method
CN112860585B (en) Test script assertion generation method and device
CN112597510B (en) Access control method and device
US20140025439A1 (en) Regression free business process management
CN112181407B (en) Service realization processing method, device, system, electronic equipment and storage medium
CN112102058A (en) Management system parameter configuration method and device
CN110704742B (en) Feature extraction method and device
CN113486637A (en) Intelligent dynamic custom contract generation method and device
CN111858018B (en) Cgroup configuration method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant