CN109460220B - Message predefined code generation method and device, electronic equipment and storage medium - Google Patents

Message predefined code generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN109460220B
CN109460220B CN201811220484.5A CN201811220484A CN109460220B CN 109460220 B CN109460220 B CN 109460220B CN 201811220484 A CN201811220484 A CN 201811220484A CN 109460220 B CN109460220 B CN 109460220B
Authority
CN
China
Prior art keywords
field
information
message
identifier
data
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
CN201811220484.5A
Other languages
Chinese (zh)
Other versions
CN109460220A (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.)
Taikang Insurance Group Co Ltd
Taikang Pension Insurance Co Ltd
Original Assignee
Taikang Insurance Group Co Ltd
Taikang Pension Insurance Co Ltd
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 Taikang Insurance Group Co Ltd, Taikang Pension Insurance Co Ltd filed Critical Taikang Insurance Group Co Ltd
Priority to CN201811220484.5A priority Critical patent/CN109460220B/en
Publication of CN109460220A publication Critical patent/CN109460220A/en
Application granted granted Critical
Publication of CN109460220B publication Critical patent/CN109460220B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a method, a device, electronic equipment and a storage medium for generating a message predefined code, wherein field identification and field attribute information are obtained according to field data of a sample message; acquiring an object identifier corresponding to the field identifier in an object mapping set, wherein the object mapping set comprises an object identifier used for indicating a business object and object definition information; determining object definition information corresponding to the object identification in the object mapping set according to the field attribute information; the invention can continuously and correspondingly improve the existing message predefined codes or generate new message predefined codes along with the continuous updating and enrichment of the message contents, thereby improving the generation efficiency of the message predefined codes and further improving the efficiency and the reliability of serialization and deserialization in message transmission.

Description

Message predefined code generation method and device, electronic equipment and storage medium
Technical Field
The present invention relates to information processing technologies, and in particular, to a method and an apparatus for generating a message predefined code, an electronic device, and a storage medium.
Background
With the increasing data transmission requirements, the interface call between systems usually adopts data formats such as XML or JSON to transmit data packets. The specific process of intersystem data transmission is that a sending end converts a service object in a memory into a data message of XML or JSON (serialization), and after the data message is transmitted to a receiving end, the receiving end converts the data message into the service object again and stores the service object into content (deserialization). The message predefined code is the key of the serialization and deserialization processes, so the generation efficiency of the message predefined code needs to be improved.
In the conventional mode, when data messages are used for data exchange, both communication parties need to write corresponding message predefined codes for the type and version of the protocol used, and the message predefined codes contain logic processing modes for various different types of data items. When the contents of the data messages are updated, developers are required to redesign the original analysis codes, and a large amount of new codes are required to be written.
However, with the development of information technology, the information carried by the data packet is more and more abundant, and the amount of data to be analyzed is larger and larger. The problems of complex development, large workload, more repetitive work and the like exist in the process of manually completing the writing of the predefined codes by developers. The existing message predefined code generation method is not efficient.
Disclosure of Invention
The invention provides a method and a device for generating a message predefined code, electronic equipment and a storage medium, which improve the generation efficiency of the message predefined code.
According to a first aspect of the present invention, a method for generating a predefined message code is provided, which includes:
according to field data of the sample message, obtaining field identification and field attribute information;
acquiring an object identifier corresponding to the field identifier in an object mapping set, wherein the object mapping set comprises an object identifier used for indicating a business object and object definition information;
determining object definition information corresponding to the object identification in the object mapping set according to the field attribute information;
and generating or updating a message predefined code according to the object definition information.
Optionally, in a possible implementation manner of the first aspect, the obtaining, in the object mapping set, an object identifier corresponding to the field identifier includes:
judging whether an object identifier corresponding to the field identifier is stored in an object mapping set or not;
if the object identifier corresponding to the field identifier is judged to be stored in the object mapping set, finding the pre-stored object identifier;
and if the object identifier corresponding to the field identifier is not stored in the object mapping set, adding the object identifier corresponding to the field identifier in the object mapping set.
Optionally, in another possible implementation manner of the first aspect, the field attribute information includes: field type information and sub-element information;
after the pre-stored object identifier is found, determining object definition information corresponding to the object identifier in the object mapping set according to the field attribute information includes:
determining sample definition information corresponding to the field identification according to the field type information and the sub-element information corresponding to the field identification;
comparing the original object definition information corresponding to the object identifier in the object mapping set with the sample definition information to obtain newly added definition information, wherein the newly added definition information is sample definition information different from the original object definition information;
and updating the newly added definition information into the original object definition information to obtain object definition information corresponding to the object identifier in the object mapping set.
Optionally, in yet another possible implementation manner of the first aspect, the field attribute information includes: field type information and sub-element information;
after adding the object identifier corresponding to the field identifier to the object mapping set, determining, according to the field attribute information, object definition information corresponding to the object identifier in the object mapping set includes:
determining sample definition information corresponding to the field identification according to the field type information and the sub-element information corresponding to the field identification;
and taking the sample definition information as object definition information corresponding to the object identification in the object mapping set.
Optionally, in another possible implementation manner of the first aspect, the obtaining, according to field data of the sample packet, field identification and field attribute information includes:
acquiring a sample message, and determining message structure information of the sample message, wherein the message structure information comprises an XML format structure or a JSON format structure;
and obtaining a tree data structure according to the message structure information and the field data of the sample message, wherein each node data of the tree data structure comprises the field identification and the field attribute information of the field data.
Optionally, in yet another possible implementation manner of the first aspect, the field attribute information includes: field type information and sub-element information;
the obtaining a tree data structure according to the message structure information and the field data in the sample message includes:
acquiring node positions and node data of each field data of the sample message according to the message structure information, wherein the message structure information defines the subordination relationship among the field data, the node positions indicate nodes which are correspondingly stored in the field data, and the node data comprise field identification, field type information and sub-element information of the field data;
and storing each node data into a root node, a child node or a leaf node according to the node position to obtain a tree data structure body.
Optionally, in another possible implementation manner of the first aspect, the obtaining, according to the message structure information, a node position and node data of each field data of the sample message includes:
taking the topmost field data defined by the message structure information as target data;
acquiring a field identifier of the target data, and writing a multiple mark into field type information of the target data if the stored node data of the sample message includes the field identifier of the target data, wherein the field type information further includes an object type and character length information of the target data;
acquiring subdata subordinate to the next level of the target data according to the message structure information;
acquiring field type information of the subdata, and determining sub-element information of the target data according to the field type information of the subdata;
determining the node position of the target data according to the message structure information, and storing the field identification, the field type information and the sub-element information as the node data of the node position;
and if the sub-element information contains sub-element information of an object type, taking the sub-data of the object type as the target data, and returning to execute the field identifier for acquiring the target data.
Optionally, in yet another possible implementation manner of the first aspect, the determining sub-element information of the target data according to field type information of the sub data includes:
if the field type information of the sub data is null, determining the nullable type as the sub element information of the target data;
if the field type information of the subdata contains a text type, writing the text type into the sub-element information of the target data;
and if the field type information of the sub data contains the object type, writing the object type into the sub element information of the target data.
Optionally, in another possible implementation manner of the first aspect, the obtaining, according to field data of the sample packet, field identification and field attribute information further includes:
acquiring data source information of the field attribute information;
the determining, according to the field attribute information, object definition information corresponding to the object identifier in the object mapping set further includes:
and writing the data source information into the object definition information.
According to a second aspect of the present invention, there is provided a message predefined code generating apparatus, including:
the message analysis module is used for obtaining field identification and field attribute information according to the field data of the sample message;
the mapping construction module is used for acquiring the object identifier corresponding to the field identifier from an object mapping set, wherein the object mapping set comprises the object identifier used for indicating the business object and object definition information;
the object definition module is used for determining object definition information corresponding to the object identification in the object mapping set according to the field attribute information;
and the code generation module is used for generating or updating the message predefined codes according to the object definition information.
According to a third aspect of the present invention, there is provided an electronic apparatus comprising: the message pre-defined code generation method comprises a memory, a processor and a computer program, wherein the computer program is stored in the memory, and the processor runs the computer program to execute the message pre-defined code generation method in the first aspect and various possible implementation manners of the first aspect.
According to a fourth aspect of the present invention, there is provided a storage medium, in which execution instructions are stored, and when executed by a processor, the execution instructions are configured to implement the message predefined code generating method described in the first aspect and various possible implementations of the first aspect.
According to the message predefined code generation method, the message predefined code generation device, the electronic equipment and the storage medium, the field identification and the field attribute information are obtained according to the field data of the sample message; acquiring an object identifier corresponding to the field identifier in an object mapping set, wherein the object mapping set comprises an object identifier used for indicating a business object and object definition information; determining object definition information corresponding to the object identification in the object mapping set according to the field attribute information; the invention can continuously and correspondingly improve the existing message predefined codes or generate new message predefined codes along with the continuous updating and enrichment of the message contents, thereby improving the generation efficiency of the message predefined codes and further improving the efficiency and the reliability of serialization and deserialization in message transmission.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic view of an application scenario of a method for generating a predefined message code according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a method for generating a predefined message code according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a sample message with an XML format structure according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating a structure relationship of partial field data of the sample packet shown in FIG. 3;
fig. 5 is a schematic flowchart of a node data obtaining method according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a message predefined code generating apparatus according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be understood that, in the various embodiments of the present application, the size of the serial number of each process does not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
It should be understood that, in this application, "comprises" and "comprising," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in this application, "plurality" means two or more. "and/or" is merely an association describing an associated object, meaning that three relationships may exist, for example, and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
It should be understood that in this application, "B corresponding to A" means that B is associated with A, from which B can be determined. Determining B from a does not mean determining B from a alone, but may be determined from a and/or other information. And the matching of A and B means that the similarity of A and B is greater than or equal to a preset threshold value.
As used herein, "if" may be interpreted as "at … …" or "when … …" or "in response to a determination" or "in response to a detection", depending on the context.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 1 is a schematic view of an application scenario of a method for generating a predefined message code according to an embodiment of the present invention. As shown in the figure, the data transmission between the user end 1 and the user end 2 is performed in the form of a message. Before data is sent from the user side 1 to the user side 2, the user side 1 and the user side 2 generate the message predefined codes in advance by using the sample messages according to the message predefined code generation method in the following various embodiments of the present invention. The sample message may be written by a developer. In the data transmission process, the user terminal 1 uses the pre-generated message predefined code to perform the serialization processing process on the data to be transmitted, and sends the constructed message to the user terminal 2 in a wired transmission mode or a wireless transmission mode. The user end 2 performs deserialization processing on the received message by using the pre-generated message predefined code, and analyzes to obtain the data content in the message.
Referring to fig. 2, which is a flowchart illustrating a method for generating a predefined message code according to an embodiment of the present invention, an execution main body of the method shown in fig. 2 may be a software and/or hardware device. The method comprises the following steps of S101 to S104:
s101, according to the field data of the sample message, obtaining field identification and field attribute information.
The structure of the sample packet may be understood to include at least an XML format structure and a JSON format structure.
As an alternative implementation, the field identification and field attribute information may be stored by constructing a tree data structure. Specifically, a sample message is obtained first, and message structure information of the sample message is determined, where the message structure information includes an XML format structure or a JSON format structure. Although the XML format structure and the JSON format structure are both tree-structured message structures, there are still differences in format and information type, so that corresponding message structure information needs to be obtained according to different message structures.
And then, obtaining a tree data structure according to the message structure information and the field data of the sample message. Wherein each node data of the tree data structure includes field identification and field attribute information of the field data. Fig. 3 is a schematic diagram of a sample message with an XML format structure according to an embodiment of the present invention. Fig. 4 is a schematic diagram of a structural relationship between part of field data of the sample packet shown in fig. 3.
Optionally, the field attribute information may include: field type information and sub-element information.
The field type information is, for example, whether the field is an object type or a text type. The object type means that there is also dependent content under this field. The sub-element information refers to the dependent content of the current field. For example, the messages shown in fig. 3 and 4 include sub-elements under the "feedback request" (response) field: the result code (result _ code) is "0", the code information (message) is "success", and the policy object containing the next-level child elements. Wherein the field type of the result code and the code information is a text type, and the field type of the policy object is an object type. The message with the XML format structure shown in fig. 3 may be parsed into the tree relationship shown in fig. 4. The root node is a 'feedback request', and the child nodes at the lower level of the root node comprise result codes, code information and policy objects. The result code and the code information are leaf nodes, no sub-elements at the next level exist, and the policy object further divides sub-elements including a policy type (type), a certificate number (policy _ no), an applicant object (application) and other possible sub-elements. Policy type (type) and certificate number are leaf nodes. The applicant object is a child element of the object type that includes name, address object, mailbox, gender, below. Wherein, the name, mailbox and gender are leaf nodes. The number of the address objects is two, and the first address object comprises an address text, an address type and a number; the second address object includes address text and an address type.
In the foregoing implementation manner, an implementation process of obtaining the tree data structure according to the message structure information and the field data in the sample message may specifically be: and acquiring the node position and node data of each field data of the sample message according to the message structure information. And then storing each node data into a root node, a child node or a leaf node according to the node position to obtain a tree data structure body.
The message structure information defines the dependency relationship between field data, and the message structure information can be understood as format information and syntax rules under various format structures. The node position indicates a node where the field data is correspondingly stored, and the node data comprises field identification, field type information and sub-element information of the field data. The field identification may be a field name or a field ID. For example, one leaf node data includes: the field mark is Zhang III, the field type information is the text type, and the sub-element information is null.
It is understood that the construction of the tree data structure is completed by determining the node position and node data of each field and then storing the node position and node data in the tree data structure. Through the constructed tree data structure body, the field identification and the field attribute information can be conveniently and rapidly inquired and obtained, and the message analysis efficiency is improved.
Fig. 5 is a schematic flow chart of a node data acquisition method according to an embodiment of the present invention. Optionally, in the process of constructing the tree data structure, the obtaining of the node position and the node data of each field data of the sample packet according to the packet structure information may be implemented in a manner of recursively analyzing each field in the packet. The process shown in fig. 5 specifically includes steps S201 to S208, which are specifically as follows:
s201, using the topmost field data defined by the message structure information as target data.
For example, the "feedback request" in the messages shown in fig. 3 and 4 is the data of the top field of the message, which corresponds to the root node. The present embodiment preferably traverses the data of each child node from the root node down sequentially until all the data traverse to the leaf node.
S202, acquiring the field identification of the target data, and writing multiple marks into the field type information of the target data if the stored node data of the sample message includes the field identification of the target data.
Wherein the field type information further includes an object type and character length information of the target data. The multiple marks are used for identifying that the field data can repeatedly appear in the same message for multiple times, for example, the address object, the address text and the address type all appear in the same message for 2 times, and the multiple marks should be written in the field type information thereof so as to accurately define the field data.
S203, according to the message structure information, obtaining subdata subordinate to the next level of the target data.
S204, obtaining the field type information of the subdata, and determining the sub-element information of the target data according to the field type information of the subdata.
The field type information may be understood as a text type, an object type, and a null. The field type information of the sub data is null, which indicates that there is no sub element under the current target data, and it can be understood that the sub element under the object is fillable, for example, in the sub node of the address object shown in fig. 3, if the first address object contains "number" 100123 ", but the" number "corresponding to the second address object is null, the number of the sub element in the corresponding address object may be null, and the number is written into the sub element information of the address object.
In an alternative implementation, the specific implementation may include:
if the field type information of the sub data is null, determining the nullable type as the sub element information of the target data;
if the field type information of the subdata contains a text type, writing the text type into the sub-element information of the target data;
and if the field type information of the sub data contains the object type, writing the object type into the sub element information of the target data.
In this embodiment, steps S202 and steps S203-S204 are two independent processes, and are not limited by the described sequence of actions, and steps S202 and steps S203-S204 may be performed in other sequences or simultaneously.
S205, according to the message structure information, determining the node position of the target data, and storing the field identifier, the field type information and the sub-element information as the node data of the node position.
The field type information and the sub-element information may be understood as the above-described field attribute information. The node data stored as the node positions may be understood as constructing a tree data structure.
S206, judging whether the sub-element information contains the sub-element information of the object type. If yes, the step is shifted to S207; if not, go to S208.
S207, taking the sub data of the object type as the target data, and returning to execute S202.
It can be understood that if there are also child elements of the object type, it can be seen that the child element is not a leaf node, and the above loop process needs to be continued downwards.
And S208, ending.
It can be understood that, if none of the child element information is the object type, that is, all branches traverse to the leaf node, the traversal of the entire packet is completed, and the process proceeds to S208 to end the loop.
S102, obtaining the object identification corresponding to the field identification in an object mapping set, wherein the object mapping set comprises the object identification used for indicating the business object and the object definition information.
As an implementation manner, the obtaining of the object identifier may specifically be understood as:
and judging whether the object identifier corresponding to the field identifier is stored in the object mapping set, wherein the following two different processing modes can be provided according to the judgment structure.
If the object identifier corresponding to the field identifier is stored in the object mapping set, which indicates that the object mapping set stores the information of the object indicated by the object identifier, the pre-stored object identifier is found, and the object identifier is found.
And if the object identifier corresponding to the field identifier is not stored in the object mapping set, which indicates that the object mapping set does not have the information of the object indicated by the object identifier, adding the object identifier corresponding to the field identifier in the object mapping set to realize the creation of the object identifier.
In this embodiment, the object mapping set may be understood as an object dictionary for recording objects and their defined corresponding relationships.
S103, determining object definition information corresponding to the object identification in the object mapping set according to the field attribute information.
It is understood that the field attribute information includes: field type information and sub-element information.
In the implementation manner that the object mapping set has stored the information indicating the object by the object identifier and finds the object identifier, the specific manner of determining the object definition information may be: firstly, determining sample definition information corresponding to the field identification according to the field type information and the sub-element information corresponding to the field identification. The sample definition information may also include field identifiers, such as field names or field codes. And then, carrying out difference comparison on original object definition information corresponding to the object identification in the object mapping set and the sample definition information to obtain newly added definition information, wherein the newly added definition information is sample definition information different from the original object definition information. For example, only 1 address object in the original policy object is added with the new definition information, and 2 or more address objects in the new message may be added with the new definition information, so that the new definition information includes multiple marks of the address objects. And finally, updating the newly added definition information into the original object definition information to obtain the object definition information corresponding to the object identifier in the object mapping set. The object definition information may also include object identifiers, such as object names, name spaces where the objects are located, and/or codes of the objects, and may be used to identify the objects corresponding to the object definition information.
In an implementation manner that the object mapping set does not store information indicating an object by the object identifier and creates the object identifier, a specific manner of determining the object definition information may be: firstly, determining sample definition information corresponding to the field identification according to the field type information and the sub-element information corresponding to the field identification. And then directly using the sample definition information as the object definition information corresponding to the object identifier in the object mapping set.
In the foregoing various implementation manners, in order to define each field data of the packet more clearly, step S101 (obtaining the field identifier and the field attribute information according to the field data of the sample packet) may further include: and acquiring data source information of the field attribute information. The data source information may also obtain the data source of the applicant object, i.e., the position of the applicant object field data in the message, for example, at the same time as, before, or after the field identification and field attribute information of the applicant object is obtained. The location in the message may be embodied in the parameter name.
On the basis of obtaining the data source information, S103 (determining, according to the field attribute information, object definition information corresponding to the object identifier in the object mapping set) may also include: and writing the data source information into the object definition information. Thereby improving the accuracy of the object definition information.
S104, generating or updating a message predefined code according to the object definition information.
The message predefined code can be a code of C language or Java language, and can be generated according to actual requirements. Specifically, some subclass of class file GeneratorBase may be adopted to generate the object definition information into the message predefined code. In the specific generation of new message predefined codes or when old message predefined codes are updated, corresponding comments can be generated in the codes according to the sub-element sample data of each object, so that developers can conveniently refer to the codes.
For example, for the predefined codes generated corresponding to the code information in fig. 3 and fig. 4, the following may be used:
*************************************************************
///<summary>
// message (bound filling)
///example: [ success ]
///</summary>
/< example > [ success ] </example >
[XmlElement(ElementName="message",Namespace="")]
public string message{get;set;}
*************************************************************
In the above exemplary predefined codes of the message, [ XmlElement (ElementName ═ message ", name ═ () ] defines a data source; public string message { get; set; defines code information.
In the method for generating the predefined message code provided by this embodiment, a field identifier and field attribute information are obtained according to field data of a sample message; acquiring an object identifier corresponding to the field identifier in an object mapping set, wherein the object mapping set comprises an object identifier used for indicating a business object and object definition information; determining object definition information corresponding to the object identification in the object mapping set according to the field attribute information; the invention can continuously and correspondingly improve the existing message predefined codes or generate new message predefined codes along with the continuous updating and enrichment of the message contents, thereby improving the generation efficiency of the message predefined codes and further improving the efficiency and the reliability of serialization and deserialization in message transmission.
The message predefined codes generated by the embodiment can be used in the serialization process and the deserialization process, all objects in the message are found by analyzing the message structure, and even if the same object appears for multiple times, the objects can be distinguished and combined in the modes of multiple marks, field marks and the like, so that the efficiency of interface docking development in data transmission is improved, and the efficiency of message analysis and construction is improved.
As an alternative implementation manner, the above various embodiments may implement the corresponding steps by calling the following various object functions.
DataAnalyzor: and the abstract class is used for defining the object structure definition obtained by analyzing various messages. From this class derived XmlAnalyzor and JsonNalyzor are used for XML and JSON message analysis respectively.
Classfilegeneratorbae: abstract classes for defining the generation of object definition code in different programming languages from object structure definitions. CSharpGenerator and JavaGenerator derived from this class are used to generate message pre-defined codes in C # and JAVA languages, respectively.
Classesnfo: is a collection in which business object definition information neutral to the development language is defined. The set of class definition objects ClassDef and the set of namespace definition objects NameSpaceDef are included.
ClassDef is definition information for the business object. Information of the business object itself (e.g., object identification) is included, as well as attribute information included to define the set of PropertyDef.
PropertyDef: information is defined for attributes of the business object. The definitions of attribute names, types, multiplicity, nullability and the like are included.
Fig. 6 is a schematic structural diagram of a message predefined code generating apparatus according to an embodiment of the present invention. The message predefined code generating device 60 shown in fig. 6 mainly includes:
the message analysis module 61 is configured to obtain a field identifier and field attribute information according to field data of the sample message;
a mapping construction module 62, configured to obtain an object identifier corresponding to the field identifier from an object mapping set, where the object mapping set includes an object identifier used for indicating a business object and object definition information;
an object definition module 63, configured to determine, according to the field attribute information, object definition information corresponding to the object identifier in the object mapping set;
and a code generation module 64, configured to generate or update a message predefined code according to the object definition information.
The message predefined code generating device 60 in the embodiment shown in fig. 6 may be correspondingly used to execute the steps in the method embodiment shown in fig. 2, and the implementation principle and the technical effect are similar, which are not described herein again.
Optionally, the mapping construction module 62 is specifically configured to:
judging whether an object identifier corresponding to the field identifier is stored in an object mapping set or not; if yes, finding the pre-stored object identification; and if not, adding the object identifier corresponding to the field identifier in the object mapping set.
Optionally, the field attribute information includes: field type information and sub-element information. After the mapping construction module 62 finds the pre-stored object identifier, the object definition module 63 is configured to:
determining sample definition information corresponding to the field identification according to the field type information and the sub-element information corresponding to the field identification; comparing the original object definition information corresponding to the object identifier in the object mapping set with the sample definition information to obtain newly added definition information, wherein the newly added definition information is sample definition information different from the original object definition information; and updating the newly added definition information into the original object definition information to obtain object definition information corresponding to the object identifier in the object mapping set.
Optionally, the field attribute information includes: field type information and sub-element information. After the mapping construction module 62 adds the object identifier corresponding to the field identifier to the object mapping set, the object definition module 63 is configured to:
determining sample definition information corresponding to the field identification according to the field type information and the sub-element information corresponding to the field identification; and taking the sample definition information as object definition information corresponding to the object identification in the object mapping set.
Optionally, the message analysis module 61 is configured to:
acquiring a sample message, and determining message structure information of the sample message, wherein the message structure information comprises an XML format structure or a JSON format structure; and obtaining a tree data structure according to the message structure information and the field data of the sample message, wherein each node data of the tree data structure comprises the field identification and the field attribute information of the field data.
Optionally, the field attribute information includes: field type information and sub-element information. The message analysis module 61 is configured to:
acquiring node positions and node data of each field data of the sample message according to the message structure information, wherein the message structure information defines the dependency relationship among the field data, the node positions indicate nodes correspondingly stored in the field data, and the node data comprises field identification, field type information and sub-element information of the field data; and storing each node data into a root node, a child node or a leaf node according to the node position to obtain a tree data structure body.
Optionally, the message analysis module 61 is specifically configured to: taking the topmost field data defined by the message structure information as target data;
acquiring a field identifier of the target data, and writing a multiple mark into field type information of the target data if the stored node data of the sample message includes the field identifier of the target data, wherein the field type information further includes an object type and character length information of the target data; acquiring subdata subordinate to the next level of the target data according to the message structure information; acquiring field type information of the subdata, and determining sub-element information of the target data according to the field type information of the subdata; determining the node position of the target data according to the message structure information, and storing the field identification, the field type information and the sub-element information as the node data of the node position; and if the sub-element information contains sub-element information of an object type, taking the sub-data of the object type as the target data, and returning to execute the field identifier for acquiring the target data.
Optionally, the message analysis module 61 is specifically configured to: if the field type information of the sub data is null, determining the nullable type as the sub element information of the target data;
if the field type information of the subdata contains a text type, writing the text type into the sub-element information of the target data;
and if the field type information of the sub data contains the object type, writing the object type into the sub element information of the target data.
Optionally, the message analysis module 61 is further configured to:
and acquiring data source information of the field attribute information.
Accordingly, the object definition module 63 is further configured to:
and writing the data source information into the object definition information.
Referring to fig. 7, which is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention, the electronic device 70 includes: a processor 71, a memory 72 and computer programs; wherein
A memory 72 for storing the computer program, which may also be a flash memory (flash). The computer program is, for example, an application program, a functional module, or the like that implements the above method.
A processor 71 for executing the computer program stored by the memory to implement the steps of the above method. Reference may be made in particular to the description relating to the preceding method embodiment.
Alternatively, the memory 72 may be separate or integrated with the processor 71.
When the memory 72 is a device independent of the processor 71, the electronic apparatus may further include:
a bus 73 for connecting the memory 72 and the processor 71.
The present invention also provides a readable storage medium, in which a computer program is stored, which, when being executed by a processor, is adapted to implement the methods provided by the various embodiments described above.
The readable storage medium may be a computer storage medium or a communication medium. Communication media includes any medium that facilitates transfer of a computer program from one place to another. Computer storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, a readable storage medium is coupled to the processor such that the processor can read information from, and write information to, the readable storage medium. Of course, the readable storage medium may also be an integral part of the processor. The processor and the readable storage medium may reside in an Application Specific Integrated Circuits (ASIC). Additionally, the ASIC may reside in user equipment. Of course, the processor and the readable storage medium may also reside as discrete components in a communication device. The readable storage medium may be a read-only memory (ROM), a random-access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
The present invention also provides a program product comprising execution instructions stored in a readable storage medium. The at least one processor of the device may read the execution instructions from the readable storage medium, and the execution of the execution instructions by the at least one processor causes the device to implement the methods provided by the various embodiments described above.
In the above embodiments of the electronic device, it should be understood that the Processor may be a Central Processing Unit (CPU), other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (9)

1. A message predefined code generation method is characterized by comprising the following steps:
according to field data of the sample message, obtaining field identification and field attribute information; the field attribute information comprises field type information and sub-element information;
acquiring an object identifier corresponding to the field identifier in an object mapping set, wherein the object mapping set comprises an object identifier used for indicating a business object and object definition information;
determining sample definition information corresponding to the field identifier according to the field type information and the sub-element information corresponding to the field identifier, and updating or determining object definition information corresponding to the object identifier in the object mapping set based on the sample definition information;
generating or updating a message predefined code according to the object definition information;
the obtaining of the object identifier corresponding to the field identifier in the object mapping set includes:
judging whether the object identifier corresponding to the field identifier is stored in the object mapping set or not;
if yes, finding the pre-stored object identification;
after the pre-stored object identifier is found, updating object definition information corresponding to the object identifier in the object mapping set based on the sample definition information, including:
comparing the original object definition information corresponding to the object identifier in the object mapping set with the sample definition information to obtain newly added definition information, wherein the newly added definition information is sample definition information different from the original object definition information;
and updating the newly added definition information into the original object definition information to obtain object definition information corresponding to the object identifier in the object mapping set.
2. The method of claim 1, wherein obtaining the object id corresponding to the field id in the object mapping set further comprises:
and if the object identifier corresponding to the field identifier is not stored in the object mapping set, adding the object identifier corresponding to the field identifier in the object mapping set.
3. The method according to claim 2, wherein after adding the object identifier corresponding to the field identifier to the object mapping set, the determining, based on the sample definition information, the object definition information corresponding to the object identifier in the object mapping set includes:
and taking the sample definition information as object definition information corresponding to the object identification in the object mapping set.
4. The method according to claim 1, wherein the obtaining of the field identifier and the field attribute information according to the field data of the sample packet comprises:
acquiring a sample message, and determining message structure information of the sample message, wherein the message structure information comprises an XML format structure or a JSON format structure;
and obtaining a tree data structure according to the message structure information and the field data of the sample message, wherein each node data of the tree data structure comprises the field identification and the field attribute information of the field data.
5. The method of claim 4, wherein the field attribute information comprises: field type information and sub-element information;
the obtaining a tree data structure according to the message structure information and the field data in the sample message includes:
acquiring node positions and node data of each field data of the sample message according to the message structure information, wherein the message structure information defines the subordination relationship among the field data, the node positions indicate nodes which are correspondingly stored in the field data, and the node data comprise field identification, field type information and sub-element information of the field data;
and storing each node data into a root node, a child node or a leaf node according to the node position to obtain a tree data structure body.
6. The method according to claim 5, wherein the obtaining the node position and the node data of each field data of the sample packet according to the packet structure information comprises:
taking the topmost field data defined by the message structure information as target data;
acquiring a field identifier of the target data, and writing a multiple mark into field type information of the target data if the stored node data of the sample message includes the field identifier of the target data, wherein the field type information further includes an object type and character length information of the target data;
acquiring subdata subordinate to the next level of the target data according to the message structure information;
acquiring field type information of the subdata, and determining sub-element information of the target data according to the field type information of the subdata;
determining the node position of the target data according to the message structure information, and storing the field identification, the field type information and the sub-element information as the node data of the node position;
and if the sub-element information contains sub-element information of an object type, taking the sub-data of the object type as the target data, and returning to execute the field identifier for acquiring the target data.
7. An apparatus for generating a predefined code for a message, comprising:
the message analysis module is used for obtaining field identification and field attribute information according to the field data of the sample message; the field attribute information comprises field type information and sub-element information;
the mapping construction module is used for acquiring the object identifier corresponding to the field identifier from an object mapping set, wherein the object mapping set comprises the object identifier used for indicating the business object and object definition information;
the object definition module is used for determining sample definition information corresponding to the field identifier according to the field type information and the sub-element information corresponding to the field identifier, and updating or determining the object definition information corresponding to the object identifier in the object mapping set based on the sample definition information;
the code generation module is used for generating or updating message predefined codes according to the object definition information;
the mapping construction module is specifically configured to: judging whether an object identifier corresponding to the field identifier is stored in an object mapping set or not; if yes, finding the pre-stored object identification;
after the mapping construction module finds the pre-stored object identifier, the object definition module is configured to: determining sample definition information corresponding to the field identification according to the field type information and the sub-element information corresponding to the field identification; comparing the original object definition information corresponding to the object identifier in the object mapping set with the sample definition information to obtain newly added definition information, wherein the newly added definition information is sample definition information different from the original object definition information; and updating the newly added definition information into the original object definition information to obtain object definition information corresponding to the object identifier in the object mapping set.
8. An electronic device, comprising: a memory, a processor and a computer program, the computer program being stored in the memory, the processor running the computer program to perform the message predefined code generating method according to any one of claims 1 to 6.
9. A storage medium having stored thereon execution instructions for implementing the message predefined code generating method according to any one of claims 1 to 6 when executed by a processor.
CN201811220484.5A 2018-10-19 2018-10-19 Message predefined code generation method and device, electronic equipment and storage medium Active CN109460220B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811220484.5A CN109460220B (en) 2018-10-19 2018-10-19 Message predefined code generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811220484.5A CN109460220B (en) 2018-10-19 2018-10-19 Message predefined code generation method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109460220A CN109460220A (en) 2019-03-12
CN109460220B true CN109460220B (en) 2022-04-12

Family

ID=65607844

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811220484.5A Active CN109460220B (en) 2018-10-19 2018-10-19 Message predefined code generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109460220B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112698819A (en) * 2019-10-22 2021-04-23 北京信普飞科科技有限公司 Method, device and storage medium for designing tree-oriented object programming program
CN111930612B (en) * 2020-07-09 2024-03-19 北京皮尔布莱尼软件有限公司 Code updating correctness detection method and device and computing equipment
CN112055018B (en) * 2020-09-03 2023-05-23 中国银行股份有限公司 Message analysis method and device
CN112433722B (en) * 2020-11-27 2024-10-01 深圳前海微众银行股份有限公司 Modularized system code development method, device, equipment and system
CN112671842B (en) * 2020-12-08 2022-07-12 成都质数斯达克科技有限公司 Information transmission method and device, electronic equipment and readable storage medium
CN112910855B (en) * 2021-01-18 2023-04-07 中国民航信息网络股份有限公司 Sample message processing method and device
CN113268306B (en) * 2021-06-08 2024-03-19 金蝶软件(中国)有限公司 Resume analysis interface calling method and device and computer storage medium
CN115168365B (en) * 2022-09-01 2022-12-02 浪潮通信信息系统有限公司 Data storage method and device, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622444A (en) * 2012-03-15 2012-08-01 深圳市同洲视讯传媒有限公司 XML (extensible markup language) message processing method and XML message processing device
CN106598581A (en) * 2016-12-06 2017-04-26 成都能通科技有限公司 ASTERIX message parsing code generation method based on XML

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622444A (en) * 2012-03-15 2012-08-01 深圳市同洲视讯传媒有限公司 XML (extensible markup language) message processing method and XML message processing device
CN106598581A (en) * 2016-12-06 2017-04-26 成都能通科技有限公司 ASTERIX message parsing code generation method based on XML

Also Published As

Publication number Publication date
CN109460220A (en) 2019-03-12

Similar Documents

Publication Publication Date Title
CN109460220B (en) Message predefined code generation method and device, electronic equipment and storage medium
US20220035600A1 (en) API Specification Generation
US9483260B1 (en) Documentation generation for web APIs based on byte code analysis
EP3502896B1 (en) Generation of an adapters configuration user interface using a data structure
US8874704B2 (en) Semi-automatic discovery and generation of useful service blueprints
US9250864B2 (en) Relationship management for data modeling in an integrated development environment
CN113238740B (en) Code generation method, code generation device, storage medium and electronic device
KR20160031519A (en) Parser generation
CN109144514B (en) JSON format data analysis and storage method and device
CN104320312A (en) Network application safety test tool and fuzz test case generation method and system
CN114168149A (en) Data conversion method and device
US7912870B2 (en) Automated generation of modeling language profiles
US8086436B2 (en) Preliminary data representations of a deployment activity model
CN109325217B (en) File conversion method, system, device and computer readable storage medium
CN113949749B (en) XML message processing method and device
US20080276230A1 (en) Processing bundle file using virtual xml document
CN113572630A (en) Method and device for generating network configuration information, electronic equipment and medium
US9483578B2 (en) Computer-readable storage medium storing update program, update method, and update device
CN112130860B (en) JSON object analysis method and device, electronic equipment and storage medium
CN113536762A (en) JSON text comparison method and device
CN114296726A (en) Code generation method and device, computer equipment and storage medium
CN109388400B (en) Automatic page generation method and device
US20070299805A1 (en) System and method of report layout reference processing
CN113992549B (en) Test method, test device, electronic equipment and storage medium
CN118585353A (en) Cloud server-based management method, equipment and medium for equipment interface of Internet of things

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