Method, device, equipment and storage medium for generating architecture map based on JSON data
1. A method for generating an architecture graph based on JSON data is characterized by comprising the following steps:
configuring a JSON file, wherein the JSON file corresponds to an architecture scene;
according to the JSON file and the architecture scene, an object model of the architecture scene is manufactured;
and drawing a corresponding architecture map by using the object model.
2. The method for generating an architecture graph based on JSON data according to claim 1, wherein the making an object model of the architecture scene according to the JSON file and the architecture scene specifically includes:
determining a base class inherited by each drawing object in the architecture scene, and loading a loader module, a calculator module and a builder module of the base class;
analyzing fields in the JSON file based on the loader module, and creating each drawing object in the framework template;
and analyzing the JSON file based on the calculator module to obtain model information of each drawing object, wherein the model information comprises a model name, a model type and a model size.
3. The method for generating an architecture graph based on JSON data according to claim 2, wherein the drawing, by using the object model, the corresponding architecture graph specifically includes:
and filling the object model into the corresponding object of Gojs by using the builder to obtain the architecture map.
4. The method according to claim 3, wherein the using the builder to fill the object model into the corresponding object of Gojs to obtain the architecture graph specifically includes:
calculating the position information, the size and the background color of each node of the object model by utilizing Gojs;
drawing the architecture atlas by using Gojs according to a preset display mode, expanding and contracting the sub-classification display by using a preset display mode button, associating the object models together through lines, and displaying in a Canvas in a 2D plane form.
5. The method for generating an architecture graph based on JSON data according to claim 4, wherein the Gojs calculates the position information, the size, and the background color of each node according to the object model, and specifically includes:
and drawing an icon of the object model through a preset template by utilizing Gojs, and determining the current classification name, the sub-classification name and the architecture map name of the object model.
6. An apparatus for generating an architecture graph based on JSON data, the apparatus comprising:
the configuration module is used for configuring a JSON file, and the JSON file corresponds to an architecture scene;
the making module is used for making an object model of the architecture scene according to the JSON file and the architecture scene;
and the drawing module is used for drawing the corresponding architecture map by using the object model.
7. The apparatus according to claim 6, wherein the production module comprises a loading unit, a parsing unit and a drawing model unit;
the loading unit is specifically configured to determine a base class inherited by each drawing object in the architecture scene, and load a loader module, a calculator module, and a builder module of the base class;
the parsing unit is specifically configured to parse fields in the JSON file based on the loader module, and create each drawing object in the architecture template;
the drawing model unit is specifically configured to parse the JSON file based on the calculator module to obtain model information of each drawing object, where the model information includes a model name, a model type, and a model size.
8. The apparatus for generating an architecture graph based on JSON data according to claim 7,
the drawing module is specifically configured to fill the object model into the corresponding object of Gojs by using the builder to obtain the architecture map.
9. An electronic device comprising a memory having stored therein program instructions and a processor that, when executing the program instructions, performs the steps in the method of generating an architecture graph based on JSON data of any one of claims 1-5.
10. A storage medium having stored therein computer program instructions which, when executed by a processor, perform the steps of the method of generating an architecture graph based on JSON data of any one of claims 1 to 5.
Background
At present, most scenes need to come the architecture map to solve the communication barrier between the staff, reach the consensus, let relevant personnel surveyability through the architecture map to promote work efficiency, understand the responsibility, optimize and improve etc. but not everyone can all use professional software to draw, and the efficiency of using professional software to draw is also very high with costing.
Disclosure of Invention
The invention aims to solve the technical problem of the prior art and provides a method, a device, equipment and a storage medium for generating an architecture graph based on JSON data.
The technical scheme for solving the technical problems is as follows:
a method of generating an architecture graph based on JSON data, the method comprising:
configuring a JSON file, wherein the JSON file corresponds to an architecture scene;
according to the JSON file and the architecture scene, an object model of the architecture scene is manufactured;
and drawing a corresponding architecture map by using the object model.
On the basis of the technical scheme, the invention can be further improved as follows.
Further, the making an object model of the architecture scene according to the JSON file and the architecture scene specifically includes:
determining a base class inherited by each drawing object in the architecture scene, and loading a loader module, a calculator module and a builder module of the base class;
analyzing fields in the JSON file based on the loader module, and creating each drawing object in the framework template;
and analyzing the JSON file based on the calculator module to obtain model information of each drawing object, wherein the model information comprises a model name, a model type and a model size.
Further, the drawing a corresponding architecture map by using the object model specifically includes:
and filling the object model into the corresponding object of Gojs by using the builder to obtain the architecture map.
Further, the using the builder to fill the object model into the corresponding object of Gojs to obtain the architecture map specifically includes:
calculating the position information, the size and the background color of each node of the object model by utilizing Gojs;
drawing the architecture atlas by using Gojs according to a preset display mode, expanding and contracting the sub-classification display by using a preset display mode button, associating the object models together through lines, and displaying in a Canvas in a 2D plane form.
Further, the Gojs calculates the position information, the size, and the background color of each node according to the object model, and specifically includes:
and drawing an icon of the object model through a preset template by utilizing Gojs, and determining the current classification name, the sub-classification name and the architecture map name of the object model.
The method has the beneficial effects that: the method comprises the steps of configuring a JSON file, wherein the JSON file corresponds to an architecture scene, making an object model of the architecture scene according to the JSON file and the architecture scene, and drawing the corresponding architecture map by using the object model. The invention can reduce the cost of creating and modifying the architecture map, instantly modify the architecture map in effect, and even people who do not draw can easily modify the architecture map. Therefore, non-professionals can quickly create and modify the architecture map, and the cost for drawing the architecture map is reduced. The framework maps are classified, so that the corresponding framework maps can be quickly found according to the requirements of the framework maps.
The invention also solves another technical scheme of the technical problems as follows:
an apparatus to generate an architecture graph based on JSON data, the apparatus comprising:
the configuration module is used for configuring a JSON file, and the JSON file corresponds to an architecture scene;
the making module is used for making an object model of the architecture scene according to the JSON file and the architecture scene;
and the drawing module is used for drawing the corresponding architecture map by using the object model.
Furthermore, the manufacturing module comprises a loading unit, an analysis unit and a model drawing unit;
the loading unit is specifically configured to determine a base class inherited by each drawing object in the architecture scene, and load a loader module, a calculator module, and a builder module of the base class;
the parsing unit is specifically configured to parse fields in the JSON file based on the loader module, and create each drawing object in the architecture template;
the drawing model unit is specifically configured to parse the JSON file based on the calculator module to obtain model information of each drawing object, where the model information includes a model name, a model type, and a model size.
Further, the drawing module is specifically configured to fill the object model into the corresponding object of Gojs by using the builder to obtain the architecture map.
Further, the drawing module is specifically configured to calculate, for the object model, position information, a size, and a background color of each node by using Gojs;
drawing the architecture atlas by using Gojs according to a preset display mode, expanding and contracting the sub-classification display by using a preset display mode button, associating the object models together through lines, and displaying in a Canvas in a 2D plane form.
Further, the making module is specifically configured to draw an icon of the object model through a preset template by using Gojs, and determine a current classification name, a sub-classification name, and an architecture graph name of the object model.
Further, the present invention provides an electronic device comprising: a memory for storing a computer program; a processor, configured to implement the steps of the method for generating an architecture graph based on JSON data according to any one of the above technical solutions when the computer program is executed.
The present invention further provides a computer-readable storage medium, on which a computer program is stored, and when being executed by a processor, the computer program implements the steps of the method for generating an architecture graph based on JSON data according to any one of the above technical solutions.
Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments of the present invention or in the description of the prior art will be briefly described below, and it is obvious that the drawings described below are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for generating an architecture graph based on JSON data according to an embodiment of the present invention;
fig. 2 is a schematic block diagram of an apparatus for generating an architecture graph based on JSON data according to another embodiment of the present invention.
Detailed Description
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 some, not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, shall fall within the scope of protection of the present invention.
As shown in fig. 1, the method for generating an architecture graph based on JSON data according to the embodiment of the present invention includes the following steps:
110. and configuring a JSON file, wherein the JSON file corresponds to the architecture scene.
120. And making an object model of the architecture scene according to the JSON file and the architecture scene.
130. And drawing a corresponding architecture map by using the object model.
Further, step 120 specifically includes:
121. determining a base class inherited by each drawing object in the architecture scene, and loading a loader module, a calculator module and a builder module of the base class.
122. And analyzing fields in the JSON file based on the loader module, and creating each drawing object in the framework template.
123. And analyzing the JSON file based on the calculator module to obtain model information of each drawing object, wherein the model information comprises a model name, a model type and a model size.
Further, step 130 specifically includes:
131. and filling the object model into the corresponding object of Gojs by using the builder to obtain the architecture map.
Further, step 131 specifically includes:
1311. and calculating the position information, the size and the background color of each node for the object model by utilizing Gojs.
1322. Drawing the architecture atlas by using Gojs according to a preset display mode, expanding and contracting the sub-classification display by using a preset display mode button, associating the object models together through lines, and displaying in a Canvas in a 2D plane form.
Further, step 1311 specifically includes:
and drawing an icon of the object model through a preset template by utilizing Gojs, and determining the current classification name, the sub-classification name and the architecture map name of the object model.
It should be understood that JSON (JS Object Notation), in particular, is a lightweight data exchange format that is based on a subset of ECMAScript (JS specification set by the european computer association) and that stores and represents data in a text format that is completely independent of the programming language. The simple and clear hierarchical structure of the JSON makes the JSON become an ideal data exchange language, is easy to read and write by people and machine analysis and generation, and effectively improves the network transmission efficiency.
JSON can convert a set of data represented in a JavaScript object into a string, and then can easily transfer the string between networks or programs and restore it to a data format supported by each programming language when necessary, for example, in PHP, JSON can be restored to an array or a basic object. When AJAX is used, if an array value is needed, JSON is needed to convert the array into a character string.
Gojs is a JavaScript and TypeScript library, is used for constructing interactive charts and graphs, can well support the functions of drawing, adding, deleting, modifying and the like of the graphs, and does not have similar plug-ins at present. Gojs can build a variety of charts and graphs, from simple flow charts and organizational charts, to highly specific industrial charts such as SCADA charts, BPMN charts, medical charts and genealogical charts, and the like. However, the role of Gojs is usually positioned on the presentation and design of diagrams and its function is not fully utilized.
It should be understood that JSON files defining different architectural scenarios include the architectural templates needed to make the different scenarios; analyzing data in JSON files in different scenes and classifying the data; generate corresponding architecture map and can preview
It should be appreciated that the architecture graph may also be generated based on automatically drawn templates
For example, taking enterprise architecture data as an example, the enterprise architecture data JSON file general format includes a parent class ID, object information, the name of the current class, child classes, and a hierarchy and parent-child relationships that can implement objects according to a data structure.
Some other data such as drawing author name, creation time, data status, modification author name, modification time, etc. are also included in the object information. The data user in the object information can define and show in the atlas according to the need, and the data in the object information is only used in the demonstration enterprise architecture. And automatically generating a Graph object corresponding to the current architecture Graph template by using an algorithm through a parent classification ID according to the data, and automatically generating a corresponding Graph structure by using Gojs through the defined architecture Graph template to display the Graph structure in a canvas in a 2D plane form. Gojs calculates the position information, size, background color, etc. of nodes according to Graph objects
The method comprises the steps that an effect Graph which is automatically generated by JSON data of the current enterprise architecture is drawn by Gojs through a template object and a Graph object, and the effect Graph, the current classification name, the sub-classification name and the architecture Graph name are provided, the display of button expansion or contraction sub-classification is provided, and reasonable lines are used for associating the effect Graph, the sub-classification name and the architecture Graph name with each other. When a user clicks on a specific architecture graph, the current architecture graph is previewed.
The method for generating the architecture map based on the JSON data comprises the steps of configuring a JSON file, making an object model of an architecture scene according to the JSON file and the architecture scene, and drawing the corresponding architecture map by using the object model. The invention can reduce the cost of creating and modifying the architecture map, instantly modify the architecture map in effect, and even people who do not draw can easily modify the architecture map. Therefore, non-professionals can quickly create and modify the architecture map, and the cost for drawing the architecture map is reduced. The framework maps are classified, so that the corresponding framework maps can be quickly found according to the requirements of the framework maps.
As shown in fig. 2, an apparatus for generating an architecture graph based on JSON data, the apparatus comprising:
the configuration module is used for configuring a JSON file, and the JSON file corresponds to an architecture scene;
the making module is used for making an object model of the architecture scene according to the JSON file and the architecture scene;
and the drawing module is used for drawing the corresponding architecture map by using the object model.
Furthermore, the manufacturing module comprises a loading unit, an analysis unit and a model drawing unit;
the loading unit is specifically configured to determine a base class inherited by each drawing object in the architecture scene, and load a loader module, a calculator module, and a builder module of the base class;
the parsing unit is specifically configured to parse fields in the JSON file based on the loader module, and create each drawing object in the architecture template;
the drawing model unit is specifically configured to parse the JSON file based on the calculator module to obtain model information of each drawing object, where the model information includes a model name, a model type, and a model size.
Further, the drawing module is specifically configured to fill the object model into the corresponding object of Gojs by using the builder to obtain the architecture map.
Further, the drawing module is specifically configured to calculate, for the object model, position information, a size, and a background color of each node by using Gojs;
drawing the architecture atlas by using Gojs according to a preset display mode, expanding and contracting the sub-classification display by using a preset display mode button, associating the object models together through lines, and displaying in a Canvas in a 2D plane form.
Further, the making module is specifically configured to draw an icon of the object model through a preset template by using Gojs, and determine a current classification name, a sub-classification name, and an architecture graph name of the object model.
Further, the present invention provides an electronic device comprising: a memory for storing a computer program; a processor, configured to implement the steps of the method for generating an architecture graph based on JSON data according to any one of the above technical solutions when the computer program is executed.
The present invention further provides a computer-readable storage medium, on which a computer program is stored, and when being executed by a processor, the computer program implements the steps of the method for generating an architecture graph based on JSON data according to any one of the above technical solutions.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium.
Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media which may not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.
While the invention has been described with reference to specific embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.