diff --git a/procedures/getACLForEntitySet.sql b/procedures/getACLForEntitySet.sql new file mode 100644 index 0000000000000000000000000000000000000000..525bb10c7a1c40ece5d4b2b1a75b653e4ea0552c --- /dev/null +++ b/procedures/getACLForEntitySet.sql @@ -0,0 +1,48 @@ +/* + * This file is a part of the CaosDB Project. + * + * Copyright (C) 2022 IndiScale GmbH + * Copyright (C) 2022 Henrik tom Wörden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +/** + * Creates a table with the columns (entity ID, acl) from a given table with + * entity IDs. Here, acl in the string representation of the acl. + * Parameters + * ---------- + * + * entitySet: table with list of IDs + */ +DELIMITER // +DROP PROCEDURE IF EXISTS db_5_0.applyPOV; +CREATE OR REPLACE PROCEDURE db_5_0.getACLForEntitySet(in entitySet VARCHAR(255)) +BEGIN + -- TODO in future one might want to retrieve only a distinct set of acl + -- with (acl_id, acl) and a table with (entity_id, acl_id) to reduce the + -- amount of data being transfered + + -- TODO Double check: Versioning is not an issue here since acl is not + -- versioned. + SET @stmtStr = CONCAT('SELECT entity_n_acl.id, entity_acl.acl from ', + '(select entities.id, entities.acl from entities where id in (select id from `', + entitySet, + '`) ) as entity_n_acl inner join entity_acl on entity_n_acl.acl=entity_acl.id;',) + PREPARE stmt FROM @stmtStr; + EXECUTE stmt; + +END +//