Tuesday, August 26, 2008

Tip: How to convert Oracle BLOB to VARCHAR for temporary viewing - SQL

 

   1: SELECT
   2: utl_raw.cast_to_varchar2
   3: (
   4:     dbms_lob.substr
   5:     (
   6:         BLOB_COLUMN, dbms_lob.getLength(BLOB_COLUMN), 1
   7:     )
   8: ) BLOB_AS_VARCHAR
   9: FROM THE_TABE 

Interesting huh?...

Friday, August 01, 2008

Multi-project with Maven

-- PARENT Application Holder
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=BrokerGateway -DartifactId=BrokerGateway -DpackageName= -Dversion=1.0

# Create a new simple project BrokerGateway inside the workspace with eclipse (From the menu bar, select File >New >Project. Select Simple >Project). Eclipse will create a simple .project-file for your BrokerGateway Project and you should be able to see the pom.xml-file.
# Delete the src-folder and open the pom.xml - file to change the packaging of your parent project to pom

  <packaging>pom</packaging>

GO INSIDE PROJECT FOLDER ON COMMAND LINE AND ISSUE THE FOLLOWING COMMANDS

-- Endpoint Module
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=BrokerGateway.EndpointManager -DartifactId=BrokerGatewayEndpointManager -DpackageName=com.reliable.fbs.brokergateway.endpointmanager -Dversion=1.0

-- Entity Module
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=BrokerGateway.EntityManager -DartifactId=BrokerGatewayEntityManager -DpackageName=com.reliable.fbs.brokergateway.business.entity -Dversion=1.0

-- Util Module
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=BrokerGateway.Utils -DartifactId=BrokerGatewayUtils -DpackageName=com.reliable.fbs.brokergateway.utils -Dversion=1.0

-- Web Module
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=BrokerGateway.Web -DartifactId=BrokerGatewayWeb -DpackageName=com.reliable.fbs.brokergateway.web -Dversion=1.0

===========================================================

# Add the newly created modules to your parent pom.

  <modules>
    <module>guide-ide-eclipse-site</module>
    <module>guide-ide-eclipse-core</module>
    <module>guide-ide-eclipse-module1</module>
  </modules>

# Add the parent to the POMs of the new modules:

  <parent>
  <groupId>BrokerGateway</groupId>
  <artifactId>BrokerGateway</artifactId>
  <version>1.0</version>
  </parent>

# Add dependencies to respective modules from module1 to the core-module:

    <dependency>
      <groupId>BrokerGateway.Utils</groupId>
      <artifactId>BrokerGatewayUtils</artifactId>
      <version>1.0</version>
    </dependency>

===========================================================

mvn install
mvn eclipse:eclipse
mvn site -- to generate the documentation website for the app

===========================================================

Check in your project using the eclipse team support (select from the context menu Team >Share Project). Note: Don not check in the generated eclipse files. If you use CVS you should have a .cvsignore-file with the following entries for each module:

---------------------------------------------
target
.classpath
.project
.wtpmodules
---------------------------------------------

Even the parent project should have this .cvsignore-file. Eclipse will automatically generate a new simple .project-file when you check out the project from the repository.

From now on you have different options to proceed. If you are working on all modules simultaneously and you rather have eclipse project dependencies than binary dependencies, you should set up a new workspace and import all projects form step-by-step/guide-ide-eclipse. Note, you have to delete the .project-file of your parent project before. The result is equals to checking out the whole project from the command line, running mvn eclipse:eclipse and finally importing the projects into your eclipse workspace. In both cases you will be able to synchronize your changes using eclipse.

In case of large projects with many people it can be quite tedious to check out all modules and keep them up to date. Especially if you are only interested in one or two modules. In this case using binary dependencies is much more comfortable. Just check out the modules you want to work on with eclipse and run mvn eclipse:eclipse for each module (see also Maven as an external tool). Of course all referenced artifacts have to be available from your maven repository.

Tip: Formatting Numbers in DisplayTag Columns

Displaytag supports easy display of formatted number columns using the format attribute on <display:column> - however, it’s not really well documented on the Displaytag site. Here’s how to do simple number formatting without requiring a decorator class:

<displaytag:column property="amount" title="$ Amount" format="{0,number,#.##}"/> 

This will display a decimal formatted to a maximum of 2 decimal places!