MarcEdit Plug-ins: OCLC Connexion data plug-in example

Ugh, I’m hoping that I can keep my eyes open long enough to finish getting this built, but thought I’d provide a little info on the plug-in framework that I’m setting up in MarcEdit.  First, a reason why I’m even doing this. 

As time is going forward, I’m finding that I have a few ideas for functions (requested or not) that I’d like to add to MarcEdit.  However, the program is getting large enough (in terms of download size) — so I’ve developed a plug-in framework to allow others (if they like) but mostly so I can create some code modules that folks can choose to download or no.  Presently, the plug-in tools included into MarcEdit include a plug-in manager and then a way to execute plug-ins.  The last thing needing to be added is I need to override a few of the MarcEditor operations like the save function so that if you are executing a plug-in module, the module can react to save requests rather than having to have users step back out to the plug-in interface.  But if I don’t finish this tonight, I still may package and give out what I’ve got at the moment.

 

Anyway, here’s how its working.  I’ll show the only plug-in that I’ve written thus far.  I’ve wanted for a while to be able to interact with the OCLC local save files.  While not documented anywhere, a little examination of the data files shows that OCLC is using an ms access data format for their database storage and using a funny custom xml format for their own internal data storage format.  It looks a lot like MARC21XML — though not exactly.  Not sure why they didn’t go that root though — since the ISO draft of the format could have supported all the elements I’m currently seeing.  But no worries.  It’s easy enough to parse.  I’ll be posting the source to the plug-in once I get this finished, so you’ll get a chance to see how it all works then (including the MarcEdit interaction).

Plug-in Manager:

This works a lot like the Mozilla plug-in manager.  To get to the plug-in manager, you will see a new option on the Main window under tools:

image

You will also note from the above that a new menu item, Plug-ins has been added to the main window and the MarcEditor (the two parts of the program that currently support plug-in interaction).  When you click on the Plug-in Manager option, you see the following:

image

At present, I having pushed the OCLC Connexion Data plug-in up to the server, so its not in the available list — but you can see how installed and available plug-ins can be found, downloaded and removed. 

So how does it work — essentially, the plug-in should be created as a .NET assembly.  Doesn’t matter the language.  The OCLC example is written in C#, but any .NET compatible language will work (IronPython, Java#, C++, etc).  For a plug-in to work in MarcEdit, you need to create a Connection class with a Startup Function.  For example:

 

using System;
using System.Collections.Generic;
using System.Text;

namespace oclc_helper
{
    public class Connection 
    {
        
        public static void Startup(Interfaces.IHost objEditor)
        {
            //so I need to make sure I can access the macrointerfaces host.
            if (objEditor != null)
            {
                variables.objEditor = objEditor;
            }
            frmQuery frm = new frmQuery();
            frm.Show();
        }
    }
}

This is the entire code sample from the OCLC Connexion plug-in.  Essentially, a static startup function must be created.  It takes one argument — the an Interface from the MarcEdit application.  This is so you can interact with the MarcEditor.  If this plug-in isn’t setup to interact with the MarcEditor, null will be passed into the function. 

From there, its just a normal assembly.  For example, the OCLC tool current looks like the following:

Opening screen:

image

So, you can see the plug-in shows up in the new Plug-in menu entry.  Click on the entry and you see the following window:

image

 

Select the Connexion file to load, then click on Load File.  You will then see the following:

image

At this point, the plug-in is essentially just loading data directly from the MS Access Data store.  This takes data from the tblSaveFile which stores among other things, the save #, oclc number (will be set to NEW or a number) the record title, in addition to other info.

So select the data and clicking on the edit records button currently exports this data into the MarcEditor and minimizes this window.  This is because at this point, you still need to save the edits using the plug-in wizard rather than from the editor.  Should change I think, but I’m giving you how it works at this moment.

Anyway, select some items and click Edit Records.  You see this:

image

Basically, it takes the data into MarcEdit’s mnemonic format.  Of course, the data is all in Unicode (since that’s how Connexion wants to work with you).  So you edit data by using Unicode characters (not the mnemonics) [Note to self, make sure that the one mnemonic, {dollar} has been replaced when retranslated].

After you make your edits, you reinitalize the minimized plug-in window.  You will now see a save button.

image

The program makes the assumption that you having deleted any items, reorganized items — but have kept them in the same order that they were exported in.  So long as that’s the case, you click on Save Records and the program will retranslate the edited data from the MarcEditor back into Connexion’s database file. 

 

So that’s how it will work.  As I say, I’ll post the source when I push the plug-in up to the server.  With luck, that should happen tonight.  I’ve been fixing and enhancing a number of functions — so its been a long two days as I’ve been finishing up this update.  I think I’ve slept 4 hours since Friday.  Hopefully, I can wrap this up before 10 tonight — that way its not a long week next week.

 

–TR


Posted

in

by

Tags:

Comments

One response to “MarcEdit Plug-ins: OCLC Connexion data plug-in example”

  1. […] MarcEdit Plug-ins: OCLC Connexion Plug-in data […]