WO2014056145A1 - 使Web应用获取数据库变化的方法和系统 - Google Patents

使Web应用获取数据库变化的方法和系统 Download PDF

Info

Publication number
WO2014056145A1
WO2014056145A1 PCT/CN2012/082628 CN2012082628W WO2014056145A1 WO 2014056145 A1 WO2014056145 A1 WO 2014056145A1 CN 2012082628 W CN2012082628 W CN 2012082628W WO 2014056145 A1 WO2014056145 A1 WO 2014056145A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
record
web application
web
event
Prior art date
Application number
PCT/CN2012/082628
Other languages
English (en)
French (fr)
Inventor
胡立新
孙谦
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201280001498.2A priority Critical patent/CN103858121B/zh
Priority to JP2015535946A priority patent/JP6085897B2/ja
Priority to PCT/CN2012/082628 priority patent/WO2014056145A1/zh
Priority to EP12886190.3A priority patent/EP2897056A4/en
Publication of WO2014056145A1 publication Critical patent/WO2014056145A1/zh
Priority to US14/682,455 priority patent/US20150213077A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3006Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/87Monitoring of transactions

Definitions

  • the present invention relates to browser technology, and more particularly to a method and system for using a browser Web database.
  • Indexed DB is used to store large amounts of structured data in a browser and provide an index to ensure efficient queries.
  • the lightweight NoSQL non-relational database Indexed DB has a simpler syntax structure, making it easier for developers to implement Web applications that support local databases. .
  • the present invention proposes a system and method for enabling a web application to acquire database changes, so that the web application can timely and efficiently obtain data changes of the browser web database.
  • the first aspect is to provide a system for causing a web application to acquire a database change, the system comprising a browser, a web database, and a web application running in the browser, the browser comprising:
  • the database processing component of the browser acquires an operation request of the web application, and according to the operation Make a request to complete the operation of the Web database;
  • the database event generated by the event processing component of the browser according to the operation performed in the web database the database event being monitored by the web application; when the database event is generated, the property of the web application from the database event Get the changed content of the database.
  • the system when the web application includes the first page and the second page, the system is specifically: the database processing component of the browser acquires an operation request of the web application, and according to the The operation request completes an operation on the web database; the operation request is from a first page of the web application; the event processing component of the browser generates a database event according to the operation completed in the web database, and the database event is the web page
  • the application monitors; when the database event is generated, the web application obtains the changed content of the database from the attributes of the database event, and synchronizes the content related to the changed content of the database in the second page. deal with.
  • the attribute of the database event specifically includes: describing change information of the web database, where the change information includes: according to an operation request of the web application, the database has been The database name, the table name, and the change entry of the operation; the web application acquiring the related content of the database from the attribute of the database event, specifically: the web application acquiring the database name, the table name, and the change from the attribute of the database event An entry that determines the content of the changes in the web database.
  • the change entry specifically includes: one of an operation type, a key value, a new record value, and an old record value of the data record. Or multiple.
  • the new record value corresponding to the change entry is the new record value of the updated record
  • the old record value corresponding to the change entry is the old record value of the updated record.
  • the performing the operation on the web database according to the operation request further includes: database processing of the browser The component checks, according to the database name, the table name, and the key value in the operation, whether the record having the same database name, table name, and key value already exists in the database, and if the record already exists, determining that the storage operation is converted to Update the entry; if the corresponding record does not exist in the database, it is determined that the deposit operation is converted to an added entry.
  • the change entries are arranged in a chronological order of corresponding database operations, and if more than one operation is performed on a record in an operation request of a web application, The change entry contains only the last action on the record.
  • a seventh possible implementation manner of any one of the foregoing implementations is as follows:
  • the web application in the browser is configured to listen to a database event as: one of a window, a document, a body, or a database object.
  • a second aspect of the present invention provides a method for causing a web application to acquire a database change, including a browser and a web database, a first web application, and a second web application, the method comprising:
  • the database event is monitored by the second web application according to a database event generated by the operation performed in the web database;
  • the second web application obtains the changed content of the database from the attributes of the database event.
  • the attribute of the database event specifically includes: describing change information of the web database, where the change information includes an operation request of the first web application.
  • the second web application obtains the related content of the database from the attributes of the database event, specifically: the second web application obtains the database name from the attribute of the database event , table names, and change entries to determine the content of changes in the web database.
  • the change entry specifically includes: one or more of an operation type, a key value, a new record value, and an old record value of the data record.
  • the change entry includes at least one of the following operation types: when the operation type is empty, the changed key value, the new record value, and the old record value are all If the operation type is deleted, the key value of the corresponding change entry is the key value of the deleted record, and the old record value corresponding to the change entry is the record value of the deleted record; when the operation type is increased, the corresponding The key value of the change entry is the key value of the added record, and the new record value corresponding to the change entry is the record value of the added record; when the operation type is update, the key value of the corresponding change entry is the key value of the updated record.
  • the new record value corresponding to the change entry is the new record value of the updated record, and the old record value corresponding to the change entry is the old record value of the updated record.
  • the operation of the web database is completed according to the operation request, specifically including : checking whether there is already a record in the database that is the same as the database name, the table name, and the key value according to the database name, the table name, and the key value in the operation, and if the record already exists, determining that the storage operation is performed Convert to an update entry; if there is no corresponding record in the database, then determine to convert the save operation to an add entry.
  • the operation request of the first web application carries a database event parameter, so as to determine, according to the parameter, whether a database event is generated after the database transaction successfully processing is completed.
  • the above aspects of the present invention generate a corresponding database event according to a change of a Web database by a browser, so that a web application in the browser can listen to the database event and allocate a corresponding event processing function, thereby enabling the web application to be in a database event. Get the database changes in the properties and handle them accordingly. Database changes can be made more easily between different pages or different modules of a web application.
  • FIG. 1 is a schematic diagram of a computing environment according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a browser frame according to an embodiment of the present invention.
  • FIG. 5 is a diagram showing another form of database event in accordance with an embodiment of the present invention.
  • 6 is a signaling flowchart of another embodiment of the present invention.
  • 7 is a step of generating a database event according to an embodiment of the present invention.
  • Figure 8 is a diagram of the steps of determining database event attributes in accordance with an embodiment of the present invention. detailed description
  • a computer readable storage medium can be any device or medium that can store code and/or data for the computer system.
  • the computer referred to in the present invention refers to a microprocessor-based terminal device having computing capabilities, including but not limited to any type of computer system such as a personal computer, a tablet computer, a portable computer, and a mobile phone.
  • the computing environment 100 of the system includes a browser 101, a web database 102, and a CPU processor 106.
  • the browser 101 includes a database processing unit 104, an event processing unit 105, and a web application 103.
  • Each web application can open multiple pages in the browser.
  • page eight, page B and page C belong to the same web application.
  • the URL addresses of these pages belong to the same domain, such as belonging to www. .huawei.com , and the address of page A can be www.huaweide vice.
  • web applications can also be browser extensions. These browser extensions are usually composed of HTML and JavaScript, just like web applications, and can be created and accessed through a browser. Each web application can create one or more web databases through a browser. Web databases are usually stored in a computing environment in the form of files, either local or on other computers in the network. The solution for obtaining the database change of the web application of the present invention is not only applicable between the same web application, such as between the above page A and page B; and is also applicable between different web applications, such as between the extensions of the above browsers. .
  • the method steps of the system mainly include:
  • the database processing component 104 of the browser acquires an operation request of the web application 103, and completes an operation on the web database according to the operation request.
  • the operation request is generated by the web application 103 according to the user's operation in the browser.
  • the event processing component 105 of the browser is logged by the web application 103 according to a database event generated by an operation performed in the web database.
  • the database event includes a type of the event, such as the type of the event is database;
  • the web application 103 detects that there is a database event generation, the web application 103 acquires the changed content from the attributes of the database event.
  • FIG. 3 is a schematic diagram of a browser structure based on the computing environment of FIG. 1 and corresponding to the browser structure of the system of the present invention.
  • the web application 203 in the browser 201 opens two different pages of the application, a browser first page A and a browser second page B, hereinafter referred to as page A and page B, where page A and page B is also considered to be two objects of the web application 203, and the two pages should belong to the same i or, for example, 3 ⁇ 4. : Same as i or i or named www.huawei.com. Multiple pages of a browser can be on different tabs in the same form, or in different forms in the same browser.
  • the web application 203 sends an operation request to the database processing component 204 of the browser, and the database processing component 204 operates the web database according to the operation request; during the implementation, the communication between the web application 203 and the database processing component 204 can pass.
  • JavaScript API implementation JavaScript API implementation.
  • the event processing component 205 of the browser generates a database event according to an operation in the Web database corresponding to the operation request, the database event being monitored by the web application 203.
  • the database event is monitored by the web application 203, and is specifically configured to be directed to another page B.
  • the web application 203 allocates a database event listener object 202 and a database event processing function 206 to the page B. Any one of the window, document, body or database object; the database event listener object 202 listens to the database event method specifically: registering the database event of the browser in the event processing component 205 of the browser, and then processing the event After generating the database event, component 205 can send the database event to database event listener object 202 based on the registration information of database event listener object 202.
  • the web application 203 acquires changed content of the database from attributes of the database event; Specifically, it may be that after the database event listener object 202 receives the database event from the event processing component 205, the database event is forwarded to the database event processing function 206; when there are more operational steps, the record needs to be recorded. In the environment of the step, the data of each step is optionally recorded by the event processing component 205 and carried in the database event to the database event listener object 202.
  • the database event processing function 206 describes the database event attribute by using the database processing component 204 to the web database according to the attribute of the database event.
  • the identifier of each element in the change entry includes: an identifier corresponding to the key value, an identifier corresponding to the new record value, and an identifier corresponding to the old record value; wherein the identifier corresponding to the new record value is based on the actual content stored in the Web database.
  • the event processing component 205 generates a database event after the database operation is completed, and the page B obtains the attribute of the database event through the database event processing function 206, and then performs corresponding processing according to the content of the database change in the attribute.
  • page A can also have database event listener object 202 (not shown in Figure 3) and database event handler 206 (not shown in Figure 3) having the same functionality in page B, thereby browsing through
  • the monitoring of the database event generated in the event processing component 205 of the device realizes the monitoring of the database operation in the page B by the page A, and finally achieves the purpose of monitoring each other between the page A and the page B.
  • the browser can make different settings according to the timing of the processing of the database event attribute according to whether the page B and the page A are in a browser, and the specific implementation manner can be expressed as:
  • the browser may be set such that the database event processing function 206 performs the attribute of the database event after acquiring the attribute of the database event. Processing, that is, updating in page B belongs to the same database as page A, and the content corresponding to each change item in the same table enables the content of the same attribute in page B and page A to be synchronously changed and updated; this is to ensure When page A and page B are displayed side by side, real-time updates of the content that the application of page B can now listen to can be real-time updated.
  • the above operation of the user in the browser can be further divided into: 1) inputting the parameters in the page A, and clicking the confirmation button in the page A to complete the data in the page A.
  • the confirmation button is clicked as the trigger point for initiating the operation request of the web application; 2) in a column of page A (the one column may correspond to one of the changed items)
  • the operation request to send the web application is triggered.
  • the specific implementation manner is not limited to the two types mentioned above, and may be other operations related to the operation in the browser to trigger the sending of the web application.
  • the generation of the database event may be preferably: 1) recording all web application operations corresponding to a certain change item in the page A, and then triggering the generation of the database event, wherein the triggering manner may be in the above two manners.
  • the process of generating a database event all the web application operation contents corresponding to a certain change item of the above record are included in the attribute of the database event, so that the database event listener object 202 in the page B is from The operation content of all web application operations corresponding to the change entry is obtained in the attribute of the database event. or,
  • the operation request of the web application includes parameters for generating a database event, and the browser can determine, according to the parameter, whether a database event is generated after the operation request of the web application is completed.
  • parameters for generating a database event may be set in the database processing component 204 without carrying the parameter in an operation request of the web application, thereby implementing certain objects on certain pages or pages.
  • the operation optionally generates a database event.
  • the "suppressevent" parameter can be specified when executing an operation request of a web application, and no database event is generated when the event parameter is used. This parameter can also be used to prevent infinite loops, specifying that no events are generated when the database is manipulated in the event handler.
  • a record update (update)
  • a database update operation is performed, which may cause an infinite loop.
  • This parameter can also avoid unnecessary database events, such as some database operations that do not need to be monitored, to save system resources.
  • the default transaction can also generate no events, only database events are generated when the "firedatabaseevent" parameter is specified. This helps save system resources and better compatibility. There are many web applications that do not need to monitor database events, so it is a better solution to not generate events.
  • the attributes of the database event include change information describing the database change, and the change information includes the
  • the operation request of the web application causes the changed database name, table name, and change item, and the change item information is obtained from the attribute of the event in the database event processing function by the web application in the browser, and the web application is changed according to the change information. Get changes to the database.
  • Figure 4 shows the contents of a database event of an embodiment of the present invention, including some read-only attributes.
  • Each item of the change entry includes the operation type of the data record ( operationType ), as well as optional key values ( key ), old record values ( oldValue ), and new record values ( newValue ), which can be stored in array form.
  • the property key value keys is an array of strings ( DOMStringList ).
  • the change entry includes at least one of the following types of operations:
  • the corresponding changed key value, new record value, and old record value are all empty;
  • the key value of the corresponding change entry is the key value of the deleted record, corresponding to the change entry
  • the old record value is the record value of the deleted record;
  • the key value of the corresponding change entry is the key value of the added record, and the new record value corresponding to the change entry is the record value of the added record;
  • the key value of the corresponding change entry is the key value of the updated record
  • the new record value corresponding to the change entry is the new record value of the updated record
  • the old record value corresponding to the change entry is the updated record.
  • the old record value is the key value of the corresponding change entry.
  • FIG. 5 illustrates the contents of a browser database event described in another equivalent manner of an embodiment of the present invention, which may be applied to the systems described in FIGS. 1 and 3.
  • the number of database event objects can contain According to the change list DatabaseChangeList object, the list object specifically includes a change entry of a detailed data record.
  • a set of operation requests of one or more web applications is referred to as a database transaction.
  • the database processing component of the browser checks whether the database name already exists in the database according to the database name, the table name, and the key value in the operation. a record having the same table name and key value, if it is already present, determining to convert the operation type corresponding to the change entry to the update entry, and the event processing component 205 of the browser generates the corresponding attribute of the database event, correspondingly
  • the key value is the key value of the updated record
  • the new record value of the corresponding entry is the new record value of the updated record
  • the old record value of the corresponding entry is the old record value of the updated record.
  • the event processing component 205 of the browser If there is no record in the database that is the same as the database name, the table name, and the key value, it is determined that the operation type corresponding to the change item is converted into an added item, and the event processing component 205 of the browser generates a corresponding In the attribute of the database event, the corresponding key value is the key value of the completed record, and the new record value of the corresponding entry is the record value of the completed record.
  • the same record is often manipulated multiple times and then submitted when the user saves or automatically saves it. For example, if the value of a field is modified for a record and then the record is deleted, the corresponding database transaction contains two operations of modification and deletion when the user saves the submitted data.
  • the change entries in the database event attribute are arranged in the chronological order of the corresponding database operations; if the last operation in the database transaction is a clear operation, that is, all the records of the table are deleted, the corresponding key value, the new record value, and the old record value All are empty, so in this case, if all the recorded key values and the old recorded values are not included in the event, the amount of data may be large, and generally not necessary, so only record emptying Related operations after the operation.
  • the shopping basket module of the e-commerce web application when the product is added, the option of emptying the existing items in the shopping basket is provided at the same time, so that the corresponding database transaction includes the emptying operation of the table data of the shopping basket first, and then Add a new item record.
  • the user modifies the number of items in the shopping basket, but does not submit it immediately, and then performs the emptying operation of the shopping basket, and submits, so that the corresponding database transaction only contains the emptying operation.
  • the change order in the database event attribute is in the chronological order of the corresponding database operation.
  • the change entry contains only the last operation of the record, such as: When selecting a product purchase quantity, it may be possible to make multiple selections for the required quantity, then the change item corresponding to the certain product will only save the last selected quantity; several times of input and modification are made in an edit box in the web page. The change entry corresponding to the certain edit box will only save the last modified content.
  • the browser displays a list of items already selected in the shopping basket (or shopping cart) on one page, and opens another webpage displaying specific products on the website, and then clicks to add to the shopping basket. .
  • the best option is to automatically refresh the list of items on the shopping basket page to show the newly added shopping basket.
  • the content record of the shopping basket is stored in the local Web database, and the product display page (corresponding to page A in Fig. 3) adds the item to the shopping basket, that is, when the web application performs the database add operation, a database event (database) is generated.
  • FIG. 6 is a second web application implemented on the first web
  • the operation of the web database is performed according to the operation request, where the first web application and the second web application run in the browser;
  • the database event generated by the operation performed in the web database is monitored by the second web application.
  • FIG. 7 a detailed processing procedure for generating a database event by a browser according to an embodiment of the present invention is described, which is a specific application of the method shown in FIG. 6.
  • an operation request of one or more web applications is performed.
  • the collection is called a database transaction.
  • Step S301 the browser acquires an operation request of the first web application, and generates a transaction of the web database according to the operation request, and completes each operation of the web database in the web database transaction; and step S302, determining whether the transaction to the web database is successfully completed. If it fails, step S309 is performed to perform rollback of the transaction of the Web database; if successful, step S303 is performed;
  • Step S303 analyzing database event parameters in the database transaction
  • Step S304 determining whether it is necessary to generate a database event, if yes, proceeding to step S305, otherwise executing step S308;
  • Step S307 The second web application listens to the database event generation, and acquires related content of the database from attributes of the database event.
  • Step S308 suppressing the database event, that is, not generating a database event.
  • the browser analyzes the operation content of the database transaction and generates the attributes of the corresponding database event.
  • a database transaction may contain multiple database operations, and may even perform multiple operations on the same record, which may be combined and simplified.
  • the attribute content of the database event, and at the same time accurately correspond to changes in the database.
  • the embodiment of the present invention further includes the following sub-steps in the above step S305: Step S401, analyzing the operation content completed in the web database;
  • Step S402 determining whether the operation content includes a clear operation; if not, executing step S404 to analyze all database operations; if yes, executing step S403, and analyzing only the corresponding database for the database, table or entry that has performed the clear operation The database operation after the last cleanup operation of the database, table, or entry, and discarding the analysis of the database operation before the cleanup operation;
  • Step S405 a merge operation; wherein the record that has performed more than one operation analyzes only the last operation of the record;
  • Step S406 analyzing the merged operation one by one, if the operation type is empty, executing step S407, the key value of the corresponding change entry, the new record value, and the old record value are all set to null; if the operation type is deleted Then, in step S408, the key value corresponding to the change entry is set to the key value of the deletion record, and the old record value of the corresponding entry is set to the record value of the delete record; if the operation type is increased, step S409 is performed, corresponding to The key value of the change entry is set to the key value of the completed record, and the new record value of the corresponding entry is set to the record value of the completed record; if the operation type is update, step S410 is performed, and the key value of the corresponding change entry is set to The key value of the update record is completed, the new record value of the corresponding entry is set to the new record value of the update record, and the old record value of the corresponding entry is set to the old record value of the completed update;
  • step S406 If there is still an unparsed operation, the browser proceeds to step S406, otherwise step S411 is executed to generate an attribute of the database event, including the change item obtained above.
  • the record of the operation of the database is simplified by increasing the judgment and processing of the clear operation; and the final database operation is obtained by the merge processing of the records of the database operation, so as to accurately generate the database event attribute.
  • step S305 may further record only the change information describing the web database, where the change information includes a name of each element in the database name, the table name, and the change entry that the database has operated according to the operation request of the web application;
  • the identifier of each element in the change entry includes: an identifier corresponding to the key value, an identifier corresponding to the new record value, and an identifier corresponding to the old record value; the identifier corresponding to the old record value in FIG. 4 is oldValues, and the old record The value is the actual value of oldValues.
  • Step S307 performs the following operations:
  • the second web application is applied to the web database to perform a content operation corresponding to the attribute of the database event, and the operation may be simply obtaining the content of the attribute corresponding to the database event in the web database. Listening for database events between two applications in the same browser and monitoring between two pages of the same application. In addition to differences in transmission, the two methods are different for the objects registered in the time processing component.
  • the content can be applied in the same mode, so it will not be described here.
  • Embodiments of the invention may store instructions on a computer readable storage medium that, when executed by a computer, perform the above-described method of causing a web application to acquire database changes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Quality & Reliability (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明的一个实施方式提供了一种使Web应用获取数据库变化的系统,该系统包括浏览器、Web数据库和运行于所述的浏览器中的Web应用,其特征在于,所述的浏览器中包括:浏览器的数据库处理部件获取所述Web应用的操作请求,并根据所述操作请求完成对Web数据库的操作;浏览器的事件处理部件根据Web数据库中完成的操作生成的数据库事件,所述数据库事件被所述Web应用所监听;在监听到有数据库事件生成时,所述Web应用从所述数据库事件的属性中获取数据库的变化的内容。使得Web应用可以在数据库事件的属性中获取到数据库变化,并完成相应的处理。

Description

使 Web应用获取数据库变化的方法和系统 技术领域
本发明涉及浏览器技术, 特别是涉及使用浏览器 Web数据库的方法和系 统。
背景技术
早期的浏览器只能简单的通过 Cookie 在本地保存小段文本数据, 目前的 主流浏览器已经支持更加强大的本地存储方案, 如 Web Storage和 Web SQL Database 技术标准。 另外还有正在快速发展不断完善的浏览器数据库标准 Indexed DB , 这个标准用于在浏览器中存储大量结构化的数据, 并提供索引以 保证高效率的查询。 相比 Web SQL Database中使用 SQL语句作为字符串参 数传递给 JavaScript API, 轻量级的 NoSQL非关系型数据库 Indexed DB的语 法结构更为简单, 让开发者可以更容易的实现支持本地数据库的 Web应用。
在浏览器本地存储数据 Web应用来说非常重要, 因为互联网并不是无处 不在,也没有足够快。本地存储让开发者将一些数据保存在本地计算机以便快 速处理, 这意味着如 Web邮箱, 在线文档编辑等应用可以离线使用, 也让数 据可以緩存在本地以便将来使用, 这使得 Web应用更快更可靠, 用户体验也 更好。 对 Web应用中的大规模数据, 则有必要使用数据库来保存。 数据库中 的数据是随着业务逻辑不断发生变化的,然而目前的浏览器数据库并没有提供 相应机制使 Web应用能方便的获知这些数据变化。 Web应用只能通过不同页 面之间进行交互来获知数据的变化情况,这样实现比较低效或者造成应用各模 块耦合性较高。 发明内容
本发明提出一种使 Web应用获取数据库变化的系统和方法, 使得 Web应 用能及时有效的获取浏览器 Web数据库的数据变化。
第一方面是提供一种使 Web应用获取数据库变化的系统, 该系统包括浏 览器、 Web数据库和运行于所述的浏览器中的 Web应用, 所述的浏览器中包 括:
浏览器的数据库处理部件获取所述 Web应用的操作请求, 并根据所述操 作请求完成对 Web数据库的操作;
浏览器的事件处理部件根据 Web数据库中完成的操作生成的数据库事件, 所述数据库事件被所述 Web应用所监听; 在监听到有数据库事件生成时, 所 述 Web应用从所述数据库事件的属性中获取数据库的变化的内容。
结合第一方面的第一种可能实现方式, 所述 Web应用包含第一页面和第 二页面时, 所述系统具体为: 浏览器的数据库处理部件获取所述 Web应用的 操作请求, 并根据所述操作请求完成对 Web数据库的操作; 所述操作请求来 自所述 Web应用的第一页面; 浏览器的事件处理部件根据 Web数据库中完成 的操作生成的数据库事件, 所述数据库事件被所述 Web应用所监听; 在监听 到有数据库事件生成时, 所述 Web应用从所述数据库事件的属性中获取数据 库的变化的内容,并将第二页面中与所述数据库的变化的内容相关部分做同步 处理。
结合第一方面的第二种可能实现方式, 所述的数据库事件的属性, 具体包 括:描述所述 Web数据库的变更信息,其中,所述变更信息包括根据所述 Web 应用的操作请求在数据库已操作的数据库名、 表名和变更条目; 所述 Web应 用从所述数据库事件的属性中获取数据库的相关内容, 具体包括: 所述 Web 应用从数据库事件的属性中获取所述数据库名、 表名和变更条目, 确定 Web 数据库中的变化的内容。
结合第一种实现方式或第二种实现方式的第三种可能实现方式,所述变更 条目, 具体包括: 数据记录的操作类型、 键值、 新的记录值和旧的记录值中的 一项或多项。
结合第三种实现方式的第四种可能实现方式,变更条目至少包括以下操作 类型中的一种: 所述操作类型为清空时, 对应变更的键值、 新的记录值和旧的 记录值都为空; 所述操作类型为删除时,对应变更条目的键值为已删除记录的 键值,对应变更条目的旧的记录值为已删除记录的记录值; 所述操作类型为增 加时,对应变更条目的键值为已增加记录的键值,对应变更条目的新的记录值 为已增加记录的记录值; 所述操作类型为更新时,对应变更条目的键值为已更 新记录的键值,对应变更条目的新的记录值为已更新记录的新记录值,对应变 更条目的旧的记录值为已更新记录的旧记录值。 结合第四种可能的第五种可能, 如果所述浏览器中的 Web应用的操作请 求为存放操作,则所述根据所述操作请求完成对 Web数据库的操作,还包括: 浏览器的数据库处理部件根据该操作中的数据库名、表名和键值来检查数据库 中是否已经存在与所述数据库名、表名和键值均相同的记录,如果所述记录已 经存在, 则确定所述存放操作转换为更新条目; 如果数据库中没有存在相应记 录, 则确定所述存放操作转换为增加条目。
结合第四种实现方式的第六种可能实现方式,所述变更条目按照对应数据 库操作的时间顺序排列, 如果在一个 Web应用的操作请求中对一条记录进行 了多于一次的操作, 则所述的变更条目中对该记录只包含最后一次的操作。
结合上述任意一种实现方式的第七种可能实现方式: 所述浏览器中 Web 应用用于监听数据库事件的为: window, document, body或数据库对象其中 的一种。
本发明的第二方面是提供一种用于使 Web应用获取数据库变化的方法, 其中, 包括浏览器和 Web数据库、 第一 Web应用和第二 Web应用, 所述方法 包括:
获取第一 Web应用的操作请求, 并根据所述操作请求完成对 Web数据库 的操作; 其中第一 Web应用和第二 Web应用运行于所述浏览器中;
根据 Web数据库中完成的操作生成的数据库事件, 所述数据库事件被第 二 Web应用所监听;
在监听到有数据库事件生成时, 所述第二 Web应用从所述数据库事件的 属性中获取数据库的变化的内容。
结合第二方面的第一种可能实现方式, 所述的数据库事件的属性, 具体包 括:描述所述 Web数据库的变更信息,其中,所述变更信息包括所述第一 Web 应用的操作请求所要操作的数据库名、 表名和变更条目; 则所述第二 Web应 用从所述数据库事件的属性中获取数据库的相关内容, 具体包括: 所述第二 Web应用从数据库事件的属性中获取所述数据库名、 表名和变更条目, 确定 Web数据库中的变化的内容。
结合第一种实现方式的第二种可能实现方式, 所述变更条目, 具体包括: 数据记录的操作类型、 键值、 新的记录值和旧的记录值中的一项或多。 结合第二种实现方式的第三种可能实现方式,变更条目至少包括以下操作 类型中的一种: 所述操作类型为清空时, 对应变更的键值、 新的记录值和旧的 记录值都为空; 所述操作类型为删除时,对应变更条目的键值为已删除记录的 键值,对应变更条目的旧的记录值为已删除记录的记录值; 所述操作类型为增 加时,对应变更条目的键值为已增加记录的键值,对应变更条目的新的记录值 为已增加记录的记录值; 所述操作类型为更新时,对应变更条目的键值为已更 新记录的键值,对应变更条目的新的记录值为已更新记录的新记录值,对应变 更条目的旧的记录值为已更新记录的旧记录值。
结合第三种实现方式的第四种可能实现方式, 如果所述浏览器中的第一 Web应用的操作请求为存放操作, 则所述并根据所述操作请求完成对 Web数 据库的操作, 具体包括: 根据该操作中的数据库名、 表名和键值来检查数据库 中是否已经存在有与所述数据库名、表名和键值均相同的记录, 如果所述记录 已经存在, 则确定将所述存放操作转换为更新条目; 如果数据库中没有存在相 应记录, 则确定将所述存放操作转换为增加条目。
结合上述任意一种实现方式的的第五种可能实现方式, 第一 Web应用的 操作请求中携带数据库事件参数,以便根据所述参数确定在数据库事务成功处 理完成后是否产生数据库事件。 本发明上述各方面是通过浏览器根据 Web数据库的变化产生相应的数据 库事件, 使浏览器中的 Web应用可以监听该数据库事件, 并分配相应的事件 处理函数,从而使得 Web应用可以在数据库事件的属性中获取到数据库变化, 并进行相应的处理。 这样一个 Web应用的不同页面或不同模块之间可以更容 易的获取到数据库的变化。
附图说明
图 1是本发明实施方式的计算环境示意图;
图 2是本发明实施方式的信令流程图;
图 3是本发明实施方式的浏览器框架示意图;
图 4是本发明实施方式的数据库事件的内容;
图 5是本发明实施方式的数据库事件的另一种形式的内容;
图 6是本发明另一种实施方式的信令流程图; 图 7是本发明实施方式的产生数据库事件的步骤;
图 8是本发明实施方式的确定数据库事件属性的步骤。 具体实施方式
下面将结合本发明实施例中的附图 ,对本发明实施例中的技术方案进行清 楚、 完整地描述, 显然, 所描述的实施例是本发明的一部分实施例, 而不是全 部实施例。基于本发明中的实施例, 本领域普通技术人员在没有做出创造性劳 动的前提下所获得的所有其他实施例, 都应属于本发明保护的范围。
在说明书中详细描述的数据结构和代码通常存储在计算机可读存储介质 中, 其可以是能够存储供计算机系统的代码和 /或数据的任何设备或者介质。 这包括但不限于: 易失性存储器, 非易失性存储器, 磁性和光学存储设备, 诸 如磁盘、 磁带、 CD、 DVD, 或者能够存储计算机可读介质的目前已知或以后 开发的其他介质。
本发明中所说的计算机指基于微处理器的具有计算能力的终端设备,包括 但不限于个人电脑, 平板电脑, 便携电脑和手机等任何类型的计算机系统。
本发明的一个实施方式是提供一种获取 Web数据库变化的系统,参阅图 1 , 该系统的计算环境 100包括:浏览器 101、 Web数据库 102、 CPU处理器 106。 浏览器 101中包括:数据库处理部件 104、事件处理部件 105和 Web应用 103。 每个 Web应用可以在浏览器中打开多个页面, 如图 1中的页面八、 页面 B和 页面 C都属于同一个 Web应用, 通常这些页面的 URL地址都属于同一个域, 如 都属 于 www.huawei.com , 而 其 中 页 面 A 的 地址 可 以 为 www.huaweide vice . com/ cn/ method=index , 而 页 面 B 的 地址可 以 为 www.huaweidevice.com/cn/method=getFaqInfo=9097。 另夕卜 Web应用也可以是 浏览器扩展, 这些浏览器扩展的构成通常和 Web应用一样主要由 HTML 和 JavaScript所构成, 并可以通过浏览器创建和访问 Web数据库。每个 Web应用 可以通过浏览器创建一个或多个 Web数据库, Web数据库通常以文件形式存 放在计算环境中, 可以是本地计算机也可以在网络中的其他计算机上。 本发明 的 Web应用获取数据库变化的方案不仅适用于同一个 Web应用内部之间进行, 如上述页面 A、 页面 B之间; 还适用于不同 Web应用之间进行, 如上述浏览 器的扩展之间。 该系统的方法步骤主要包括:
S101、浏览器的数据库处理部件 104获取所述 Web应用 103的操作请求, 并根据所述操作请求完成对 Web数据库的操作;
优选的,所述操作请求由 Web应用 103根据用户在浏览器中的操作产生。 S102、 浏览器的事件处理部件 105根据 Web数据库中完成的操作生成的 数据库事件, 所述数据库事件被所述 Web应用 103所监听;
优选的, 所述数据库事件包含事件的类型, 如事件的类型为 database;
S103、 在 Web应用 103监听到有数据库事件生成时, Web应用 103从数 据库事件的属性中获取变化的内容。
图 3是基于图 1的计算环境,对应与本发明系统的浏览器结构图, 其实现 的信令流程如图 2所示。具体参阅图 3 , 浏览器 201中的 Web应用 203打开了 该应用两个不同的页面, 浏览器第一页面 A和浏览器第二页面 B , 以下简称 页面 A和页面 B,其中页面 A和页面 B也被认为是 Web应用 203的两个对象, 这两个页面应该属于同一个 i或, 例 ¾。: 同属于 i或名为 www.huawei.com的 i或。 浏览器的多个页面可以位于同一窗体中的不同标签页,也可以在同一浏览器的 不同窗体中。 其中在页面 A中 Web应用 203向浏览器的数据库处理部件 204 发送操作请求, 数据库处理部件 204根据所述操作请求对 Web数据库进行操 作;实现过程中 Web应用 203和数据库处理部件 204的通信可以通过 JavaScript API实现。
浏览器的事件处理部件 205根据 Web数据库中对应所述操作请求完成的 操作生成数据库事件, 所述数据库事件被 Web应用 203所监听。
其中, 所述数据库事件被 Web应用 203所监听, 具体表现为针对另外一 个页面 B, Web应用 203为页面 B分配数据库事件监听对象 202和数据库事 件处理函数 206, 所述数据库事件监听对象具体可以是 window, document, body或数据库对象中的任意一种; 数据库事件监听对象 202监听所述数据库 事件方法具体为:在浏览器的事件处理部件 205上注册监听浏览器的数据库事 件的信息, 则事件处理部件 205在生成数据库事件后, 能够根据数据库事件监 听对象 202的注册信息, 将所述数据库事件发送给数据库事件监听对象 202。
所述 Web应用 203从所述数据库事件的属性中获取数据库的变化的内容; 具体表现为:优选的可以是数据库事件监听对象 202接收到来自事件处理部件 205的数据库事件后, 将所述数据库事件转发给数据库事件处理函数 206; 在 有较多操作步骤, 并需要记录所述步骤的环境时, 可选的通过事件处理部件 205 记录各步骤的数据, 并携带在数据库事件中传递给数据库事件监听对象 202。
可选的还可以是数据库事件监听对象 202接收到来自事件处理部件 205 的数据库事件后,数据库事件处理函数 206根据该数据库事件的属性,通过数 据库处理部件 204到 Web数据库中获取数据库事件属性所描述的 Web数据库 中的内容; 其中数据库事件的属性包括描述所述 Web数据库的变更信息, 所 述变更信息包括根据所述 Web应用的操作请求在数据库已操作的数据库名、 表名和变更条目里各元素的标识。其中变更条目里各元素的标识包括: 键值对 应的标识、新的记录值对应的标识和旧的记录值对应的标识; 其中新的记录值 对应的标识根据实际的对 Web数据库中存储内容的划分可以有一个或者多个。 该可选的方式适用只需要获取最后结果, 且该结果占用较多资源情况。
实现过程中数据库处理部件 204和数据库事件处理函数 206之间的通信, 数据库事件监听对象 202 和事件处理部件 205 之间的通信都可以通过 JavaScript API实现。
事件处理部件 205在数据库操作完成后产生数据库事件, 页面 B通过数 据库事件处理函数 206中获取数据库事件的属性,然后根据属性中的数据库变 化的内容进行相应处理。 实际运用中, 页面 A也可以拥有页面 B中具有相同 功能的数据库事件监听对象 202, (未在图 3中标出)和数据库事件处理函数 206, (未在图 3中标出), 从而通过对浏览器的事件处理部件 205中产生的数据库事 件的监听, 实现页面 A对页面 B中数据库操作的监听, 最终达到页面 A和页 面 B相互监听的目的。
浏览器可以根据页面 B和页面 A是否在一个浏览器中, 对于数据库事件 属性的处理的时机做不同的设置,, 具体的实现方式可以表现为:
1 )当页面 A和页面 B在同一个浏览器中以不同页面标签替换显示时(即 同一时间只能显示页面 A和页面 B中的一个页面), 可以设置浏览器, 使得数 据库事件处理函数 206在由页面 A切换到页面 B时才进行数据库事件属性的 处理, 此时在最大程度上减少数据库事件属性的处理的频率基础上,正常实现 页面 B中呈现出的监听结果的目的;
2 )当页面 A和页面 B在同一个浏览器的不同窗体中显示时, 可以设置浏 览器,使得数据库事件处理函数 206在获取到数据库事件的属性后就进行对所 述数据库事件的属性的处理,即在页面 B中更新与页面 A同属于一个数据库, 并且在同一张表中的各变更条目所对应的内容, 使得页面 B和页面 A中相同 属性的内容能够同步变化和更新; 这是为了保证在页面 A和页面 B并列显示 时, 能够实页面 B的应用现监听到的内容的实时更新。
上述用户在浏览器中的操作 (浏览器产生 Web应用操作请求)过程又可 以区分为: 1 )在页面 A中输入完各参数, 并需要点击页面 A中确认按钮才会 完成页面 A中数据的操作时, 此时就以点击所述确认按钮作为发起 Web应用 的操作请求的触发点; 2 )在页面 A中某一栏(所述某一栏可以对应变更条目 中的某一项) 中输入完参数, 并在转移鼠标焦点到其他栏时, 触发发送 Web 应用的操作请求。 具体的实现方式, 不局限于上述举出的 2种, 还可以是其他 有关浏览器中的操作来触发发送 Web应用的操作请求。
具体实施方式中, 数据库事件的产生优选的可以釆用: 1 )记录用户在页 面 A中对应某一变更条目的所有 Web应用操作, 然后触发产生数据库事件, 其中触发方式可以是上述两种方式中的任——种; 产生数据库事件的过程中, 将上述记录的对应某一变更条目的所有 Web应用操作内容都包含在所述数据 库事件的属性中, 以便页面 B中的数据库事件监听对象 202从所述数据库事 件的属性中获取到对应该变更条目的所有 Web应用操作的操作内容。 或者,
2 )仅记录用户在页面 A 中最后的操作结果, 即完成对数据库的操作后, 在数据库中保存的结果。 这样可以直接在生成数据库事件时,携带该数据库中 保留的完成 Web应用操作请求后的结果。
Web应用的操作请求中包含了用于生成数据库事件的参数,浏览器可以根 据所述参数确定在 Web应用的操作请求完成后是否产生数据库事件。 具体实 现过程中,还可以是在数据库处理部件 204中设置用于生成数据库事件的参数, 而不用在 Web应用的操作请求中携带所述参数, 从而实现对某些页面或者页 面中的某些对象的操作可选的生成数据库事件。 举例说明, 执行 Web应用的操作请求时可以指定 "suppressevent" 参数, 在使用该事件参数时, 则不产生数据库事件。 此参数也可以用来防止死循环, 能够在事件处理函数中对数据库进行操作时,指定不产生事件。 比如监听数据 库事件的处理函数中, 在监听到某个记录更新 (update ) 时, 再进行一次数据 库 update操作, 这时可能引起死循环。 此参数也可以避免产生一些不必要的 数据库事件, 比如某些无需监控的数据库操作, 以达到节约系统资源。
另外一种方式, 缺省的事务也可以不产生事件, 只有指定了 "firedatabaseevent" 参数时, 才产生数据库事件。 这样有利于节约系统资源, 以及更好的兼容性。 有很多 Web应用是没有必要监控数据库事件的, 因此缺 省不产生事件是更佳方案。
数据库事件的属性中包括描述数据库变化的变更信息,变更信息包括所述
Web应用的操作请求引起发生变化的数据库名、表名和变更条目, 变更条目信 息由所述浏览器中的 Web应用在数据库事件处理函数中从事件的属性中获取, 根据所述的变更信息 Web应用获取到数据库的变化。
图 4 示出了本发明实施方式的数据库事件的内容, 包含一些只读属性
( readonly attribute ) 的字符串 ( DOMString ) 或字符串数组 ( 歹' J表 DOMStringList )。变更条目的每一项包括数据记录的操作类型( operationType ), 以及可选的键值( key )、 旧的记录值( oldValue )和新的记录值( newValue ), 这些属性可以用数组形式存放数据, 如属性键值 keys 为字符串数组 ( DOMStringList )。 变更条目至少包括以下操作类型中的一种:
在操作类型为清空时,对应变更的键值、新的记录值和旧的记录值都为空; 在操作类型为删除时,对应变更条目的键值为已删除记录的键值,对应变更条 目的旧的记录值为已删除记录的记录值; 在操作类型为增加时,对应变更条目 的键值为已增加记录的键值,对应变更条目的新的记录值为已增加记录的记录 值; 在操作类型为更新时, 对应变更条目的键值为已更新记录的键值, 对应变 更条目的新的记录值为已更新记录的新记录值,对应变更条目的旧的记录值为 已更新记录的旧记录值。
图 5 示出了本发明实施方式的另一种等价方式所描述的浏览器数据库事 件的内容, 可以运用于图 1和图 3所述的系统。数据库事件对象中可以包含数 据变化列表 DatabaseChangeList对象, 该列表对象中具体包含详细的数据记录 的变更条目。 本实施例中将一个或者多个 Web应用的操作请求的集合称为数 据库事务。
如果浏览器中的 Web应用的数据库操作请求中包括存放(Put )操作, 浏 览器的数据库处理部件根据该操作中的数据库名、表名和键值来检查数据库中 是否已经存在有与所述数据库名、 表名和键值均相同的记录, 如果已经存在, 则确定将该操作对应所述变更条目的操作类型转换为更新条目,则浏览器的事 件处理部件 205生成相应的数据库事件的属性中,相应的键值为已更新记录的 键值,对应条目的新的记录值为已更新记录的新记录值,对应条目的旧的记录 值为已更新记录的旧记录值。;
如果数据库中没有存在有与所述数据库名、表名和键值均相同的记录, 则 确定将该操作对应所述变更条目的操作类型转换为增加条目,则浏览器的事件 处理部件 205生成相应的数据库事件的属性中,相应的键值为完成增加记录的 键值, 对应条目的新的记录值为完成增加记录的记录值。
在提供电子表格的 Web应用中, 经常会对同一条记录进行多次操作, 然 后在用户保存或自动保存时才提交数据。比如对一条记录修改了某个字段的值, 然后又将此记录删除了,则在用户保存提交数据时对应的数据库事务中则包含 修改和删除两个操作。
数据库事件属性中的变更条目按照对应数据库操作的时间顺序排列;如果 数据库事务中的最后一次操作是清空操作, 即删除表的全部记录, 则对应的键 值、新的记录值和旧的记录值都为空即可, 因此这种情况下如果将全部记录的 键值和旧的记录值都包含在事件中并不合适,数据量可能会比较大, 而且一般 也没有必要, 因此可以仅记录清空操作之后的相关操作。 比如在电子商务 Web 应用中的购物篮模块中在添加商品时,同时提供先清空购物篮中已有物品的选 项, 则这样对应的数据库事务中包含先进行购物篮的表数据的清空操作, 然后 再增加新的物品记录。 另外一种情况是用户修改了购物篮中物品的数量,但是 并没有马上提交, 然后又进行了购物篮的清空操作, 并提交, 这样对应的数据 库事务中仅包含清空操作。
除上述将数据库事件属性中的变更条目按照对应数据库操作的时间顺序 排列外, 还有一种方式就是一个 Web应用的操作请求中对一条记录进行多于 一次的操作, 而变更条目中对该记录只包含最后一次的操作, 如: 在选择某件 产品购买数量时, 可能会对所要求的数量进行多次选择, 则对应所述某件产品 的变更条目只会保存最后选定的数量; 在 Web页面里的某个编辑框里进行了 几次的输入以及修改,则对应所述某个编辑框的变更条目只会保存最后修改完 的内容。 注意, 操作对应的事件属性中旧的记录值(oldValue )是数据库事务 执行之前的记录值, 而不是某个数据库操作执行前的记录值, 因为一个数据库 事务中可能有多个数据库操作,所述数据库事务执行之前的记录值即该数据库 事务中第一个数据库操作之前的记录值。如: 在一个数据库事务对某条记录进 行了两次(update ) 更新操作, 在产生数据库事件属性时对操作进行了合并处 理, 即上述的变更条目中对该记录只包含最后一次的操作,如果使用最后一次 更新操作之前的记录值作为合并后的操作对应的变更条目中的旧的记录值 ( oldValue ), 显然是不准确的。
以电子商务 Web应用为例,浏览器在一个页面中显示购物篮(或购物车) 中已经选取的物品清单, 又打开了本网站的另一个显示具体商品的网页, 然后 点击了添加到购物篮。 这样, 最佳方案是在购物篮页面自动刷新物品清单, 显 示用户新添加的购物篮。 釆用本发明的实施方式可以如下实现:
购物篮的内容记录存储在本地的 Web数据库中, 商品显示页面(对应图 3 中的页面 A )将物品增加到购物篮时, 即 Web应用进行数据库 add操作时, 产生数据库事件 ( database )。
在购物篮页面(对应图 3中的页面 B )监听数据库事件(database ), 然后 在事件处理函数中更新购物篮中的物品清单。 Web应用可以直接从 database 事件中获取到所增加数据条目的新内容值, 因此无需访问数据库, 直接就可以 在购物篮物品清单中增加新的商品信息, 保持页面 A与页面 B的同步。
对于浏览器来说, 其组成元素不仅仅局限于一个 Web应用的不同页面, 可能还会涉及到 Web应用之间数据的变化的获知, 如: 两个相同的 Web应用 之间的数据的变化的获知或者两个不同的 Web应用之间的数据的变化的获知; 这里 Web应用可以是浏览器的某一个插件, 也可以是浏览器生成页面的某个 对象,还可以是浏览器自身的组成部分。图 6是实现第二 Web应用对第一 Web 应用中变化的数据的获取的信令示意图, 其过程包括:
5201、 获取第一 Web应用的操作请求, 并根据所述操作请求完成对 Web 数据库的操作; 其中第一 Web应用和第二 Web应用运行于所述浏览器中;
5202、 根据 Web数据库中完成的操作生成的数据库事件, 所述数据库事 件被第二 Web应用所监听;
5203、 在监听到有数据库事件生成时, 所述第二 Web应用从所述数据库 事件的属性中获取数据库的变化的内容。
通过本实施例, 实现了第二 Web应用对于第一 Web应用操作请求完成后 所产生的数据库时间的监听,减少了各第一 Web应用和第二 Web应用的耦合, 提高了数据操作的独立性。如图 7所示,描述了本发明实施方式的一个浏览器 产生数据库事件的详细处理步骤, 它是图 6所示的方法的具体应用; 本实施例 中将一个或者多个 Web应用的操作请求的集合称为数据库事务。
步骤 S301 , 浏览器获取第一 Web应用的操作请求, 并根据所述操作请求 生成 Web数据库的事务, 完成 Web数据库事务中对 Web数据库的各个操作; 步骤 S302, 判断对 Web数据库的事务是否成功完成, 如果失败则执行步 骤 S309, 进行 Web数据库的事务的回滚; 如果成功, 则执行步骤 S303 ;
步骤 S303 , 分析数据库事务中的数据库事件参数;
步骤 S304 , 判断是否需要生成数据库事件, 如果是则执行步骤 S305 , 否 则执行步骤 S308;
步骤 S305 , 根据 Web数据库中完成的操作生成的数据库事件的属性; 步骤 S306, 生成数据库事件;
步骤 S307 , 第二 Web应用监听到所述数据库事件生成, 则从所述数据库 事件的属性中获取数据库的相关内容。
步骤 S308, 压制数据库事件, 即不产生数据库事件。
浏览器对数据库事务中的操作内容进行分析,生成相应数据库事件的属性, 一个数据库事务中可能包含了多种数据库操作,甚至可以对同一条记录进行了 多次操作, 可以进行合并处理, 简化产生的数据库事件的属性内容, 同时又准 确对应数据库的变化。 如图 8所示, 本发明的实施方式在上述步骤 S305中又 包含以下子步骤: 步骤 S401 , 分析 Web数据库中完成的操作内容;
步骤 S402 , 判断所述操作内容是否包含清除操作; 如果不包含则执行步 骤 S404, 分析全部数据库操作; 如果包含, 则执行步骤 S403 , 对于执行过清 除操作的数据库、 表或者条目, 只分析对应所述数据库、 表或者条目最后一次 清除操作之后的数据库操作, 而舍弃清除操作之前的数据库操作的分析;
步骤 S405 , 合并操作; 其中对进行了多于一次操作的记录只分析该记录 最后一次的操作;
步骤 S406 , 对合并后的操作逐一分析, 如果操作类型是清空时, 则执行 步骤 S407 , 对应变更条目的键值、 新的记录值和旧的记录值都置为空; 如果 操作类型为删除时, 则执行步骤 S408 , 对应变更条目的键值置为完成删除记 录的键值,对应条目的旧的记录值置为完成删除记录的记录值; 如果操作类型 为增加时,则执行步骤 S409,对应变更条目的键值置为完成增加记录的键值, 对应条目的新的记录值置为完成增加记录的记录值; 如果操作类型为更新时, 则执行步骤 S410 , 对应变更条目的键值置为完成更新记录的键值, 对应条目 的新的记录值置为完成更新记录的新记录值,对应条目的旧的记录值置为完成 更新己录的旧 己录值;
如果还有未分析的操作,则浏览器继续执行步骤 S406 ,否则执行步骤 S411 , 生成数据库事件的属性, 包含以上得出的变更条目。
本实施例通过增加清除操作的判断和处理, 精简了数据库的操作的记录; 并通过数据库操作的记录的合并处理,得到了最后的数据库操作, 以便准确的 生成数据库事件属性。
优选的, 步骤 S305还可是仅记录描述所述 Web数据库的变更信息, 所述 变更信息包括根据所述 Web应用的操作请求在数据库已操作的数据库名、 表 名和变更条目里各元素的名称; 其中变更条目里各元素的标识包括: 键值对应 的标识、新的记录值对应的标识和旧的记录值对应的标识; 如图 4中的旧的记 录值对应的标识为 oldValues,而旧的记录值为 oldValues实际的值。则步骤 S307 执行以下操作: 第二 Web应用到 Web数据库中进行对应与数据库事件的属性 的内容操作, 所述操作可以是简单的获取 Web数据库中对应所述数据库事件 的属性的内容。 对于同一浏览器中两个应用之间的数据库事件的监听与同一应用的两个 页面间完成监听, 两种方式除传输上有所差异外, 具体为在时间处理部件中注 册的对象不同, 其他内容都可以按照同一模式套用, 因此, 这里不再赘述。
本发明的实施方式可以在计算机可读存储介质存储有指令,当该指令由计 算机执行时, 计算机执行上述使 Web应用获取数据库变化的方法。
以上所述仅为本发明的实施方式, 并非因此限制本发明的专利范围, 凡是 利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接 运用在其他相关的技术领域, 均同理包括在本发明的专利保护范围内。

Claims

权 利 要 求
1、 一种使 Web应用获取数据库变化的系统, 该系统包括浏览器、 Web数据库 和运行于所述的浏览器中的 Web应用, 其特征在于, 所述的浏览器中包括: 浏览器的数据库处理部件获取所述 Web应用的操作请求, 并根据所述操 作请求完成对 Web数据库的操作;
浏览器的事件处理部件根据 Web数据库中完成的操作生成的数据库事件, 所述数据库事件被所述 Web应用所监听; 在监听到有数据库事件生成时, 所 述 Web应用从所述数据库事件的属性中获取数据库的变化的内容。
2、 根据权利要求 1所述的系统, 其特征在于, 所述 Web应用包含第一页面和 第二页面时, 所述系统具体为:
浏览器的数据库处理部件获取所述 Web应用的操作请求, 并根据所述操 作请求完成对 Web数据库的操作; 所述操作请求来自所述 Web应用的第一页 面;
浏览器的事件处理部件根据 Web数据库中完成的操作生成的数据库事件, 所述数据库事件被所述 Web应用所监听; 在监听到有数据库事件生成时, 所 述 Web应用从所述数据库事件的属性中获取数据库的变化的内容, 并将第二 页面中与所述数据库的变化的内容相关部分做同步处理。
3、根据权利要求 1 或 2所述的系统,其特征在于,所述的数据库事件的属性, 具体包括:
描述所述 Web数据库的变更信息,其中,所述变更信息包括根据所述 Web 应用的操作请求在数据库已操作的数据库名、 表名和变更条目;
所述 Web应用从所述数据库事件的属性中获取数据库的相关内容, 具体 包括:
所述 Web应用从数据库事件的属性中获取所述数据库名、 表名和变更条 目, 确定 Web数据库中的变化的内容。
4、 根据权利要求 3所述的系统, 其特征在于, 所述变更条目, 具体包括: 数据记录的操作类型、 键值、 新的记录值和旧的记录值中的一项或多项。
5、 根据权利要求 4所述的系统, 其特征在于, 变更条目至少包括以下操作类 型中的一种: 所述操作类型为清空时,对应变更条目的键值、新的记录值和旧的记录值 都为空;
所述操作类型为删除时,对应变更条目的键值为已删除记录的键值,对应 变更条目的旧的记录值为已删除记录的记录值;
所述操作类型为增加时,对应变更条目的键值为已增加记录的键值,对应 变更条目的新的记录值为已增加记录的记录值;
所述操作类型为更新时,对应变更条目的键值为已更新记录的键值,对应变更 条目的新的记录值为已更新记录的新记录值,对应变更条目的旧的记录值为已 更新己录的旧 己录值。
6、 根据权利要求 5所述的系统, 其特征在于, 如果所述浏览器中的 Web应用 的操作请求为存放操作,则所述根据所述操作请求完成对 Web数据库的操作, 还包括:
浏览器的数据库处理部件根据该操作中的数据库名、表名和键值来检查数 据库中是否已经存在与所述数据库名、表名和键值均相同的记录,如果所述记 录已经存在, 则确定所述存放操作转换为更新条目; 如果数据库中没有存在相 应记录, 则确定所述存放操作转换为增加条目。
7、 根据权利要求 5所述的系统, 其特征在于, 所述变更条目按照对应数据库 操作的时间顺序排列,
如果在一个 Web应用的操作请求中对一条记录进行了多于一次的操作, 则所述的变更条目中对该记录只包含最后一次的操作。
8、 根据权利要求 1-7任一所述的系统, 其特征在于:
所述浏览器中 Web应用用于监听数据库事件的为: window, document, body或数据库对象其中的一种。
9、 一种用于使 Web应用获取数据库变化的方法, 其中, 该方法运用于包括浏 览器、 Web数据库、第一 Web应用和第二 Web应用的环境中,所述方法包括: 获取第一 Web应用的操作请求, 并根据所述操作请求完成对 Web数据库 的操作; 其中第一 Web应用和第二 Web应用运行于所述浏览器中;
根据 Web数据库中完成的操作生成的数据库事件, 所述数据库事件被第 二 Web应用所监听; 在监听到有数据库事件生成时, 所述第二 Web应用从所述数据库事件的 属性中获取数据库的变化的内容。
10、 根据权利要求 9所述的方法, 其特征在于, 所述的数据库事件的属性, 具 体包括:
描述所述 Web数据库的变更信息,其中,所述变更信息包括所述第一 Web 应用的操作请求所要操作的数据库名、 表名和变更条目;
则所述第二 Web应用从所述数据库事件的属性中获取数据库的相关内容, 具体包括:
所述第二 Web应用从数据库事件的属性中获取所述数据库名、 表名和变 更条目, 确定 Web数据库中的变化的内容。
11、 根据权利要求 10所述的方法, 其特征在于, 所述变更条目, 具体包括: 数据记录的操作类型、 键值、 新的记录值和旧的记录值中的一项或多。
12、 根据权利要求 11所述的方法, 其特征在于, 变更条目至少包括以下操作 类型中的一种:
所述操作类型为清空时,对应变更的键值、新的记录值和旧的记录值都为 空;
所述操作类型为删除时,对应变更条目的键值为已删除记录的键值,对应 变更条目的旧的记录值为已删除记录的记录值;
所述操作类型为增加时,对应变更条目的键值为已增加记录的键值,对应 变更条目的新的记录值为已增加记录的记录值;
所述操作类型为更新时,对应变更条目的键值为已更新记录的键值,对应 变更条目的新的记录值为已更新记录的新记录值,对应变更条目的旧的记录值 为已更新记录的旧记录值。
13、根据权利要求 12所述的方法,其特征在于,如果所述浏览器中的第一 Web 应用的操作请求为存放操作, 则所述并根据所述操作请求完成对 Web数据库 的操作, 具体包括:
根据该操作中的数据库名、表名和键值来检查数据库中是否已经存在有与 所述数据库名、 表名和键值均相同的记录, 如果所述记录已经存在, 则确定将 所述存放操作转换为更新条目; 如果数据库中没有存在相应记录, 则确定将所 述存放操作转换为增加条目。
14、 根据权利要求 9-13所述的方法, 其特征在于, 还包括:
第一 Web应用的操作请求中携带数据库事件参数, 以便根据所述参数确 定在数据库事务成功处理完成后是否产生数据库事件。
PCT/CN2012/082628 2012-10-09 2012-10-09 使Web应用获取数据库变化的方法和系统 WO2014056145A1 (zh)

Priority Applications (5)

Application Number Priority Date Filing Date Title
CN201280001498.2A CN103858121B (zh) 2012-10-09 2012-10-09 使Web应用获取数据库变化的方法和系统
JP2015535946A JP6085897B2 (ja) 2012-10-09 2012-10-09 ウェブアプリケーションにデータベースの変更内容を取得させるための方法及びシステム
PCT/CN2012/082628 WO2014056145A1 (zh) 2012-10-09 2012-10-09 使Web应用获取数据库变化的方法和系统
EP12886190.3A EP2897056A4 (en) 2012-10-09 2012-10-09 METHOD AND SYSTEM FOR MANUFACTURING A WEB APPLICATION FOR DATA BANK CHANGES
US14/682,455 US20150213077A1 (en) 2012-10-09 2015-04-09 Method and system for causing a web application to obtain a database change

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2012/082628 WO2014056145A1 (zh) 2012-10-09 2012-10-09 使Web应用获取数据库变化的方法和系统

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/682,455 Continuation US20150213077A1 (en) 2012-10-09 2015-04-09 Method and system for causing a web application to obtain a database change

Publications (1)

Publication Number Publication Date
WO2014056145A1 true WO2014056145A1 (zh) 2014-04-17

Family

ID=50476860

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/082628 WO2014056145A1 (zh) 2012-10-09 2012-10-09 使Web应用获取数据库变化的方法和系统

Country Status (5)

Country Link
US (1) US20150213077A1 (zh)
EP (1) EP2897056A4 (zh)
JP (1) JP6085897B2 (zh)
CN (1) CN103858121B (zh)
WO (1) WO2014056145A1 (zh)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107122354B (zh) 2016-02-24 2020-05-08 华为技术有限公司 事务执行方法、装置及系统
CN106850307B (zh) * 2017-02-21 2020-07-07 青岛海信移动通信技术股份有限公司 一种属性信息处理方法及装置
CN110018867A (zh) * 2018-11-12 2019-07-16 阿里巴巴集团控股有限公司 用于页面交互的方法和装置
CN111367932B (zh) * 2020-03-06 2023-05-12 深圳市今天国际物流技术股份有限公司 数据库表单变更通知方法、装置、计算机设备及存储介质
US20220092148A1 (en) * 2020-09-21 2022-03-24 Content Directions, Inc. dba Linkstorm Methods and systems for cross-domain two-way communication by dynamic web content
CN112632159B (zh) * 2020-12-01 2021-09-28 腾讯科技(深圳)有限公司 数据库访问控制方法及装置、电子设备、存储介质
CN112685487B (zh) * 2021-01-15 2022-09-16 金现代信息产业股份有限公司 在浏览器环境下通过IndexedDB模拟关系型数据库的方法和装置
CN115061612B (zh) * 2022-04-25 2024-05-03 杭州每刻科技有限公司 一种明细组件在全屏状态下的展示方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008106383A1 (en) * 2007-02-27 2008-09-04 Microsoft Corporation Persistent spatial collaboration
US20090037492A1 (en) * 2007-07-31 2009-02-05 Ahmad Baitalmal Framework for Synchronizing Applications
US20090299952A1 (en) * 2008-05-27 2009-12-03 Zheng Jerry Systems and methods for automatic quality assurance of workflow reports
US20110055329A1 (en) * 2009-08-31 2011-03-03 International Business Machines Corporation Dynamic data sharing in a collaborative environment
US20120102093A1 (en) * 2010-10-25 2012-04-26 Microsoft Corporation Synchronization of form fields in a client-server environment

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5712971A (en) * 1995-12-11 1998-01-27 Ab Initio Software Corporation Methods and systems for reconstructing the state of a computation
US5933826A (en) * 1997-03-21 1999-08-03 Novell, Inc. Method and apparatus for securing and storing executable content
US6631512B1 (en) * 1999-01-15 2003-10-07 Gillis E Onyeabor Method and system for database-driven, scalable web page development, deployment-download, and execution
US7149738B2 (en) * 2002-12-16 2006-12-12 International Business Machines Corporation Resource and data administration technologies for IT non-experts
JP4451188B2 (ja) * 2004-04-05 2010-04-14 株式会社日立製作所 情報処理システム、及び情報処理システムの制御方法
US20070022120A1 (en) * 2005-07-25 2007-01-25 Microsoft Corporation Caching and modifying portions of a multi-dimensional database on a user device
US8725719B2 (en) * 2007-02-13 2014-05-13 Microsoft Corporation Managing web page links using structured data
CN101902411A (zh) * 2009-06-01 2010-12-01 高维海 即时网站系统以及网站与即时通讯平台结合的方法
CN101694660B (zh) * 2009-06-01 2016-03-30 高维海 即时网站系统以及网站与即时通讯平台结合的方法
CN102023847A (zh) * 2009-09-10 2011-04-20 北京盖特佳信息安全技术股份有限公司 一种基于ie浏览器的推方式多系统同步数据录入的实现方法
CN102713959A (zh) * 2009-11-09 2012-10-03 双重验证有限公司 实时在线广告的验证系统与方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008106383A1 (en) * 2007-02-27 2008-09-04 Microsoft Corporation Persistent spatial collaboration
US20090037492A1 (en) * 2007-07-31 2009-02-05 Ahmad Baitalmal Framework for Synchronizing Applications
US20090299952A1 (en) * 2008-05-27 2009-12-03 Zheng Jerry Systems and methods for automatic quality assurance of workflow reports
US20110055329A1 (en) * 2009-08-31 2011-03-03 International Business Machines Corporation Dynamic data sharing in a collaborative environment
US20120102093A1 (en) * 2010-10-25 2012-04-26 Microsoft Corporation Synchronization of form fields in a client-server environment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2897056A4 *

Also Published As

Publication number Publication date
CN103858121B (zh) 2017-07-21
EP2897056A4 (en) 2015-09-16
EP2897056A1 (en) 2015-07-22
US20150213077A1 (en) 2015-07-30
JP6085897B2 (ja) 2017-03-01
CN103858121A (zh) 2014-06-11
JP2015534692A (ja) 2015-12-03

Similar Documents

Publication Publication Date Title
US11941017B2 (en) Event driven extract, transform, load (ETL) processing
WO2014056145A1 (zh) 使Web应用获取数据库变化的方法和系统
US9116906B2 (en) Centralized read access logging
US8224804B2 (en) Indexing of partitioned external data sources
EP2874077B1 (en) Stateless database cache
WO2017071189A1 (zh) 网页的访问方法、装置、设备及非易失性计算机存储介质
US9235636B2 (en) Presenting data in response to an incomplete query
US20130007205A1 (en) Intelligent offline caching of non-navigated content based on usage metrics
US11151098B2 (en) Enabling multi-tenant access to respective isolated data sets organized using different application schemas
US9854052B2 (en) Business object attachments and expiring URLs
US11294973B2 (en) Codeless information service for abstract retrieval of disparate data
JP2010519625A (ja) ライブエンティティインターネットストアサービス
JP2005259138A (ja) 非統合ツールの統合アーキテクチャ
WO2017124692A1 (zh) 查找表单页面和目标页面转化关系的方法和装置
US10956278B2 (en) Intelligent captain selection for disaster recovery of search head cluster
US10042956B2 (en) Facilitating application processes defined using application objects to operate based on structured and unstructured data stores
US20240073222A1 (en) Techniques for managing projects and monitoring network-based assets
US20140006000A1 (en) Built-in response time analytics for business applications
US10289617B2 (en) Accessing on-premise and off-premise datastores that are organized using different application schemas
US20220156245A1 (en) System and method for managing custom fields
US11341320B1 (en) Custom report builder
US11556316B2 (en) Distributed extensible dynamic graph
WO2017181619A1 (zh) 页面响应方法及装置
US9679010B2 (en) Methods, systems, and apparatus for search of electronic information attachments
US11249828B1 (en) Simulation service providing a generic API endpoint

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12886190

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2015535946

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2012886190

Country of ref document: EP