Wednesday, November 03, 2010

Got published, again!

What? .. "Defining a Coparticipation Network Using Comments on Digg"
Where? .. IEEE Intelligent Systems
Why? .. Because he's a genius.

Link: http://www.computer.org/portal/web/csdl/doi/10.1109/MIS.2010.98

Tuesday, August 24, 2010

Liferay Performance Tuning

This stuff is really exciting. So I've got a few days to compare a bundled liferay out-of-the-box instance with the one that's enhanced by our company for a certain client. I'll be responsible to analyze the difference in performance statistics by profiling the application. I started off with Grinder and just recently learned about the visually appealing VisualVM.

Apparently, I'll have to collect stats from both of the tools to summarize the overall difference. Ideally, I'd be able to pinpoint the exact methods that must be rewritten to improve the performance. Instrumenting the CPU using VisualVM by limiting it Liferay specific classes seems like a good idea.

Let's see. I'll try to update this post with results, if and when I get them :)

Thursday, July 29, 2010

Struts2 - Adding Properties to the pageContext

In struts2, to access a property inside a JSP that we set in the overridden execute method of Action Interface, we use the following property tag:
<s:property value="results" />
where s is an alias for struts-tags tag library and results is a Collection (can be anything) that we've populated in execute method. Note here that it must be a variable/property in you action handler class with both of its getter and setter methods available. The property tag will call the getResults() getter method.
This is clean. But it should be noted that results is not available in the pageContext of the page being processed currently. So, for example, if you want to use the results collection inside a jsp scriptlet by doing something like
pageContext.getAttribute("results")
this will not work. You cannot even say something like
request.getAttribute("results")
Anyways, it's possible and pretty clean too :) All you've to do is to set the pageContext attribute by using another struts tag,
<s:set name="pageResults" value="%{results}" />
This is equivalent to
pageContext.setAttribute("pageResults",results)
but the later won't work. The name is what you want to name the results in the pageContext, like a variable name; and the value is its value. So here, Set tag will call getResults() and assign the returned value to a pageContext variable called pageResults.

That's it :)

Friday, June 11, 2010

Grails and MySQL - Enforcing Foreign Key Constraints

Problem

Imagine a scenario where you've two Grails domains called Book and BookAuthor (could by anything) with there respective MySQL tables. You've made sure that every time a Book is created, it must be associated to some BookAuthor by adding something like

BookAuthor author

in your Book domain. Also, you don't have to do anything in BookAuthor domain. Now when someone deletes a BookAuthor, Grails should enforce the foreign key constraint and does not allow it to happen. However, it does and the BookAuthor gets deleted. On top of that, the Book domain is now broken, because all the Books with the deleted BookAuthor as their author are now broken.

Solution

I was hinted that this can be prevented by using InnoDB as the storage engine for those particular tables. For details, read this, or this. For a quick solution, all you've to do is to add the following in your DataSource.groovy in the dataSource enclosure:

dialect = 'org.hibernate.dialect.MySQL5InnoDBDialect'

I dropped the database and let Grails recreate it because the tables have to be created with InnoDB as the storage engine. Note here that the default storage engine that MySQL uses while creating the tables is MyISAM.

This solved things for me. Now, whenever someone tries to delete a BookAuthor, which is associated to some Book, it is prevented by Grails with this message - "The BookAuthor id1 cannot be deleted" .. that's it :)

Happy coding, thanks!

Wednesday, March 31, 2010

About Sentiment Analysis

http://www.ubervu.com/help/analytics/#analyticsq6

I wish I had filed a patent or something :(

It's going to be big. I was able to foresee the potential in sentiment analysis, but never got time to finish it ... anyways, kudos to ubervu - I'll be an spectator :)

Wednesday, March 24, 2010

Feelings poster

I am just loving this!



http://www.ctherapy.com/Results_Pages/descriptions.asp?ProductID=M1000