Developing MyHealth on InfoGrid — Day 1
This is the first of a series of posts documenting the creation of an open-source web app called MyHealth to manage personal health and wellness data, based on the InfoGrid Web Graph Database.
This scratches a personal itch, and I figure I might as well chronicle the progress of this little side project so developers new to InfoGrid get a taste.
I don’t think I’m the only geek who’d like to manage their health, wellness and fitness information better and keep it under their own control, so perhaps you might want to help out. There seems to be little or no open-source software for personal health information management that was written in this century, or so, and it will be cool to do it based on cutting-edge NoSQL graph database technology.
I’ll check today’s code every day and post on this blog. As it is a side project, I don’t expect to do more than an hour of work each day, and likely less. You are very welcome to contribute if you like, just send a note to the InfoGrid mailing list.
So here is day 1:
1. Let’s get the InfoGrid code:
mkdir -p ~/svn/svn.infogrid.org/infogrid svn checkout http://svn.infogrid.org/infogrid/trunk
2. Make sure our setup is right and InfoGrid builds
cd ~/svn/svn.infogrid.org/infogrid/trunk ig-tools/build.sh -a
This takes a while, so off to writing some of this blog post.
Oops, test failed because I forgot to start Tomcat. So let’s run NetBeans, which I’ll use as my IDE, and run Tomcat from there. Then re-run the last of the user interface tests that depend on Tomcat:
ig-tools/build.sh -run ig-ui
3. We’ll going to put MyHealth right into the InfoGrid SVN:
mkdir ig-app-myhealth mkdir ig-app-myhealth/modules mkdir ig-app-myhealth/app
I learned this past week that this directory structure is best described as an “InfoGrid-ism” (Hi Ben!) i.e. a convention that makes using InfoGrid easier. The modules subdirectory will contain the modules from which MyHealth is assembled, other than the InfoGrid modules, and the app directory will contain the web app project.
4. Use the brand-new project creation scripts:
cd ig-app-myhealth/modules
../../ig-tools/create-model-module.pl --name org.infogrid.model.MyHealth \
--infogridpath ../..
This created a ModelModule, aka a schema for the graph database. Which also can be opened up as a project in NetBeans.
Then we also create a web project by cloning the MeshWorld example app:
cd ../app ../../ig-tools/clone-meshworld.pl --name org.infogrid.myhealth.www \ --infogridpath ../..
5. Open both of those projects in NetBeans to make sure everything is right and can be built.
Select “Clean and Build” first on the model project, then on the web project. Works fine. We haven’t told those project about each other, but we will later.
6. Setting up a MySQL database.
In MySql, create a database and set some privileges:
mysql -u root -p mysql> create database myhealth; mysql> grant all privileges on myhealth.* to 'myhealth'@'localhost' identified by 'secret'; mysql> flush privileges;
In the org.infogrid.myhealth.www project in NetBeans, edit the context.xml file to read as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/org.infogrid.myhealth.www" cookies="false">
<Resource auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
name="jdbc/org.infogrid.myhealth.www"
url="jdbc:mysql://localhost:3306/myhealth"
username="myhealth"
password="secret"
maxActive="20"
maxIdle="10"
maxWait="-1" />
</Context>
To stay on the safe side, rebuild the web project.
6. Assigning an App Server and Run
In NetBeans, open the properties for project org.infogrid.myhealth.www, select the Run tab, and pick a local Tomcat installation as the assigned app server.
Running the web project. It runs! It is totally and utterly useless so far, and has no health content or health-relevant schema of any kind. But it runs, and we’ll keep the MyHealth app running from now on regardless how many changes we make and features we write.
7. Check-in so you guys can check out what has been created so far:
cd ../.. svn add -N ig-app-myhealth ig-app-myhealth/modules ig-app-myhealth/app ig-tools/add-project-to-svn.pl ig-app-myhealth-modules/org.infogrid.model.MyHealth ig-tools/add-project-to-svn.pl ig-app-myhealth-app/org.infogrid.myhealth.www
(These Perl scripts are just wrappers around svn to to check the right files and directories of NetBeans projects into SVN)
Done for today. We have a working app even if it does not do anything useful yet.
And, as JP is fond to say, “so to bed”.
