This is a Project Zero video tutorial. During this presentation, I will show the basics of using the Zero Resource Model, or ZRM, for short. ZRM is built on top of the zero.data module for relational data access and Project Zero's core Resource Framework and delivers a compelling story for quickly providing your application with RESTful data services. At its core is a declarative model using a JSON syntax to describe data shape and constraints to both server and client functionality. This enables automatic persistence into several popular databases, including MySQL, Oracle, DB2, and Derby, and a robust validation framework. In addition to a black-box RESTful HTTP API, ZRM has a programmatic API that enables you to customize your application to suit its needs. Further, an implementation of the Dojo Data API is provided to bind server data to client-side widgets. The demonstration in this tutorial is a trivial application that allows a user to interact with employee information. I will show how to include ZRM into an application, declare the employee data type model, give initial data to the system, automatically create database artifacts, and create a basic HTML interface that we can interact with the data. So let's get started. First, we need to create a new Project Zero application. We will be using Zero's command line interface in the tutorial, so let's bring up a shell. If you have any questions setting up the CLI, please consult the documentation at projectzero.org/download. If you have the CLI set up correctly, any folder will do. Create a new application by typing "zero create myapp" at the prompt. This will create a blank application. Change into your newly created application's root and resolve dependencies. Its always a good habit to resolve. Create and edit the application files in your favorite editor. Mine is TextMate. Here we see the basic application folder structure. The next action we need to take is to add the Zero Resource Model to our application. This is done by editing the ivy.xml file in the config directory. ZRM's module name is zero.resource. Also later we will be using functionality in the zero.dojo module, so let's add that too. Now let's declare our employee resource model. There are two folders we need that are not created in blank applications. Resource models, by convention, live in the models folder in the app folder and initial data in a fixtures folder. So create those. The name of our resource model is "employees". So we name the file "employees.json". For more information about the syntax of Resource Models, please visit projectzero.org/documentation. Our model has four fields, firstname, lastname, location, and phonenumber. Location has four options, RTP, Beijing, Hursley, and SVL. Next, let's define some initial data to load into the system. We create a file named initial_data.json in the fixtures folder an paste in some data in the JSON format. You can find out more about loading data into the system at projectzero.org/documentation. Our last file we need to create in order to hook into Project Zero's core resource framework. This is done by creating a Groovy script with the same name as our Resource Model JSON file. The contents of the Groovy script at a minimum requires one delegating method into ZRM's black box resource handler. If you need to customize your application's handling of HTTP requests, overriding methods in this script get what you need. So now we need to create the database artifacts to support our application's resource models. Let's get back to a shell prompt and make sure we are in our application's root. Again resolving for good measure. And now we execute the model_sync CLI task contributed by ZRM. Executing this will create any tables that haven't been already and load data for those model types defined in the initial_data.json file. We are now ready to start our application and test the HTTP API. Execute zero start on the CLI. Let's do a GET request to the resource collection for employees using curl. We can verify that the data returned is the data we provided in the initial_data.json file. Now let's create an HTML front end for our RESTful data. We will use Dojo and an implementation of the Dojo Data API for ZRM. Create an datagrid.html file in our application's public folder. I've pasted in an existing page to save the life of my keyboard. Let's look at the contents of the page. First we get the core dojo.js file and then declare Dojo module dependencies for the page. The second two are actually provided by the zero.dojo module we declared a dependency on earlier in our application's ivy.xml file. The ZRMStore is an implementation of the Dojo Data API and the DataGrid extends Dojo's default Grid to encapsulate some basic CRUD functionality. Next we import some stylesheets. Now let's talk about the two div's in the page's body. The first one declare's an instance of ZRMStore and assigns an id. The second declares a DataGrid instance, binding to the ZRMStore data by way of the id. We tell the DataGrid that it is bound to the employee model type. This corresponds to the Groovy file and the Resource Model JSON file in our application. We have ourselves a basic application. So let's bring up a browser and point it to the datagrid.html file that we just created. Here we have a basic data grid, populated with the data we specified the initial_data.json file. We can edit the data inline and tab through the data. Fields that have options get a drop down box. We have some actions that we can perform. Create, Delete, Refresh, and Save. Let's create a row. I'll add myself. That's not my real phone number. And note that the ID and UPDATED fields are read only. The data is not persisted to the server until the Save button is clicked. We can delete rows as needed. Deletes are not persisted until the Save button is clicked. Verify by clicking Refresh.