Let’s start with some clarifications:
More information about SBA, SBQL and ODRA could be found on the official site: http://www.sbql.pl/.
The IDE is at an early development stage thus some changes or issues could happen. Currently to install the IDE follow the procedure:
Right now you should have the IDE correctly installed.
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.
After a while you should see an empty project (ignore the warnings):
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.
Now we have an empty source file which we are about to fill with some code.
Let’s start with a module:
module
We can use a similar procedure to add a class and its instance.
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.
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.
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.
You should see a dialog for entering connection properties. However this time simply select Use default 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).
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).
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.
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;
.
It is also possible to switch back to the previous window and execute the method getNames() (by clicking the small icon as described previously).
The IDE supports many other features like:
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.