Browse Source

ISLANDORA_214 Add demo objects hook to core.

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
c89a5b31ee
  1. 6
      collection_views/cmodel_collection_query.txt
  2. 117
      fedora_repository.module

6
collection_views/cmodel_collection_query.txt

@ -0,0 +1,6 @@
select $object $title from <#ri>
where ($object <dc:title> $title
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0>
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title

117
fedora_repository.module

@ -1409,33 +1409,92 @@ function fedora_repository_required_fedora_objects() {
'title' => 'Islandora Core', 'title' => 'Islandora Core',
'objects' => array ( 'objects' => array (
array ( array (
'foxml_file' => "$module_path",
'pid' => 'islandora:collectionCModel', 'pid' => 'islandora:collectionCModel',
'label' => 'Islandora Collection Content Model',
'dsid' => 'ISLANDORACM', 'dsid' => 'ISLANDORACM',
'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml", 'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml",
'dsversion' => NULL, 'dsversion' => NULL,
'' 'cmodel' => 'fedora-system:ContentModel-3.0',
), ),
array ( array (
'foxml_file' => "$module_path/newspapers_pageCModel.xml", 'pid' => 'islandora:strict_pdf',
'pid' => 'newspapers:pageCModel', 'label' => 'Islandora strict PDF content model',
'dsid' => NULL, 'dsid' => 'ISLANDORACM',
'datastream_file' => NULL, 'datastream_file' => "$module_path/content_models/STRICT_PDFCM.xml",
'dsversion' => NULL, 'dsversion' => NULL,
'cmodel' => 'fedora-system:ContentModel-3.0',
), ),
array( array(
'foxml_file' => "$module_path/newspapers_viewerSdep-issueCModel.xml", 'pid' => 'islandora:top',
'pid' => 'newspapers:viewerSdep-issueCModel', 'label' => 'Islandora Top-level Collection',
'dsid' => NULL, 'cmodel' => 'islandora:collectionCModel',
'datastream_file' => NULL, 'datastreams' => array (
'dsversion' => NULL, array (
'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml",
),
array (
'dsid' => 'TN',
'datastream_file' => "$module_path/images/Gnome-emblem-photos.png",
'mimetype' => 'image/png',
),
),
),
array (
'pid' => 'islandora:ContentModelCollection',
'label' => 'Collection of installed content models',
'cmodel' => 'islandora:collectionCModel',
'parent' => 'islandora:top',
'datastreams' => array (
array (
'dsid' => 'COLLECTION_VIEW',
'datastream_file' => "$module_path/collection_views/simple_list_view.xml",
),
array (
'dsid' => 'TN',
'datastream_file' => "$module_path/images/contentModel.jpg",
'mimetype' => 'image/jpeg',
),
array (
'dsid' => 'QUERY',
'datastream_file' => "$module_path/collection_views/cmodel_collection_query.txt",
'mimetype' => 'text/plain',
),
),
),
array (
'pid' => 'islandora:demos',
'label' => 'Islandora demos collection',
'cmodel' => 'islandora:collectionCModel',
'parent' => 'islandora:top',
'datastreams' => array (
array (
'dsid' => 'TN',
'datastream_file' => "$module_path/images/Gnome-emblem-photos.png",
'mimetype' => 'image/png',
),
array (
'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml",
),
),
),
array (
'pid' => 'islandora:pdf_collection',
'label' => 'Islandora Demo PDF Collection',
'cmodel' => 'islandora:collectionCModel',
'parent' => 'islandora:demos',
'datastreams' => array (
array (
'dsid' => 'TN',
'datastream_file' => "$module_path/images/Crystal_Clear_mimetype_pdf.png",
'mimetype' => 'image/png',
),
array (
'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/PDF-COLLECTION POLICY.xml",
),
), ),
array(
'foxml_file' => "$module_path/newspapers_viewerSdep-pageCModel.xml",
'pid' => 'newspapers:viewerSdep-pageCModel',
'dsid' => NULL,
'datastream_file' => NULL,
'dsversion' => NULL,
), ),
), ),
), ),
@ -1803,8 +1862,30 @@ function fedora_repository_batch_reingest_object($object, &$context) {
$context['message'][] = "$new_item->pid installed."; $context['message'][] = "$new_item->pid installed.";
} }
} }
elseif (!empty($object['dsid'])) { elseif (!empty($object['dsid']) && !empty($object['datastream_file'])) {
$datastreams = array (
array (
'dsid' => $object['dsid'],
'datastream_file' => $object['datastream_file'],
)
);
}
elseif (!empty($object['datastreams'])) {
$datastreams = $object['datastreams'];
}
if (!empty($datastreams) && is_array($datastreams)) {
$label = !empty($object['label']) ? $object['label'] : '';
$new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label);
if (!empty($object['cmodel'])) {
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
}
if (!empty($object['parent'])) {
$new_item->add_relationship('isMemberOfCollection', $object['parent']);
}
foreach($datastreams as $ds) {
$new_item->add_datastream_from_file($ds['datastream_file'], $ds['dsid'], !empty($ds['label']) ? $ds['label'] : '', !empty($ds['mimetype']) ? $ds['mimetype'] : 'text/xml');
}
} }
} }
} }

Loading…
Cancel
Save