Monthly Archives: March 2014

A blog about things 2014-03-10 14:03:00

Since my last Blog I have done a lot of work to get my workspace up and running. I first had to download and install java EE version of Eclipse from http://www.eclipse.org/downloads/

Once I had the EE version of eclipse i set out to make sure that EGit was installed and configured. It was already installed out of the box. So I cloned my project and then imported it into eclipse as a maven project. All this was done by following these instructions
Once that project was in my eclipse I built it by right clicking on the project -> Run As->Maven Clean. Then right clicking on the project -> Run As->Maven install. 
This kicks out a open.war to webapps/target folder. Then I deploy the openmrs.war to webapps folder in tomcat and am able to access the site via localhost:8080/openmrs. 

From the blog A blog about things by TRStaake and used with permission of the author. All other rights reserved by the author.

New Issue!

When we arrived at class last Monday we realized our issue had now been assigned to another developer. So then the hunt began and we eventually found an issue TRUNK-3009. We all are now tackling the replacement of “Global Properties” throughout the vast Wiki OpenMRS has.

From the blog tbruceblog » cs401 by tbruce731 and used with permission of the author. All other rights reserved by the author.

Group Status Report

As a group, we started the week finding out that our original ticket, TRUNK-324, had been claimed by someone else. We had a quick meeting and agreed to work on the TRUNK-3009 instead. TRUNK-3009 is a documentation bug.

For this ticket we are supposed to look for all references in the wiki to Global Preferences, and change them to Settings. According to the description given in OpenMRS the “Global Properties” page was renamed and updated to just a “Settings” page for version 1.9. So if the wiki mentions GPs they need to be updated, as there are still hundreds of references to Global Properties on the wiki.

The description of the bug is somewhat vague, so before we start working on this one of our team member, Connor Kelly, put a comment on the page to make sure that our understanding of the ticket is what they want. The comment was as follows:

“My intention is to go through the whole wiki and replace any instance of “Global Properties” or “global properties” with “Settings (formerly Global properties)”, is my undesrtanding correct on this or am I missing something? I don’t want to mess up the whole wiki.”

On Saturday, March 8, 2014, we got an answer on the comment saying that the update should include that the change only affects version 1.9 and above.

We are now ready to get started on searching and replacing any string “global property” within the wiki page.

The change and what users will find while reading the wiki page is as follows:

Settings (formerly Global Properties 1.8 and below)

Finally, as a group we have agreed to split up the documentation section found in the left panel of the OpenMRS Wiki home page.

From the blog Naty Zelaya » CS@Worcester by natyzelaya and used with permission of the author. All other rights reserved by the author.

More Readings…

Well, finally got the files and such accessible from my own computer in eclipse, which was more of a hassle than I really expected, I found I had to read up more on JUnits and how they work. Took a bit of time looking through various online sources, so now I feel like I can really get into this.

Hopefully, at least. Jury might still be out on that one. Learned a few new things, at least.

From the blog Kyle's Works » CS@Worcester by kyleprimmer and used with permission of the author. All other rights reserved by the author.

First Bug Attempt

This week got off to a bumpy start when someone else claimed the bug that my group had decided to work on the week before. However, we got together in class and decided that it would be good to work on another documentation bug, specifically one about editing the wiki to reflect a naming change. However, we had a question about what the desired edit’s should look like, so I posted a question to the bug. After a couple of days I finally got an answer back, so now we are able to start working on and hopefully finish that bug in the next week. 

From the blog ckelley6 » CS401 by ckelley6 and used with permission of the author. All other rights reserved by the author.

Functional Reactive Programming in Scheme with guile-2d

Last month, the GNU Guile project celebrated the 3rd anniversary of
its 2.0 release with a hacker potluck. Guilers were encouraged to
bring a tasty hack to the mailing list to share with everyone. My
dish was a simple functional reactive programming library.

Functional reactive programming (FRP) provides a way to describe
time-varying values and their relationships using a functional and
declarative programming style. To understand what this means, let’s
investigate a typical variable definition in Scheme. The expression
(define c (+ a b)) defines the variable c to be the sum of
variables a and b at the time of evaluation. If a or
b is assigned a new value, c remains the same. However, for
applications that deal with state that transforms over time, it would
be convenient if we could define c to react to changes in a
and b by recomputing the sum. Contrast this approach with the
more traditional style of modeling dynamic state via events and
callbacks. A lot of programmers, myself included, have written code
with so many callbacks that the resulting program is unmaintainable
spaghetti code. Callback hell is real, but if you accept FRP into
your heart then you will be saved!

By now you’re probably wondering: "What the hell does all this mean?"
So, here’s a real-world example of guile-2d’s FRP API:

(define-signal position
  (signal-fold v+ (vector2 320 240)
               (signal-map (lambda (v)
                             (vscale v 4))
                           (signal-sample game-agenda 1 key-arrows))))

In guile-2d, time-varying values are called "signals". The above
signal describes a relationship between the arrow keys on the keyboard
and the position of the player. signal-sample is used to trigger
a signal update upon every game tick that provides the current state
of the arrow keys. key-arrows is a vector2 that maps to the
current state of the arrow keys, allowing for 8 direction movement.
This vector2 is then scaled 4x to make the player move faster.
Finally, the scaled vector is added to the previous player position
via signal-fold. The player’s position is at (320, 240)
initially. As you can see, there are no callbacks and explicit
mutation needed. Those details have been abstracted away, freeing the
programmer to focus on more important things.

I think it’s helpful to see FRP in action to really appreciate the
magic. So, check out this screencast!

To see all of the juicy implementation details, check out the git
repository
. Thanks for following along!

From the blog dthompson by David Thompson and used with permission of the author. All other rights reserved by the author.

Digging Into OpenMRS

This week TR and I met up to discuss our ticket and finish setting up our machines for implementation. Once we finished installing OpenMRS and successfully logged in as Super we focused on choosing an IDE for development. We decided to go with Eclipse Kepler(4.3.2) version because it already comes pre-packaged with development tools such as Git and CVS which makes importing Git projects a snap. I was pleasantly surprised at how effortless it was to clone the omrs repository and import the omrs-core into the Package Explorer in Eclipse. Once we imported the files and ran a successful ant build we felt confident that our machine was set up correctly, we then turned our attention to understanding how the OpenMRS system works, more specifically how the patient drug regiment system functions, since this is where we are going to be doing our implementation. Once we became familiar with the patient regiment tab/page itself we started to analyze the patch that was implemented back in 2012. The patch itself is a decent size with absolutely no comments. It contains a mixture of Java, JavaScript and HTML and references several classes. We emailed the composer of the patch, but our email has yet to be answered. Working through the patch I have been tracing back to the origin of the included calls and functions. In doing so, I have had much success and feel confident that I have narrowed down the amount of classes where implementation will be needed to about five. I have begun to study these various classes. The majority of these classes are *.jsp and servlets and once again commenting is at a minimum, so more time will be needed to analyze exactly what calls what and where functions are being passed to. This Sunday TR and I will be meting again to set up some short term goals including a greater understanding of the classes, injecting some code and testing it on our local machines.
Till Next Time,
Matthew Lopatka

From the blog mlopatka by matthewlopatka and used with permission of the author. All other rights reserved by the author.

Android ImageView’s and Out of Memory Errors

It has been a rather unfruitful couple of weeks.  I have been battling with Android’s infamous out of memory errors for most of the past two weeks.  It has been seemingly impossible to find a solution for my app which satisfies all of its necessary requirements.  I would like to have an independent class for handling the execution of images on a background thread.  I also want that class to create Bitmaps, which fit the ImageView so as to not waste heap space.  Then I want to cache those images, to increase load times while avoiding the creation of duplicate bitmaps, again saving heap space.  So what are the problems?

Well for starters, I need some way of grabbing the width and height of the ImageView; which is more difficult than you would expect.  You cannot simply create an ImageView in the activities onCreate method and call its getWidth and getHeight methods because the screen has not been laid out yet. One way you can get around this is to use the ViewTreeObserver class to set up an OnPreDrawListener or a GlobalLayoutListener, then grab the image width and height from within them.  For example, you can override the onPreDraw method within the OnPreDrawListener and fire any code you want from within there. The Android developers page says onPreDraw is the “Callback method to be invoked when the view tree is about to be drawn”.  The method is constantly being called; perhaps every time the screen refreshes.  That means to use it I needed some kind of catch so my code only fires when a new bitmap is loaded. It was simple enough to handle with a boolean value, but it seemed wasteful to be in a constant cycle when I only need the value once.   Another attempt I made was to override the onWindowFocusChanged method in the Activity classes, which holds my fragments and then call a custom method within the fragments to populate the imageView with the properly sized bitmap.  At first I thought it worked, but the method is only called when the activity sets up, not when each fragment is loaded.  That, and it was not a very modular approach requiring a method override in every activity where I wanted to use images.

In the end, I settled on a different solution.  I had seen a blog, before this out of memory issue ever began; and I was able to implement the solution.  I searched for the blog again but I could not find it, I think because it was a link within one of the hundreds of Stack Overflow posts I have been reading lately.  That said, if I come across the blog again I will post the link.

Anyway, the idea was to add a CustomView class to a FrameLayout and within the CustomView class override the onSizeChanged method.  Then within that method, you can set the newX and newY parameter values as your width and height for the bitmap you want to create.  Originally, I did not want to use this approach because wrapping my imageView in a FrameLayout seemed unnecessary.  OnSizeChanged is not called if you don’t add the CustomView to the FrameLayout.  It also turns out that Layouts in general provide some basic animations for developers.  That was a bonus, unfortunately the animations I made felt a bit clunky and created unnecessary animation delays.  I decided to avoid animation for now, at least until I understand a bit more about it.  Also, I don’t want to waste any of my semester on unnecessary improvements until the basic functions are complete.  In any event, I had overcome the first unexpected hurdle of the week and am now able to generate properly sized bitmaps.  I used the suggested code from the Android Developers page for decoding large bitmaps.

Unfortunately, loading properly sized bitmaps did not fix the out of memory issue, but it was happening less frequently.  I decided I would continue following the advice on the Android developers sight regarding Displaying Bitmaps Efficiently  at https://developer.android.com/training/displaying-bitmaps/index.html as best I could.  Personally, I find there to be a huge lack of details on the Android developers page, which can make implementing their code difficult at times.

I eventually was able to use the AsyncTask class to handle my images on an independent thread, build a cache for the images, and create custom sized bitmaps all in one class that extends View in order to grab the ImageView dimensions.  Along with some clean up in the onDestroy methods of my fragments; I managed to greatly reduce the memory leak to the point where a user would need to button mash through the pictures for a long time before it would crash.  However, this was obviously still unacceptable.

The leak left was much to small to crash the app when used normally, but I knew it was there and it irritated me to no end.  I eventually realized I was creating a new custom view each time I was loading an image, instead of overwriting the same view.  I also discovered that some of what I thought was a memory leak is not,  in the case of loading multiple images in and out of the same ImageView the heap space will appear to be growing by a few kilobytes each time the image changes.  However, that memory is eventually reclaimed, perhaps it is simply the heap space becoming fragmented which is eventually cleaned up, but I am really not sure.  To be sure there was no longer a leak though, I set up an onPreDrawListener which changed the image every time it was called, many times each second.  Then I left the app to run for a couple of hours loading images on my Samsung Galaxy S3 and it no longer crashed due to an out of memory error.  Success!

In the end, I actually decided to remove the cache logic.  My reasons are the cache requires more heap space for storing multiple images, and when a fragment loses focus the entire cache is stored on the heap so the user can go back.  You can recycle the bitmaps in the onPause method, but then they need to be loaded into the cache again.  It sort of defeats the purpose of having the cache.  Furthermore, users will not typically be cycling through images when using the app and it did not make sense because you can only cache only 3 or 4 large bitmaps before one must be evicted.  When I tested the app on actual devices, the image load times seemed instantaneous too.  I only needed to be sure that if the user cycled through all the images repeatedly the app would not crash and the gain in speed for memory the cache offers does not seem worth it.

On top of all that, I made some UI changes to my app this week and I think they will make using the app much clearer.  I broke what was three roofs into five, allowing me to remove valley and hip sets from the instruction section and allow them to be standard when needed.  Along with that, templates have their own create button now. I also provided buttons for cycling through multiple roof rafters.  Now the instructions tab can house nothing but actual instruction texts and the app as a whole seems more intuitive. I was hoping to add more roofs and content these past two weeks, but it just did not work out.  This week I will tackle gambrel and mansard roofs.  Next, it will be onto adding textual content, drawing diagrams, publishing the Android version; and beginning on the iOS version.  As time becomes to much of a constraint I may add the mansard roof in the next version of the app.

Till next time.

Jason Hintlian

From the blog jasonhintlian » cs-wsu by jasonhintlian and used with permission of the author. All other rights reserved by the author.

GitHub Activities

Well….This is kind of annoying. I hate that feeling that I’m not even sure what the heck I’m doing. GitHub doesn’t seem to like cooperation with me. I think I’ve gotten it downloaded properly, but I seem to have trouble finding things to edit and such.

I have been able to edit a few things on the School/Class Wiki, though. Managed to update my own page to include some of the information from the recent ‘assignment’ from class (blog link, OpenMRS ID, GitHub Username), and added a function to collapse all that information from the Issue Tracker activity. I find it a lot easier to work with that, seeing as if I’m not sure what I need to do, I can find another page with the formatting I’m looking for, then copy/experiment. Might look into doing some things for our project from there. Already started making the page, at least (though, it was mostly copy/paste from the original CS 401 page).

I managed to get linked to the project ticket for our group, though that was mostly them adding me, than anything else, and I think I’ve copied the files from the original to my machine, but I’m still looking for a way to edit….

Well, now I think I’m getting somewhere updating eclipse. Had to go in and update what I currently had on my computer, and then install Maven, though there were a few errors popping up. If I avoid the optional things, maybe…

Well, it seems to be working. Maybe. Fingers crossed…

Ok….. most of these downloads are going over 100%…… Hope nothing’s broken… Please? Well, restarting eclipse again…

HA! Finally got everything working (so far as I can tell). Hopefully this will let me keep working.

From the blog Kyle's Works » CS@Worcester by kyleprimmer and used with permission of the author. All other rights reserved by the author.

Week 5

This week i started looking at the ticket TRUNK -248 with my group. the ticket is dealing with going through the to-do’s and finding where the to-dos are asking for a Junit test. First i did a bit of research on junit tests so i could some background. After a quick google search i went to http://www.vogella.com/tutorials/JUnit/article.html which was a great in depth article on Junit. i didn’t focus on the using aspects too much since that’s not what my ticket is asking for however it did explain how the tests work and what too search for in the source code to track some of these down. After that i went to https://wiki.openmrs.org/display/docs/Step+by+Step+Installation+for+Developers which helped me setup the openmrs core in eclipse. I had to go to help marketplace and get a plugin for maven on eclipse. after installing the maven plugin i went to file import then chose import and then existing maven project and chose the core repo that i cloned from github. After the import finished which took a couple of minutes i finally had access to the OpenMRS source code. I started looking through some of the code and identifying some of the todo items that ask for junit tests. I wasnt sure if the ticket was still active or not but i did find a bunch of to-do items asking for junit tests so it seems like it still is. This following week me and my group hope to identify as many of these as possible to we can accomplish our ticket.

From the blog Dhimitris CS Blog » CS401 by dnatsis and used with permission of the author. All other rights reserved by the author.