Select Git revision
ext_bottom_line_test_data.py
-
Henrik tom Wörden authoredHenrik tom Wörden authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
retrieveEntity.sql 6.43 KiB
/*
* ** header v3.0
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2018 Research Group Biomedical Physics,
* Max-Planck-Institute for Dynamics and Self-Organization Göttingen
* Copyright (C) 2020 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale
*
* 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/>.
*
* ** end header
*/
delimiter //
drop procedure if exists db_5_0.retrieveEntity //
/**
* Select the content of an entity.
*
* By default the head is selected, but a specific version may be given.
*
* Parameters
* ----------
* EntityID
* The entity's id.
* Version
* The version id. In this procedure only, the version may also be given as
* `HEAD` for the latest version or as `HEAD~n`, which retrieves the n-th
* ancestor of `HEAD`.
*
* ResultSet
* ---------
* Tuple of (Datatype, Collection, EntityID, EntityName, EntityDesc,
* EntityRole, FileSize, FilePath, FileHash, ACL, Version)
*/
create procedure db_5_0.retrieveEntity(
in EntityID INT UNSIGNED,
in Version VARBINARY(255))
retrieveEntityBody: BEGIN
DECLARE FilePath VARCHAR(255) DEFAULT NULL;
DECLARE FileSize VARCHAR(255) DEFAULT NULL;
DECLARE FileHash VARCHAR(255) DEFAULT NULL;
DECLARE DatatypeID INT UNSIGNED DEFAULT NULL;
DECLARE CollectionName VARCHAR(255) DEFAULT NULL;
DECLARE IsHead BOOLEAN DEFAULT TRUE;
DECLARE IVersion INT UNSIGNED DEFAULT NULL;
DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL;
SELECT internal_id INTO InternalEntityID from entity_ids WHERE id = EntityID;
IF InternalEntityID IS NULL THEN
-- RETURN EARLY - Entity does not exist.
SELECT 0 FROM entities WHERE 0 = 1;
LEAVE retrieveEntityBody;
END IF;