Thursday, March 15, 2012

Server-side logging for Apache Tomcat

Okay, so after spending two days on a problem that wasn't an actual problem, I was frustrated and determined that the only way I could get any feedback from the program was to implement a logging. I don't know if I've never had to use logging before because I'm smart and thus don't need it, or because I'm stupid and like doing things the hard way, but there goes.

A very simple guide to using logging for Apache Tomcat:

1.) The output will be put into the logs in the tomcat directory catalina.20XX-XX-XX.log.

2.) Include the following imports:
import java.util.logging.Level;
import java.util.logging.Logger;

3.) Initialize the logger in the class you want logged:
private static String nameOfLogger = <INSERT_CLASS_NAME_HERE>.class.getName();
private static Logger myLogger = Logger.getLogger(nameOfLogger); '

4.) Insert the following code if you want something always to be logged (alternatively, you can change "severe" to other levels, if you want the messages to only be printed if a certain level is reached):
myLogger.severe(<STRING YOU WANT PRINTED>);

5.) Don't forget to set the level of the logger:
myLogger.setLevel(Level.WARNING);

6.) Also create a logging.properties file in the /war/WEB-INF/ folder
An example file is like this:
# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
#
# <system-properties>
#   <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#

# Set the default logging level for all loggers to WARNING
.level = WARNING

For more information check out this wonderful guide

Wednesday, March 7, 2012

Integrating Open Reconcile with Google Refine

Since I published a WAR of open reconcile, I figure I should add a note on what to do if you want to have better integration between Google Refine and Open Reconcile (and have Google Refine's source code).

There are just two files you need to modify to add a "Configure Open Reconcile" option to the "Start reconciling" dialog box. First off, do know that I am sacrificing some FreeBase integration functionality. If this bothers you, don't follow these instructions. Also, if editing javascript/html scares you (why are you at this blog?), don't do this.

We're going to turn the "Add namespace" button into the button we want. It's rather simple, just open recon-dialog.html from grefine/main/webapp/modules/core/scripts/reconciliation/ Just change the text of the button from "Add namespace" to "Configure Open Reconcile".

Next, you'll undoubtedly see it calls a function. The function can be found in the same folder in recon-dialog.js. Find the function _addNamespacedService. Comment out or delete all of the existing code in that function (keeping in mind that it's not well-tabbed) and put this in instead:

     var self = this;
      var dialog = $(DOM.loadHTML("core", "scripts/reconciliation/config-open-service-dialog.html"));
      var elmts = DOM.bind(dialog);

      var level = DialogSystem.showDialog(dialog);
      var dismiss = function() {
        DialogSystem.dismissUntil(level - 1);
      };

      elmts.cancelButton.click(dismiss);
      elmts.addButton.click(function() {
        var url = $.trim(elmts.input[0].value);
        if (url.length > 10) {
            window.open(url.substring(0,url.length-10));
        }
        dismiss();
      });
      elmts.input.focus().select();

If you're paying attention, you will see that I'm referencing an html file that doesn't exist. I just coped add-standard-service-dialog.html and changed    
 <button class="button" bind="addButton">Add Service</button>
to
<button class="button" bind="addButton">Go To Config</button>

Okay, just return the file or re-create distribution files if you don't run it in the console (see <a href="http://code.google.com/p/google-refine/wiki/DevelopersGuide">Google Refine documentation</a> for how to do that).

I find this is helpful so I don't have to keep links to everything. It takes the url in, chops of the "/reconcile" that points to the service, and in this webapp the configuration screen is at the root. To do most options (Delete a row, preview data the row will pull, and eventually and substitution rules or synonyms) you need to "List All Current Libraries".

Thursday, March 1, 2012

OpenReconcile

The project is almost done. I'm really tempted to add a synonym table function, where you can specify and type and have it automatically replace one value with another if the criteria is met. It'd be useful for things like species name, where human is often entered in place of homo sapiens.

Of course I'd also like to implement learning too, but that's not going to happen this semester.

Wednesday, February 22, 2012

Finally!

Okay, after a long period of constantly switching gears, I have a product that works that is open-source-able, but will meet my employer's needs out of the box without any customization!

It allows the user to pick between Oracle or PostGRES databases for their data. You can add information via a walkthru or just all by hand. The only thing that I think might be helpful is a test-feature, to make sure the connection can be made property. I think I'll try to get that added, and it'll fail if the information throws an error.

In other news, I finally have an example thesis and know what I need to do to finish (write 100 pages, lol). Also random thing I learned: San Francisco is one of the most stressful cities in the U.S., very true. So much wealth and poverty, too many extremes.

Friday, January 6, 2012

Open Reconciliation

I've completed opening the reconciliation service. Now it has a front-page that lets the user intelligently put in references to where s/he wants data pulled from. The data is then stored in a SQLite database, which the servlet reads from the populate the metadata and to grab the vocabulary that the requests are reconciled against.

It will be put up on: http://code.google.com/p/open-reconcile/ when I have it looking less jury-rigged.

Friday, December 16, 2011

SQLite and Moving

First off, after successfully adapting Google Refine to my company's needs, I now go full circle and adapt the software I wrote for the company to be open-source and useable by all. This task has lead to met implementing server-side SQLite using GWT framwork (and the sqlitejdbc JAR). It's going surprisingly well. It's probably not the best most secure idea in the world, but at least where I am, it'll be behind a log-in screen.

After this I may get involved in contributing to Google Refine's development. It depends on my company's needs, of course. All and all, this semester has been one of the most productive of my life.

Wednesday, December 7, 2011

Rebranding Google Refine

Google Refine is cool with you modifying their code and redistributing it... as long as you don't call it "Google Refine." So, I'm going through the process of rebranding Google Refine as BIORefine.

The first thing I did was whip up a nifty little replacement for the Google Refine logo.






It was created with two different heights 30px and 40px. it goes in the grefine/main/webapp/modules/core/images folder.

grefine/main/webapp/modules/core/index.vt is edited to change Google Refine to BIORefine.

There are a handful of other files to be changed (mostly the .html files in grefine/main/webapp/modules/core/scripts/index/ such as create-project-ui-source-selection.html).

Edit: I'll probably update this guide as I find more that I've missed (like about.html - although I did leave all the text in, just added that BIORefine is a modified version of Google Refine).