Documentation

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
jvx:reference [2020/06/15 08:50]
cduncan [DataBook]
jvx:reference [2020/06/15 09:58]
cduncan [Master/Detail]
Line 584: Line 584:
 This example demonstrates how a simple launcher is implemented and why it is necessary to have a launcher in the first place. Compared with the “[[#​jvx|JVx]] are of course a lot more complex than these examples, that is because they implement all the required functionality and also take care of a lot of boiler plate operations. It is taking care of all technology specific code and allows to keep your application free from knowing about the platform it runs on. This example demonstrates how a simple launcher is implemented and why it is necessary to have a launcher in the first place. Compared with the “[[#​jvx|JVx]] are of course a lot more complex than these examples, that is because they implement all the required functionality and also take care of a lot of boiler plate operations. It is taking care of all technology specific code and allows to keep your application free from knowing about the platform it runs on.
  
-====== ​DataBooks ​======+====== ​Databooks ​======
  
-Let’s talk about DataBooks, which allow access to data without any effort.+Let’s talk about databooks, which allow access to data without any effort.
  
 ===== What is it? ===== ===== What is it? =====
  
-DataBooks ​are an active model, which allow you to directly query and manipulate the data. Contrary to many other systems, [[https://​sourceforge.net/​projects/​jvx/​|JVx]] does not map the data into objects, but allows you to directly access it in a table-like fashion exposing columns, rows, and values.+Databooks ​are an active model that allow you to directly query and manipulate the data. Contrary to many other systems, [[https://​sourceforge.net/​projects/​jvx/​|JVx]] does not map the data into objects, but allows you to directly access it in a table-like fashion exposing columns, rows, and values.
  
 One could say that it is like a three dimensional array with these dimensions: One could say that it is like a three dimensional array with these dimensions:
Line 606: Line 606:
 The row definition defines what columns are available in the row and stores some additional information about them, like the names of the [[https://​en.wikipedia.org/​wiki/​Unique_key|primary key]] columns. You can think of the row definition as the headers of a table. The row definition defines what columns are available in the row and stores some additional information about them, like the names of the [[https://​en.wikipedia.org/​wiki/​Unique_key|primary key]] columns. You can think of the row definition as the headers of a table.
  
-Its creation and usage is rather simple, and, if you’re working with RemoteDataBooks there is no need to create one at all, as it is automatically created when the data book is opened. A row definition holds and manages column definitions,​ which define the columns.+Its creation and usage is rather simple, and, if you’re working with RemoteDataBooks there is no need to create one at all, as it is automatically created when the databook ​is opened. A row definition holds and manages column definitions,​ which define the columns.
  
 <code java> <code java>
Line 624: Line 624:
 columnDefinition.setNullable(false);​ columnDefinition.setNullable(false);​
 </​code>​ </​code>​
-==== MetaData ​====+==== Meta Data ====
  
 Most of the column definition is additional information about the column, like if it is nullable, the label of the column, default values, allowed values, and similar information. Most of the column definition is additional information about the column, like if it is nullable, the label of the column, default values, allowed values, and similar information.
Line 657: Line 657:
 The data page is basically a list of data rows. It also holds its own row definition, which is shared with all the contained data rows. The data page is basically a list of data rows. It also holds its own row definition, which is shared with all the contained data rows.
  
-The main usage of data pages is to allow paging in a master/​detail relationship. If the master selects a different row, the detail ​data book selects the related data page.+The main usage of data pages is to allow paging in a master/​detail relationship. If the master selects a different row, the detail ​databook ​selects the related data page.
  
-===== Data Book =====+===== Databook ​=====
  
-The data book is the main model of [[https://​sourceforge.net/​projects/​jvx/​|JVx]],​ it provides direct access to its current data page and data row by extending from IDataRow and IDataPage.+The databook ​is the main model of [[https://​sourceforge.net/​projects/​jvx/​|JVx]],​ it provides direct access to its current data page and data row by extending from IDataRow and IDataPage.
  
-By default, the data book holds one data page and only has multiple data pages if it is the detail in a master/​detail relationship.+By default, the databook ​holds one data page and only has multiple data pages if it is the detail in a master/​detail relationship.
  
 ===== Usage Example ===== ===== Usage Example =====
  
-Here is a simple example of a ''​%%MemDataBook%%'',​ an ''​%%IDataBook%%''​ implementation ​which only operates in memory:+Here is a simple example of a ''​%%MemDataBook%%'',​ an ''​%%IDataBook%%''​ implementation ​that only operates in memory:
  
 <code java> <code java>
Line 706: Line 706:
 ==== Accessing the Data With Strings ==== ==== Accessing the Data With Strings ====
  
-One of the major advantages of the data book concept is that there is no need to create new classes to represent each table, view, or query result. One can always use the data book directly and easily, and model changes don’t necessitate changes on the client side. The downside to this approach is that we lose compile time checks because we access the data dynamically. However, this can be mitigated by using [[https://​marketplace.eclipse.org/​content/​eplug-jvx|EPlug,​ an Eclipse plugin]] which provides compile time checks and many more features.+One of the major advantages of the databook ​concept is that there is no need to create new classes to represent each table, view, or query result. One can always use the databook ​directly and easily, and model changes don’t necessitate changes on the client side. The downside to this approach is that we lose compile time checks because we access the data dynamically. However, this can be mitigated by using [[https://​marketplace.eclipse.org/​content/​eplug-jvx|EPlug,​ an Eclipse plugin]] which provides compile time checks and many more features.
  
 ==== No Primitives, Objects Only ==== ==== No Primitives, Objects Only ====
Line 716: Line 716:
   * Binary Data   * Binary Data
  
-Text and binary data are both objects (arrays of primitives are objects after all) and numbers are either primitives or objects. Most of the time, if we deal with numbers inside a database, we want them to be of arbitrary precision, which means we must represent them as ''​%%BigDecimal%%''​. Supporting ''​%%double%%''​ or ''​%%float%%''​ in these cases would be dangerous because one might write a ''​%%float%%''​ into the database [[https://​en.wikipedia.org/​wiki/​Floating-point_arithmetic|which might or might not end up with the correct value]] in the database. To completely eliminate such problems, we only support objects, which means that one is “limited” to the usage of number extensions like ''​%%BigLong%%''​ and ''​%%BigDecimal%%'',​ which do not suffer from such problems.+Text and binary data are both objects (arrays of primitives are objects after all) and numbers are either primitives or objects. Most of the time, if we deal with numbers inside a database, we want them to be of arbitrary precision, which means we must represent them as ''​%%BigDecimal%%''​. Supporting ''​%%double%%''​ or ''​%%float%%''​ in these cases would be dangerous because one might write a ''​%%float%%''​ into the database [[https://​en.wikipedia.org/​wiki/​Floating-point_arithmetic|which might or might not end up with the correct value]] in the database. To completely eliminate such problems, we only support objects, which means that one is “limited” to the usage of number extensions like ''​%%BigLong%%''​ and ''​%%BigDecimal%%'',​ which do not suffer from such problems.
  
 ==== Where Are the Data Pages? ==== ==== Where Are the Data Pages? ====
  
-What is not clear from this example is how and when data pages are used. As a matter of fact, most of the time there is no need to think about data pages because they are managed directly by the data book, and, if used like this, there is only one data page. Multiple data pages will be used if there is a master/​detail relationship defined, in which case the data book selects the correct data page automatically.+What is not clear from this example is how and when data pages are used. As a matter of fact, most of the time there is no need to think about data pages because they are managed directly by the databook, and, if used like this, there is only one data page. Multiple data pages will be used if there is a master/​detail relationship defined, in which case the databook ​selects the correct data page automatically.
  
 ===== Master/​Detail ===== ===== Master/​Detail =====
  
-[[https://​en.wikipedia.org/​wiki/​Master%E2%80%93detail_interface#​Data_model|Master/​detail]] is something that occurs in nearly every data model. It means simply that there is one master ​dataset which is referenced by one or multiple detail ​datasets. Or to express it in SQL:+[[https://​en.wikipedia.org/​wiki/​Master%E2%80%93detail_interface#​Data_model|Master/​detail]] is something that occurs in nearly every data model. It simply ​means that there is one master ​data set that is referenced by one or multiple detail ​data sets. Or to express it in SQL:
  
 <code sql> <code sql>
Line 733: Line 733:
   left join DETAIL d on m.ID=d.MASTER_ID;​   left join DETAIL d on m.ID=d.MASTER_ID;​
 </​code>​ </​code>​
-We can of course express a master/​detail relationship when using data books. For that we just create a ''​%%ReferenceDefinition%%''​ and assign it to the detail ​data book:+We canof courseexpress a master/​detail relationship when using databooks. For thatwe just create a ''​%%ReferenceDefinition%%''​ and assign it to the detail ​databook:
  
 <code java> <code java>
Line 767: Line 767:
                    ​8| ​        3                    ​8| ​        3
 </​code>​ </​code>​
-Now if we select the second row in the ''​%%masterDataBook%%'',​ the ''​%%detailDataBook%%''​ will just contain the rows with the corresponding ''​%%MASTER_ID%%'',​ so 3, 4 and 5.+Nowif we select the second row in the ''​%%masterDataBook%%'',​ the ''​%%detailDataBook%%''​ will just contain the rows with the corresponding ''​%%MASTER_ID%%'',​ so 3, 4and 5.
  
 <​code>​ <​code>​
Line 778: Line 778:
      ​3 ​            ​5| ​        2      ​3 ​            ​5| ​        2
 </​code>​ </​code>​
-The ''​%%detailDataBook%%''​ is automatically adjusted according to the selection in the ''​%%masterDatabook%%''​. Of course this can have an arbitrary depthtoo.+The ''​%%detailDataBook%%''​ is automatically adjusted according to the selection in the ''​%%masterDatabook%%''​. Of coursethis can have an arbitrary depth too.
  
 ===== Conclusion ===== ===== Conclusion =====
  
-The data book is the backbone of [[https://​sourceforge.net/​projects/​jvx/​|JVx]]it provides a clean and easy way to access and manipulate data. At the same time, it is flexible and can be customized to specific needs with ease.+The data book is the backbone of [[https://​sourceforge.net/​projects/​jvx/​|JVx]]it provides a clean and easy way to access and manipulate data. At the same time, it is flexible and can be customized to specific needs with ease.
  
 ====== Application Basics ====== ====== Application Basics ======
  
-Let’s talk about the basicshow a [[https://​sourceforge.net/​projects/​jvx/​|JVx]] application starts, works and how the connection strings together the client and server side.+Let’s talk about the basicshow a [[https://​sourceforge.net/​projects/​jvx/​|JVx]] application starts, ​how it worksand how the connection strings together the client and server side.
  
 ===== Multitier Architecture ===== ===== Multitier Architecture =====
Line 817: Line 817:
 frame.eventWindowClosed().addListener(() -> System.exit(0));​ frame.eventWindowClosed().addListener(() -> System.exit(0));​
 </​code>​ </​code>​
-We can start to create and manipulate the GUI. In this case we are building a simple window with a label inside. ​Last but not least, we make sure that the JVM will exit when the window is closed.+We can start to create and manipulate the GUI. In this casewe are building a simple window with a label inside. ​Lastly, we make sure that the JVM will exit when the window is closed.
  
 A very good example and showcase for that is the [[https://​github.com/​sibvisions/​jvx.kitchensink|JVx Kitchensink]]. A very good example and showcase for that is the [[https://​github.com/​sibvisions/​jvx.kitchensink|JVx Kitchensink]].
  
-That’s itThat is the most simple way to start a [[https://​sourceforge.net/​projects/​jvx/​|JVx]] application. We can use all controls, and we can use ''​%%MemDataBook%%''​s without any problem or limitation. Best of all, we can simply switch to another technology by using another factory.+That’s itThat is the most simple way to start a [[https://​sourceforge.net/​projects/​jvx/​|JVx]] application. We can use all controls, and we can use ''​%%MemDataBook%%''​s without any problem or limitation. Best of all, we can simply switch to another technology by using another factory.
  
-===== Anatomy of a remote ​JVx application ​=====+===== Anatomy of a Remote ​JVx Application ​=====
  
-Of course [[https://​sourceforge.net/​projects/​jvx/​|JVx]] wouldn’t be that useful if it would just provide static GUI components. Now, to explain what else is required for a remote [[https://​sourceforge.net/​projects/​jvx/​|JVx]] application I have to go far afield, so let’s head down the rabbit hole.+Of course[[https://​sourceforge.net/​projects/​jvx/​|JVx]] wouldn’t be that useful if it would just provide static GUI components. Now, to explain what else is required for a remote [[https://​sourceforge.net/​projects/​jvx/​|JVx]] applicationI have to go far afield, so let’s head down the rabbit hole.
  
 {{:​jvx:​reference:​jvx-client-server.png?​nolink| Layers}} {{:​jvx:​reference:​jvx-client-server.png?​nolink| Layers}}
  
-What you are seeing here is a rough sketch of how the architecture of [[https://​sourceforge.net/​projects/​jvx/​|JVx]] looks like. Let’s walk through the image step by step. We will look at each successive layer and work our way from the database on the server to the databook ​on the client.+What you are seeing here is a rough sketch of how the architecture of [[https://​sourceforge.net/​projects/​jvx/​|JVx]] looks like. Let’s walk through the image step by step. We will look at each successive layer and work our way from the database on the server to the data book on the client.
  
-==== DBAccess, ​accessing ​database ​====+==== DBAccess, ​Accessing ​Database ​====
  
 Accessing a database is easy when using ''​%%DBAccess%%''​. All we must do is to set the [[https://​en.wikipedia.org/​wiki/​Java_Database_Connectivity|JDBC]] URL of the server and connect to it: Accessing a database is easy when using ''​%%DBAccess%%''​. All we must do is to set the [[https://​en.wikipedia.org/​wiki/​Java_Database_Connectivity|JDBC]] URL of the server and connect to it:
Line 842: Line 842:
 dbAccess.open();​ dbAccess.open();​
 </​code>​ </​code>​
-As a note, the instance returned by ''​%%getDBAccess(...)%%''​ is the database specific ''​%%DBAccess%%''​ extension, which does know how to handle its database.+As a note, the instance returned by ''​%%getDBAccess(...)%%''​ is the database-specific ''​%%DBAccess%%''​ extension, which knows how to handle its database.
  
-We can of course use ''​%%DBAccess%%''​ to directly access the database:+We canof courseuse ''​%%DBAccess%%''​ to directly access the database:
  
 <code java> <code java>
Line 853: Line 853:
 List<​Bean>​ data = dbAccess.executeQuery("​select * from SOME_TABLE"​);​ List<​Bean>​ data = dbAccess.executeQuery("​select * from SOME_TABLE"​);​
 </​code>​ </​code>​
-…or manipulate the database, ​or query information about the database ​or execute procedures or do anything else.+…or manipulate the database, query information about the databaseexecute proceduresor anything else!
  
-==== DBStorage, ​preparing ​the database access ​for databooks ​====+==== DBStorage, ​Preparing ​the Database Access ​for Databooks ​====
  
-The downside of using DBAccess is that everything must be database specific. To become database ​agnostic ​we must use ''​%%DBStorage%%''​. ''​%%DBStorage%%''​ does not care which database it is connected to and can operate on any of them:+The downside of using DBAccess is that everything must be database-specific. To become database-neutral, ​we must use ''​%%DBStorage%%''​. ''​%%DBStorage%%''​ does not care which database it is connected to and can operate on any of them:
  
 <code java> <code java>
Line 865: Line 865:
 storage.open();​ storage.open();​
 </​code>​ </​code>​
-We can use this to insert, update, delete and fetch data. Additionally the ''​%%DBStorage%%''​ does retrieve and manage the metadata of the table we’ve set, which means that we can query all column names, what type they are, we can even access the indexes and the default values. Short, the ''​%%DBStorage%%''​ leaves little to be desired when it comes to operating on a database.+We can use this to insert, update, delete and fetch data. Additionallythe ''​%%DBStorage%%''​ does retrieve and manage the metadata of the table we’ve set, which means that we can query all column names, what type they are, we can even access the indexes and the default values. Short, the ''​%%DBStorage%%''​ leaves little to be desired when it comes to operating on a database.
  
-If we query data from the ''​%%DBStorage%%''​ we receive a List of rows. The rows are are either represented as ''​%%Object%%''​ array, ''​%%IBean%%''​ or a POJO and we can easily manipulate the data, like this:+If we query data from the ''​%%DBStorage%%''​we receive a list of rows. The rows are either represented as ''​%%Object%%''​ array, ''​%%IBean%%''​or a POJOand we can easily manipulate the data, like this:
  
 <code java> <code java>
Line 876: Line 876:
 } }
 </​code>​ </​code>​
-As one can see, it looks quite familiar to the DataBook, which isn’t a coincidence. The ''​%%DBStorage%%''​ “powers” the DataBooks ​on the server side, a DataBook ​will get its data from and will send its modified data to the ''​%%DBStorage%%''​.+As one can see, it looks quite familiar to the DataBook, which isn’t a coincidence. The ''​%%DBStorage%%''​ “powers” the databooks ​on the server side, a databook ​will get its data from and will send its modified data to the ''​%%DBStorage%%''​.
  
-I’ve been using the ''​%%DBStorage%%''​ here as an example, but actually the Storage ​is not dependent on a database. ''​%%IStorage%%''​ can be implemented to provide any sort of data provider, like reading from an XML or JSON file, scraping data from a website, fetching data from a different process or reading it directly from a hardware sensor.+I’ve been using the ''​%%DBStorage%%''​ here as an example, but actually the storage ​is not dependent on a database. ''​%%IStorage%%''​ can be implemented to provide any sort of data provider, like reading from an XML or JSON file, scraping data from a website, fetching data from a different processor reading it directly from a hardware sensor.
  
 ==== Life Cycle Objects, the business objects with all the logic ==== ==== Life Cycle Objects, the business objects with all the logic ====
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information