среда, 17 августа 2011 г.

"Soft" pencil down

Hi there,

Now, when became "soft pencil down" date, we have completely finished coding period on project and we are making final code review. So this review aggregates overall changesets which have been made by me, when coding on project. Notably, that during whole summer I have made a lot of changesets. Also, according to community's methodology, every two-three weeks I was making merging of active trunk into my project branch to keep my project up-to-date. This will greatly simplify merge of my project branch into trunk.

As for creating review, I used all possible revisions for code review, except those which are related to merge commits. Strangely, but when I was trying to add those revisions to review, Crucible did not allowed me to do this.

As reviewers for reviewers, I sent notification with invitation for all OpenMRS developers. By default I added to reviewers list four major devs including my mentor.

For now, half of them made about 15% of review. I suppose that review will be done till the ending of this week in the best case (or till the ending of the next week in other case). Next image shows dashboard of this review:

As for currect activity, I'm working on some trunk tickets related to HL7 service within OpenMRS. These are quite interesting tickets and I'm planning to tell you about that in my next post. Also, I'm planning to finish working on project documentation till to ending of this week.

With best regards, Taras Chorny!

воскресенье, 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!

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

Taking part in OpenMRS development sprint and everyday routine

Hi there,

Well, the first month of summer almost gone, there were a lot-lot of interesting things during first three weeks of this month, and last week wasn't exception of that. So, after I finished integration of localization tool into project and provided mechanism of handling error messages, I decided to integrate myself with current community activities. I thought to myself, that taking part in a development sprint would be the best in this case. 

Currently, there is a development sprint that is devoted to order entry. Order entry is a process of electronic entry of medical practitioner instructions for the treatment of patients (particularly hospitalized patients) under his or her care. The main goal of sprint is to create enterprise-quality support for order-entry within OpenMRS. 

So, I joined to that development sprint, choosed the first ticket and began to work. And it began to be very interesting for me, although even if that was introductory ticket of sorts, it was very plesantly to work with whole community, to saw how another tickets were clacked like nuts and how whole sprint work flow is organized. Also was plesantly to saw how well managed work. And, as soon as I closed the first my ticket I immediately took the next one, and then next one. And I was watching, how well was any of code reviews. After any review I was receiving feedbacks about quality of my code, was making follow up changes within code if it was necessary. 

And, you know, watching on all this process, I wanted to be better and more better to help community to make things even better. So, I began to work with twice inspiration. I got the ticket where was needed a lot of work, and done it. In fact, sprint leader praised me and offered to do a really big and interesting. I was very honored, and took that ticket without any doubts. Sprint leader has made some clarifications for me and I began to work on that ticket. And you know, the devil is not so black as he is painted, and I did that ticket. By that time I already have had partial acces to branch, on which is being all work of sprint. So, I was commiting more and more code, was receiving feedbacks, was making follow up changes and to the end of this week I'm about to completely close this ticket. Really, I'm satisfied of work shoulder to shoulder with whole community, it's really great, and I am grateful to them that they gave me such opportunity.

As for my project, this week I also made a lot of routine work. But, in general, probably, you can guess, that usually a lion's share of work consists of routine. Unfortunately, we have no way to getting away of that. So, according to my schedule, I had to perform some pages translation and to merge active trunk into my working branch. And I have done all this things. I can say that they also were useful for me because I improved my knowledges of foreign languages even more. As for merging active trunk into my branch, I did it without any hustle (inter alia, I had only one merging conflict and sucessfully resolved it). This is due to the way how distributed work on whole project and mostly due to that fact, that the component of whole system, on which is targeted my project, isn't frequently changing.

So, I guess that it's all for today, if you have any questions leave them in comments below.

With best regards, Taras Chorny!

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

Providing mechanism for localization of error messages

Hi there,

After succesfull integration of custom localization tool, I began testing how it works. And really, it worked like a charmed, and showed good performance, and I was really happy. But as soon as I missed field for new db name, when filled in form at 2nd step of advanced installation, I was unpleasantly surprised. Regardless, wizard was running in Italian, instead of error message "Base dati di nuova nome è richiesta" I saw "New database name is required" still in English. Cause, I simply forgot about localization of error messages. So, I decided to fix it as soon as possible.
First, that you should know about, that the nature of error messages quite differs from normal messages. The first difference, is that any error message, in comparison with normal GUI message,  won't be shown with 100% of probability. It can be shown, or it can't be shown, it depends. We can say that they are forming dynamicaly. But our localization tool can handle only static messages which are kept inside of messages properties files.So, as conclusion of that, we should have to teach our localization tool to handle such messages. 

So, how did I accomplish that? First, I decided that all error messages should be inside properties files, otherwise, the problem seems to be unsolveable. And as next step, I defined entire set of error messages, which ever can be displayed to user. Then, I completely localized them (it took most of my time). Jumping ahead, I should say that some error messages can be formed from dynamical parts, and it makes additional inconveniences. For representation of such messages I used compound messages. More about them you can read here.
So, after all messages were prepared, I should have find the way, how to point out localization tool, which translation of error message to use. Decision was really simple and graceful at the same time - in all places in code, where forming errors, I used error messages keys. For example, when user didn't fill new db name field, instead of "New database name is required" I put "install.error.dbNewName". Thereby, localization tool will accept such key and load corresponding translation of message fo this key. For handling compound error messages I'm also putting all dynamical part of message with their code together. For this I had to use map for keeping error messages. For this map I used the key of messages as entry's key, and an array of objects as entry's value. As result, in templates handling of error messages proceeds as follows:

        #foreach ($error in $errors.entrySet())
            #if (!$error.getValue())
where $errors - the map, mentioned above, $l10n - our custom localization tool.

So, described above feature really works, and results of its work is shown below:

As you can see, now for italian locale we can see correct translation of message about occured error.

This as all for today, you can leave your comment if you have some questions or suggestions.

With best wishes, Taras Chorny!