I decided I should probably finally get around to moving this blog from WordPress to Domino, if for no other reason than to have a perfect testbed for the weird stuff I've been doing lately. The first task is to write an importer, so I decided to just do a straight SQL rows -> Domino documents import. This couldn't be easier if you follow this simple guide:
- Write a Java agent that uses the appropriate JDBC connector for your database. In my case, it's MySQL, so I had it do a "show tables" to get a list of tables, then loop over those to do "select * from whatever" statements to get all documents.
- Since it's Domino, you can just do
- Oh wait, you can't all the time. Make sure to handle a couple cases, like converting BigIntegers to longs and Timestamps to DateTimes.
- Wait, Domino doesn't even handle Boolean? For frack's sake, FINE:
row.replaceItemValue(column, cell.equals(Boolean.TRUE) ? 1 : 0);
- Oh hey, that import went really smoothly! Now I'll just make some views based on the table name and... crap. Forgot to include the table name! Maybe I shouldn't have written this importer at four in the morning.
- Better delete all the documents and start over.
- What's this, an error when I went to delete all the documents in the All view? "Field is too large (32k) or..." oh no.
- Oh crap.
- Ah, I know - I'll just write an agent to do
session.CurrentDatabase.AllDocuments.RemoveAll(True) and that'll fix that.
- Hmm, nope, that didn't work. Alright, based on the documents created around the same time, I can guess that it's the "option_value" field that's too big. Why did it even cram that data into summary if it completely breaks the document? Well, no point in dealing with that now. It's time for StampAll to take care of that!
- Nope? Okay, how about
- Not all categorized? What kind of error message is THAT?
- Time to delete the database and start over!
- Alright, THIS TIME, check to see if the String value is over, let's say, 16000 bytes and, if so, store it in a RichTextItem instead.
- Oh nice, it worked.
- Oh crap, I forgot to include the table name again.
And that's all there is to it!