Skip to content
Snippets Groups Projects

DOC, STY: in code documentation and styling for readablility

Merged Henrik tom Wörden requested to merge f-pov-doc into dev
Files
3
@@ -34,13 +34,16 @@ DELIMITER //
@@ -34,13 +34,16 @@ DELIMITER //
* ----------
* ----------
*
*
* versioned : boolean
* versioned : boolean
* If True, sourceSet and targetSet have an _iversion column, otherwise that column will be
* If True, sourceSet and targetSet have an _iversion column, otherwise that column will be ignored
* ignored (or only HEAD will be inserted into targetSet).
* (or only HEAD will be inserted into targetSet).
 
 
 
TODO description of sourceSet and targetSet is insufficient!
*/
*/
CREATE PROCEDURE db_5_0.applyPOV(in sourceSet VARCHAR(255), /* (?) Name of the table that the POV will be applied to. This can be a temporary table. */
CREATE PROCEDURE db_5_0.applyPOV(in sourceSet VARCHAR(255), /* (?) Name of the table that the POV will be applied to. This can be a temporary table. */
in targetSet VARCHAR(255), /* (?) Name of the result table of this POV. */
in targetSet VARCHAR(255), /* (?) Name of the result table of this POV. */
in propertiesTable VARCHAR(255),
in propertiesTable VARCHAR(255),
in refIdsTable VARCHAR(255),
in refIdsTable VARCHAR(255), /* (?) Name of a tmp table that contains all ids of children of the value interpreted as entity */
in o CHAR(4), /* The operator for this operation. can be one of:
in o CHAR(4), /* The operator for this operation. can be one of:
0 check for "equals NULL"
0 check for "equals NULL"
!0 check for "not NULL"
!0 check for "not NULL"
@@ -81,6 +84,10 @@ POV_LABEL: BEGIN
@@ -81,6 +84,10 @@ POV_LABEL: BEGIN
DECLARE keepTabl VARCHAR(255) DEFAULT NULL;
DECLARE keepTabl VARCHAR(255) DEFAULT NULL;
DECLARE existence_op VARCHAR(255) DEFAULT "EXISTS";
DECLARE existence_op VARCHAR(255) DEFAULT "EXISTS";
 
#-- ######### HINT ##############
 
#-- first the appropriate statement is created which in the end prepared and executed
 
#-- #############################
 
IF o = '->' THEN
IF o = '->' THEN
#-- special case: pure reference property
#-- special case: pure reference property
call applyRefPOV(sourceSet,targetSet, propertiesTable, refIdsTable, versioned);
call applyRefPOV(sourceSet,targetSet, propertiesTable, refIdsTable, versioned);
@@ -229,6 +236,8 @@ POV_LABEL: BEGIN
@@ -229,6 +236,8 @@ POV_LABEL: BEGIN
IF o = "!=" AND refIdsTable IS NOT NULL THEN
IF o = "!=" AND refIdsTable IS NOT NULL THEN
SET existence_op = "NOT EXISTS";
SET existence_op = "NOT EXISTS";
END IF;
END IF;
 
/* select all entities that reference the entity or a child of the
 
* value interpreted as ID*/
SET sRefData = IF(vText IS NULL,
SET sRefData = IF(vText IS NULL,
' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `reference_data`',
' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `reference_data`',
IF(refIdsTable IS NULL,
IF(refIdsTable IS NULL,
@@ -243,6 +252,7 @@ POV_LABEL: BEGIN
@@ -243,6 +252,7 @@ POV_LABEL: BEGIN
END IF;
END IF;
 
#-- create array of statement parts (and replace null with empty string) (?)
SET data = CONCAT('(',sTextData,
SET data = CONCAT('(',sTextData,
IF(sNameData IS NULL, '', sNameData),
IF(sNameData IS NULL, '', sNameData),
IF(sEnumData IS NULL, '', sEnumData),
IF(sEnumData IS NULL, '', sEnumData),
@@ -259,6 +269,7 @@ POV_LABEL: BEGIN
@@ -259,6 +269,7 @@ POV_LABEL: BEGIN
call createTmpTable(keepTabl, versioned);
call createTmpTable(keepTabl, versioned);
IF versioned THEN
IF versioned THEN
#-- generate statement from statement parts
#-- generate statement from statement parts
 
#-- (versioned section)
SET @stmtPOVkeepTblStr = CONCAT(
SET @stmtPOVkeepTblStr = CONCAT(
'INSERT IGNORE INTO `', keepTabl, '` (id, _iversion) SELECT entity_id AS id, _iversion FROM ', data,
'INSERT IGNORE INTO `', keepTabl, '` (id, _iversion) SELECT entity_id AS id, _iversion FROM ', data,
' as data', IF(propertiesTable IS NULL, '', CONCAT(
' as data', IF(propertiesTable IS NULL, '', CONCAT(
@@ -299,7 +310,14 @@ POV_LABEL: BEGIN
@@ -299,7 +310,14 @@ POV_LABEL: BEGIN
DEALLOCATE PREPARE stmtPOVkeepTbl;
DEALLOCATE PREPARE stmtPOVkeepTbl;
ELSE
ELSE
#-- generate statement from statement parts
#-- generate statement from statement parts
SET @stmtPOVkeepTblStr = CONCAT('INSERT IGNORE INTO `', keepTabl, '` (id) SELECT DISTINCT entity_id AS id FROM ', data, ' as data', IF(propertiesTable IS NULL, '', CONCAT(' WHERE EXISTS (Select 1 from `', propertiesTable, '` AS prop WHERE prop.id = data.property_id AND (prop.id2=data.entity_id OR prop.id2=0))')));
SET @stmtPOVkeepTblStr = CONCAT(
 
'INSERT IGNORE INTO `', keepTabl,
 
'` (id) SELECT DISTINCT entity_id AS id FROM ', data, ' as data',
 
IF(propertiesTable IS NULL, '',
 
CONCAT(' WHERE EXISTS (Select 1 from `', propertiesTable,
 
'` AS prop WHERE prop.id = data.property_id AND
 
(prop.id2=data.entity_id OR prop.id2=0))')));
 
#-- (unversioned section)
SET @stmtPOVStr = CONCAT(
SET @stmtPOVStr = CONCAT(
IF(targetSet IS NULL,
IF(targetSet IS NULL,
Loading