Tuesday, March 30, 2010

From database table to Excel with Groovy

I have a MySQL table with customers data and I want to select records and create an Excel CSV file from them. This can be easily done in Groovy with few lines of code:

package it.alfresco.groovy

import groovy.sql.Sql

def sql = Sql.newInstance("jdbc:mysql://localhost:3306/test",
"root", "******", "com.mysql.jdbc.Driver")

def query = "select * from webinar order by company"

outFile = new File("/Users/mturatti/Desktop/Roadshow.csv")
appendFlag = false
outStream = new FileOutputStream(outFile, appendFlag)
writer = new FileWriter(outFile, appendFlag)
outChannel = outStream.channel

outFile << "Firstname; Lastname; Email; Company; Job Title; Process\r\n"
sql.eachRow(query, { outFile << "${it.firstname}; ${it.lastname}; ${it.email}; ${it.company}; ${it.title}; 1\r" });

println outFile.text.size()
The table contains the following columns: firstname, lastname, email, company, title.
The resulting CSV file can be opened by Excel and Openoffice.

Sunday, December 20, 2009

Spring 3.0 GA

Spring 3.0 is now GA. Spring has already fully demonstrated to be a successful alternative to EJB development. JEE 6 has learnt from Spring and simplified a lot enterprise Java development, becoming much more lightweight and usable. It shows that some good degree of competition can improve the market, but I hope Spring will keep following its own philosophy instead of trying too much to compete with JEE. the risk I see is that Spring could become too wide and difficult to understand.
Spring has demonstrated that the open community can produce better products than vendors' committees, so keep doing the good job of simplifying enterprise development.

Friday, December 11, 2009

Competitive Strategies

If you want to learn and discuss about competitive strategy, my friend Marco has started a very interesting blog on the subject. As an expert manager and consultant, Marco collects is thoughts and discuss books and articles about strategic management. Sometime we need to stop, exit from day by day activities and think out of the box to evaluate whether we are following a strategic path or just following short-term tactics.

Somebody once wrote: Strategy without tactic is a dream. Tactic without strategy is a nightmare.

Tuesday, November 3, 2009

Fuji Simple Service API, SpringDM and OSGi Integration with JBI

Sujit Biswas wrote an interesting article which:

"[...] shows how to integrate Fuji simple service api with spring/springDM application, We will create a springDM application which instantiates the above provider Implementation , based on spring-config and spring-osgi-config files."

Fuji allows for Spring and OSGi services integration

"The simple service provides the capability to invoke/interact with JAVA code outside of JBI, i.e Service API provides a bridge between code that is hosted outside of a JBI component and service endpoints available on the NMR."

This enables integration of OSGI/POJO services with JBI. Read Sujit's article for more.

About Fuji:

"Project Fuji forms the core component of Open ESB v3 effort and represents Sun's next generation open source integration runtime, focused on providing a lightweight, developer-friendly, and extensible platform for composite application development.

At the core of Project Fuji is a lightweight micro-kernel based on JBI (JSR 208) and OSGi. Packaged as an OSGi bundle, the micro-kernel can be installed in any OSGi R4 compliant runtime (such as Felix, Knopflerfish or Equinox), including GlassFish v3. JSR 208 support introduces a robust, message-based service bus to the OSGi environment and allows the wide range of existing JBI "components" (adapters and containers) to run in Fuji.

Developer experience is a primary focal point in Fuji as evidenced by the level of flexibility and accessibility offered in the platform. Starting with a rapid, top-down development language, IFL (Integration Flow Language), developers can quickly and easily generate an integration application using a domain-specific grammar. The service development model favors convention and configuration over boilerplate code and framework APIs, allowing integration developers to focus on the code that matters. "

Sunday, October 11, 2009