Visual programming method, device, equipment and storage medium
By converting the basic functions in the Java atomic function library into Blockly's Block primitive objects and generating Java programs in the visual programming home page, the problem of interconversion between Blockly and the Java language is solved and development efficiency is improved.
Patent Information
- Application Number
- CN202111229751.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-22
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-10-22
AI Technical Summary
In the existing technology, the Blockly tool does not support code conversion in the Java language, resulting in low development efficiency.
By obtaining the basic functions and description information in the Java atomic function library, an initial Java primitive object is constructed, and converted into a Block primitive object using a preset conversion algorithm to generate a visual programming main page. After the user operates on this page, according to The target Block primitive object finds and replaces the initial primitive object to generate the target Java program.
It realizes the conversion between Java language and Blockly language, improves development efficiency, and enables users to generate corresponding Java code logic in the visual programming homepage.
Smart Images

Figure CN113961183B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of research and development management, and in particular to a visual programming method, device, equipment and storage medium. Background Art
[0002] Blockly is a visual programming tool released by Google, which is built on web technology. Its functional design is similar to Scratch, a children's programming language under MIT (open source software license agreement). When using Blockly, users can build code logic by dragging modules, and the process is very similar to building blocks. From the user's perspective, Blockly is a simple and easy-to-use visual tool for generating code. From the developer's perspective, Blockly is a text box that contains the code entered by the user.
[0003] For a highly collaborative and agile ecological application system, business personnel use Blockly for simple graphical programming, and developers use professional development languages for programming, and the two can be seamlessly converted to each other.
[0004] In the prior art, the open source version of Blockly only provides code conversion functions with JavaScript, Python, PHP, Dart, Lua, and XML. As Java is the current mainstream commercial development language, the prior art does not support conversion between it and Blockly, resulting in low development efficiency. Summary of the invention
[0005] The main purpose of the present invention is to solve the problem of how to convert Blockly into Java to improve development efficiency.
[0006] A first aspect of the present invention provides a visual programming method, comprising:
[0007] Acquire multiple basic functions and description information of each basic function in a preset Java atomic function library, and construct multiple initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
[0008] According to a preset conversion algorithm, each of the initial Java primitive objects is converted to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects;
[0009] Constructing a visual programming main page according to the description information of each basic function and the initial Block primitive object;
[0010] Receive operation information of the user on the visual programming main page, and generate an initial primitive object sequence for representing business requirements according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user;
[0011] According to the graphic element information in the target Block graphic element object, the target Java graphic element object corresponding to the target Block graphic element object is searched, and the target Block graphic element object in the initial graphic element object sequence is replaced with the target Java graphic element object to obtain the target graphic element object sequence, and the target program is generated according to the target graphic element object sequence.
[0012] Optionally, in a first implementation of the first aspect of the present invention, performing primitive conversion on each of the initial Java primitive objects according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects includes:
[0013] Perform syntax analysis on each of the initial Java graphic primitive objects based on the JavaParser tool library to obtain an initial abstract syntax tree for each of the initial Java graphic primitive objects;
[0014] Based on a preset formatting algorithm, flatten the nested structure in the abstract syntax tree into an associative array structure to obtain a target abstract syntax tree;
[0015] Based on a preset conversion rule, the atomic expressions in the target abstract syntax tree are converted into an extensible markup language to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects.
[0016] Optionally, in a second implementation of the first aspect of the present invention, constructing a visual programming main page according to the description information of each basic function and the initial Block primitive object includes:
[0017] Constructing a primitive description tree according to the description information of each basic function and the initial Block primitive object;
[0018] Rendering a page based on a preset homepage template file to obtain a static programming main page, wherein the static programming main page includes multiple page modules;
[0019] Receive a data request from each of the page modules, and according to the data request, obtain the tree node information corresponding to the primitive description tree, and partially reload the page module to obtain a visual programming main page.
[0020] Optionally, in a third implementation of the first aspect of the present invention, after constructing the primitive description tree according to the description information of each of the basic functions and the initial Block primitive object, the method further includes:
[0021] The primitive description tree is stored in the server, and when a newly added initial Block primitive object is detected, the primitive description tree in the server is updated.
[0022] Optionally, in a fourth implementation of the first aspect of the present invention, the page rendering based on a preset homepage template file to obtain a static programming main page includes:
[0023] Traversing the document nodes in the homepage template file, and generating a document object node tree model corresponding to the homepage template file according to the document nodes;
[0024] Parsing the cascading style sheet markup in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on the parsing result;
[0025] Constructing a rendering tree model corresponding to the homepage template file according to the document object model node tree model and the cascading style sheet rule tree model;
[0026] Based on the rendering tree model corresponding to the homepage template file, layout the elements in the homepage template file to the nodes corresponding to the rendering tree model;
[0027] Each node in the rendering tree model is drawn in turn to obtain a static programming main page.
[0028] Optionally, in a fifth implementation of the first aspect of the present invention, the receiving of operation information of the user on the visual programming main page and generating an initial graphic element object sequence for representing the business requirement according to the operation information includes:
[0029] Receiving operation information of the user on the visual programming main page, wherein the operation information includes identification information of the dragged object and arrangement information of the dragged object;
[0030] Determine at least one target Block primitive object according to the identification information of the dragged object;
[0031] The target Block primitive objects are arranged according to the arrangement information of the dragged object to obtain an initial primitive object sequence.
[0032] Optionally, in a sixth implementation of the first aspect of the present invention, searching for a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence includes:
[0033] According to the identification information of the target Block primitive object, detecting the target Java primitive object in the local storage space, wherein the target Java primitive object corresponds to the target Block primitive object;
[0034] If the target Java primitive object is not detected in the local storage space, searching the target Java primitive object in the remote server according to the primitive information in the target Block primitive object;
[0035] The target Java primitive object is lazily loaded, and the target Block primitive object in the initial primitive object sequence is replaced with the target Java primitive object to obtain a target primitive object sequence, and a target program is generated according to the target primitive object sequence.
[0036] A second aspect of the present invention provides a visual programming device, comprising:
[0037] A graphics primitive construction module is used to obtain multiple basic functions in a preset Java atomic function library and description information of each of the basic functions, and to construct multiple initial Java graphics primitive objects based on the basic functions, wherein each initial Java graphics primitive object corresponds to one of the basic functions;
[0038] A primitive conversion module, used for performing primitive conversion on each of the initial Java primitive objects according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects;
[0039] A homepage construction module, used to construct a visual programming main page according to the description information of each basic function and the initial Block primitive object;
[0040] A sequence generation module, used to receive operation information of the user on the visual programming main page, and generate an initial primitive object sequence for representing business requirements according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user;
[0041] A program generation module is used to search for a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, and replace the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generate a target program according to the target primitive object sequence.
[0042] Optionally, in a first implementation of the second aspect of the present invention, the primitive conversion module specifically includes:
[0043] A syntax parsing unit, used for performing syntax parsing on each of the initial Java primitive objects based on a JavaParser tool library to obtain an initial abstract syntax tree for each of the initial Java primitive objects;
[0044] A formatting unit, configured to flatten the nested structure in the abstract syntax tree into an associative array structure based on a preset formatting algorithm to obtain a target abstract syntax tree;
[0045] The expression conversion unit converts the atomic expression in the target abstract syntax tree into an extensible markup language based on a preset conversion rule, and obtains an initial Block primitive object corresponding to each of the initial Java primitive objects.
[0046] Optionally, in a second implementation of the second aspect of the present invention, the homepage construction module specifically includes:
[0047] A description tree construction unit, used to construct a primitive description tree according to the description information of each basic function and the initial Block primitive object;
[0048] A homepage template rendering unit, used for rendering a page based on a preset homepage template file to obtain a static programming main page, wherein the static programming main page includes a plurality of page modules;
[0049] The data loading unit is used to receive the data request of each of the page modules, and obtain the tree node information corresponding to the primitive description tree according to the data request, and partially reload the page module to obtain the visual programming main page.
[0050] Optionally, in a third implementation of the second aspect of the present invention, the homepage template rendering unit is specifically used to:
[0051] Traversing the document nodes in the homepage template file, and generating a document object node tree model corresponding to the homepage template file according to the document nodes;
[0052] Parsing the cascading style sheet markup in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on the parsing result;
[0053] Constructing a rendering tree model corresponding to the homepage template file according to the document object model node tree model and the cascading style sheet rule tree model;
[0054] Based on the rendering tree model corresponding to the homepage template file, layout the elements in the homepage template file to the nodes corresponding to the rendering tree model;
[0055] Each node in the rendering tree model is drawn in turn to obtain a static programming main page.
[0056] Optionally, in a fourth implementation of the second aspect of the present invention, the sequence generation module specifically includes:
[0057] A receiving unit, configured to receive operation information of a user on the main page of the visual programming, wherein the operation information includes identification information of the dragged object and arrangement information of the dragged object;
[0058] A determination unit, configured to determine at least one target Block primitive object according to the identification information of the dragged object;
[0059] The arrangement unit is used to arrange the target Block primitive objects according to the arrangement information of the dragged object to obtain an initial primitive object sequence.
[0060] Optionally, in a fifth implementation of the second aspect of the present invention, the program generation module specifically includes:
[0061] A local search unit, configured to detect a target Java primitive object in a local storage space according to the identification information of the target Block primitive object, wherein the target Java primitive object corresponds to the target Block primitive object;
[0062] A remote search unit, configured to search for the target Java primitive object in a remote server according to primitive information in the target Block primitive object if the target Java primitive object is not detected in the local storage space;
[0063] The primitive replacement unit is used to lazily load the target Java primitive object, and replace the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain the target primitive object sequence, and generate a target program according to the target primitive object sequence.
[0064] A third aspect of the present invention provides a visual programming device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the visual programming device executes the above-mentioned visual programming method.
[0065] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned visual programming method.
[0066] In the technical solution provided by the present invention, a Java primitive object is constructed by using a Java basic function, and then the Java primitive object is converted into a Block primitive object by a preset algorithm, and then a corresponding visual programming homepage is constructed according to the description of the basic function and the Block primitive object. After the user operates in the visual programming homepage, an initial primitive object sequence consisting of multiple Block primitive objects is generated, and finally the Block primitive object in the initial primitive sequence is replaced with the corresponding Java primitive object, thereby generating a target program. The present invention realizes the conversion between Java language and Blockly language, and the user only needs to operate in the visual programming homepage to generate the corresponding Java code logic, thereby improving the development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 A schematic diagram of a first embodiment of a visual programming method in an embodiment of the present invention;
[0068] Figure 2 It is a schematic diagram of a second embodiment of the visual programming method in an embodiment of the present invention;
[0069] Figure 3 A schematic diagram of a third embodiment of the visual programming method in an embodiment of the present invention;
[0070] Figure 4 Schematic diagram of a fourth embodiment of the visual programming method in an embodiment of the present invention;
[0071] Figure 5 A schematic diagram of an embodiment of a visual programming device in an embodiment of the present invention;
[0072] Figure 6 It is a schematic diagram of another embodiment of the visual programming device in the embodiment of the present invention;
[0073] Figure 7 A schematic diagram of an embodiment of a visual programming device in an embodiment of the present invention;
[0074] Figure 8 Schematic diagram of a syntax tree in an embodiment of the present invention. DETAILED DESCRIPTION
[0075] The embodiments of the present invention provide a visual programming method, apparatus, device and storage medium, which have higher development efficiency.
[0076] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0077] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the visual programming method in the embodiment of the present invention includes:
[0078] 101. Acquire multiple basic functions and description information of each basic function in a preset Java atomic function library, and construct multiple initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
[0079] It is understandable that Java is one of the mainstream development languages in the current market. Its data package (atomic function library) encapsulates a large number of native functions for developers to call. By calling different types of native functions and their combinations, the corresponding product logic is realized. Specifically, the Java atomic function library f contains a relationship judgment function set, a character class operation function set, a date and time class operation function set, a basic type array collection class operation function set, a numerical calculation class operation function set, an object list traversal operation function set, a mapping table operation function set, and a basic attribute and type conversion operation function set, corresponding to the classes: f.logic, f.text, f.time, f.list, f.math, f.loop, f.map. f.logic contains about 20 basic functions such as greater than or equal to, f.text contains about 80 basic functions such as start at, end at, and intercept, f.math contains about 40 basic functions such as four arithmetic operations, f.loop contains about 50 basic functions such as traversal, and f.map contains about 8 basic functions such as get and put. Furthermore, the server constructs a corresponding primitive object based on each basic function as a unit. The primitive object is an encapsulation of the function, which only provides the name of the primitive object to the outside world without providing any function details.
[0080] 102. Performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
[0081] It is understandable that Java primitive objects are based on specific Java language development logic, which is not friendly to business personnel without language foundation. In order to improve the efficiency of collaborative development, the server converts Java primitive objects into Block primitive objects based on a preset conversion algorithm. Among them, Blockly is a graphical programming language, which can realize simple programming by selecting and combining Block primitive objects. Each Block primitive object is a code block. It is worth mentioning that Blockly officially only provides Blockly conversion to JavaScript, Dart, Python or XML language. Java is not within its support range, and reverse conversion from other languages (non-Blockly) to Blockly is not supported.
[0082] 103. Build the main page of visual programming based on the description information of each basic function and the initial Block primitive object;
[0083] It is understandable that the main page of visual programming provides users with multiple selectable and combinable Block primitive objects. Each Block primitive object corresponds to a Java basic function. The description information of the function is added to the attribute node of the corresponding primitive object. When the user accesses the primitive object, the description information can be seen. Optionally, in order to improve programming efficiency and user experience, the main page of visual programming is divided into three module areas: "classification area", "building block area" and "script area". Among them, the classification area is used to classify Block primitive objects by module. Each classification uses a different color and has different functions. For example, the Loops classification stores loop building blocks, and the Math classification stores mathematical operation building blocks; the building block area is used to store building blocks (i.e. Block primitive objects) under the classification. Different building blocks represent different functions. In Blockly, building blocks can be written in programming languages including Java, so as to flexibly define building blocks. The script area is used to write code. Drag the building blocks in the building block area to the script area, and the building blocks are snapped together to form a building block group. The building block group can become an executable code segment, and the code segment is executed to obtain the calculation result. Furthermore, business personnel select the corresponding category area and the building blocks under the category area from the visual programming page according to business needs, and drag them to the script area to build a complete set of model calculation logic, such as calculating the credit score based on data such as the loan amount, repayment amount, and number of overdue repayments.
[0084] 104. Receive operation information of the user on the main page of the visual programming, and generate an initial primitive object sequence for representing the business requirement according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user;
[0085] It is understandable that business personnel select corresponding Block primitive objects in the visual programming main page according to specific business needs, and arrange and combine them in a certain order to generate an initial primitive object sequence for representing the application to be built. The user can select Block primitive objects in the visual programming main page by touching, dragging with the mouse, sliding, etc., which is not limited in this embodiment.
[0086] 105. According to the graphic element information in the target Block graphic element object, search for the target Java graphic element object corresponding to the target Block graphic element object, and replace the target Block graphic element object in the initial graphic element object sequence with the target Java graphic element object to obtain the target graphic element object sequence, and generate the target program according to the target graphic element object sequence.
[0087] It is understandable that each Block primitive object has a corresponding relationship with a Java primitive object, and this corresponding relationship is stored in the primitive information, so that the server can find the corresponding Java primitive object according to the primitive information in the Block primitive object. The initial primitive object sequence is composed of multiple Block primitive objects arranged in a certain order, and the target primitive object sequence is composed of multiple Java primitive objects arranged in a certain order. Each Java primitive object represents a Java code snippet. The Java code snippets are spliced according to the order of the objects in the target primitive object sequence to build the application.
[0088] Optionally, the server first detects the target Java graphic primitive object in the local storage space according to the identification information of the target Block graphic primitive object, wherein the target Java graphic primitive object corresponds to the target Block graphic primitive object; secondly, if the target Java graphic primitive object is not detected in the local storage space, the target Java graphic primitive object is searched in the remote server according to the graphic primitive information in the target Block graphic primitive object; then the server lazily loads the target Java graphic primitive object, and replaces the target Block graphic primitive object in the initial graphic primitive object sequence with the target Java graphic primitive object to obtain the target graphic primitive object sequence, and generates the target program file according to the target graphic primitive object sequence.
[0089] It is understandable that the local storage space is the storage medium of the terminal. For example, for data security considerations, the local storage space is the read-only memory (ROM) in the terminal, so that data can be read and searched non-destructively. If the local storage space does not store the Java primitive object corresponding to the target Block primitive object, the primitive resource location information in the target Block primitive object is used to find the corresponding target Java primitive object from the remote server and lazily load it. Lazy loading (Load On Demond) is a data acquisition method that improves the system response speed. It loads the corresponding data as the user scrolls the page, that is, only the data required for the content displayed on the current page is loaded, which effectively reduces the resource consumption of the server.
[0090] In this embodiment, by constructing a Java primitive object with a Java function and converting the Java primitive object into a Block primitive object, the user only needs to operate in the visual programming homepage to generate the corresponding Java code logic, thereby improving development efficiency.
[0091] See also Figure 2 , the second embodiment of the visual programming method in the embodiment of the present invention includes:
[0092] 201. Acquire multiple basic functions and description information of each basic function in a preset Java atomic function library, and construct multiple initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
[0093] Among them, step 201 is similar to the execution steps of the above step 101, and the details are not repeated here.
[0094] 202. Perform syntax parsing on each initial Java graphic primitive object based on the JavaParser tool library to obtain an initial abstract syntax tree of each initial Java graphic primitive object;
[0095] It can be understood that JavaParser is a Java source code parsing tool library that can parse Java code snippets into corresponding abstract syntax trees, which facilitates further analysis and modification of the code. Furthermore, the abstract syntax tree can be divided into conditional syntax branches and result syntax branches. The conditional syntax branch is used to represent the conditional control logic part in the code snippet, and the result syntax branch is used to represent the result behavior corresponding to the conditional control logic part in the code snippet, such as "if a>1&&(b>0||c<2), {d=10};". Among them, "if a>1&&(b>0||c<2)" is the conditional syntax branch, and "d=10" is the result syntax branch. Please refer to the corresponding syntax tree. Figure 8 .
[0096] 203. Based on a preset formatting algorithm, flatten the nested structure in the abstract syntax tree into an associative array structure to obtain a target abstract syntax tree;
[0097] Further, the server traverses the parsed abstract syntax tree to determine the nested structure therein, and converts it into a flat structure through a preset formatting algorithm. Specifically, the flat structure is an associative array. Assuming that the Java code snippet is "if(a>0&&b>0){c=1;d=2;}else if(a>0){c=2;}else{c=3;}", it is flattened and converted into [[a>0&&b>0,[c=1,d=2]],[a>0,[c=2]],[c=3]] through the formatting algorithm; the nested conditional syntax tree structure is formatted into a semi-flat structure, and the same relational statements are combined together, such as {V0==0&&(V1>5||V2<6)||V5>0||V3!=2} is formatted into {[OR,[AND,V0==0,[[OR,V1>5,V2<6]]],V5>0,V3!=2]}.
[0098] 204. Based on a preset conversion rule, convert the atomic expression in the target abstract syntax tree into an extensible markup language to obtain an initial Block primitive object corresponding to each initial Java primitive object;
[0099] It is understandable that the server processes the atomic expression differently according to its type, thereby converting it into the corresponding Xml (Extensible Markup Language) node fragment. Specifically, the server divides the atomic expression into relational operation expressions, method call expressions, and field expressions. For relational operation expressions, the server obtains its left value, operator, and right value, and replaces them with the corresponding parameter node values in the preset relational operation Xml template; for method call expressions, the server obtains its method name and method parameters, and converts the method parameters into parameters in Xml format, and then matches the corresponding template from multiple preset method Xml templates according to the method name, and replaces the corresponding default parameters in the template with the method parameters converted to Xml format; for field expressions, directly fill their values into the corresponding Xml templates, such as attribute expressions, the server directly replaces the default attribute value in the variable Xml template with the attribute value. For string expressions, the server directly fills the string with the default value in the character Xml template.
[0100] 205. Construct the main page of visual programming according to the description information of each basic function and the initial Block primitive object;
[0101] 206. Receive operation information of the user on the visual programming main page, and generate an initial primitive object sequence for representing the business requirement according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user;
[0102] 207. According to the graphic element information in the target Block graphic element object, search for the target Java graphic element object corresponding to the target Block graphic element object, and replace the target Block graphic element object in the initial graphic element object sequence with the target Java graphic element object to obtain the target graphic element object sequence, and generate the target program according to the target graphic element object sequence.
[0103] Among them, steps 205-207 are similar to the execution steps of the above steps 103-105, and will not be repeated here.
[0104] In this embodiment, the process of converting a Java primitive object into a Block primitive object is described in detail, and its nested structure and atomic expression are converted through syntax tree parsing, thereby realizing the conversion between Java and Blockly.
[0105] See also Figure 3, a third embodiment of the visual programming method in the embodiment of the present invention includes:
[0106] 301. Acquire multiple basic functions and description information of each basic function in a preset Java atomic function library, and construct multiple initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
[0107] 302. Performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
[0108] Among them, steps 301-302 are similar to the execution steps of the above steps 101-102, and the details are not repeated here.
[0109] 303. Construct a primitive description tree according to the description information of each basic function and the initial Block primitive object;
[0110] It is understandable that the primitive description tree refers to tree-shaped description information formed according to the category feature information of the primitives, and the branches of the tree have a hierarchical relationship. For example, square primitives are all subordinate primitives of the square primitive branch described by the category tree.
[0111] 304. Rendering a page based on a preset homepage template file to obtain a static programming main page, wherein the static programming main page includes a plurality of page modules;
[0112] It can be understood that the preset homepage template file is an Html page file, which contains cascading styles (CSS) and scripts. The server first traverses the document nodes in the homepage template file, and generates a document object node tree model corresponding to the homepage template file based on the document nodes; secondly, the cascading style sheet tags in the homepage template file are parsed, and based on the parsing results, a cascading style sheet rule tree model corresponding to the homepage template file is generated; according to the document object model node tree model and the cascading style sheet rule tree model, a rendering tree model corresponding to the homepage template file is constructed; then, based on the rendering tree model corresponding to the homepage template file, the elements in the homepage template file are laid out on the nodes corresponding to the rendering tree model; finally, each node in the rendering tree model is drawn in turn to obtain a static programming main page.
[0113] 305. Receive a data request from each page module, and obtain tree node information corresponding to the primitive description tree according to the data request, and partially reload the page module to obtain a visual programming main page;
[0114] It can be understood that the server first renders the preset homepage template file to generate a static page, then executes the initial script file to generate data requests for each module in the static page, and obtains the corresponding tree node information in the element description tree according to the data request to perform local reload. In a specific implementation, the element description tree can be regarded as a data storage structure, and the generation of data requests can realize local data interaction based on asynchronous Ajax without refreshing all resources of the entire page, thereby improving the generation efficiency of the visual programming main page.
[0115] 306. Receive operation information of the user on the visual programming main page, and generate an initial primitive object sequence for representing the business requirement according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user;
[0116] 307. According to the graphic element information in the target Block graphic element object, search for the target Java graphic element object corresponding to the target Block graphic element object, and replace the target Block graphic element object in the initial graphic element object sequence with the target Java graphic element object to obtain the target graphic element object sequence, and generate the target program according to the target graphic element object sequence.
[0117] Among them, steps 306-307 are similar to the execution steps of the above steps 104-105, and will not be repeated here.
[0118] In this embodiment, the process of constructing a visualization page is described in detail. A plurality of node information is generated by constructing a primitive description tree. When the initial page rendering is completed, a data request is made to obtain the corresponding node information, and then a dynamically interactive visualization programming homepage is loaded.
[0119] See also Figure 4 , a fourth embodiment of the visual programming method in the embodiment of the present invention includes:
[0120] 401. Acquire multiple basic functions and description information of each basic function in a preset Java atomic function library, and construct multiple initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
[0121] 402. Performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
[0122] 403. Construct a visual programming main page according to the description information of each basic function and the initial Block primitive object;
[0123] Among them, steps 401-403 are similar to the execution steps of the above steps 101-103, and the details are not repeated here.
[0124] 404. Receive operation information of the user on the main page of the visual programming, wherein the operation information includes identification information of the dragged object and arrangement information of the dragged object;
[0125] It can be understood that in this embodiment, the user generates an initial primitive object sequence corresponding to the business needs by dragging the graphic blocks in the main page of the visual programming. Among them, the graphic blocks dragged by the user have unique identification information, such as the graphic block sequence number, etc., and the identification information of the graphic block has a corresponding mapping relationship with the Block graphic primitive object.
[0126] 405. Determine at least one target Block primitive object according to the identification information of the dragged object, and arrange the target Block primitive objects according to the arrangement information of the dragged object to obtain an initial primitive object sequence;
[0127] It can be understood that when a graphic block dragged by the user from the selection area is detected in the script area, the server first obtains the identification information of the graphic block, then searches for the corresponding Block graphic object according to the mapping relationship, and then sorts the corresponding Block graphic objects in sequence according to the arrangement order of the graphic blocks in the script area, thereby forming an initial graphic object sequence.
[0128] 406. According to the graphic element information in the target Block graphic element object, search for the target Java graphic element object corresponding to the target Block graphic element object, and replace the target Block graphic element object in the initial graphic element object sequence with the target Java graphic element object to obtain the target graphic element object sequence, and generate the target program according to the target graphic element object sequence.
[0129] Among them, step 406 is similar to the execution steps of the above step 105, and the details are not repeated here.
[0130] In this embodiment, the construction process of the initial primitive object sequence is described in detail. The user drags the Block primitive object blocks in the visualization page and arranges them in a certain order, thereby generating the initial primitive object sequence.
[0131] The visual programming method in the embodiment of the present invention is described above. The visual programming device in the embodiment of the present invention is described below. Figure 5 , an embodiment of the visual programming device in the embodiment of the present invention includes:
[0132] The primitive construction unit module 501 is used to obtain multiple basic functions in a preset Java atomic function library and description information of each of the basic functions, and to construct multiple initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one of the basic functions;
[0133] The primitive conversion module 502 is used to perform primitive conversion on each of the initial Java primitive objects according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects;
[0134] A home page construction module 503 is used to construct a visual programming main page according to the description information of each basic function and the initial Block primitive object;
[0135] The sequence generation module 504 is used to receive the operation information of the user on the visual programming main page, and generate an initial primitive object sequence for representing the business requirements according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user;
[0136] The program generation module 505 is used to search for the target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, and replace the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain the target primitive object sequence, and generate the target program according to the target primitive object sequence.
[0137] In this embodiment, by constructing a Java primitive object with a Java function and converting the Java primitive object into a Block primitive object, the user only needs to operate in the visual programming homepage to generate the corresponding Java code logic, thereby improving development efficiency.
[0138] See also Figure 6 Another embodiment of the visual programming device in the embodiment of the present invention includes:
[0139] The primitive construction unit module 501 is used to obtain multiple basic functions in a preset Java atomic function library and description information of each of the basic functions, and to construct multiple initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one of the basic functions;
[0140] The primitive conversion module 502 is used to perform primitive conversion on each of the initial Java primitive objects according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects;
[0141] A home page construction module 503 is used to construct a visual programming main page according to the description information of each basic function and the initial Block primitive object;
[0142] The sequence generation module 504 is used to receive the operation information of the user on the visual programming main page, and generate an initial primitive object sequence for representing the business requirements according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user;
[0143] The program generation module 505 is used to search for the target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, and replace the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain the target primitive object sequence, and generate the target program according to the target primitive object sequence.
[0144] The primitive conversion module 502 specifically includes:
[0145] A syntax parsing unit 5021 is used to perform syntax parsing on each of the initial Java primitive objects based on a JavaParser tool library to obtain an initial abstract syntax tree for each of the initial Java primitive objects;
[0146] A formatting unit 5022, configured to flatten the nested structure in the abstract syntax tree into an associative array structure based on a preset formatting algorithm to obtain a target abstract syntax tree;
[0147] The expression conversion unit 5023 converts the atomic expressions in the target abstract syntax tree into extensible markup language based on a preset conversion rule, and obtains an initial Block primitive object corresponding to each of the initial Java primitive objects.
[0148] The homepage construction module 503 specifically includes:
[0149] A description tree construction unit 5031 is used to construct a primitive description tree according to the description information of each basic function and the initial Block primitive object;
[0150] The homepage template rendering unit 5032 is used to render a page based on a preset homepage template file to obtain a static programming main page, wherein the static programming main page includes multiple page modules;
[0151] The data loading unit 5033 is used to receive the data request of each of the page modules, and obtain the tree node information corresponding to the primitive description tree according to the data request, and partially reload the page module to obtain the visual programming main page.
[0152] The homepage template rendering unit 5032 is specifically used for:
[0153] Traversing the document nodes in the homepage template file, and generating a document object node tree model corresponding to the homepage template file according to the document nodes;
[0154] Parsing the cascading style sheet markup in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on the parsing result;
[0155] Constructing a rendering tree model corresponding to the homepage template file according to the document object model node tree model and the cascading style sheet rule tree model;
[0156] Based on the rendering tree model corresponding to the homepage template file, layout the elements in the homepage template file to the nodes corresponding to the rendering tree model;
[0157] Each node in the rendering tree model is drawn in turn to obtain a static programming main page.
[0158] The sequence generation module 504 specifically includes:
[0159] The receiving unit 5041 is used to receive the operation information of the user on the visual programming main page, wherein the operation information includes the identification information of the dragged object and the arrangement information of the dragged object;
[0160] A determining unit 5042, configured to determine at least one target Block primitive object according to the identification information of the dragged object;
[0161] The arrangement unit 5043 is used to arrange the target Block primitive objects according to the arrangement information of the dragged object to obtain an initial primitive object sequence.
[0162] The program generation module 505 specifically includes:
[0163] A local search unit 5051 is used to detect a target Java primitive object in a local storage space according to the identification information of the target Block primitive object, wherein the target Java primitive object corresponds to the target Block primitive object;
[0164] The remote search unit 5052 is used to search for the target Java primitive object in the remote server according to the primitive information in the target Block primitive object if the target Java primitive object is not detected in the local storage space;
[0165] The primitive replacement unit 5053 is used to lazily load the target Java primitive object, and replace the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generate a target program according to the target primitive object sequence.
[0166] In the embodiment of the present invention, the modular design allows the hardware of each part of the visual programming device to focus on the realization of a certain function, thereby maximizing the performance of the hardware. At the same time, the modular design also reduces the coupling between the modules of the device, making maintenance more convenient.
[0167] above Figure 5 and Figure 6 The visual programming apparatus in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The visual programming device in the embodiment of the present invention is described in detail from the perspective of hardware processing.
[0168] Figure 7 7 is a schematic diagram of the structure of a visual programming device provided by an embodiment of the present invention. The visual programming device 700 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 710 (for example, one or more processors) and a memory 720, and one or more storage media 730 (for example, one or more mass storage devices) storing application programs 733 or data 732. Among them, the memory 720 and the storage medium 730 may be temporary storage or permanent storage. The program stored in the storage medium 730 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the visual programming device 700. Furthermore, the processor 710 may be configured to communicate with the storage medium 730 to execute a series of instruction operations in the storage medium 730 on the visual programming device 700.
[0169] The visual programming device 700 may also include one or more power supplies 740, one or more wired or wireless network interfaces 750, one or more input and output interfaces 760, and / or one or more operating systems 731, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 7The structure of the visual programming device shown does not constitute a limitation on the visual programming device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0170] The present invention also provides a visual programming device, which includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor executes the steps of the visual programming method in the above-mentioned embodiments.
[0171] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium, and when the instructions are executed on a computer, the computer executes the steps of the visual programming method.
[0172] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0173] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0174] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A visual programming method, characterized in that: The visual programming method comprises: Acquire multiple basic functions and description information of each basic function in a preset Java atomic function library, and construct multiple initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function; According to a preset conversion algorithm, each of the initial Java primitive objects is converted to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects; Constructing a visual programming main page according to the description information of each basic function and the initial Block primitive object; Receive operation information of the user on the visual programming main page, and generate an initial primitive object sequence for representing business requirements according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user; According to the primitive information in the target Block primitive object, searching for the target Java primitive object corresponding to the target Block primitive object, and replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence; The step of performing a primitive conversion on each of the initial Java primitive objects according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects includes: performing syntax parsing on each of the initial Java primitive objects based on a JavaParser tool library to obtain an initial abstract syntax tree for each of the initial Java primitive objects; flattening the nested structure in the abstract syntax tree into an associative array structure based on a preset formatting algorithm to obtain a target abstract syntax tree; converting the atomic expression in the target abstract syntax tree into an extensible markup language based on a preset conversion rule to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects; The construction of the visual programming main page according to the description information of each of the basic functions and the initial Block primitive object includes: constructing a primitive description tree according to the description information of each of the basic functions and the initial Block primitive object; rendering the page based on a preset homepage template file to obtain a static programming main page, wherein the static programming main page includes multiple page modules; receiving a data request for each of the page modules, and according to the data request, obtaining tree node information corresponding to the primitive description tree, and partially reloading the page module to obtain the visual programming main page.
2. The visual programming method according to claim 1, characterized in that: After constructing the primitive description tree according to the description information of each of the basic functions and the initial Block primitive object, the method further includes: The primitive description tree is stored in the server, and when a newly added initial Block primitive object is detected, the primitive description tree in the server is updated.
3. The visual programming method according to claim 1, characterized in that: The page rendering is performed based on the preset homepage template file to obtain the static programming main page, including: Traversing the document nodes in the homepage template file, and generating a document object node tree model corresponding to the homepage template file according to the document nodes; Parsing the cascading style sheet markup in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on the parsing result; Constructing a rendering tree model corresponding to the homepage template file according to the document object node tree model and the cascading style sheet rule tree model; Based on the rendering tree model corresponding to the homepage template file, layout the elements in the homepage template file to the nodes corresponding to the rendering tree model; Each node in the rendering tree model is drawn in turn to obtain a static programming main page.
4. The visual programming method according to claim 1, characterized in that: The receiving of the operation information of the user on the visual programming main page and generating an initial graphic element object sequence for representing the business requirement according to the operation information comprises: Receiving operation information of the user on the visual programming main page, wherein the operation information includes identification information of the dragged object and arrangement information of the dragged object; Determine at least one target Block primitive object according to the identification information of the dragged object; The target Block primitive objects are arranged according to the arrangement information of the dragged object to obtain an initial primitive object sequence.
5. The visual programming method according to any one of claims 1 to 4, characterized in that: The step of searching for a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence includes: According to the identification information of the target Block primitive object, detecting the target Java primitive object in the local storage space, wherein the target Java primitive object corresponds to the target Block primitive object; If the target Java primitive object is not detected in the local storage space, searching the target Java primitive object in the remote server according to the primitive information in the target Block primitive object; The target Java primitive object is lazily loaded, and the target Block primitive object in the initial primitive object sequence is replaced with the target Java primitive object to obtain a target primitive object sequence, and a target program is generated according to the target primitive object sequence.
6. A visual programming device, characterized in that: The visual programming device comprises: A graphics primitive construction module is used to obtain multiple basic functions in a preset Java atomic function library and description information of each of the basic functions, and to construct multiple initial Java graphics primitive objects based on the basic functions, wherein each initial Java graphics primitive object corresponds to one of the basic functions; A primitive conversion module, used for performing primitive conversion on each of the initial Java primitive objects according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects; A homepage construction module, used to construct a visual programming main page according to the description information of each basic function and the initial Block primitive object; A sequence generation module, used to receive operation information of the user on the visual programming main page, and generate an initial primitive object sequence for representing business requirements according to the operation information, wherein the initial primitive object sequence includes at least one target Block primitive object selected by the user; A program generation module, used for searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object, obtaining a target primitive object sequence, and generating a target program according to the target primitive object sequence; The primitive conversion module specifically includes: a syntax parsing unit, which is used to perform syntax parsing on each of the initial Java primitive objects based on the JavaParser tool library to obtain an initial abstract syntax tree for each of the initial Java primitive objects; a formatting unit, which is used to flatten the nested structure in the abstract syntax tree into an associative array structure based on a preset formatting algorithm to obtain a target abstract syntax tree; an expression conversion unit, which converts the atomic expression in the target abstract syntax tree into an extensible markup language based on a preset conversion rule to obtain an initial Block primitive object corresponding to each of the initial Java primitive objects; The home page construction module specifically includes: a description tree construction unit, which is used to construct a primitive description tree according to the description information of each basic function and the initial Block primitive object; a home page template rendering unit, which is used to render the page based on a preset home page template file to obtain a static programming main page, wherein the static programming main page includes multiple page modules; a data loading unit, which is used to receive a data request from each of the page modules, and according to the data request, obtain the tree node information corresponding to the primitive description tree, and partially reload the page module to obtain a visual programming main page.
7. A visual programming device, characterized in that: The visual programming device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory so that the visual programming device executes the visual programming method as described in any one of claims 1-5.
8. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by a processor, the visual programming method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Visualized code generation method and system thereof
CN106445556A
Service orchestration model generation method and device, equipment and medium
CN112083911A
