mnylc / islandora_multi_importer

This is a flexible, twig based, all cmodel, tabular data to islandora Object importer with optional ZeroMQ processing
GNU General Public License v3.0
16 stars 15 forks source link

Issue 89: Fake Object now can now be in Fake relationships (but never commit) #91

Closed DiegoPino closed 6 years ago

DiegoPino commented 6 years ago

This pull fixes #89, a nasty issue triggered by IMI and Context being deployed on the same system. We fix it on this side since as the issue explain, Context is not to blame, its how Islandora loosely asumes Abstract Objects have methods that are not required and then copy pasta leads to this.

I added a new Class and a new relationships class to fakeObject that only responds to certain expected methods with real data, allowing the Context reaction to at least happen. I can't say what will happen if that reaction removes or alters Datastreams, but at least on this side we are dealing with the implementation.

How to test?

Either switch to this branch (issue-89) or apply the patch as Github recommends. You can either try this live or run the following code in a development PHP box

module_load_include('inc', 'islandora', 'includes/tuque_wrapper');
module_load_include('inc', 'islandora_multi_importer', 'includes/FakeObject');
// THIS PIECE IS IMI
$islandora_object = new FakeObject("imi:faker", array("islandora:collectionCMode, islandora:sp_simple_image"));

// THIS PIECE IS CONTEXT, IF NO ERROR THEM I SOLVED IT
if (is_object($islandora_object) && property_exists($islandora_object, "id") ) {
    $cmodels = $islandora_object->relationships->get("info:fedora/fedora-system:def/model#", "hasModel");
   print_r($cmodels);
    $islandora_object_cmodels = array();
    foreach ($cmodels as $cmodel) {
        $islandora_object_cmodels[] = $cmodel["object"]["value"];
    }
    dpm($islandora_object_cmodels);
    if (!in_array("islandora:collectionCModel", $islandora_object_cmodels)) {
        print_r("not collection, actually it is, but proves the point");
    } else {
        print_r("is a collection");
    }
}

Which is a test case for showing how IMI now allows for Context to read Fake Objects correctly.

Disclaimer: this is an exception, IMI is flexible, but not as flexible as other module's code/expectations or assumptions of what an Abstract Object is or not is https://github.com/Islandora/tuque/blob/ceaa130ab092dbad9d3c37073cba4575687d63ea/Object.php#L39

Once this is tested, please let me know if all is ok to merge it. Enjoy!

@McFateM @kromabiles @jmignault