Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: add some functions modifying data

...

Code Block
languagesql
SELECT ds5_bitstream2item(123);  -- 456
SELECT ds5_item2collectionhandle(456);  -- '123456789/789'

SELECT ds5_metadata_field2id('dc', 'title');  -- 64
SELECT ds5_metadata_field2id('dc', 'description', 'abstract');  -- 27
SELECT ds5_metadata_id2field(27);  -- (dc,description,abstract)
SELECT (ds5_metadata_id2field(27)).element;  -- 'description'

Overview

argument
result 
bitstreambundleitemcollectioncommunity
bitstream-----
bundleds5_bitstream2bundle----
itemds5_bitstream2item
ds5_bitstream2itemhandle
ds5_bundle2item
ds5_bundle2itemhandle

ds5_item2itemhandle
ds5_itemhandle2item

--
collectionds5_bitstream2collection
ds5_bitstream2collectionhandle
ds5_bundle2collection
ds5_bundle2collectionhandle

ds5_item2collection
ds5_item2collectionhandle
ds5_itemhandle2collection

ds5_itemhandle2collectionhandle
ds5_collection2collectionhandle
ds5_collectionhandle2collection
-
communityds5_bitstream2community
ds5_bitstream2communityhandle
ds5_bundle2community
ds5_bundle2communityhandle

ds5_item2community
ds5_item2communityhandle
ds5_itemhandle2community
ds5_itemhandle2communityhandle

ds5_collection2community
ds5_collection2communityhandle
ds5_collectionhandle2community
ds5_collectionhandle2communityhandle 
ds5_community2communityhandle
ds5_communityhandle2community

Other functions:

ds5_metadata_id2field
ds5_metadata_field2id

...

Code Block
languagesql
DROP FUNCTION ds5_bitstream2bundle(integer);
DROP FUNCTION ds5_bitstream2item(integer);
DROP FUNCTION ds5_bitstream2itemhandle(integer);
DROP FUNCTION ds5_bitstream2collection(integer);
DROP FUNCTION ds5_bitstream2collectionhandle(integer);
DROP FUNCTION ds5_bitstream2community(integer);
DROP FUNCTION ds5_bitstream2communityhandle(integer);
DROP FUNCTION ds5_bundle2item(integer);
DROP FUNCTION ds5_bundle2itemhandle(integer);
DROP FUNCTION ds5_bundle2collection(integer);
DROP FUNCTION ds5_bundle2collectionhandle(integer);
DROP FUNCTION ds5_bundle2community(integer);
DROP FUNCTION ds5_bundle2communityhandle(integer);
DROP FUNCTION ds5_item2itemhandle(integer);
DROP FUNCTION ds5_itemhandle2item(varchar);
DROP FUNCTION ds5_item2collection(integer);
DROP FUNCTION ds5_item2collectionhandle(integer);
DROP FUNCTION ds5_itemhandle2collection(varchar);
DROP FUNCTION ds5_itemhandle2collectionhandle(varchar);
DROP FUNCTION ds5_item2community(integer);
DROP FUNCTION ds5_item2communityhandle(integer);
DROP FUNCTION ds5_itemhandle2community(varchar);
DROP FUNCTION ds5_itemhandle2communityhandle(varchar);
DROP FUNCTION ds5_collection2collectionhandle(integer);
DROP FUNCTION ds5_collectionhandle2collection(varchar);
DROP FUNCTION ds5_collection2community(integer);
DROP FUNCTION ds5_collection2communityhandle(integer);
DROP FUNCTION ds5_collectionhandle2community(varchar);
DROP FUNCTION ds5_collectionhandle2communityhandle(varchar);
DROP FUNCTION ds5_community2communityhandle(integer);
DROP FUNCTION ds5_communityhandle2community(varchar);
DROP FUNCTION ds5_metadata_id2field(integer);
DROP FUNCTION ds5_metadata_field2id(varchar, varchar, varchar);
DROP FUNCTION ds5_metadata_field2id(varchar, varchar);

Functions modifying data

Code Block
languagesql
-- returns eperson_id or NULL if no such eperson was found
CREATE OR REPLACE FUNCTION ds5_eperson_delete_by_eperson_id(int) RETURNS int
AS $$
#print_strict_params on
DECLARE
  eperson_id_to_delete int;
BEGIN
  DELETE FROM metadatavalue WHERE resource_type_id = 7 AND resource_id = $1;
  DELETE FROM subscription WHERE eperson_id = $1;
  DELETE FROM epersongroup2eperson WHERE eperson_id = $1;
  DELETE FROM eperson WHERE eperson_id = $1;
  RETURN $1;
END
$$ LANGUAGE plpgsql;

-- returns eperson_id or NULL if no such eperson was found
CREATE OR REPLACE FUNCTION ds5_eperson_delete_by_email(character varying) RETURNS int
AS $$
#print_strict_params on
BEGIN
  RETURN ds5_eperson_delete_by_eperson_id((SELECT eperson_id FROM eperson WHERE email = $1));
END
$$ LANGUAGE plpgsql;


SELECT ds5_eperson_delete_by_email('johndoe@example.com');




DROP FUNCTION ds5_eperson_delete_by_eperson_id(int);
DROP FUNCTION ds5_eperson_delete_by_email(character varying);