Well, I’ve finally got a basic, no-functionality plug-in. I tried copying various aspects of other ODA adapters, such as the Flat File and JDBC ODA Plug-ins. However, nothing worked better than just going with a lot of pre-set-up options. So, here is a walkthrough on how to get a shell of a plug-in. I should note that these instructions are for BIRT release 2.1, the official release as of this posting. Soon BIRT 2.2 will be out–it’s currently in RC0 (release candidate 0), so it should not be more than a few weeks until BIRT 2.2 is unleashed. I haven’t worked with BIRT 2.2 yet, but it should definitely be something to look forward to. I haven’t worked with any release other than BIRT 2.1, so if you’re using another version (such as BIRT 2.2 RC0), then this may not work. I’d be surprised if it did not work on an official release though, so go ahead and try anyway if you’re on a full release.
First, we’ll probably want to switch to the Plug-in Development Environment (PDE) in Eclipse. This is accessible by accessing the menus Window => Open Perspective => Other… and selecting Plug-in Development from the pop-up box.
Now onto the creating. Create a new project, select Plug-in Project and click Next.
Enter a Project name. For this, I used “openmrsdb”. The rest should probably stay the same, unless you don’t want this project in your normal workspace. Click Next.
Our Plug-in ID will stay the same, as will the version number and name. I did enter a Plug-in provider, “OpenMRS,” but you don’t need to enter anything. Classpath I left blank for now, even though some tutorials included some things. I didn’t have anything I felt needed to be included, so it stayed blank. If this actually changes in the future, then I’ll update this post then.
Leave the default Activator settings (checked, default name). As for the next checkbox, uncheck it. We are currently building the Runtime Plug-in, which is only a backend. We will make a separate plug-in for the UI soon. And leave the setting for rich client application (No). Click Next.
We do want to use a template, so leave that checkbox marked and click on “ODA Data Source Runtime Driver.” Click Next.
Most of this can stay as it is right now. However, we do want to change “Number of Data Source properties” to 3; you’ll see why soon. Also, I changed “Data Source Display Name” and “Data Set Display Name.” This is purely cosmetic, but who wants a bad user experience? By default, these will be “Openmrsdb Data Source” and “Openmrsdb Data Set,” which are right, but a little odd to say or think about. I change the Data Source name to “OpenMRS Database,” and the Data Set name to “OpenMRS Data Set.” The reason is that we are clearly drawing data from the OpenMRS database, not drawing a source from the OpenMRS database. As for the Data Set name, I thought it sounded redundant to have “Database” in between “OpenMRS” and “Data Set,” but still wanted it to say “Data Set.” Those name changes are completely up to you, and may vary depending on what your ODA driver does. Finally, click Finish.
When you finish, an editor should come up showing some properties about your new plug-in. Click the “Extensions” tab on the bottom, as this is where we have to do some work. Under “All Extensions,” click the arrow to explore the entry. Click the arrow for the first, “openmrsdb (dataSource).” Again, click the arrow for (properties) underneath that. You should see a list of three properties (property1, property2, property3). Click on property1, and you should see a few boxes come up on the right. We are going to fill in the information for these. Enter this data, leaving the rest of the boxes alone:
property1: name = SERVER; defaultDisplayName = %data.source.server; defaultValue = http://
property2: name = USERNAME; defaultDisplayName = %data.source.username
property3: name = PASSWORD; defaultDisplayName = %data.source.password; isEncryptable = true
These are generally self explanatory. These represent the properties that are saved and will be passed when creating a connection. We will want to specify a server, a username, and a password. However, the default display names I gave them don’t currently mean anything. We’re going to have to set those now.
From your project browser, open the file “plugin.properties” at the root of the project. Add these lines to the end of the file:
data.source.server=OpenMRS Server Path
data.source.username=Username
data.source.password=Password
These will be read by the UI to be displayed when you are setting the connection properties. The reason they are in this file is for internationalization support. You may make other language’s versions of these strings, so that people of other languages may more readily use the driver. You may notice that the other values that were optionally changed earlier (data source and data set names) are in this file. You can change them here if you want to change those names ever again. Go ahead and close that file and the editor for the project information, saving if you haven’t already. If you want to get to the editor again, you can try to open one of the files from the project, such as plugin.xml or MANIFEST.MF, and these will get you to that editor, though possibly under a different tab.
Now, we want to create the UI Plug-in. This is probably even simpler. Create another Plug-in Project, and name this one openmrsdb.ui (or equivalent). It doesn’t really matter what the name is, though having the original name plus “.ui” seems natural to me. Leave the rest of the options the same, unless you want to move this out of your normal workspace. Again we don’t really change anything, though you can change the plug-in name or provider here again. Unlike last time, however, leave checked the box “This plug-in will make contributions to the UI.”
On the next screen, we want to use the template “ODA Data Source Designer.” Note that there are a lot more templates this time, due to the fact that the UI contributions checkbox was checked. I guess there aren’t many plug-ins that don’t have to do with the UI. Click next.
This screen is important. Many of the values here must match up with the values from the previous plug-in. If you didn’t change anything other than what I told you you could, you should be fine. Again at the bottom, you can change the names. I changed them to be the same as the ones I set with the runtime plug-in, just to be sure. Couldn’t hurt to change them, right? Finally, click finish.
Now, you’re done. You’ve got a shell of a plug-in. To see it in “action,” you’re going to want to run the project as an Eclipse application. Right click on one of the projects and select Run As => Eclipse Application. When the new instance of Eclipse starts up, you’re going to want to add a new reporting project and add a new report to the project. Switch to the BIRT reporting perspective, and open the “Data Explorer” view. Right click on Data Sources, and click “New Data Source.” Select “OpenMRS Database” from the list (or whatever it is called. As default, it would be “Openmrsdb Data Source”) and click Next.
Aha! It is the connection properties for our plug-in! Success! You should see something that looks like this:

Except yours won’t have data filled in until you fill it in. It doesn’t matter what you put, as it doesn’t do anything yet (the Test Connection button will always work too :-). There’s not too much more to see, but you can try creating a data set. It will ask for a query in a box. This is not what will eventually be there, as we want our users to see something nicer than a plain old query box. No, the purpose of this driver is to smooth the connection.
That will be a good adapter. But for now, all we have is a shell. It’s the beginnings of a wonderful connection between report designer and database. From here, it’s..well, still uphill. But it’s a good start.
Many thanks to Scott Rosenbaum for writing a nice Primer on ODA Extensions and BIRT, available at EclipseMag.net (registration required). It was the first thing that got me a nice shell, and it’s going to help tremendously in adding functionality.
