GDL2: the GNUstep Database Library
Some of my previous articles presented the Graphical Object Relationship Modeler (Gorm) and Renaissance, two important projects for GNUstep. This article aims to provide a short introduction to GDL2—the GNUstep Database Library. While this article focuses on GDL2, the reader is encouraged to read previous GNUstep articles, (Linux Journal, April 2003 and March 2004) for a better understanding of Gorm and of the Objective-C language.
GDL2 is a free (LGPL) implementation of EOF, Enterprise Objects Framework. EOF was created by NeXT Computer, Inc. in 1994 as a collection of API to develop efficiently object-oriented database applications using the Objective-C language. It evolved from a lower-level framework, known as DB Kit, that was available on NeXTSTEP. Apple's implementations of EOF now are based on the Java language, leaving Objective-C developers with no choices but to consider rewriting their applications in Java or looking at a free implementation of EOF. GDL2 is aimed at compatibility with version 4.5 of EOF.
EOF is divided into multiple layers: EOAccess, EOControl and EOInterface. The role of the former is to transfer data from the RDBMS to enterprise objects and from objects to raw database data. EOControl is used to maintain an in-memory graph of enterprise objects and delegate modifications to the database using EOAccess. EOInterface is used to map enterprise objects to user interface elements. Unfortunately, EOInterface is not yet implemented in GDL2. Figure 1 presents the various layers, how they relate to Foundation, AppKit and how they relate in a typical client/server AppKit application that makes use of EOF.

Figure 1. The EOF architecture applies a uniform object-oriented interface to diverse databases, with no SQL coding needed.
Furthermore, EOF allows developers to create database-oriented applications without writing any SQL. Instead, the developers concentrate on manipulating real objects. In addition, when synchronizing changes made to objects with the database, EOF has mechanisms to validate, enforce referential integrity, generate primary and foreign keys, manage transactions and provide locking—either pessimistic, optimistic or on-demand—to ensure integrity of the data thus, removing entirely this burden from the application developers.
The source code of the test application and all listings, fully commented, are available from the Linux Journal FTP site (see the on-line Resources section). You should refer to this source code for a better understanding of all listings shown in this article.
In order to install GDL2 and create our test application, we first must install GNUstep and Gorm. Furthermore, we need to install PostgreSQL because we are using the Postgres95 EOF adaptor in our example.
The latest stable release is always recommended. For this project, this includes GNUstep make 1.9.1, GNUstep base 1.9.1, GNUstep GUI 0.9.2, GNUstep back 0.9.2, Gorm 0.7.5 and PostgreSQL 7.4.2. When installing PostgreSQL, be sure to install the development packages for libpq header files, as they are required in order to compile GDL2. Debian provides the postgresql-dev package while Red Hat provides the postgresql-devel package. Once the requirements are installed, proceed with the following commands:
# wget ftp://ftp.gnustep.org/pub/gnustep/libs/gdl2-0.9.1.tar.gz # tar -zxvf gdl2-0.9.1.tar.gz # cd gdl2-0.9.1 # ./configure # makeAnd finally, as root:
# make installThis will download GDL2 v0.9.1 from the GNUstep FTP server, compile and install it.
In the first GNUstep article, the Model-View-Controller (MVC) design pattern was introduced. When using EOF, much of the controller's logic described in the previous article now is being managed automatically by EOF. In fact, the application's user interface becomes the View, EOF the controller and database itself, the Model.
In this article, we create a trivial inventory management application that makes use of the MVC model. This application displays a window, a table view showing the inventory items and three buttons used to update the inventory, insert or delete a new item. Before creating the application, we need to create our inventory database and the credentials we will use in our test application. To do so, proceed with the following commands:
% su - postgres % createuser --pwprompt inventory Enter password for user "inventory": (specify a password) Enter it again: Shall the new user be allowed to create databases? (y/ n) y Shall the new user be allowed to create more new users? (y/ n) n CREATE USER % createdb -O inventory inventory CREATE DATABASE
Once the database and the user are created, we next create the sequence and table used by our test application. Be sure the authentication mechanisms in PostgreSQL are configured well before using the psql tool:
% psql -U inventory inventory create sequence inventory_seq start with 1; create table inventory ( iid int4, name varchar(255), quantity int4, order_date timestamp, primary key (iid) );
Once the steps related to the database are completed, we now proceed, with Gorm, to create the user interface for the inventory application. To do so, open the modeler and from the Document menu, choose New Application. From the Inspector window, set the window title to Inventory. Then, from the Palettes window, drag a NSTableView object to the application's window and insert a third table column using copy/paste. Set the table columns' titles to Name, Quantity and Order Date. Also, set the table column identifiers to name, quantity and order_date respectively. Then, drag three buttons from the Palettes window to the application's window and set their respective title to Update, Insert and Delete.
From the File window, click on the Classes icon and select the NSObject item. From the Classes menu, choose Create Subclass.... Rename the controller class to AppController and create the window and tableView outlets. Furthermore, insert:, delete: and update: actions must be added. Once we have created the outlets and actions, we are ready to instantiate our controller class. Do so and then connect the window and tableView outlets, set the delegate/datasource on the tableview and the delegate/windowController on the window to our application's controller.
Furthermore, connect the actions on the buttons. From the Document menu, choose Save... and specify the name MainMenu.gorm. Additionally, connect the NSOwner's delegate outlet to AppController. Finally, from the Classes view, select AppController and create the class files (AppController.h and AppController.m). Overall, the user interface should look like Figure 2.
Once the user interface has been created, open AppController.h in your favorite editor and add the items and editingContext instance variables, as shown in Listing 1. Then, modify AppController.m in order to implement the -delete:, -insert: and -update: methods. Furthermore, you need to add the -init, -dealloc, -numberOfRowsInTableView, -tableView:objectValueForTableColumn:row:, -tableView:setObjectValue:forTableColumn:row:, -applicationDidFinishLaunching: methods as well as the application entry point, main() and the required #import directives for EOF headers. Listing 2 shows the complete source of the application's controller. A description of all methods is provided in the next section.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Validate an E-Mail Address with PHP, the Right Way
- New Products
- Tech Tip: Really Simple HTTP Server with Python
- Developer Poll
- git-annex assistant
46 min 20 sec ago - direct cable connection
1 hour 8 min ago - Agreed on AirDroid. With my
1 hour 19 min ago - I just learned this
1 hour 23 min ago - enterprise
1 hour 53 min ago - not living upto the mobile revolution
4 hours 44 min ago - Deceptive Advertising and
5 hours 20 min ago - Let\'s declare that you have
5 hours 21 min ago - Alterations in Contest Due
5 hours 22 min ago - At a numbers mindset, your
5 hours 23 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




Comments
Re: GDL2: the GNUstep Database Library
Interesting article.
At this moment, this site at this link doesn't seem to exist:
And for the Python-inclined, there is a EOF-inspired Object-Relational database bridge called "Modeling" at: