Warning! This is a preliminary software. Use it at your own risk.

Tutorial #2 - Introduction to ODRA eIDE2

Let’s start with some clarifications:

SBA
(Stack-Based Architecture) is a formal methodology addressing object-oriented database query and programming languages.
SBQL
(Stack-Based Query Language) is a query/programming language following the SBA principles. SBQL has been carefully designed from the pragmatic (practical) point of view. The pragmatic quality of SBQL is achieved by orthogonality of introduced data/object constructors, orthogonality of all the language constructs, object relativism, orthogonal persistence, typing safety and introduction of all the classical and some new programming abstractions.
ODRA
is a prototype object-oriented database management system following the SBA philosophy and implementing SBQL.
ODRA eIDE2
is a new version of the Integrated Development Environment for the ODRA. This edition is based on Eclipse and Xtext.
webODRA2
is a new version of a web framework for the ODRA.

More information about SBA, SBQL and ODRA could be found on the official site: http://www.sbql.pl/.

Installation of the IDE

The IDE is at an early development stage thus some changes or issues could happen. Currently to install the IDE follow the procedure:

  • make sure that a Java Runtime Environment is installed correctly (tested with jdk1.7.0_21);
  • download an XText release of the Eclipse (tested with eclipse-dsl-kepler-R-win32-x86_64). You can download the entire release or upgrade your current version;
  • extract the downloaded archive and run the Eclipse;
  • add a new Update Site which contains the IDE software. To do this choose Help -> Install New Software... from the menu bar and press the Add... button. Enter ODRA Update Site as name and http://eide2.pjwstk.edu.pl/update/ as url. Select ODRA eIDE2 and click the Next button. Follow the wizard and all necessary software should be downloaded and installed.

Right now you should have the IDE correctly installed.

Your first project

Now, when everything is set and ready, we can start our first project. Choose: File -> New -> Other -> ODRA DB (SBQL) category and ODRA DB (SBQL) Project. Enter the project name (e.g. Sbql Test) and optionally change a location.

ODRA eIDE2 Project Wizard

After a while you should see an empty project (ignore the warnings):

ODRA eIDE2 Empty Project

Let’s add some source files (generally they should be located in the source folder with a sbql file type): click the src folder and from its context menu (using the right mouse button) select New -> File and enter a name, e.g. Product.sbql.

ODRA eIDE2 Source File

Now we have an empty source file which we are about to fill with some code.

Let’s start with a module:

  • type module
  • press CTRL + Space: you should see a hint showing two options. The first one allows for manually typing the code; the second uses a dedicated template (which is easier/faster to use).

ODRA eIDE2 Module Hint

We can use a similar procedure to add a class and its instance.

ODRA eIDE2 Empty class

Let’s add some fields to the class. Place the cursor inside the class instance and without typing anything just press CTRL + space. You should see a template for adding a field – select it.

ODRA eIDE2 Adding a field

Provide a name, e.g. name and its type. Please note that you can select it from a list of available types. In this case select/type the string.

ODRA eIDE2 Selecting a field's type

Repeat the procedure a few times and add a method or two. After a while you will have a class with fields and methods, e.g.:

			module ProductMod {
				class ProductClass {
					instance Product: {
						name: string;
						description: string;
						manufactureDate: date;
						stockItems: integer;
					}		
				}
				 
				getNames() : string[0..*] {
					return Products.name;
				}
				
				createProduct(_name: string) {
					create permanent Products(_name as name, 
								"" as description, 
								0 as stockItems, 
								now() as manufactureDate);
				}
				
				Products: ProductClass[0..*];
			}
			

Before we can try the code we need to connect to the ODRA server. Make sure that the ODRA DB server is running and listening. Connect to the server from the IDE by selecting the project and from its context menu chose ODRA Server.

ODRA eIDE2 connecting to ODRA DB Server

You should see a dialog for entering connection properties. However this time simply select Use default server.

ODRA eIDE2 connecting to ODRA DB Server

If everything is OK the dialog will be dismissed and your project is connected to the server.

Now we can compile the source file and transfer it to the server (simply by using the Save button in the IDE).

Executing a SBQL method

The IDE also gives us an easy way for executing parameterless methods: click the small icon near the procedure’s name and double click the link. The result is presented on the console. Currently there are no objects so the result is empty (in the XML format).

ODRA eIDE2 Execute method

Connect to the server using CLI

It is also possible to connect to the server using a Command Line Interpreter. This approach makes possible executing various commands and SBQL statements as well. To do that simply select ODRA CLI from the project’s context menu (next to the ODRA Server option).

Type help in the window and press the Enter key. You will see a list of available commands.

ODRA eIDE2 CLI

Let’s create a few Products using the CLI and of the defined methods. First let’s take a look on the existing artefacts. The ls command will show the current items. Simply type ls and press Enter. Then change the current module to the ProductMod: cm ProductMod. Execute the method creating a new product: createProduct(“Simple product 1”);. Repeat the procedure with different names and check the result by typing Products;.

ODRA eIDE2 CLI

It is also possible to switch back to the previous window and execute the method getNames() (by clicking the small icon as described previously).

Other IDE features

The IDE supports many other features like:

  • various views, e.g. Outline (the top-right corner of the window),
  • navigation: pointing on an item (e.g. a complex type) with the CTRL key we can navigate to its definition,
  • references: it is possible to find all references to an item (e.g. a type or a declaration),
  • javadoc-like tooltips: hovering on a type will show a tooltip with its description,
  • the IDE is built on the Eclipse roots which means that it is possible to add a plethora of useful plugins (e.g. versioning systems, various editors, DB explorers, etc.).

Refactoring

Currently the IDE supports only a renaming (select Rename Element from the context menu or press ALT + SHIFT + R) but in the future we plan to add some other refactorings.

ODRA eIDE2 Refactorings

comments powered by Disqus