Tuesday, August 14, 2007

Tuesday, August 7, 2007

Object graph of "Discipline" class



*Note: The "..." means "Task nn"

Object graph of "Phase" class

Wednesday, July 11, 2007

How to get the "text" value of an XML element in GWT

Hibernating gPasma

In a nutshell, adding Hibernate to a GWT project consists in:

  • Adding the Hibernate libraries (jars) to the classpath
  • Adding your JDBC driver to the classpath
  • Creating Object mappings (.hbm.xml files) between your Beans and DB tables
  • Configuring Hibernate to use your DB and mappings (hibernate.cfg.xml)
  • Configure Log4J (optional - log4j.properties)
  • Creating GWT services that will use Hibernate to access the DB (aService.java, aServiceAsync.java, aServiceImpl.java)
This is the application stack for gPasma (or any GWT and Hibernate app):


The stack identified as 'GWT Services' actually uses the GWT and Hibernate APIs in order to persist the objects. GWT is used to traffic the objects between server and GUI (RPC calls) and Hibernate is used to manage DB sessions, threading and ultimately generating the DB specific calls.

This is a very simplified DB model for the application that will be implemented for this first Hibernate attempt:
The idea behind it is that a 'Process Model' contains 'Process Disciplines' that at their turn contain 'Tasks'. There might be many Process Models but they won't share the disciplines. This basically means that if if we want to generate a new Process Model from a previously existing one, we just copy all the Disciplines and Tasks to the new. Any modifications made only affect the new Process Model, leaving the previous untouched.

An Eclipse project using GWT and Hibernate should look similar to this (very ugly) image:


The items marked with an * are files that have to be changed/added when adding Hibernate to the project.

Tuesday, July 10, 2007

Using TortoiseCVS with eclipse

I find SVN (subversion) a version control system far superior to CVS. In order to try to go around some of it's limitations, I'm using TortoiseCVS.
The default connection method used by eclipse is incompatible with TortoiseCVS.
To be able to use both programs to manage code on the client side, some steps are necessary:

I sucessfully used the method described on the links above ( Generate... and Making...). For loading the keys in Pageant I use a DOS script. The file is named loadKeys.cmd. It expects the key and pageant.exe to be in the same folder; Its contents are as follow:

C:\sshKeys\pageant.exe C:\sshKeys\ssh2RSA.ppk

More Hibernate links

Thursday, June 28, 2007

Object Relational Mapping (Hibernate)

Since GWT seens to be a good framework for the UI AJAX development, it's time to think about the Database.

Hibernate seens to be the most popular ORM framework. This tutorial on Hibernate provides a good introduction to the technology.

The database model most likely will be simple (at least on the first versions) and would not necessarily need an ORM but in order to allow for easier evolution and enhance the overall quality of the software we decided to adopt Hibernate as the standard at the early stages of defining the platform.

Monday, June 25, 2007

Running Tomcat 5.x in pusku under your account

Install Tomcat 5.x according to the installation instructions; then edit $CATALINA_HOME/conf/server.xml by changing the port number like this:


The only way I found an unused port was through trial and error.

Installing XPlanner in pusku

Assuming the war (installation) file has been downloaded from www.xplanner.org and the README.txt has been read, edit
$CATALINA_HOME/webapps/xplanner/WEB-INF/classes/xplanner-custom.properties
:

# XPLANNER CUSTOM PROPERTY FILE
#
# Add any properties you override from their value in xplanner.properties
#
## XPlanner hibernate configuration
hibernate.dialect=com.technoetic.xplanner.db.hibernate.XPlannerMySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.dbname=x00123
hibernate.connection.url=jdbc:mysql://localhost/x00123
hibernate.connection.username=x00123
hibernate.connection.password=mypassword
#hibernate.show_sql=false

## Email configuration
xplanner.application.url=http://localhost:8518/xplanner
xplanner.mail.smtp.host=localhost
xplanner.mail.smtp.port=9876

## Security configuration
#xplanner.security=on

## Send reminder emails on missing time entry
#xplanner.project.send.notification=true

## Include weekends in charts
#xplanner.effort.chart.include.weekends=false

## XPlanner progress bar implementation
#xplanner.progressbar.impl=image

Wednesday, June 20, 2007

GWT first impressions

Google Web Toolkit is a set of libraries (aka. framework) that lets you create AJAX enabled web-sites without having to know any JavaScript or dealing with the inner workings of the protocol.

Basically you create your user interfaces in Java in a way that is similar to AWT or Swing, test, debug it using your java IDE of choice and when you are satisfied compile it to JavaScript to be deployed.

The resulting HTML/JavaScript/CSS files are cross-browser compatible.

If your application depends on server-side inteligence (lets say you access a DB) you will write 'services' (not the same as web-services, beware) in any language you like (just Java is featured on the samples, tough) and call then using GWT RPC calls.

The standard GWT services inherit from the traditional Servlets interface so they can be considered as Servlets, altough you don't generally use any of the Session objects that characterize a Servlet.

These services exchange information with the client in an assyncronous way. The UI call the server and continues working normally. When the answer arrives, it is displayed. That's AJAX.

Information goes to the service in the form of method parameters and returns to the client as a 'callback object'. Both method paramethers and the returned object are required to be 'serializabe' following GWT rules.

Errors come in the form of exceptions and should be taken care in the UI (you could just supress it on the server side, if you want to write bad SW). The standard RPC call should include the methods 'onSucess' where you use the received data and 'onFailure' where you do error treatment.

A big change from previous approaches is that Session state should be managed at client side, not server side. If you want you can still recover the session object and manage state the traditional way, people doesn't seen to be doing that tough. At the very basic, it will require server iterations that are not needed. With AJAX, the client is stateful and the server is stateless.

What came hard to me is how JSP and Servlets mix and match with GWT. The answer is: They don't need to. Altough you can pass information to and from JSP/Servlets via Session objects, you can build any user interface and client/server iteration needed for your application in GWT alone. Unless you need to add AJAX to some specific points in an pre-existing web application, not using JSP or Servlets at all seens to be the easiest way.

Java code used on the client side must be translatable to JavaScript and so is restricted to Java 1.4 specification for the packages java.lang and java.util. On the server side anything can be used, meaning any version of Java, or if you want to take the pain to handle the RPC calls, any programming language.

Styling of the application is done via CSS. The CSS file is defined in the 'module' that defines your GWT application.

Internationalization and Unit Tests (Junit) are easily implemented via the 'stub generating' scripts available. I18n is done via a proprierties file in which the variables representing the strings in your application are entered. You refer to these variables in your code and use the script to compile an interface (that you should implement) that will contain the corresponding strings.

Widgets are user interface objects (like an menu or a navigation tree) that can be used to build your application. GWT ships with a handfull of those that can be combined in 'composites' thus creating new widgets.

There are plenty of freely available composites/Widgets on the internet to implement common functionalities like drag and drop, calendars, color pickers.

Normally you will display the results of your RPC calls using some Widget.


How I created the basic GWT project for gPasma:

This allows the project to be easily imported in Eclipse
projectCreator -eclipse gPasma

Creates the basic folder layout and sample 'hello world' app
applicationCreator -eclipse gPasma com.haagahelia.client.GPasma

The gwt library (from where you run this scripts) must be inside the workspace in order to the 'run' functionality to work from inside Eclipse. I actually suggest the folder for the project is created manually and a folder /lib is added to it with GWT inside it before the scripts are run.

When you download the sources from CVS you will probably have to edit the path to GWT jar files in the following files:

Normal:
gPasma-compile.cmd
gPasmaConstants-i18n.cmd
gPasma-shell.cmd
gPasmaTest-hosted.cmd
gPasmaTest-web.cmd

If you are using Eclipse, then alter the [Path to GWT] and [Path to Proj] in the following files,
where applicable:

.classpath
gPasma.launch
gPasmaConstants-i18n.launch
gPasmaTest-hosted.launch
gPasmaTest.web.launch

The i18n and Test files are used by internationalization and Junit respectively and may not be available in the project yet.

Some references:

GWT site:

http://code.google.com/webtoolkit

Kick start guides:

http://google.wikia.com/wiki/Jump_Start_Your_AJAX_Development_with_the_Google_Web_Toolkit

Making RPC calls:

http://roberthanson.blogspot.com/2006/06/trivial-gwt-example.html

Deploying:

http://jroller.com/page/kenlars99?entry=deploying_the_gwt_dynatable_example

Friday, June 15, 2007

Integrating Eclipse and Tomcat

The installation of eclipse is simple, just unpack it somewhere (like c:) and start it. You will have to point it to your JDK (window->preferences->java).

Tomcat is also simple to install, just unpack it somewhere.

The current version of Eclipse have a feature that allows the integration of application servers (Tomcat, Jboss, etc) to the IDE. That way you can start and stop Tomcat and debug your applications without leaving the IDE. This greatly improves the productivity.

In a previous post I mentioned Tomcat Plug-in that allows this. The new native integration should be better.

Instructions on how to integrate Tomcat to Eclipse are found here:

http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/


In case your 'update manager' doesn't show any URLs (there is no place to get the updates), you can find instructions to add a new one here:

http://www.eclipse.org/callisto/discovery.php

Thursday, June 14, 2007

Installing a issue tracking

After finding a Issue Tracker, the next thing is to figure out where to install it.

Pusku server seemed a good option. The first thing I had to do was to fix the permissions in my home directory, so I could publish pages in the apache server. The default didn't allow apache to CD into my home dir.

This was done with the command:

chmod 701 .

Next, I downloaded one Issue Tracker:

wget http://belnet.dl.sourceforge.net/sourceforge/mantisbt/mantis-1.0.7.tar.gz

Mantis is self-contained and since I had used it before I though it was a good idea to give it a try.

The installation process is simple, the instructions can be found in:

http://manual.mantisbugtracker.com/manual.installation.php

Basically you extract the file, move it to your webserver folder (in my case public_html under my home folder) and open the configuration script on the browser. It can be found in:

http://yoursite/mantis/admin/install.php

There were some issues in the installation:
  1. The hostname for the DB server had to be specified as 'localhost' otherwise the installation failled. It seens that my user doesn't have permissions to use the database from other hosts.
  2. The file 'mantis/config_inc.php' could not be created by the script. Had to create it manually. Again a permissions issue.
  3. Email is disabled from PHP in the server. To avoid error messages, I disabled it in the application. This is done by adding the line: $g_enable_email_notification = 'off';
    to 'config_inc.php'
After installing, the default administrator user have to be disabled and the /admin directory under mantis have to be deleted.

The bug tracking system is available at the URI:
http://pusku.helia.fi/~h00432/mantis/login_page.php

Arthur and I are administrators to the system and can create new users.

Finding an Issue tracking system

To the extent of my knowledge, we are only able to run java based applications on the server. That means we have to find a issue tracking system that runs under Tomcat.

We could start by evaluating this:

http://scarab.tigris.org/ - Scarab, from the sponsors of Subversion


I know also:

Mantis (runs under apache and needs PHP and Mysql)
Bugzilla (runs under apache and needs Perl and MySQL)

Arthur pointed me Xplanner, that is built specifically to manage XP projects:

http://xplanner.org/index.html

Wednesday, June 13, 2007

Installing the original prototype

Installing and running the previous prototype for gPasma

First things first, so the first step was to import the project into CVS.

I decided to import it under the folder 'PasmaTaskLibraryProject\5_implementation\original_prototype' of the repository: '/home/gpasma-1/gpasma-1_valju_pasmaweb/repository'

Next step was to get rid of some word documents that were hanging around with the source files (they were already inside the 'doc' folder) and deleting all the .class files.

Finally to the fun part. After a quick look into the sources I concluded the previous project was using a database schema called 'prosessimalli' and logging in as root to the MySQL server.

Since I don't want to have my MySQL root account open like that I decided to create an unprivileged user called 'proto'.

For this I started my MySQL command line client, log in as root (locally) and issued the commands:


cd C:\Program Files\MySQL\MySQL Server 5.0\bin
mysql -u root -p
  • Starts the mysql command line client
create database prosessimalli;
  • Creates a new database
grant all privileges on prosessimalli.* to proto identified by 'myPass';
  • This gives all privileges on the db 'prosessimalli' to my new user 'proto'
next step is create the tables and populate them. This was done using the existing sql scripts for creating and populating the DB, with the commands:

mysql -u proto -p prosessimalli < sql_lauseet.sql
mysql -u proto -p prosessimalli < insert_tehtava.sql
mysql -u proto -p prosessimalli < insert_tehtavatulos_1.sql

the names after the '<' simbol are the sql scritpts. The password for the user you just created will be asked before the script is run.

In case you are wondering why I used the command line, it is just because I don't have PHPMyAdmin, don't know how to use it and can't be bothered to learn...

Next step is to run the application. Since I had tomcat integrated to Eclipse via TomcatPlug-in (see tools of the trade post) I decide to use it. Here are the steps:

  1. Created a new Tomcat project called 'proto'
  2. Copied the .htm files to the project root
  3. Copied the business, tietokanta and WebGui folders to /web-inf/src
  4. Copied the jsp and lib folders and the web.xml file to /web-inf
  5. restarted Tomcat and accessed the URI: http://localhost:8080/proto/
Default user names and passwords for the application:

Regular user: kirkas
pass: aurinko

Admin user: sininen
pass: meri

Saturday, June 9, 2007

Tools of the trade

These are the programs we are using in the development:

  • Windows XP
    • Originally installed on the laptops
  • Openoffice
    • Back office suite. For reading existing documentation (.doc) and creating new.
  • Gimp
    • Bitmap Image editing
  • GTK
    • Gnome toolkit. Required by Gimp.
  • InkScape
    • Vector graphics (logos) editing/creating
  • MySQL
    • Database for local development
  • Eclipse (www.eclipse.org)
    • Official IDE for this project
  • Tomcat 6 (http://tomcat.apache.org/download-60.cgi)
    • Java application server
  • Tomcat 5.5.23 (http://tomcat.apache.org/download-55.cgi)
    • Tomcat 6 is new and isn't integrated natively yet into eclipse...
  • Netbeans
    • Alternative IDE
  • TortoiseCVS
    • UI for CVS
  • CVS
    • Version controlling
  • Firefox
    • Standards are so good that Microsoft creates it's own. Because of that, web applications need to be tested in the most popular browsers.
  • 7-zip
    • Open source compressing utility
  • VM-Ware Server
    • For running Linux under windows
  • cgywin (http://www.cygwin.com/)
    • Running X applications remotelly
  • Ubuntu Linux 7
    • Just in case I get bored of blue screens of death
  • JDK 6 (www.java.sun.com)
    • Java development Kit, latest version.
  • Firebug (http://www.getfirebug.com/)
    • Real time CSS, JavaScript, HTML debbuger Firefox plug-in
  • Eclipse Tomcat launcher plug-in (http://www.eclipsetotale.com/tomcatPlugin.html#A3)
    • Basically lets you control Tomcat from eclipse and enables debbuging. Tutorial on installing it : http://www.eclipsetotale.com/tomcatPlugin.html#A3 or http://plato.acadiau.ca/courses/comp/dsilver/2513/EclipseAndTomcatTutorial/
  • PUTTY
    • SSH and SCP client to connect to the network server
  • TextPad
    • For when you need a text editor that will just open your files whith no questioning.
  • WinSCP (http://winscp.net/)
    • For copying files easily between windows and the Linux server.
  • Azureus
    • For downloading torrents (like huge programs)
  • Google browser sync
    • Syncronize bookmarks and browser settings between different computers
  • Cute PDF Writer
    • Free PDF generator via print dialog
  • WinMerge
    • Compare files (Diff) and let you conciliate the changes.

Friday, June 1, 2007

EPF key concepts

This is a list of the key concepts of EPF composer. For a more detailed overview check:

http://www.eclipse.org/epf/general/EPFComposerOverviewPart1.pdf

  • Role - someone involved in the SW creation process. Ex. SW developer, Analyst
  • Work product - The result of a task. Ex. A class diagram, a prototype
  • Artifact - same as work product
  • Task - An set of actions that consumes and/or produces artifacts/work products. Performed by roles.
  • Configuration - A process tailored to the company's needs. Ex. some tasks left out, some guidance added.
  • Guidance - Information about the development process. Ex. whitepapers, graphics, links, texts.