воскресенье, 31 июля 2011 г.

Improving custom LocalizationTool class

Hi there,

During whole this week, I'm being worried with the best solution about using ResourceTool class (exactly our subclass of this - LocalizationTool). At first, let me tell you pre-history of this. At the beggining of this week me and my mentor were continuing review of code and were making testing of project. Notably, that we noticed one serious bug related to extending ResourceTool class. Even if this it worked, we weren't satisfied of such solution because it was not quite reusable. So, we were targeted on receiving more simple and more usable subclass of velocity resource tool at the same time.

As you can found out from the source code of ResourceTool (see the latest version on grepcode), guys, who has implemented ResourceTool class, has screwed up with design of that tool. But nevertheless, I did not believe, that they were so bleary-eyed  and, suspecting that something wrong with that "grepcode", I have downloaded source code of ResourceTool directly from repository. And, surprisingly, I found out that it quite differs from the "grepcode" version. Looking at that source code I noticed, that desired solution can be simply achieved by changing only one method that loads resource bundles. The only one method, it's great - I was thinking to myself!! And I've already done it and have tested. It works. See result version of code for localiztion tool class below:

 * This class is intended for accessing {@link ResourceBundle} and formatting messages therein.
public class LocalizationTool extends ResourceTool {

* Its need to override base class method to be able to change its locale property outside the
* class hierarchy
public void setLocale(Locale locale) {

* To be able to load resource bundles outside the class path we need to override this method
protected ResourceBundle getBundle(String baseName, Object loc) {
Locale locale = (loc == null) ? getLocale() : LocaleUtility.fromSpecification(String.valueOf(loc));
if (baseName == null || locale == null) {
return null;
return CustomResourseLoader.getInstance(null).getResourceBundle(locale);

This is truly very simple and much reusable then the one that was before. I think you'll like that solution because of its grace and simplicity. I've committed the appropriate changeset. Also I've merged trunk into my branch to keep  my project in accordance to current trunk code. I think, that received solution is much better that the one, that was before.

That is all for today, you can leave your opinion in the commants section below.

With best wishes, Taras Chorny!

воскресенье, 24 июля 2011 г.

Testing and bugs removing before merging into trunk

Hi there,

Suddenly, this summer came across its middle and brought me onto the straight way of project completion. And, you know, after midterm date, the time passes much more faster then before this. This week was a proof of that fact. May be, that is because I've had a lot of work, but regardless. What interesting happened with me and my project (or together) this week? In few words, I was working on rigorous testing of project functionality and bugs removing. So, let don't jumping ahead, and tell everything one-by-one.

The first and the most important fix within my project was related to changing the way how we are handling our custom localization tool within velocity's ToolContext. As you should have known, earlier ToolContext has been configuring once per session (or more, depends if user wanted to change his preferred language on first page during wizard running). But the main drawback of this was that fact that we shoul keep a map of tool contexts an clients sessions. This isn't appropriate taking into account that fact that in general, only one user will have an opportunity to run installation progress at the same time and others will be able only to review progress of installation. So, we decided to reject the idea of sessions and tool context with a session scope map and use single tool context with localization tool, that has request scope of sorts therein. Let me explain. In this case, tool context object will be one per application, but on receiving each next request, we'll change the locale property of our custom localization tool, which is contained inside corresponding toolbox object (ToolContext, in turn, contains that toolbox). So, I fixed it as told above and tested it. Notably, that result was succesfull, and performance left in appropriate level too.

The next thing, I changed the technical way how we are persisting user selected language. After code review with my mentor I was inclined to use pure JDBC to accomplish it. That is because we have decided, that using of OpenMRS Context object isn't a good practice in this case, specially, when OpenMRS application is not directly started till the moment, when we are saving user's preferred locale.So, I changed it, used raw Connection and PreparedStatement objects to persist user's selected language.

Also, during the code review, we found out that there are some of GUI messages, which aren't localized yet. So, I immediately started performing of corresponding translation and done this task in an hour.

Next, we decided to use chooselang.vm page as default page of installation wizard. And now, when some critical error occurs during wizard running, the user will be redirected to that page, instead of installmethod.vm template page.

May be, this isall that I'd like to tell you about work on my project this week, because rest things are mostly boring routine.

And as for work with community this week, in general I was working on ticket the main aim of which is to prevent multiple users to run installation wizard at the same time. I made couple of patches for that ticket. They should be applied to trunk and will be included into OpenMRS, which is coming soon. But, perhaps, this is a topic of my next week post.

With best regards, Taras Chorny!

суббота, 9 июля 2011 г.

Summing up before midterm

Hi there,

We are on the porch of the midterm and looking back on the way, that we have passed, I'm understanding that there were a lot of interesting moments and we have done truly important job. Making evaluation of our work, I'm sure, that we have done about 75% of work or even greater and all this due to having excellent time planning. Really, when we were planning our work we were inclined to put things with greater risk into beginning of the time line to be sure that they will be done as soon as possible. Also it looks very convenient to solve more difficult tasks when you are fresh and full of energy. And yes, our plan had worked and we have done integration of localization tool for velocity templates a week earlier than we had expected.

Generally, the complexity of that work was slightly more than medium (7 on a scale from 1 to 10). It requires a hard thought work, because you need think over a lot of aspects to make different things be able to work together. The complexity of  another tasks was slightly less than medium (4 on a scale from 1 to 10). But those tasks took really a lot of time.

Work on performing of translations consists of routine and routine once again. When you are doing this, you should try various variants of word-combinations to provide the most suitable translation which conveys the meaning as best as possible. You are changing sentence structure several times and finally, you are having translation that meets all your requirements. And this is really routine because you're repeating the same operations a lot of times. Regardless, such work have one great advantage that  overcomes all its drawbacks. You are opening a lot of truly useful knowlege about cultural and language features of other countries.

And due to this, now I know an answer to one of questions, which were interesting to me all time. How can man learn more than 20 foreign languages? And the answer, I believe, is that many languages ​​are very similar, since they belong to one ethnic group languages. For example, Romance languages group includes Italian, French, Spanish and Portuguese languages. All those languages descend from Vulgar Latin, the language of ancient Rome. And basically they are really similar, because they have a slightly similar alphabet, lexical and semantic sentence structure and etc. And the translations into these languages ​​have many common. The same thing can be said about British languages group.

So, all these kinds of work are really interesting because they can make you better as developer and help you more diversify as a person. And, if we add to this work within community, we will have truly useful pastime. Sometimes, when I'm returning to home little sad and tired I'm sitting at my computer, beginning to work with my community and sadness dissipate by itself. And this is one of the many plesant things that can happen with you, when you participate in this surprising program with such a cool community.

With best wishes, Taras Chorny!

суббота, 2 июля 2011 г.

Preparing first presentation and localizing pages for testing way of installation OpenMRS data base

Hi there,

Сoming an hour when I will have to show my first presentation about work that I've already done. Actually, it will be 14th of July, and till this date I should prepare it and rehearse with my mentor. But, I was not waiting too long, and immediately after the group B, I started working on my own presentation. At the beginning, truth, I was worried about it, because I did not do anything like that before. But, If you can't stand the heat, stay out of the kitchen. And being thinking about this proverb, I began to work on my presentation. First, that I did, I discussed idea of presentation and plan with my mentor, and after that I have had clear goal and the way how to achieve it. So, all that remained to be done, this is to be creative and try to present everything the more clear as possible. Although, there are some restrictions for presentation:
  1. it should take 10 min;
  2. since it will be closer to the midterm, it should be focused both on design startegy and on some demos;
  3. inter alia, it should be interesting and not boring, because I scheduled to show it at the end of the list and attendees, probably, can be bit tired.
Easier said than done. And soon after the day of creative work I have had complete draft version of my presentation. I was really happy, prepared draft speech and sent it to my mentor for checking. He reviewed it, made some comments and gave me his feedback. I fixed his comments and now, I do beleive that next week we will have complete version of presentation.  

Next interesting thing, that I have had this week, it was participating in development sprint. I was really impressed of how well managed sprints in our community last week and with great pleasure worked on tickets within sprint this week. Mostly, my work this week was related to unit testing, and I wrote a several tests and fixed some of already existing ones. The main aim for me, when I was writting tests, was to make them "green" and to cover most common test cases for different functionality. And due to good help that I received from sprint leader, I have done my work as soon as possible without any hustle.
And the last thing, that I'd like to tell you this week it's about my work on providing localization for new way of installation OpenMRS data base (this is testing installation). It work was closely related to installation wizard. You may ask me why I'm doing this work only now, I'm reaching out for you. Because it was added to the trunk quite recently. So, first, I merged active trunk into working copy of my branch, resolved all conflicts (this time, there were a lot of conflicts, and I had to work hard on them). After succesfull merging I noticed, that I should localize one new page, and add localization support for existing one. Also I had to handle additional error messages which are related to new way of OpenMRS data base installation. What turned out from that, you can see on figures below:

This figure shows updated page for selecting way of installation. Testing way of installation was added into the bootom of page. All messages related to that way were translated and added into web app's messages resources files. The next picture shows new one page for setting testing database installayion properties. All GUI messages for this page were localized too.

So, more than enough is too much. You can leave your opinion within comments below.

With best wishes, Taras Chorny!