API for object insert, items for example

I'm trying to load an existing data collection to Omeka. The existing collection is too big to load by hand, instead I'll need to automate the load.

I notice that Omeka uses MyISAM, hence no referential integrity constraints in the DB, so I'm hesitant to directly convert the schema and load outside of Omeka's existing functionality.

Is there API that I can use?

When I look at ItemsController I see code that appears to require an interactive user session with a browser.

Any suggestions welcome, thanks.

The next version of Omeka will include an insert_item() helper function that will make this much easier -- one of our other devs, Jim, is working on migration scripts and may have more insight, particularly regarding the use of phased loading to possibly have a script run in the background and not time-out over HTTP.

Here's a look at the code for inserting items that's being used in the soon-to-be-released upgrade of the dropbox plugin:

* This function will be deprecated in the upcoming 1.0 release
* in favor of an insert_item function added to the core
function insert_item($itemMetadata = array(), $elementTexts = array())
    // Insert a new Item
    $item = new Item;

    // Item Metadata
    $item->public           = $itemMetadata['public'];
    $item->featured         = $itemMetadata['featured'];
    $item->collection_id    = $itemMetadata['collection_id'];

    foreach ($elementTexts as $elementSetName => $elements) {
        foreach ($elements as $elementName => $elementTexts) {
            $element = $item->getElementByNameAndSetName($elementName, $elementSetName);
            foreach ($elementTexts as $elementText) {
                $item->addTextForElement($element, $elementText['text'], $elementText['html']);

    // Save Item and all of its metadata

    // Save Element Texts

    return $item;

And in a plugin's controller, you would use something similar to the following code to pass metadata to the helper function:

$itemMetadata = array(  'public'            => $_POST['public'],
                                        'featured'          => $_POST['featured'],
                                        'collection_id'     => $_POST['collection_id']);

                $elementTexts = array('Dublin Core' => array('Title' => array(array('text' => $originalName, 'html' => false))));
                $item = dropbox_insert_item($itemMetadata, $elementTexts);

Does that help? You may be interested in joining our Developer Google Group where these more-technical questions are often asked: http://groups.google.com/group/omeka-dev


Yes, thanks for sharing the code, that helps a bit..