Friday, January 11, 2008

Fixed some bugs in the implementation of Yen's algorithm

I feel good after I fixed the bug in the implementation of Yen's algorithm. It turned out that I had a incorrect definition of Comparator for the class of "CQYDirectedPath". It's really painful to read the code (even it's me who created these codes) and figure out what's going on. But it's probably worth, because I start thinking of re-implement this algorithm in Java. After I uploaded the latest version, I found there was another guy left a comment, which is about another bug in my code. In his case, there are duplicate edges in the graph file,  my program can not correctly calculate the number of edges. It's relatively easy to solve this problem. Now, we have version 1.0.2.

Sunday, December 30, 2007

Create a new portlet in tDar

In order to add one new portlet in the tDar portal. Some basic procedures are required to follow:
  1. Create a class which inherits from "org.gridlab.gridsphere.provider.event.jsr.ActionFormEvent";
    1. It's better to create a separated project for the new porlet; in the project, we have
      1. a directory 'src'
      2. a directory 'webapp', under which some important configuration files are, like portlet.xml, layout.xml.
      3. build.properties
      4. build.xml: configurations about the compiling, deployment etc. (probably manual changes are required)
  2. Make relative configurations
    1. webapp/WEB-INF/portlet.xml:
      1. description information about the portlet class
    2. conf/gridsphere/layout.xml
      1. description information about the portlet class
    3. build.xml:
      1. add the build information about the new portlet
  3. Run 'ant deploy', and restart tomcat.

A good idea might be to create a code template for a new porlet.

tDar Setup Guide

To set up the tDar environment, there are some basic procedures to follows. At this time, we use the package provided by Allen, and it makes the work much easier.
  1. All files including scripts, classes, jsp, libs etc, are all put in the directory "geon-tomcat"; first download this directory and put it in the local machine (say, C:/).
  2. We also need download another package "work", where all source codes and necessary third-party libraries are for the purpose of development.
  3. Preparation of Database
    1. Install PostgreSQL 8.x, and start the db service; (probably some configurations should be done)
    2. Create a user "geonportaluser", it should be easy if pgAdmin.exe is used.
    3. Create databases, "geonportaldb", "geoncat" and "tdar". (owner is "geonportaluser").
    4. Import the data from dump files "geoncat.dump" and "geonportaldb.dump", by the following command:
      1. psql -U geonportaluser $db < $db.dump;
    5. "cd work", and run the command, "ant init-db" to create tables in the database "tdar".
  4. Create environment variables:
    1. $JAVA_HOME : where Java directory is;
    2. $PATH : where Java bin directory is.
    3. Example:
      1. export JAVA_HOME=/usr/lib/jvm/java-6-sun
      2. export PATH=$PATH:$JAVA_HOME/bin
  5. Start of Tomcat: go to the directory "geon-tomcat/bin", and run the command:
    1. Linux:  "sudo ./startup.sh";
    2. Window: "startup.exe" (the link: http://testdrive.mapinfo.com/techsupp/miprod.nsf/kbase_by_product/87B9844AF29A886D852570530054F28B could help!)


Monday, December 24, 2007

Create a Spring project in Eclipse

First, let's take a look at how to create a Spring project in Eclipse. I would like to put the procedure step by step as follows. We assume that the project we're creating is a regular java project. There are some different ways to create a Spring project in Eclipse.  You can create a Spring project by using an Eclipse plug-in for Spring, such as Sping IDE; and you can also use existing example codes as a template, and you can also do everything just from scratch. I believe the last one is always a good choice because people can really learn something from the procedure.

But as I am also a beginner for Spring, I decide to use the simplest way first of all. I first installed the Spring IDE for Eclipse, by the URL: http://springide.org/updatesite. Note that:
Don't try to install the "Spring IDE Dependencies (only for Eclipse 3.2.x)" from the "Dependency" category on Eclipse 3.3. This feature is intended only for Eclipse 3.2 and is to keep Spring IDE backward-compatible. You will not be able to continue with the installation if you select this feature on Eclipse 3.3
It seems taking a while to download all packages, since it's composed of many library files. In the end, I found it doesn't help much with the project construction, since it doesn't generate the configure XML file for you, doesn't add the necessary third-party libraries for you, ... It seems to do nothing for you! Not lucky! We must take the last choice anyway. Probably it's a better idea to start with walking instead of running.

Before starting, we need download some third-party libraries, which would be mentioned later during the construction.
  1. Open Eclipse.
  2. New a Java project.
  3. Compile "applicationContext.xml" file, a simple template can be like, (nice, the format is kept when I did C&P.)
    1. <?xml version="1.0"?>
<!-- The template of configuration file for Spring framework. @author Yan Qi, @date 20071224 -->
<bean id="test" class="">
  <property name="">
    <bean class=""/>
  </property>
</bean>
</beans>
  1. Create source codes.
  2. Basically, at least two libraries are necessary, including spring.jar, commons-logging.jar. Add them in the lib path.
  3. One package as an example is below: http://ficsr.googlecode.com/files/LearningSpring.zip

That's it! I believe it's a good starting point to study Spring.

Coming back

Sometimes, people could be lost somewhere you never know. Not every one can come back though. About those who finally make it, I believe there must be one moment: all of a sudden, everything becomes making sense again!
Then, welcome back, my friend!