Commit c3a19945 authored by Daniel Haag's avatar Daniel Haag
Browse files

postgres functions for esb integration updated

parent 0a1e7b79
-- modifying the schema to allow an external_id
ALTER TABLE tce_user_groups ADD COLUMN external_id varchar(255);
-- functions for tcexam esb integration
-- assign_tcexam_user_to_group
......@@ -28,9 +32,11 @@ $BODY$
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION assign_tcexam_user_to_group(text, character varying, character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- delete_tcexam_user
......@@ -46,9 +52,11 @@ $BODY$
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 1;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION delete_tcexam_user(character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- get_tcexam_group
......@@ -89,9 +97,11 @@ SELECT XMLSERIALIZE ( CONTENT
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 1;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION get_tcexam_group(character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- get_tcexam_group_appointment_users
......@@ -109,25 +119,29 @@ SELECT XMLSERIALIZE ( CONTENT
XMLELEMENT(name "userVOes",
xmlagg(
XMLELEMENT(name "userVO",
XMLFOREST(user_id),
XMLFOREST(user_name as login),
XMLFOREST(user_email),
XMLFOREST(user_firstname),
XMLFOREST(user_lastname),
XMLFOREST(user_level)
XMLFOREST(u.user_id),
XMLFOREST(u.user_name as login),
XMLFOREST(u.user_email),
XMLFOREST(u.user_firstname),
XMLFOREST(u.user_lastname),
XMLFOREST(u.user_level)
))) as text )
INTO xoutput
FROM users_and_groups u
WHERE u.external_id = concat(pgroupid,':',pappointmentid)
FROM tce_user_groups g
LEFT JOIN tce_usrgroups ug ON g.group_id = ug.usrgrp_group_id
LEFT JOIN tce_users u ON u.user_id = ug.usrgrp_user_id
WHERE g.external_id = concat(pgroupid,':',pappointmentid)
;
RETURN xoutput;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 1;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION get_tcexam_group_appointment_users(character varying, character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- get_tcexam_group_users
......@@ -140,24 +154,29 @@ SELECT XMLSERIALIZE ( CONTENT
XMLELEMENT(name "userVOes",
xmlagg(
XMLELEMENT(name "userVO",
XMLFOREST(user_id),
XMLFOREST(user_name as login),
XMLFOREST(user_email),
XMLFOREST(user_firstname),
XMLFOREST(user_lastname),
XMLFOREST(user_level)
XMLFOREST(u.user_id),
XMLFOREST(u.user_name as login),
XMLFOREST(u.user_email),
XMLFOREST(u.user_firstname),
XMLFOREST(u.user_lastname),
XMLFOREST(u.user_level)
)
)
) as text )
))) as text )
FROM (SELECT * FROM (
SELECT * FROM tce_user_groups g
LEFT JOIN tce_usrgroups ug ON g.group_id = ug.usrgrp_group_id) ug
LEFT JOIN tce_users u ON u.user_id = ug.usrgrp_user_id) u
WHERE u.external_id LIKE concat($1,':%')
;
FROM tce_user_groups g
LEFT JOIN tce_usrgroups ug ON g.group_id = ug.usrgrp_group_id
LEFT JOIN tce_users u ON u.user_id = ug.usrgrp_user_id
WHERE g.external_id LIKE concat($1,':%');
$BODY$
LANGUAGE sql VOLATILE
COST 1;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION get_tcexam_group_users(character varying)
OWNER TO tcexam;
......@@ -188,9 +207,11 @@ BEGIN
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 1;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION insert_tcexam_group(text, character varying, character varying, character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- insert_tcexam_user
......@@ -223,9 +244,11 @@ $BODY$
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION insert_tcexam_user(text, character varying, character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- remove_tcexam_user_from_group
......@@ -251,9 +274,11 @@ $BODY$
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 1;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION remove_tcexam_user_from_group(text, character varying, character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- update_tcexam_group
......@@ -275,9 +300,11 @@ BEGIN
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 1;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION update_tcexam_group(character varying, character varying, character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- update_tcexam_user
......@@ -315,9 +342,11 @@ $BODY$
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 1;
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION update_tcexam_user(text, character varying, character varying)
OWNER TO postgres;
OWNER TO tcexam;
-- create esb user
......@@ -325,14 +354,17 @@ ALTER FUNCTION update_tcexam_user(text, character varying, character varying)
-- CREATE USER esb WITH PASSWORD '....';
-- grant execute right on the functions
GRANT EXECUTE ON FUNCTION assign_tcexam_user_to_group TO esb;
GRANT EXECUTE ON FUNCTION delete_tcexam_user TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group_appointment_users TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group_users TO esb;
GRANT EXECUTE ON FUNCTION insert_tcexam_group TO esb;
GRANT EXECUTE ON FUNCTION insert_tcexam_user TO esb;
GRANT EXECUTE ON FUNCTION remove_tcexam_user_from_group TO esb;
GRANT EXECUTE ON FUNCTION update_tcexam_group TO esb;
GRANT EXECUTE ON FUNCTION update_tcexam_user TO esb;
--
-- # Generated with:
-- # grep 'CREATE OR REPLACE FUNCTION' postgres_db_structure_functions.sql | sed 's/CREATE OR REPLACE FUNCTION //' | while read f; do echo "GRANT EXECUTE ON FUNCTION $f TO esb;"; done
GRANT EXECUTE ON FUNCTION assign_tcexam_user_to_group(xmlbody text, pgroupid character varying, pappointmentid character varying) TO esb;
GRANT EXECUTE ON FUNCTION delete_tcexam_user(login character varying) TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group(externalid character varying) TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group_appointment_users(pgroupid character varying, pappointmentid character varying) TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group_users(group_id character varying) TO esb;
GRANT EXECUTE ON FUNCTION insert_tcexam_group(xmlbody text, pgroupid character varying, pappointmentid character varying, pgroupname character varying) TO esb;
GRANT EXECUTE ON FUNCTION insert_tcexam_user(xmlbody text, pgroupid character varying, pappointmentid character varying) TO esb;
GRANT EXECUTE ON FUNCTION remove_tcexam_user_from_group(xmlbody text, pgroupid character varying, pappointmentid character varying) TO esb;
GRANT EXECUTE ON FUNCTION update_tcexam_group(pgroupid character varying, pappointmentid character varying, pgroupname character varying) TO esb;
GRANT EXECUTE ON FUNCTION update_tcexam_user(xmlbody text, pgroupid character varying, pappointmentid character varying) TO esb;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment