A source code migration adaptation method and device for a localization environment
By constructing a data dictionary and using a scanner for compatibility assessment, combined with a large code language model to optimize the source code, the compatibility issues when migrating domestic IT innovation projects to a domestic environment were resolved. This enabled efficient migration and adaptation of domestic IT innovation projects, improving the quality and efficiency of migration in a domestic environment.
Patent Information
- Application Number
- CN202410699857.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2044-05-31
AI Technical Summary
When domestic IT innovation projects are migrated to a domestic environment, there are compatibility issues with operating systems, databases, middleware, and third-party software, making it difficult to guarantee high-performance and high-reliability operation of the business. Existing technologies cannot efficiently migrate and adapt the source code.
Construct a data dictionary, including operating system, database, and middleware data dictionaries; perform compatibility checks using a scanner; optimize code block structure and format using a large code language model; set weights for each evaluation metric; rewrite code blocks; and provide migration and modification suggestions.
It improves the quality and efficiency of migration and adaptation of domestically developed applications in a localized environment, ensuring the high performance and high reliability of business systems.
Smart Images

Figure CN118550583B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to a source code migration adaptation method and device for a localization environment, and belongs to the field of code adaptation. BACKGROUND
[0002] A signal creation project is generally characterized by great difficulty, long time, and complex technology, and needs to comprehensively consider the complex conditions of enterprise technology architecture, application architecture, and business system, ensure the rapid migration of signal creation, and ensure the high performance and high reliability of business operation, which requires related migration adaptation services to provide full-stack signal creation products, full-ecological adaptation capabilities, and systematic service support capabilities, and provide protection for the smooth migration of signal creation applications. The source code of the signal creation project has strong dependence on an operating system and a database, and needs to be adapted and modified before being migrated to a localization environment.
[0003] A patent with the publication number CN114925142A discloses a multi-type database compatible method, device, equipment, and medium of an ORM framework, which discloses the following: in an ORM framework, SQL statements supported by multiple types of databases are acquired, and individualized SQL statements different from other databases are marked in each type of database; according to the SQL statements supported by the multiple types of databases and the individualized SQL statements, a SQL statement conversion tool for converting SQL statements between the multiple types of databases is created; according to the database types built in the ORM framework, the SQL statement type output by the SQL statement conversion tool is set; according to the SQL statement type, a corresponding application function is developed, and the application function is applied to the ORM framework to realize the compatibility of the ORM framework with the SQL statements of multiple types of databases. SUMMARY
[0004] In order to overcome the problems in the prior art, the application designs a source code migration adaptation method and device for a localization environment.
[0005] In order to achieve the above-mentioned purpose, the application adopts the following technical solutions:
[0006] Technical solution one
[0007] A source code migration adaptation method for a localization environment, comprising the following steps:
[0008] A data dictionary is constructed, the data dictionary is provided with a file list with compatible risks in different environments and stores scanning rules, evaluation indexes, and adaptation modification suggestions corresponding to each file;
[0009] The scanner performs compatibility judgment on each file according to the data dictionary, calculates the evaluation index value according to the judgment result, and outputs the value of each evaluation index and the position of the code block with compatibility risk;
[0010] The weights of each evaluation index are set, and the evaluation index values are weighted and summed to obtain the adaptation evaluation value of the target source code.
[0011] The code block with compatibility risk, the code type label and the code rewriting prompt are input to the code large language model, and the code block structure and format are optimized; the code block is replaced with the code large language model output result.
[0012] Further, the evaluation indexes include SO package dependency compatibility, Jar dependency compatibility, executable file dependency compatibility, database compatibility, syntax compatibility, reserved word dependency compatibility, middleware compatibility, whether the integration method meets the requirements, whether the middleware is compliant, whether the open source software is compliant, whether the third party component is compliant, and whether the software developer is on the preset list.
[0013] Further, the data dictionary includes an operating system data dictionary, a database data dictionary, a middleware data dictionary, and a third party software data dictionary.
[0014] Further, the operating system data dictionary is provided with the following fields: dependency package name, dependency package type, dependency package version, CPU architecture, operating system, binding evaluation index, adaptation risk, code reference scanning rule, file scanning rule, POM file scanning rule, and adaptation modification suggestion.
[0015] Further, the database data dictionary is provided with the following fields: database type, whether open source, whether commercial, whether domestic, package reference scanning rule, driver scanning rule, database link scanning rule, and dependency tree scanning rule.
[0016] Further, the middleware data dictionary is provided with the following fields: middleware type, package reference scanning rule, configuration file scanning rule, dependency tree scanning rule, and POM file scanning rule.
[0017] Further, the scanning rule includes a plurality of regular expressions; the scanner performs compatibility judgment and compliance judgment according to the regular expressions to obtain the value of the evaluation index.
[0018] Technical solution two
[0019] A source code migration adaptation device for a domestic environment includes a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that the processor executes the program to implement the steps of technical solution one.
[0020] Compared with the prior art, the application has the following characteristics and beneficial effects:
[0021] The application scans and analyzes the source code from four dimensions of operating system adaptation, database adaptation, middleware adaptation and third-party software, evaluates whether the source code of the signal creation application has migration risks, and gives corresponding migration modification suggestions and rewritten codes, thereby improving the quality and efficiency of the adaptation and modification of the business system. BRIEF DESCRIPTION OF DRAWINGS
[0022] Fig. 1-2 is a flowchart of the application;
[0023] Fig. 3 is a schematic diagram of the adaptation evaluation system. DETAILED DESCRIPTION
[0024] The application will be described in more detail below in combination with embodiments.
[0025] As Fig. 1 shown, a source code migration modification method for a domestication environment includes the following steps:
[0026] In combination with the adaptation migration evaluation requirements of the signal creation application in the domestication environment, a signal creation application adaptation evaluation system is constructed from four dimensions of operating system adaptation, database adaptation, middleware adaptation and third-party software adaptation. For example, the first dimension evaluation index includes SO package dependency compatibility, Jar dependency compatibility and executable file dependency compatibility; the second dimension evaluation index includes database compatibility, syntax compatibility and reserved word dependency compatibility; the third dimension evaluation index includes middleware compatibility, whether the integration mode meets the requirements and whether the middleware is compliant; and the fourth dimension evaluation index includes whether the open source software is compliant, whether the third-party component is compliant and whether the software developer is on a preset list.
[0027] A user selects a scanner, a data dictionary, evaluation indexes and sets evaluation index weights and the like through a graphical interface. The data dictionary stores a file list (such as SO files, dependent packages and open source software) having compatibility problems under different software and hardware environments (such as different chip + operating system combinations) and file attributes, adaptation risks, corresponding scanning rules, bound evaluation indexes and adaptation modification suggestions of each file. The scanner performs dependency analysis, compatibility judgment and related dependent software compliance evaluation on target signal creation application source code (including dynamic library files, static library files, dependent software packages, executable files, Jar packages and database scripts) according to the data dictionary, and outputs values of each evaluation index and positions of code blocks having compatibility risks.
[0028] The weights of each evaluation index are set, and the weighted sum of all evaluation index values is obtained to obtain a signal creation application adaptation evaluation value.
[0029] The input code block, code type label and code rewriting prompt are input to the CodeGeeX2-6B code large language model, and the code block structure and format are optimized; the code block is replaced with the code large language model output result.
[0030] In an embodiment, the data dictionary is divided into an operating system data dictionary, a database data dictionary, a middleware data dictionary, and a third-party software data dictionary.
[0031] The operating system data dictionary is used to detect whether the source code depends on the characteristics of Windows, Linux, etc. operating system, and give suggestions for adaptation and modification. Mainly for SO software package, JAR dependency package and executable file, the operating system data dictionary construction process is as follows:
[0032] (1) Collect the characteristics and compatibility requirements of operating systems in different heterogeneous environments; (2) After classifying and sorting the characteristics and compatibility requirements, write them into the operating system data dictionary, and give adaptation and migration solutions for different heterogeneous environments, providing basis for subsequent detection and evaluation; (3) Regularly update the characteristics and compatibility requirements to ensure the accuracy and timeliness of the evaluation.
[0033] The scanner identifies and counts the code segments that meet the rules according to the rule fields recorded in the operating system data dictionary, and gives corresponding adaptation and modification suggestions. This dictionary category scans the corresponding operating system adaptation problems in the source code, and a dictionary record is an adaptation scanning scheme field for a dependency package. The data dictionary includes the following fields:
[0034] Dependency package name: scan the corresponding dependency package name
[0035] Dependency package type: the type of the dependency package result, including SO file, JAR file and executable file
[0036] Dependency package version: the dependency package version corresponding to the result, a statistical field
[0037] CPU architecture: the running CPU version corresponding to the result, a statistical field
[0038] Operating system: the running operating system corresponding to the result, a statistical field
[0039] Binding evaluation index: two-way binding of this dictionary item with the corresponding data item in the index management, and the optional item changes according to the data item of the operating system index in the index management
[0040] Adaptation risk: whether the result has corresponding adaptation risk
[0041] Code reference scanning rule: scan whether the code segment in the source code matches the regular rule, if it matches, it is considered that the problem corresponding to the dictionary item is scanned
[0042] File scanning rule: detect whether the file name in the source code matches the regular expression. If it matches, the file has a problem corresponding to the dictionary item
[0043] POM file scanning rule: scan the POM file. If there is a matching dependency, record that the source code references the corresponding problem dependency
[0044] Adaptation improvement suggestion: when generating the scan result, annotate the corresponding scan record and give the improvement suggestion corresponding to the problem
[0045] Examples are shown in the following table:
[0046]
[0047] The database data dictionary construction process is as follows:
[0048] (1) Collect SQL specifications and requirements of different databases from syntax compatibility, reserved word compatibility, function compatibility, and other database object compatibility checks; (2) After classifying and sorting the SQL specifications and requirements, write them into the database data dictionary, analyze the conversion differences and matters needing attention between different databases, and give the suggestion scheme of adaptation conversion, so as to facilitate subsequent detection and evaluation; (3) Update the SQL specifications and requirements regularly to ensure the accuracy and timeliness of the evaluation.
[0049] The scanner uses the database data dictionary to identify and count the databases used or referenced by the source code project, and judges whether the project has problems in the database localization adaptation process. The data dictionary includes the following fields:
[0050] Database type: divided into three options of relational database, non-relational database, and key-value database, used for statistics
[0051] Whether open source: whether the database is an open source database, used for statistics
[0052] Whether commercial: whether the database is a commercial database, used for statistics
[0053] Whether localized: whether the database supports localization adaptation, used for statistics
[0054] Package reference scanning rule: scan the code section of the source code to detect whether there is a reference code that matches the regular expression of this field. If there is, it is considered as scanning the problem corresponding to this dictionary item once
[0055] Driver scanning rule: scan the drivers referenced in each file in the source code, including code files and configuration files. If there is a code section or configuration item that matches the regular expression, it is considered as scanning the problem corresponding to this dictionary item once
[0056] Database link scanning rule: scan the source code of each file, including code files and configuration files. If there is a code segment or configuration item that matches the regular expression, it is considered to be scanned once for the dictionary item corresponding to the problem
[0057] Dependency tree scanning rule: scan the POM file or maven-tree file generated by the maven command line. If there is a matching dependency, it is recorded that the source code references the dependency corresponding to the dictionary item
[0058] Examples are shown in the following table:
[0059]
[0060]
[0061] Middleware data dictionary and third-party software data dictionary are used to detect the source of component library in source code, whether there is a substitute. The construction process of middleware data dictionary is as follows:
[0062] (1) Sort out the characteristics and compatibility requirements of commonly used middleware, component library and third-party software in different heterogeneous environments; (2) After classification and arrangement of software and components, write to database data dictionary, sort out the replacement deployment scheme, performance optimization scheme and migration adaptation scheme of localization in different heterogeneous localization environment, provide basis for subsequent detection and evaluation; (3) Update the compatibility and adaptation information of related software and components regularly to ensure the accuracy and timeliness of evaluation.
[0063] The scanner uses the middleware data dictionary to scan the middleware used or referenced in the source code to count the third-party software. The middleware data dictionary includes the following fields:
[0064] Middleware type: including application middleware, cache middleware, message middleware, integration middleware and Web middleware, which are statistical fields.
[0065] Package reference scanning rule: scan the code segment of the source code to detect whether there is a reference code that matches the regular expression of the field. If there is, it is considered to be scanned once for the dictionary item corresponding to the problem.
[0066] Configuration file scanning rule: parse and scan the source code configuration file (including properties file or yml file). If there is a configuration item in the code configuration file that matches the rule, it is considered to be scanned once for the dictionary item problem.
[0067] Dependency tree scanning rule: scan the maven-tree file generated by the maven command line, and if there is a matching dependency, record that the source code references the dependency of the corresponding dictionary item.
[0068] POM file scanning rule: scan the source POM file, and if a matching POM reference is found, record that the source code references the dependency of the corresponding dictionary item.
[0069] Examples are as follows:
[0070]
[0071] In one embodiment, after starting the scan, a thread is created for each type of scanner, and the code scanning process is performed in parallel. The following middleware scanning is an example:
[0072] Step 1: Read the middleware scanning corresponding index item from the evaluation index library
[0073] Step 2: Read the middleware scanning dictionary item (i.e. middleware scanning detection point, such as redis middleware dependency detection which detects package references, configuration files, dependency trees, pom import configurations, etc. Different types of middleware correspond to different scanning detection index information) from the dictionary library, process the dictionary item, generate a scanning result statistics class collection, and bind the corresponding evaluation index item for each dictionary item
[0074] Step 3: In a grouped regular manner, each scanning field is processed into a final scanning field expression; start traversing the source code files, and use the corresponding scanning field regular expression for different file types; whenever a problem is scanned, identify which dictionary item the scanned problem is according to the grouped regular, and increase the scanning result statistics of the item dictionary according to the generated scanning result statistics class parameters. For example, in the yml scanning process of middleware scanning, the Redis middleware corresponding configuration item is scanned, then read whether the dictionary item is localized, whether it is open source, etc. Parameters will be returned in the statistical result set after that, and the corresponding statistical count will be increased, and the code file path, line number, etc. Information corresponding to the scanning result is recorded and summarized in the scanning result statistics class object; after traversing all files, if the scanner supports maven-tree dependency tree scanning, the dependency tree file generated in advance is scanned and counted.
[0075] Step 4: After completing the above steps, the middleware scanning result of the source code is obtained, the statistical result is processed, and is summarized in the overall statistical result of the source code. For code that needs to be compatible, source code rewriting and conversion recommendations are made according to the source code compatibility adaptation rules, and the index statistics result is generated according to the previously bound evaluation index.
[0076] Wait for all the scanners to work, get the final scanning result statistics class, and generate a ChinaSoft application adaptation evaluation report.
[0077] It should be noted that the above-mentioned source code migration and reconstruction device for the localization environment is also used to realize the method steps corresponding to each embodiment in the source code migration and reconstruction method for the localization environment as described above, which will not be repeated herein. Fig. 1
[0078] It should be noted that each functional unit / module in each embodiment of the present application can be integrated in one processing unit / module, or each unit / module can exist physically, or two or more units / modules can be integrated in one unit / module. The integrated unit / module can be realized in the form of hardware or software functional unit / module.
[0079] Through the description of the above embodiments, those skilled in the art can clearly understand that the embodiments described herein can be realized in hardware, software, firmware, middleware, code or any appropriate combination thereof. For hardware implementation, the processor can be realized in one or more of the following units: application specific integrated circuit (ASIC), digital signal processor (DSP), digital signal processing device (DSPD), programmable logic device (PLD), field programmable gate array (FPGA), processor, controller, microcontroller, microprocessor, other electronic units designed to implement the functions described herein, or a combination thereof. For software implementation, part or all of the processes of the embodiments can be instructed by a computer program to relevant hardware. When implemented, the above program can be stored in a computer readable medium or transmitted as one or more instructions or codes on a computer readable medium. The computer readable medium includes computer storage medium and communication medium, wherein the communication medium includes any medium that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that can be accessed by a computer. The computer readable medium can include but is not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer.
[0080] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not limited to the protection scope of the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should analyze that the technical solutions of the present application can be modified or replaced equivalently without departing from the essence and scope of the technical solutions of the present application.
Claims
1. A source code migration adaptation method for a localization environment, characterized by, The method comprises the following steps: constructing a data dictionary provided with a list of files with compatibility risks in different environments and storing corresponding scanning rules, evaluation indexes, and adaptation and reconstruction suggestions of each file; the scanner performs compatibility judgment on each file according to the data dictionary, calculates the evaluation index value according to the judgment result, and outputs the value of each evaluation index and the location of the code block with compatibility risks; setting the weight of each evaluation index, and performing weighted summation on the evaluation index value to obtain the adaptation evaluation value of the target source code; inputting the code block with compatibility risks, the code type label, and the code rewriting prompt into the code large language model to optimize the code block structure and format; replacing the code block with the output result of the code large language model; The evaluation indexes are operating system adaptation, database adaptation, middleware adaptation, and third-party software, and the source code is scanned and analyzed from the four dimensions of operating system adaptation, database adaptation, middleware adaptation, and third-party software to evaluate whether the innovative application has migration risks.
2. The source code migration adaptation method for a localization environment according to claim 1, wherein, The data dictionary includes an operating system data dictionary, a database data dictionary, a middleware data dictionary, and a third-party software data dictionary.
3. The source code migration adaptation method for a localization environment according to claim 2, wherein, The operating system data dictionary is provided with the following fields: dependent package name, dependent package type, dependent package version, CPU architecture, operating system, binding evaluation index, adaptation risk, code reference scanning rule, file scanning rule, POM file scanning rule, and adaptation and reconstruction suggestion.
4. The source code migration adaptation method for a localization environment according to claim 2, wherein, The database data dictionary is provided with the following fields: database type, whether open source, whether commercial, whether domestic, package reference scanning rule, driver scanning rule, database link scanning rule, and dependent tree scanning rule.
5. The source code migration adaptation method for a localization environment according to claim 2, wherein, The middleware data dictionary is provided with the following fields: middleware type, package reference scanning rule, configuration file scanning rule, dependent tree scanning rule, and POM file scanning rule.
6. The source code migration adaptation method for a localization environment according to claim 1, wherein, The scanning rules include a plurality of regular expressions; the scanner performs compatibility judgment and compliance judgment according to the regular expressions to obtain the value of the evaluation index.
7. A source code migration adaptation device for a localization environment, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, The processor implements the following steps when executing the program: constructing a data dictionary provided with a list of files with compatibility risks in different environments and storing corresponding scanning rules, evaluation indexes, and adaptation and reconstruction suggestions of each file; the scanner performs compatibility judgment on each file according to the data dictionary, calculates the evaluation index value according to the judgment result, and outputs the value of each evaluation index and the location of the code block with compatibility risks; setting the weight of each evaluation index, and performing weighted summation on the evaluation index value to obtain the adaptation evaluation value of the target source code; inputting the code block with compatibility risks, the code type label, and the code rewriting prompt into the code large language model to optimize the code block structure and format; replacing the code block with the output result of the code large language model; The evaluation indexes are operating system adaptation, database adaptation, middleware adaptation, and third-party software, and the source code is scanned and analyzed from the four dimensions of operating system adaptation, database adaptation, middleware adaptation, and third-party software to evaluate whether the innovative application has migration risks.
8. The source code migration adaptation device for a localization environment according to claim 7, wherein, The data dictionary includes an operating system data dictionary, a database data dictionary, a middleware data dictionary, and a third-party software data dictionary.
Citation Information
Patent Citations
Multi-type database compatible method and device of ORM framework, equipment and medium
CN114925142A
Software package construction method and device
CN115639986A
AI inference task scheduling method and system oriented to multiple heterogeneous environments
CN115756833A