Category Archives: Computer Science

Installing Ubuntu on a Google Chromebook

Here is an extremely useful tutorial to get Ubuntu running on a Google Chromebook (netbook).

The link to the resource can be found here.

-Michael Malloy

From the blog Michael Malloy - Worcester State Computer Science » CS@Worcester by mmalloy1 and used with permission of the author. All other rights reserved by the author.

Unit Test: @should annotations

Basically what I’ve been doing is introducing the “@should” javadoc annotation. Each api method will get one or more @should annotations that simply state a behavior of that method need testing, in other words, each @should annotations should be phrased. For instance:

  • @should not fail given null parameter
  • @should return empty list if no results

The example above would become unit test named (given the method was findPatient):

  • public void findPatient_shouldNotFailGivenNullParameter()
  • public void findPatient_shouldReturnEmptyListIfNoResults()

These are the step I followed to get started on this task:

  • Import the OpenMRS-core Repository from Eclipse
      • In Eclipse, choose File:Import
      • Choose Git: Projects from Git
      • Select Repository Source: URI
      • Browse the location of the local file on the PC (file: openmrs-core)
      • Select the master branch
      • Choose the directory you want to clone into
      • Select Use the New Project Wizard
      • Choose Java: Java Project
      • Enter a project name (To get all files imported, the given name has to be exactly the same as the local file name. In this case the project name should be: openmrs-core)
  •  Start searching all methods that do not have tests
      • In Git Bash, type command:  $grep –r ‘@should’ openmrs-core  (This command line will recurs into sub-directories to look for all “@should” instances)
      • Command:  $grep –r ‘@should’ openmrs-core > file.txt   (This line will save the output to a file text)
  • Browse ‘@should’ annotations in the packages  
      • The txt.file will output all packages that still have ‘@should’ annotations.
      • In Eclipse, look for such packages and start modifying them, so those methods become unit test names.
      • For example: /api/src/main/java/org/openmrs/somepackage/SomeObject.java:

In Eclipse: /api/src/main/java/org/openmrs/aop/AuthorizationAdvice.java:

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

General Update

So, turns out that whole compilation/posting of our completed ticket wasn’t as ‘complete’ as we’d thought. That is to say, rather than compile everything and post it to GitHub, we ended up trying to compile all our individual code first….repeatedly. It took a bit of playing around with, but we figured out that it could all be compiled and pushed up through the GitHub GUI. For whatever reason, whenever we tried it on the Bash, it just wouldn’t work properly.

After finally getting it sent up, we still hadn’t heard back from the admins about whether we’d properly fulfilled the requirements, so we’re not sure where to go with all of this. As a group, we pretty much decided to focus on the book reports that would be due soon, and just wait for confirmation. As I’ve still not heard from Dhimitris (who originally claimed the ticket), all I’ve been doing is reading more from my book.

Frankly, I was right. Reading glorified textbooks isn’t that fun. I prefer sci-fi/fantasy to non-fiction 😛

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

Taking Care of Backlog…

So, apparently, I’m really bad at keeping these sorts of things regular. So, let’s start off with two weeks ago, shall we?

Two weeks ago, we did a sort-of lab in class, one that involved downloading various applications and such before it could really get going; well, it involved all that for me, seeing as I was using vastly outdated software/programs. In order to get things working, I had to download the latest version of Eclipse available (Helios, I believe?), as well as a better version of Java in order to properly run everything. I tried to do this all in class, but for whatever reason my internet connection in the classroom seems especially bad. It was at the point that the estemated completion time was several hours, at the lowest. I think the highest I saw was about 10 hours.

Either way, after I got home, everything seemed to work out well enough. The downloads finished rather quickly, and I soon was running the proper software. Unfortunately, everything wasn’t perfect at this point, and thus I had to play around with the Eclipse settings for a bit. Now, while I really should have been typing this up as I did it, so I could remember everything I did, I was an idiot, and failed to do so. So, let’s see how much I can remember, and how much I can re-work through…

It still wasn’t letting me run files as JUnit Tests, so I had to go into the settings and preferences and such to find out why this thing still wasn’t working. Come to find, in spite of downloading the latest of Java and Eclipse, it was still trying to use an old system library, 1.6 I believe it was. I had to go in, forcibly re-direct which Build Path it was using, then I had to force it to run as JUnit Test (unfortunately, I can’t quite remember what I ended up having to do to get that to work properly, but it still didn’t want to run it).

After that fiasco was over and done with, our group finished up our ticket and got ready to compile it all together and send it. I’m not sure if we decided on a new ticket or anything, yet, but I suppose I’ll find out later today in class. In the meantime, I’ve been taking a look at that book I’m apparantly supposed to give a report on. Not gonna lie, I’m not looking foreward to reading what looks to amount to a specialized textbook. I generally shunt those off to be used as references, at best. And even then, the Internet’s generally faster for me. Well, here’s hoping this doesn’t turn out as painful as it’s starting to sound.

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

How Much Are We Responsible For..?

So, found more info on the project. Dhimitris found most of the sections where we need to add the comments, so that should work well. On the other hand, from what we can see, the last person to work on this project also went about building actual test classes for the project, so we’re not entirely sure whether or not to do the same.

There’s also some question about which sections still need to get done. Taking a look through the project, we found a few cases mentioning the need for ‘tests’, but didn’t specifically mention JUnit tests, so there’s some question of whether or not those were just lazy typo’s, or if they’re separate things we are not responsible for.

Most likely, we’ll first focus on the TODO requests in HibernateFormDAO.java, and HibernatePatientDAO.java to add the @should comments. It seems that they have some Plug-in available that uses such comments to generate test classes, so the comments are first priority. Maybe afterwards, we might be making those test classes themselves, after asking the ticket publisher.

From the blog Kyle's Works » CS@Worcester by kyleprimmer 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.

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.

OpenMRS Set Up

Setting up the system has been difficult. My laptop is running Windows 8.1, so that’s the first challenge I have.

First, when I tried to check which version of java I had installed, I got this output: “ ‘javac’ is not recognized as an internal or external command, operable program or batch file”. So, I decided to check: Program > Java > About > Version 7 (1.7.0-b147). The Developers Guide instructs to check the version as follow “javac –version” on the command line, but instead I entered “java -version” and it worked!

Then, I got stuck in the installation step. I downloaded and run the OpenMRS SDK installer. The wizard setup was completed without outputting any error. Once again, in order to get the output in the console I had to change “omrs-version” to uppercase, “OMRS-version”, otherwise the result would not have succeeded.

This time, the prompt line gave me an error: “JAVA_HOME not found in your environment. Please set the JAVA_HOME variable in your environment to match the location of your Java installation”

If you are running into the same problem, here is the solution:

  1. Locate the Java Runtime Environment (JRE) Installation Directory
    1.  If you didn’t change the installation path for the Java Runtime Environment during installation, it will be in a directory under C:\Program Files\Java. Using Explorer, open the directory C:\Program Files\Java.
    2.  Inside that path will be one or more subdirectories such as C:\Program          Files\Java\jre7
  2. Set the JAVA_HOME Variable
    1. Right-click the My Computer icon on your desktop and select Properties.
    2. Click the Advanced tab.
    3. Click the Environment Variables button.
      1. Under System Variables, click New.
      2. Enter the variable name as JAVA_HOME.
      3. Enter the variable value as the installation path for the Java Development Kit. (e.g.C:\Program Files\Java\jre7)
    4. Click OK.
    5. Click Apply Changes.

Close any command window which was open before you made these changes, and open a new command window. If the changes do not take effect even after reopening the command window, restart Windows.

After fixing the JAVA_HOME, I checked if the SDK is working properly. The console output looks similar as the one on the Developers Guide.

Now the last step, running OpenMRS locally, it starts to create the directory, but nothing happens. It never launches the web server to be tested. If I click the link, the web page loads blank. I’m still trying to figure out what I missed!

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

Wiki & Git are FUN!

The third week of the semester has been very busy. Let’s start with the wiki editing that was started in class. This is the first time I have to edit a wiki. It was fun and easy to learn how to add and modify content. What I like about the wiki application is its simplicity, which allows any user to contribute text without being a web designer.

My wiki profile has information about the Issue Tracker Activity. This activity was useful in a way that I can get familiar with the OpenMRS Issue Tracker system, which is a system that allows browsing and filtering bugs. In this activity not only learned to browse and filter issues, but I also learned to find reports based on a specific project.

The second part of the assignment was the Git Videos and the tutorial, which gave me an insight of what Git is and how it works. Git is a Version Control System (VCS) with capability to keep track the history of every file, and changes made by a team member who is working or collaborating on a single project. VCS allows to revert files back to a previous state, revert the entire project, review changes made over time, see who last modified something that might be causing a problem, who introduced an issue and when, etc.

In summary, some features that Git provides are:

  • Configuration: Free download and installation; fast and easy setup.
  • Fast: Nearly all operations are performed locally (on local disk).
  • Distributed Version Control: if any server dies, any of the client repositories can be copied back up to the server to restore it.
  • Team Centric: Allows group of contributor working simultaneously within the same project.
  • Integrity: Contributor can’t lose information in transit or get file corruption without Git being able to detect it.
  • Merging Capability: Git is flexible when more than one user’s work needs to be brought together.
  • Opt in: You decide on which projects to participate.
  • Open Software: Let people offer contributions.
  • Backup: Every user has a full backup of all data. 

Finally, this week I went through the selection of 3 tickets within the issue tracker. I am very excited to work on projects related to database.

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