-- MySQL Script generated by MySQL Workbench -- Wed 18 Mar 2015 04:48:49 PM EET -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- -- Schema mydb -- ----------------------------------------------------- -- ----------------------------------------------------- -- Table `internalTypeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `internalTypeT` ; CREATE TABLE IF NOT EXISTS `internalTypeT` ( `id` VARCHAR(10) BINARY NOT NULL, `forceSingleType` ENUM('y') NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `id_forcesingletype_id` (`id` ASC, `forceSingleType` ASC)) ENGINE = InnoDB COMMENT = 'instead of enum for internal node type'; -- ----------------------------------------------------- -- Table `nodeTypeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `nodeTypeT` ; CREATE TABLE IF NOT EXISTS `nodeTypeT` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `forceSingleNode` ENUM('y') NULL, `internalTypeId` VARCHAR(10) BINARY NOT NULL COMMENT 'refers to internalTypeT.id', `forceSingleType` ENUM('y') NULL COMMENT 'filled in automatically by trigger', `code` VARCHAR(30) BINARY NULL, `forceSinglePhoto` ENUM('y') NULL, `canEditType` ENUM('n','y') NOT NULL DEFAULT 'n', `canEditNode` ENUM('n','y') NOT NULL, `canHavePhoto` ENUM('n','y') NOT NULL DEFAULT 'n', `canHaveRatingPoints` ENUM('n','y') NOT NULL DEFAULT 'n', `canLinkFrom` ENUM('n','y') NOT NULL DEFAULT 'n', `canLinkTo` ENUM('n','y') NOT NULL DEFAULT 'n', `canSearch` ENUM('n','y') NOT NULL DEFAULT 'n', `displayInObject` ENUM('n','y') NOT NULL DEFAULT 'n', `displayInObjectList` ENUM('n','y') NOT NULL DEFAULT 'n', `searchAnd` ENUM('n','y') NOT NULL DEFAULT 'n', `displayNode` ENUM('n','y') NOT NULL DEFAULT 'y', `requiredForObject` ENUM('n','y') NOT NULL DEFAULT 'n', `sorter` INT NOT NULL DEFAULT 0, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `sorter_idx` (`sorter` ASC), INDEX `canedittype_idx` (`canEditType` ASC), INDEX `canlinkfrom_idx` (`canLinkFrom` ASC), INDEX `canlinkto_idx` (`canLinkTo` ASC), INDEX `cansearch_idx` (`canSearch` ASC), UNIQUE INDEX `internaltypeid_uq` (`internalTypeId` ASC, `forceSingleType` ASC), INDEX `caneditnode_idx` (`canEditNode` ASC), UNIQUE INDEX `code_UNIQUE` (`code` ASC), INDEX `forcesinglenode_idx` (`id` ASC, `forceSingleNode` ASC), INDEX `displaynode_idx` (`displayNode` ASC), INDEX `requiredforobject_idx` (`requiredForObject` ASC), INDEX `canhaveratingpoints_idx` (`canHaveRatingPoints` ASC), INDEX `canhavephoto_idx` (`canHavePhoto` ASC), CONSTRAINT `fk_nodeTypeT_internalTypeT1` FOREIGN KEY (`internalTypeId` , `forceSingleType`) REFERENCES `internalTypeT` (`id` , `forceSingleType`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `nodeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `nodeT` ; CREATE TABLE IF NOT EXISTS `nodeT` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `nodeTypeId` INT UNSIGNED NOT NULL, `forceSingleNode` ENUM('y') NULL, `forceSinglePhoto` ENUM('y') NULL, `name` VARCHAR(50) NOT NULL, `isRoot` ENUM('n','y') NOT NULL DEFAULT 'n', `displayNode` ENUM('n','y') NOT NULL DEFAULT 'y', `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `addedUserId` INT UNSIGNED NULL, `addedUserName` VARCHAR(255) NULL, `addedIp` VARCHAR(40) NULL, `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `changedUserId` INT UNSIGNED NULL, `changedUserName` VARCHAR(255) NULL, `changedIp` VARCHAR(40) NULL, PRIMARY KEY (`id`), INDEX `nodeT_id_nodeTypeId_idx` (`id` ASC, `nodeTypeId` ASC), UNIQUE INDEX `nodetypeid_forcesinglenode_uq` (`nodeTypeId` ASC, `forceSingleNode` ASC), INDEX `isroot_idx` (`isRoot` ASC), INDEX `id_forcesinglephoto_idx` (`id` ASC, `forceSinglePhoto` ASC), INDEX `displaynode_idx` (`displayNode` ASC), CONSTRAINT `fk_nodeT_nodeTypeT1` FOREIGN KEY (`nodeTypeId` , `forceSingleNode`) REFERENCES `nodeTypeT` (`id` , `forceSingleNode`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `nodeLinkTypeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `nodeLinkTypeT` ; CREATE TABLE IF NOT EXISTS `nodeLinkTypeT` ( `id` INT UNSIGNED NOT NULL, `code` VARCHAR(30) BINARY NOT NULL, `forceSelfLink` ENUM('n','y') NOT NULL DEFAULT 'n', `isDefault` ENUM('y') NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code` ASC), INDEX `forceSelfLink_idx` (`forceSelfLink` ASC), UNIQUE INDEX `isDefault_UNIQUE` (`isDefault` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `nodeLinkT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `nodeLinkT` ; CREATE TABLE IF NOT EXISTS `nodeLinkT` ( `_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `nodeLinkTypeId` INT UNSIGNED NOT NULL, `srcNodeId` INT UNSIGNED NOT NULL, `dstNodeId` INT UNSIGNED NOT NULL, `metric` INT UNSIGNED NOT NULL DEFAULT 1, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`_id`), UNIQUE INDEX `nodelinktypeid_srcnodeid_dstnodeid_uq` (`nodeLinkTypeId` ASC, `srcNodeId` ASC, `dstNodeId` ASC), INDEX `nodelinktypeid_dstnodeid_srcnodeid_idx` (`nodeLinkTypeId` ASC, `dstNodeId` ASC, `srcNodeId` ASC), INDEX `nodelinktypeid_srcnodeid_metric_idx` (`nodeLinkTypeId` ASC, `srcNodeId` ASC, `metric` ASC), INDEX `nodelinktypeid_dstnodeid_metric_idx` (`nodeLinkTypeId` ASC, `dstNodeId` ASC, `metric` ASC), INDEX `fk_nodeLinkT_nodeT1_idx` (`srcNodeId` ASC), INDEX `fk_nodeLinkT_nodeT2_idx` (`dstNodeId` ASC), CONSTRAINT `fk_nodeLinkT_nodeLinkTypeT1` FOREIGN KEY (`nodeLinkTypeId`) REFERENCES `nodeLinkTypeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_nodeLinkT_nodeT1` FOREIGN KEY (`srcNodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_nodeLinkT_nodeT2` FOREIGN KEY (`dstNodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `languageT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `languageT` ; CREATE TABLE IF NOT EXISTS `languageT` ( `id` CHAR(3) NOT NULL, `name` VARCHAR(50) NOT NULL, `sorter` INT NOT NULL, `isDefault` ENUM('y') NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `isDefault_UNIQUE` (`isDefault` ASC), INDEX `sorter_idx` (`sorter` ASC), INDEX `default_idx` (`isDefault` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `nodeTypeTL` -- ----------------------------------------------------- DROP TABLE IF EXISTS `nodeTypeTL` ; CREATE TABLE IF NOT EXISTS `nodeTypeTL` ( `id` INT UNSIGNED NOT NULL, `languageId` CHAR(3) NOT NULL, `name` VARCHAR(50) NOT NULL, PRIMARY KEY (`id`, `languageId`), INDEX `fk_nodeTypeTL_languageT1_idx` (`languageId` ASC), CONSTRAINT `fk_nodeTypeTL_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_nodeTypeTL_nodeTypeT1` FOREIGN KEY (`id`) REFERENCES `nodeTypeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `allowedNodeLinkT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `allowedNodeLinkT` ; CREATE TABLE IF NOT EXISTS `allowedNodeLinkT` ( `srcNodeTypeId` INT UNSIGNED NOT NULL, `dstNodeTypeId` INT UNSIGNED NOT NULL, `essential` ENUM('n','y') NOT NULL DEFAULT 'n', `singleSrc` ENUM('n','y') NOT NULL DEFAULT 'n', `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`srcNodeTypeId`, `dstNodeTypeId`), INDEX `fk_allowedNodeLinkT_nodeTypeT2_idx` (`dstNodeTypeId` ASC), INDEX `essential_idx` (`essential` ASC), INDEX `singlesrc_idx` (`singleSrc` ASC), CONSTRAINT `fk_allowedNodeLinkT_nodeTypeT1` FOREIGN KEY (`srcNodeTypeId`) REFERENCES `nodeTypeT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_allowedNodeLinkT_nodeTypeT2` FOREIGN KEY (`dstNodeTypeId`) REFERENCES `nodeTypeT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `userRoleT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `userRoleT` ; CREATE TABLE IF NOT EXISTS `userRoleT` ( `id` VARCHAR(30) BINARY NOT NULL, `isDefault` ENUM('y') NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `isDefault_UNIQUE` (`isDefault` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `userT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `userT` ; CREATE TABLE IF NOT EXISTS `userT` ( `id` INT UNSIGNED NOT NULL, `name` VARCHAR(255) NOT NULL, `phone` VARCHAR(50) NULL, `email` VARCHAR(255) NULL, `login` VARCHAR(255) NOT NULL, `password` VARCHAR(100) NOT NULL, `roleId` VARCHAR(30) BINARY NOT NULL, `enabled` ENUM('n','y') NOT NULL DEFAULT 'y', `birthDate` DATE NULL, `preferredLanguage` CHAR(3) NULL, `token` VARCHAR(20) NULL, `phoneConfirmationCode` VARCHAR(255) NULL, `phoneConfirmationExpiry` DATETIME NULL, `emailConfirmationCode` VARCHAR(255) NULL, `emailConfirmationExpiry` DATETIME NULL, PRIMARY KEY (`id`), UNIQUE INDEX `login_UNIQUE` (`login` ASC), UNIQUE INDEX `phone_UNIQUE` (`phone` ASC), INDEX `fk_userT_languageT1_idx` (`preferredLanguage` ASC), INDEX `enabled_idx` (`enabled` ASC), INDEX `fk_userT_userRoleT1_idx` (`roleId` ASC), CONSTRAINT `fk_userT_nodeT1` FOREIGN KEY (`id`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_userT_languageT1` FOREIGN KEY (`preferredLanguage`) REFERENCES `languageT` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_userT_userRoleT1` FOREIGN KEY (`roleId`) REFERENCES `userRoleT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `tagT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `tagT` ; CREATE TABLE IF NOT EXISTS `tagT` ( `id` INT UNSIGNED NOT NULL, `sorter` INT NOT NULL DEFAULT 0, `canSearch` ENUM('n','y') NOT NULL DEFAULT 'y', `canSearchRaw` ENUM('n','y') NULL, `displayInObject` ENUM('n','y') NOT NULL DEFAULT 'n', `displayInObjectRaw` ENUM('n','y') NULL, `displayInObjectList` ENUM('n','y') NOT NULL DEFAULT 'n', `displayInObjectListRaw` ENUM('n','y') NULL, `factor` DOUBLE NOT NULL DEFAULT 1.0 COMMENT 'relative measurement of tag importance - from 0.1 to 1;\nvalid only for tag types with searchAnd = \'y\'', `ratingPoints` INT UNSIGNED NOT NULL DEFAULT 0, `enabled` ENUM('n','y') NOT NULL DEFAULT 'y', PRIMARY KEY (`id`), INDEX `fk_searchLabelT_nodeT1_idx` (`id` ASC), INDEX `sorter_idx` (`sorter` ASC), INDEX `cansearch_idx` (`canSearch` ASC), INDEX `displayinobject_idx` (`displayInObject` ASC), INDEX `displayinobjectlist_idx` (`displayInObjectList` ASC), INDEX `ratingpoints_idx` (`ratingPoints` ASC), CONSTRAINT `fk_searchLabelT_nodeT1` FOREIGN KEY (`id`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `tagTL` -- ----------------------------------------------------- DROP TABLE IF EXISTS `tagTL` ; CREATE TABLE IF NOT EXISTS `tagTL` ( `id` INT UNSIGNED NOT NULL, `languageId` CHAR(3) NOT NULL, `name` VARCHAR(255) NOT NULL, `uofmPre` VARCHAR(255) NOT NULL DEFAULT '', `uofmPost` VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`, `languageId`), INDEX `fk_searchLabelTL_languageT1_idx` (`languageId` ASC), CONSTRAINT `fk_searchLabelTL_searchLabelT1` FOREIGN KEY (`id`) REFERENCES `tagT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_searchLabelTL_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `objectStatusT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `objectStatusT` ; CREATE TABLE IF NOT EXISTS `objectStatusT` ( `id` CHAR(10) BINARY NOT NULL, `public` ENUM('n','y') NOT NULL, `userEditable` ENUM('n','y') NOT NULL, `userDraftable` ENUM('n','y') NOT NULL, `isDefault` ENUM('y') NULL, `sorter` INT NOT NULL DEFAULT 0, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `isDefault_UNIQUE` (`isDefault` ASC), INDEX `public_idx` (`public` ASC), INDEX `usereditable_idx` (`userEditable` ASC), INDEX `userdraftable_idx` (`userDraftable` ASC), INDEX `sorter_idx` (`sorter` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `objectT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `objectT` ; CREATE TABLE IF NOT EXISTS `objectT` ( `id` INT UNSIGNED NOT NULL, `address` TEXT NOT NULL, `description` TEXT NOT NULL, `statusId` CHAR(10) BINARY NOT NULL, `rating` DOUBLE NOT NULL DEFAULT 0.0, `noteForModerator` TEXT NULL, `noteForUser` TEXT NULL, `alias` TEXT NULL, PRIMARY KEY (`id`), INDEX `fk_objectT_objectStatusT1_idx` (`statusId` ASC), INDEX `rating_idx` (`rating` ASC), CONSTRAINT `fk_objectT_nodeT1` FOREIGN KEY (`id`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_objectT_objectStatusT1` FOREIGN KEY (`statusId`) REFERENCES `objectStatusT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `objectStatusTL` -- ----------------------------------------------------- DROP TABLE IF EXISTS `objectStatusTL` ; CREATE TABLE IF NOT EXISTS `objectStatusTL` ( `id` CHAR(10) BINARY NOT NULL, `languageId` CHAR(3) NOT NULL, `name` VARCHAR(50) NOT NULL, PRIMARY KEY (`id`, `languageId`), INDEX `fk_objectStatusTL_languageT1_idx` (`languageId` ASC), CONSTRAINT `fk_objectStatusTL_objectStatusT1` FOREIGN KEY (`id`) REFERENCES `objectStatusT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_objectStatusTL_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `imageTypeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `imageTypeT` ; CREATE TABLE IF NOT EXISTS `imageTypeT` ( `id` CHAR(10) BINARY NOT NULL, `isDefault` ENUM('y') NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `isDefault_UNIQUE` (`isDefault` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `imageT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `imageT` ; CREATE TABLE IF NOT EXISTS `imageT` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `nodeId` INT UNSIGNED NULL, `forceSinglePhoto` ENUM('y') NULL, `name` VARCHAR(255) NOT NULL, `filenameOriginal` VARCHAR(255) NOT NULL, `filenameFs` VARCHAR(255) NOT NULL, `display` ENUM('n','y') NOT NULL DEFAULT 'y', `sorter` INT NOT NULL, `imageTypeId` CHAR(10) BINARY NOT NULL, `videoType` VARCHAR(50) NOT NULL DEFAULT '', `url` VARCHAR(255) NOT NULL DEFAULT '', `extraId` VARCHAR(255) NOT NULL DEFAULT '', `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `addedUserId` INT UNSIGNED NULL, `addedUserName` VARCHAR(255) NULL, `addedIp` VARCHAR(40) NULL, `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `changedUserId` INT UNSIGNED NULL, `changedUserName` VARCHAR(255) NULL, `changedIp` VARCHAR(40) NULL, PRIMARY KEY (`id`), INDEX `objectIdSorter_idx` (`nodeId` ASC, `display` ASC, `sorter` ASC), UNIQUE INDEX `nodeid_forcesinglephoto_uq` (`nodeId` ASC, `forceSinglePhoto` ASC), INDEX `sorter_idx` (`nodeId` ASC, `sorter` ASC), INDEX `fk_imageT_imageTypeT1_idx` (`imageTypeId` ASC), CONSTRAINT `fk_imageT_nodeT1` FOREIGN KEY (`nodeId`) REFERENCES `nodeT` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT `fk_imageT_imageTypeT1` FOREIGN KEY (`imageTypeId`) REFERENCES `imageTypeT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `internalDataTypeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `internalDataTypeT` ; CREATE TABLE IF NOT EXISTS `internalDataTypeT` ( `id` VARCHAR(10) BINARY NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB COMMENT = 'instead of enum for attribute data type'; -- ----------------------------------------------------- -- Table `attributeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeT` ; CREATE TABLE IF NOT EXISTS `attributeT` ( `id` INT UNSIGNED NOT NULL, `dataTypeId` VARCHAR(10) BINARY NOT NULL, `code` VARCHAR(30) BINARY NULL, `required` ENUM('n','y') NOT NULL DEFAULT 'n', `sortable` ENUM('n','y') NOT NULL DEFAULT 'n', PRIMARY KEY (`id`), INDEX `attributeT_idLabelId_idx` (`id` ASC), INDEX `datatype_idx` (`dataTypeId` ASC), INDEX `sortable_idx` (`sortable` ASC), UNIQUE INDEX `code_UNIQUE` (`code` ASC), CONSTRAINT `fk_attributeT_tagT1` FOREIGN KEY (`id`) REFERENCES `tagT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_attributeT_internalDataTypeT1` FOREIGN KEY (`dataTypeId`) REFERENCES `internalDataTypeT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeNumericT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeNumericT` ; CREATE TABLE IF NOT EXISTS `attributeNumericT` ( `id` INT UNSIGNED NOT NULL, `decimalMin` DECIMAL(22,6) NULL, `decimalMax` DECIMAL(22,6) NULL, `decimalRound` INT NOT NULL DEFAULT 0, PRIMARY KEY (`id`), CONSTRAINT `fk_attributeNumericT_attributeT1` FOREIGN KEY (`id`) REFERENCES `attributeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeValueNumericT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeValueNumericT` ; CREATE TABLE IF NOT EXISTS `attributeValueNumericT` ( `attributeId` INT UNSIGNED NOT NULL, `objectId` INT UNSIGNED NOT NULL, `value` DECIMAL(22,6) NOT NULL, `valueRaw` DECIMAL(22,6) NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX `value_idx` (`value` ASC), PRIMARY KEY (`attributeId`, `objectId`), INDEX `fk_attributeValueNumericT_objectT1_idx` (`objectId` ASC), CONSTRAINT `fk_attributeValueNumericT_attributeNumericT1` FOREIGN KEY (`attributeId`) REFERENCES `attributeNumericT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_attributeValueNumericT_objectT1` FOREIGN KEY (`objectId`) REFERENCES `objectT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeDatetimeFormatT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeDatetimeFormatT` ; CREATE TABLE IF NOT EXISTS `attributeDatetimeFormatT` ( `id` VARCHAR(10) BINARY NOT NULL, `storageFormat` VARCHAR(30) NOT NULL, `sorter` INT NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX `sorter_idx` (`sorter` ASC), PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeDatetimeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeDatetimeT` ; CREATE TABLE IF NOT EXISTS `attributeDatetimeT` ( `id` INT UNSIGNED NOT NULL, `datetimeStorageId` VARCHAR(10) BINARY NOT NULL, PRIMARY KEY (`id`), INDEX `fk_attributeDatetimeT_attributeDatetimeFormatT1_idx` (`datetimeStorageId` ASC), CONSTRAINT `fk_attributeDatetimeT_attributeT1` FOREIGN KEY (`id`) REFERENCES `attributeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_attributeDatetimeT_attributeDatetimeFormatT1` FOREIGN KEY (`datetimeStorageId`) REFERENCES `attributeDatetimeFormatT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeValueDatetimeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeValueDatetimeT` ; CREATE TABLE IF NOT EXISTS `attributeValueDatetimeT` ( `attributeId` INT UNSIGNED NOT NULL, `objectId` INT UNSIGNED NOT NULL, `value` DATETIME NOT NULL, `valueRaw` DATETIME NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX `value_idx` (`value` ASC), PRIMARY KEY (`attributeId`, `objectId`), INDEX `fk_attributeValueDatetimeT_objectT1_idx` (`objectId` ASC), CONSTRAINT `fk_attributeValueDatetimeT_attributeDatetimeT1` FOREIGN KEY (`attributeId`) REFERENCES `attributeDatetimeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_attributeValueDatetimeT_objectT1` FOREIGN KEY (`objectId`) REFERENCES `objectT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeDatetimeFormatTL` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeDatetimeFormatTL` ; CREATE TABLE IF NOT EXISTS `attributeDatetimeFormatTL` ( `id` VARCHAR(10) BINARY NOT NULL, `languageId` CHAR(3) NOT NULL, `name` VARCHAR(50) NOT NULL, `outputFormat` VARCHAR(30) NOT NULL, `outputFormatJs` VARCHAR(30) NOT NULL, PRIMARY KEY (`languageId`, `id`), INDEX `fk_attributeDatetimeFormatTL_languageT1_idx` (`languageId` ASC), INDEX `fk_attributeDatetimeFormatTL_attributeDatetimeFormatT1_idx` (`id` ASC), CONSTRAINT `fk_attributeDatetimeFormatTL_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_attributeDatetimeFormatTL_attributeDatetimeFormatT1` FOREIGN KEY (`id`) REFERENCES `attributeDatetimeFormatT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeTextT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeTextT` ; CREATE TABLE IF NOT EXISTS `attributeTextT` ( `id` INT UNSIGNED NOT NULL, `textIsLong` ENUM('n','y') NOT NULL DEFAULT 'n', PRIMARY KEY (`id`), CONSTRAINT `fk_attributeText_attributeT1` FOREIGN KEY (`id`) REFERENCES `attributeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeValueTextT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeValueTextT` ; CREATE TABLE IF NOT EXISTS `attributeValueTextT` ( `attributeId` INT UNSIGNED NOT NULL, `objectId` INT UNSIGNED NOT NULL, `languageId` CHAR(3) NOT NULL, `value` TEXT NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`attributeId`, `objectId`, `languageId`), INDEX `fk_attributeValueTextT_languageT1_idx` (`languageId` ASC), INDEX `fk_attributeValueTextT_objectT1_idx` (`objectId` ASC), CONSTRAINT `fk_attributeValueTextT_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_attributeValueTextT_attributeText1` FOREIGN KEY (`attributeId`) REFERENCES `attributeTextT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_attributeValueTextT_objectT1` FOREIGN KEY (`objectId`) REFERENCES `objectT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `templateT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `templateT` ; CREATE TABLE IF NOT EXISTS `templateT` ( `srcNodeTypeId` INT UNSIGNED NOT NULL, `dstNodeId` INT UNSIGNED NOT NULL, `dstNodeTypeId` INT UNSIGNED NOT NULL COMMENT 'filled in automatically by trigger', `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`srcNodeTypeId`, `dstNodeId`), INDEX `fk_templateT_nodeT1_idx` (`dstNodeId` ASC, `dstNodeTypeId` ASC), INDEX `fk_templateT_allowedNodeLinkT1_idx` (`srcNodeTypeId` ASC, `dstNodeTypeId` ASC), CONSTRAINT `fk_attributeTemplateT_nodeTypeT1` FOREIGN KEY (`srcNodeTypeId`) REFERENCES `nodeTypeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_templateT_nodeT1` FOREIGN KEY (`dstNodeId` , `dstNodeTypeId`) REFERENCES `nodeT` (`id` , `nodeTypeId`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_templateT_allowedNodeLinkT1` FOREIGN KEY (`srcNodeTypeId` , `dstNodeTypeId`) REFERENCES `allowedNodeLinkT` (`srcNodeTypeId` , `dstNodeTypeId`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `zzzNodeWorksetT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzNodeWorksetT` ; CREATE TABLE IF NOT EXISTS `zzzNodeWorksetT` ( `nodeId` INT UNSIGNED NOT NULL, `connId` BIGINT UNSIGNED NOT NULL, `isMain` INT NOT NULL DEFAULT 1, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`nodeId`, `connId`), INDEX `added_idx` (`added` ASC), INDEX `connid_nodeid_ismain_idx` (`connId` ASC, `nodeId` ASC, `isMain` ASC), INDEX `ismain_idx` (`isMain` ASC)) ENGINE = MEMORY; -- ----------------------------------------------------- -- Table `oauthProviderT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `oauthProviderT` ; CREATE TABLE IF NOT EXISTS `oauthProviderT` ( `id` VARCHAR(30) BINARY NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `userOauthT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `userOauthT` ; CREATE TABLE IF NOT EXISTS `userOauthT` ( `userId` INT UNSIGNED NOT NULL, `oauthProviderId` VARCHAR(30) BINARY NOT NULL, `identity` VARCHAR(255) NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`userId`, `oauthProviderId`), INDEX `fk_userOauthT_oauthProviderT1_idx` (`oauthProviderId` ASC), INDEX `provideridentity_idx` (`oauthProviderId` ASC, `identity` ASC), CONSTRAINT `fk_userOauthT_userT1` FOREIGN KEY (`userId`) REFERENCES `userT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_userOauthT_oauthProviderT1` FOREIGN KEY (`oauthProviderId`) REFERENCES `oauthProviderT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `zzzDevNullT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzDevNullT` ; CREATE TABLE IF NOT EXISTS `zzzDevNullT` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = BLACKHOLE; -- ----------------------------------------------------- -- Table `externalDataSourceT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `externalDataSourceT` ; CREATE TABLE IF NOT EXISTS `externalDataSourceT` ( `id` VARCHAR(30) BINARY NOT NULL, `name` VARCHAR(50) NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `externalDataT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `externalDataT` ; CREATE TABLE IF NOT EXISTS `externalDataT` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `externalDataSourceId` VARCHAR(30) BINARY NOT NULL, `externalParentKey` VARCHAR(255) NULL, `parentNodeId` INT UNSIGNED NULL, `externalKey` VARCHAR(255) BINARY NOT NULL, `tagId` INT UNSIGNED NULL, `typeCode` VARCHAR(30) BINARY NOT NULL, `enabled` ENUM('n','y') NOT NULL DEFAULT 'y', `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_externalDataT_externalDataSourceT1_idx` (`externalDataSourceId` ASC), INDEX `fk_externalDataT_tagT1_idx` (`tagId` ASC), UNIQUE INDEX `externaldatasourceid_externalkey_uq` (`externalDataSourceId` ASC, `parentNodeId` ASC, `typeCode` ASC, `externalKey` ASC), INDEX `enabled_idx` (`externalDataSourceId` ASC, `enabled` ASC), UNIQUE INDEX `externaldatasourceid_tagid_uq` (`externalDataSourceId` ASC, `tagId` ASC), INDEX `fk_externalDataT_tagT2_idx` (`parentNodeId` ASC), INDEX `externalkey_idx` (`externalKey` ASC), INDEX `externalparentkey_idx` (`externalParentKey` ASC), CONSTRAINT `fk_externalDataT_externalDataSourceT1` FOREIGN KEY (`externalDataSourceId`) REFERENCES `externalDataSourceT` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_externalDataT_tagT1` FOREIGN KEY (`tagId`) REFERENCES `tagT` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT `fk_externalDataT_tagT2` FOREIGN KEY (`parentNodeId`) REFERENCES `tagT` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `externalDataTL` -- ----------------------------------------------------- DROP TABLE IF EXISTS `externalDataTL` ; CREATE TABLE IF NOT EXISTS `externalDataTL` ( `id` INT UNSIGNED NOT NULL, `languageId` CHAR(3) NOT NULL, `name` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`, `languageId`), INDEX `fk_externalDataTL_languageT1_idx` (`languageId` ASC), CONSTRAINT `fk_externalDataTL_externalDataT1` FOREIGN KEY (`id`) REFERENCES `externalDataT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_externalDataTL_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `externalDataSourceDatasetT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `externalDataSourceDatasetT` ; CREATE TABLE IF NOT EXISTS `externalDataSourceDatasetT` ( `externalDataSourceId` VARCHAR(30) BINARY NOT NULL, `code` VARCHAR(255) NOT NULL, `nodeId` INT UNSIGNED NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`externalDataSourceId`, `code`), CONSTRAINT `fk_externalDataSourceDatasetT_externalDataSourceT1` FOREIGN KEY (`externalDataSourceId`) REFERENCES `externalDataSourceT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `externalOsmDictionaryT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `externalOsmDictionaryT` ; CREATE TABLE IF NOT EXISTS `externalOsmDictionaryT` ( `externalDataSourceId` VARCHAR(30) BINARY NOT NULL, `code` VARCHAR(255) NOT NULL, `boundingWayIds` VARCHAR(255) NOT NULL COMMENT 'ways ids for administrative bounds; taken from OSM', `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`externalDataSourceId`, `code`), CONSTRAINT `fk_osmDictionaryT_externalDataSourceDatasetT1` FOREIGN KEY (`externalDataSourceId` , `code`) REFERENCES `externalDataSourceDatasetT` (`externalDataSourceId` , `code`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `zzzIntsT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzIntsT` ; CREATE TABLE IF NOT EXISTS `zzzIntsT` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `searchSessionT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `searchSessionT` ; CREATE TABLE IF NOT EXISTS `searchSessionT` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `sid` VARCHAR(100) BINARY NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `sessionId_UNIQUE` (`sid` ASC), INDEX `added_idx` (`added` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `searchCriterionT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `searchCriterionT` ; CREATE TABLE IF NOT EXISTS `searchCriterionT` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `sessionId` BIGINT UNSIGNED NOT NULL, `nodeId` INT UNSIGNED NOT NULL, `nodeTypeId` INT UNSIGNED NULL, `internalTypeId` VARCHAR(10) BINARY NOT NULL, INDEX `fk_searchCriterion_nodeT1_idx` (`nodeId` ASC, `nodeTypeId` ASC), INDEX `nodetypeid_node_id` (`sessionId` ASC, `nodeId` ASC, `nodeTypeId` ASC), INDEX `fk_searchCriterionT_internalTypeT1_idx` (`internalTypeId` ASC), PRIMARY KEY (`id`), UNIQUE INDEX `sessionid_nodeid_uq` (`sessionId` ASC, `nodeId` ASC), CONSTRAINT `fk_searchCriterion_nodeT1` FOREIGN KEY (`nodeId` , `nodeTypeId`) REFERENCES `nodeT` (`id` , `nodeTypeId`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_searchCriterionT_internalTypeT1` FOREIGN KEY (`internalTypeId`) REFERENCES `internalTypeT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_searchCriterionT_searchSessionT1` FOREIGN KEY (`sessionId`) REFERENCES `searchSessionT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `searchCriterionNumericT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `searchCriterionNumericT` ; CREATE TABLE IF NOT EXISTS `searchCriterionNumericT` ( `searchCriterionId` BIGINT UNSIGNED NOT NULL, `valueLow` DECIMAL(22,6) NULL, `valueHigh` DECIMAL(22,6) NULL, PRIMARY KEY (`searchCriterionId`), CONSTRAINT `fk_searchCriterionNumericT_searchCriterionT1` FOREIGN KEY (`searchCriterionId`) REFERENCES `searchCriterionT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `searchCriterionDatetimeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `searchCriterionDatetimeT` ; CREATE TABLE IF NOT EXISTS `searchCriterionDatetimeT` ( `searchCriterionId` BIGINT UNSIGNED NOT NULL, `valueLow` DATETIME NULL, `valueHigh` DATETIME NULL, PRIMARY KEY (`searchCriterionId`), CONSTRAINT `fk_searchCriterionDatetimeT_searchCriterionT1` FOREIGN KEY (`searchCriterionId`) REFERENCES `searchCriterionT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `searchResultT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `searchResultT` ; CREATE TABLE IF NOT EXISTS `searchResultT` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `sessionId` BIGINT UNSIGNED NOT NULL, `nodeId` INT UNSIGNED NOT NULL, `collapsed` ENUM('n','y') NOT NULL DEFAULT 'n', `extraObjects` INT UNSIGNED NOT NULL DEFAULT 0, `relevancy` DOUBLE NOT NULL DEFAULT 0.0, INDEX `collapsed_idx` (`sessionId` ASC, `collapsed` ASC), INDEX `relevancy_idx` (`sessionId` ASC, `relevancy` DESC), PRIMARY KEY (`id`), UNIQUE INDEX `sessionid_nodeid_uq` (`sessionId` ASC, `nodeId` ASC), INDEX `fk_searchResultT_nodeT1_idx` (`nodeId` ASC), CONSTRAINT `fk_searchResultT_searchSessionT1` FOREIGN KEY (`sessionId`) REFERENCES `searchSessionT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_searchResultT_nodeT1` FOREIGN KEY (`nodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `tmpOsmDataT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `tmpOsmDataT` ; CREATE TABLE IF NOT EXISTS `tmpOsmDataT` ( `id` VARCHAR(50) NOT NULL, `highway` VARCHAR(100) NULL, `name_ukr` VARCHAR(255) NULL, `name_rus` VARCHAR(255) NULL, `name_eng` VARCHAR(255) NULL COMMENT 'temp table to import OSM data, one dataset at once', PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `zzzDevNull2T` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzDevNull2T` ; CREATE TABLE IF NOT EXISTS `zzzDevNull2T` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = BLACKHOLE COMMENT = 'used in calls where the function already executes inserts to' /* comment truncated */ /* zzzDevNullT*/; -- ----------------------------------------------------- -- Table `nodeAncestryT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `nodeAncestryT` ; CREATE TABLE IF NOT EXISTS `nodeAncestryT` ( `id` INT UNSIGNED NOT NULL, `languageId` CHAR(3) NOT NULL, `tagNames` TEXT NULL, PRIMARY KEY (`id`, `languageId`), INDEX `fk_nodeAncestryT_languageT1_idx` (`languageId` ASC), CONSTRAINT `fk_nodeAncestryT_nodeT1` FOREIGN KEY (`id`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_nodeAncestryT_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `nodeAncestrySourceT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `nodeAncestrySourceT` ; CREATE TABLE IF NOT EXISTS `nodeAncestrySourceT` ( `nodeTypeId` INT UNSIGNED NOT NULL, `srcNodeTypeId` INT UNSIGNED NOT NULL, `sorter` INT NOT NULL DEFAULT 0, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`nodeTypeId`, `srcNodeTypeId`), INDEX `fk_nodeAncestrySourceT_nodeTypeT2_idx` (`srcNodeTypeId` ASC), INDEX `sorter_idx` (`nodeTypeId` ASC, `srcNodeTypeId` ASC, `sorter` ASC), CONSTRAINT `fk_nodeAncestrySourceT_nodeTypeT1` FOREIGN KEY (`nodeTypeId`) REFERENCES `nodeTypeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_nodeAncestrySourceT_nodeTypeT2` FOREIGN KEY (`srcNodeTypeId`) REFERENCES `nodeTypeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `coordT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `coordT` ; CREATE TABLE IF NOT EXISTS `coordT` ( `nodeId` INT UNSIGNED NOT NULL, `latitude` DECIMAL(12,7) NOT NULL, `longitude` DECIMAL(12,7) NOT NULL, PRIMARY KEY (`nodeId`), CONSTRAINT `fk_coordT_nodeT1` FOREIGN KEY (`nodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `zzzDevNullLinkT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzDevNullLinkT` ; CREATE TABLE IF NOT EXISTS `zzzDevNullLinkT` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = BLACKHOLE; -- ----------------------------------------------------- -- Table `zzzDevNullNodeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzDevNullNodeT` ; CREATE TABLE IF NOT EXISTS `zzzDevNullNodeT` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = BLACKHOLE; -- ----------------------------------------------------- -- Table `zzzDevNullObjectT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzDevNullObjectT` ; CREATE TABLE IF NOT EXISTS `zzzDevNullObjectT` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = BLACKHOLE; -- ----------------------------------------------------- -- Table `zzzDevNullExternalDataT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzDevNullExternalDataT` ; CREATE TABLE IF NOT EXISTS `zzzDevNullExternalDataT` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = BLACKHOLE; -- ----------------------------------------------------- -- Table `zzzDevNullTemplateT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzDevNullTemplateT` ; CREATE TABLE IF NOT EXISTS `zzzDevNullTemplateT` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = BLACKHOLE; -- ----------------------------------------------------- -- Table `cacheObjectSortT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `cacheObjectSortT` ; CREATE TABLE IF NOT EXISTS `cacheObjectSortT` ( `objectId` INT UNSIGNED NOT NULL, `attributeId` INT UNSIGNED NOT NULL, `sorterAsc` DOUBLE NULL, `sorterDesc` DOUBLE NULL, PRIMARY KEY (`objectId`, `attributeId`), INDEX `sorterasc_idx` (`attributeId` ASC, `sorterAsc` DESC), INDEX `sorterdesc_idx` (`attributeId` ASC, `sorterDesc` DESC), CONSTRAINT `fk_cacheObjectSortT_objectT1` FOREIGN KEY (`objectId`) REFERENCES `objectT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_cacheObjectSortT_attributeT1` FOREIGN KEY (`attributeId`) REFERENCES `attributeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `zzzDevNullSearchT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzDevNullSearchT` ; CREATE TABLE IF NOT EXISTS `zzzDevNullSearchT` ( `n` INT UNSIGNED NOT NULL, PRIMARY KEY (`n`)) ENGINE = BLACKHOLE; -- ----------------------------------------------------- -- Table `zzzValidCharT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `zzzValidCharT` ; CREATE TABLE IF NOT EXISTS `zzzValidCharT` ( `id` VARCHAR(1) BINARY NOT NULL, `purpose` VARCHAR(10) NOT NULL, `replacement` VARCHAR(1) BINARY NULL, `forceSingle` ENUM('n','y') NOT NULL DEFAULT 'n', PRIMARY KEY (`id`, `purpose`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `tagCacheT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `tagCacheT` ; CREATE TABLE IF NOT EXISTS `tagCacheT` ( `id` INT UNSIGNED NOT NULL, `tagNames` TEXT NULL, `tagNamesSearch` TEXT NULL, `tagNamesFullSearch` TEXT NULL, PRIMARY KEY (`id`), CONSTRAINT `fk_tagCacheT_tagT1` FOREIGN KEY (`id`) REFERENCES `tagT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `attributeCacheT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `attributeCacheT` ; CREATE TABLE IF NOT EXISTS `attributeCacheT` ( `id` INT UNSIGNED NOT NULL, `attributeNames` TEXT NULL, `attributeNamesSearch` TEXT NULL, PRIMARY KEY (`id`), CONSTRAINT `fk_attributeCacheT_attributeT1` FOREIGN KEY (`id`) REFERENCES `attributeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `searchResultSelectedT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `searchResultSelectedT` ; CREATE TABLE IF NOT EXISTS `searchResultSelectedT` ( `sessionId` BIGINT UNSIGNED NOT NULL, `objectId` INT UNSIGNED NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`sessionId`, `objectId`), INDEX `fk_searchResultSelectedT_objectT1_idx` (`objectId` ASC), INDEX `added_idx` (`sessionId` ASC, `added` ASC), CONSTRAINT `fk_searchResultSelectedT_searchSessionT1` FOREIGN KEY (`sessionId`) REFERENCES `searchSessionT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_searchResultSelectedT_objectT1` FOREIGN KEY (`objectId`) REFERENCES `objectT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `_maintenanceLogT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `_maintenanceLogT` ; CREATE TABLE IF NOT EXISTS `_maintenanceLogT` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `sessId` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'contains uuid_short values; used to link records from within one call', `msg` VARCHAR(100) NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `sessid_idx` (`sessId` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `exceptNodeLinkNodeNodeTypeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `exceptNodeLinkNodeNodeTypeT` ; CREATE TABLE IF NOT EXISTS `exceptNodeLinkNodeNodeTypeT` ( `srcNodeId` INT UNSIGNED NOT NULL, `dstNodeTypeId` INT UNSIGNED NOT NULL, `comment` VARCHAR(255) NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`srcNodeId`, `dstNodeTypeId`), UNIQUE INDEX `dstnodetypeid_srcnodeid_idx` (`dstNodeTypeId` ASC, `srcNodeId` ASC), CONSTRAINT `fk_exceptNodeLinkNodeNodeTypeT_nodeT1` FOREIGN KEY (`srcNodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_exceptNodeLinkNodeNodeTypeT_nodeTypeT1` FOREIGN KEY (`dstNodeTypeId`) REFERENCES `nodeTypeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `tmpAdmterDataT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `tmpAdmterDataT` ; CREATE TABLE IF NOT EXISTS `tmpAdmterDataT` ( `id` VARCHAR(10) NOT NULL, `parentId` VARCHAR(10) NULL, `koatuu` VARCHAR(10) NULL, `ukrName` VARCHAR(255) NULL, `rusName` VARCHAR(255) NULL, `engName` VARCHAR(255) NULL, `oblast_koatuu` VARCHAR(10) NULL, `district_koatuu` VARCHAR(10) NULL, `adminCenterId` VARCHAR(10) NULL, `type` CHAR(2) NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `externalAdmterTypeT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `externalAdmterTypeT` ; CREATE TABLE IF NOT EXISTS `externalAdmterTypeT` ( `id` INT UNSIGNED NOT NULL, `typeCode` VARCHAR(30) BINARY NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `externalAdmterTypeTL` -- ----------------------------------------------------- DROP TABLE IF EXISTS `externalAdmterTypeTL` ; CREATE TABLE IF NOT EXISTS `externalAdmterTypeTL` ( `id` INT UNSIGNED NOT NULL, `languageId` CHAR(3) NOT NULL, `prefix` VARCHAR(100) NOT NULL, `suffix` VARCHAR(100) NOT NULL, PRIMARY KEY (`id`, `languageId`), INDEX `fk_externalAdmterTypeTL_languageT1_idx` (`languageId` ASC), CONSTRAINT `fk_externalAdmterTypeTL_externalAdmterTypeT1` FOREIGN KEY (`id`) REFERENCES `externalAdmterTypeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_externalAdmterTypeTL_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `storedTagDataT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `storedTagDataT` ; CREATE TABLE IF NOT EXISTS `storedTagDataT` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `nodeTypeId` INT UNSIGNED NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_storedTagDataT_nodeTypeT1_idx` (`nodeTypeId` ASC), CONSTRAINT `fk_storedTagDataT_nodeTypeT1` FOREIGN KEY (`nodeTypeId`) REFERENCES `nodeTypeT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `storedTagDataStreetT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `storedTagDataStreetT` ; CREATE TABLE IF NOT EXISTS `storedTagDataStreetT` ( `id` VARCHAR(10) NOT NULL, `name_ukr` VARCHAR(100) NULL, `name_rus` VARCHAR(100) NULL, `name_eng` VARCHAR(100) NULL, `external_id` INT UNSIGNED NULL, PRIMARY KEY (`id`), INDEX `fk_storedTagDataStreetT_storedTagDataT1_idx` (`external_id` ASC), CONSTRAINT `fk_storedTagDataStreetT_storedTagDataT1` FOREIGN KEY (`external_id`) REFERENCES `storedTagDataT` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `storedTagDataTL` -- ----------------------------------------------------- DROP TABLE IF EXISTS `storedTagDataTL` ; CREATE TABLE IF NOT EXISTS `storedTagDataTL` ( `id` INT UNSIGNED NOT NULL, `languageId` CHAR(3) NOT NULL, `name` VARCHAR(255) NOT NULL, `prefix` VARCHAR(255) NOT NULL DEFAULT '', `suffix` VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`, `languageId`), INDEX `fk_storedTagDataTL_languageT1_idx` (`languageId` ASC), INDEX `idx_storedtagdatat_name` (`name` ASC), CONSTRAINT `fk_storedTagDataTL_storedTagDataT1` FOREIGN KEY (`id`) REFERENCES `storedTagDataT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_storedTagDataTL_languageT1` FOREIGN KEY (`languageId`) REFERENCES `languageT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `tmpStreetDataT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `tmpStreetDataT` ; CREATE TABLE IF NOT EXISTS `tmpStreetDataT` ( `id` VARCHAR(10) NOT NULL, `name_ukr` VARCHAR(100) NULL, `name_rus` VARCHAR(100) NULL, `name_eng` VARCHAR(100) NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `moderationQueueT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `moderationQueueT` ; CREATE TABLE IF NOT EXISTS `moderationQueueT` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `nodeId` INT UNSIGNED NOT NULL, `comment1` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'initial comment', `comment2` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'comment when resolving', `resolved` ENUM('n','y') NOT NULL DEFAULT 'n', `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `addedUserId` INT NULL, `addedUserName` VARCHAR(255) NULL, `addedIp` VARCHAR(40) NULL, `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `changedUserId` INT NULL, `changedUserName` VARCHAR(255) NULL, `changedIp` VARCHAR(40) NULL, PRIMARY KEY (`id`), INDEX `fk_moderationQueueT_nodeT1_idx` (`nodeId` ASC), INDEX `resolved_idx` (`resolved` ASC), CONSTRAINT `fk_moderationQueueT_nodeT1` FOREIGN KEY (`nodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `constT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `constT` ; CREATE TABLE IF NOT EXISTS `constT` ( `id` VARCHAR(255) BINARY NOT NULL, `comment` VARCHAR(255) NOT NULL DEFAULT '', `valueString` VARCHAR(255) NULL, `valueInt` INT NULL, `valueFloat` DOUBLE NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `cacheSearchDefaultResultT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `cacheSearchDefaultResultT` ; CREATE TABLE IF NOT EXISTS `cacheSearchDefaultResultT` ( `nodeId` INT UNSIGNED NOT NULL, PRIMARY KEY (`nodeId`), CONSTRAINT `fk_cacheSearchDefaultResultT_nodeT1` FOREIGN KEY (`nodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Placeholder table for view `zzzNodeWorksetV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `zzzNodeWorksetV` (`nodeId` INT, `connId` INT, `isMain` INT, `added` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeTypeV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeTypeV` (`id` INT, `name` INT, `code` INT, `internalTypeId` INT, `forceSinglePhoto` INT, `canEditType` INT, `canEditNode` INT, `canHavePhoto` INT, `canHaveRatingPoints` INT, `canLinkFrom` INT, `canLinkTo` INT, `canSearch` INT, `displayInObject` INT, `displayInObjectList` INT, `searchAnd` INT, `displayNode` INT, `requiredForObject` INT, `sorter` INT, `languageId` INT, `added` INT, `changed` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeTypeVL` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeTypeVL` (`id` INT, `languageId` INT, `name` INT); -- ----------------------------------------------------- -- Placeholder table for view `userV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `userV` (`id` INT, `name` INT, `phone` INT, `email` INT, `login` INT, `password` INT, `roleId` INT, `enabled` INT, `birthDate` INT, `preferredLanguage` INT, `token` INT, `phoneConfirmationCode` INT, `phoneConfirmationExpiry` INT, `emailConfirmationCode` INT, `emailConfirmationExpiry` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT); -- ----------------------------------------------------- -- Placeholder table for view `userOauthV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `userOauthV` (`userId` INT, `oauthProviderId` INT, `identity` INT, `added` INT, `changed` INT); -- ----------------------------------------------------- -- Placeholder table for view `allowedNodeLinkCanCreateV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `allowedNodeLinkCanCreateV` (`srcNodeTypeId` INT, `dstNodeTypeId` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagV` (`id` INT, `typeId` INT, `forceSingleNode` INT, `isRoot` INT, `typeCode` INT, `typeName` INT, `internalTypeId` INT, `typeCanEdit` INT, `typeCanHavePhoto` INT, `typeCanHaveRatingPoints` INT, `typeCanSearch` INT, `typeDisplayInObject` INT, `typeDisplayInObjectList` INT, `typeSearchAnd` INT, `typeRequiredForObject` INT, `typeSorter` INT, `name` INT, `sorter` INT, `canSearch` INT, `canSearchRaw` INT, `displayInObject` INT, `displayInObjectRaw` INT, `displayInObjectList` INT, `displayInObjectListRaw` INT, `factor` INT, `ratingPoints` INT, `enabled` INT, `attributeDataType` INT, `attributeCode` INT, `required` INT, `sortable` INT, `uofmPre` INT, `uofmPost` INT, `geoRoot` INT, `languageId` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagVL` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagVL` (`id` INT, `languageId` INT, `name` INT, `uofmPre` INT, `uofmPost` INT); -- ----------------------------------------------------- -- Placeholder table for view `allowedNodeLinkV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `allowedNodeLinkV` (`srcNodeTypeId` INT, `dstNodeTypeId` INT, `essential` INT, `singleSrc` INT, `added` INT, `changed` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchResultV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchResultV` (`sessionId` INT, `nodeId` INT, `collapsed` INT, `extraObjects` INT, `relevancy` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchCriterionV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchCriterionV` (`nodeId` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchCriterionNumericV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchCriterionNumericV` (`nodeId` INT, `valueLow` INT, `valueHigh` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchCriterionDatetimeV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchCriterionDatetimeV` (`nodeId` INT, `valueLow` INT, `valueHigh` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeV` (`id` INT, `nodeTypeId` INT, `forceSingleNode` INT, `name` INT, `isRoot` INT, `typeName` INT, `typeCode` INT, `internalTypeId` INT, `canEditType` INT, `canEditNode` INT, `canHavePhoto` INT, `canHaveRatingPoints` INT, `canLinkFrom` INT, `canLinkTo` INT, `canSearch` INT, `displayInObject` INT, `displayInObjectList` INT, `searchAnd` INT, `requiredForObject` INT, `sorter` INT, `languageId` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeLinkV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeLinkV` (`nodeLinkTypeId` INT, `code` INT, `isDefault` INT, `srcNodeId` INT, `dstNodeId` INT, `metric` INT, `added` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeLinkOwnsV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeLinkOwnsV` (`nodeLinkTypeId` INT, `srcNodeId` INT, `dstNodeId` INT, `metric` INT, `added` INT); -- ----------------------------------------------------- -- Placeholder table for view `allowedNodeLinkByNodeV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `allowedNodeLinkByNodeV` (`srcNodeId` INT, `srcNodeTypeId` INT, `srcDisplayNode` INT, `dstNodeId` INT, `dstNodeTypeId` INT, `dstDisplayNode` INT, `essential` INT, `singleSrc` INT, `added` INT, `changed` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeRootLinkV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeRootLinkV` (`id` INT, `nodeTypeId` INT, `forceSingleNode` INT, `name` INT, `isRoot` INT, `displayNode` INT, `typeCode` INT, `typeCanSearch` INT, `typeDisplayInObject` INT, `typeDisplayInObjectList` INT, `typeRequiredForObject` INT, `typeSorter` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT, `nodeLinkTypeId` INT, `dstNodeId` INT, `metric` INT); -- ----------------------------------------------------- -- Placeholder table for view `objectV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `objectV` (`id` INT, `address` INT, `description` INT, `statusId` INT, `statusName` INT, `public` INT, `userEditable` INT, `userDraftable` INT, `latitude` INT, `longitude` INT, `rating` INT, `noteForModerator` INT, `noteForUser` INT, `alias` INT, `languageId` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT); -- ----------------------------------------------------- -- Placeholder table for view `objectForUserV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `objectForUserV` (`id` INT); -- ----------------------------------------------------- -- Placeholder table for view `_nodeRecommendLinkV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `_nodeRecommendLinkV` (`nodeLinkTypeId` INT, `nodeLinkTypeCode` INT, `srcNodeId` INT, `srcNodeTypeId` INT, `srcMetric` INT, `srcMin` INT, `viaNodeId` INT, `dstNodeId` INT, `dstNodeTypeId` INT, `dstMetric` INT, `dstMin` INT, `essential` INT, `existingMetric` INT, `singleSrcExists` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeRecommendLinkV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeRecommendLinkV` (`nodeLinkTypeId` INT, `nodeLinkTypeCode` INT, `srcNodeId` INT, `srcNodeTypeId` INT, `srcMetric` INT, `viaNodeId` INT, `dstNodeId` INT, `dstNodeTypeId` INT, `dstMetric` INT, `essential` INT, `singleSrc` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagForAdminV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagForAdminV` (`tagNames` INT, `tagNamesSearch` INT, `tagNamesFullSearch` INT, `attributeNames` INT, `attributeNamesSearch` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeAncestryV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeAncestryV` (`nodeId` INT, `tagName` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchResultTagV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchResultTagV` (`id` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchResultObjectV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchResultObjectV` (`sessionId` INT, `relevancy` INT, `criterionObjectId` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagChildV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagChildV` (`srcId` INT, `srcTypeId` INT, `srcTypeCode` INT, `srcTypeName` INT, `srcInternalTypeId` INT, `srcCanEdit` INT, `srcTypeCanSearch` INT, `srcTypeDisplayInObject` INT, `srcTypeDisplayInObjectList` INT, `srcTypeSorter` INT, `srcName` INT, `srcSorter` INT, `srcCanSearch` INT, `srcCanSearchRaw` INT, `srcDisplayInObject` INT, `srcDisplayInObjectRaw` INT, `srcDisplayInObjectList` INT, `srcDisplayInObjectListRaw` INT, `srcFactor` INT, `srcRatingPoints` INT, `srcEnabled` INT, `srcAttributeDataType` INT, `srcRequired` INT, `dstId` INT, `dstTypeId` INT, `dstTypeCode` INT, `dstTypeName` INT, `dstInternalTypeId` INT, `dstCanEdit` INT, `dstTypeCanSearch` INT, `dstTypeDisplayInObject` INT, `dstTypeDisplayInObjectList` INT, `dstTypeSorter` INT, `dstName` INT, `dstSorter` INT, `dstCanSearch` INT, `dstCanSearchRaw` INT, `dstDisplayInObject` INT, `dstDisplayInObjectRaw` INT, `dstDisplayInObjectList` INT, `dstDisplayInObjectListRaw` INT, `dstFactor` INT, `dstRatingPoints` INT, `dstEnabled` INT, `dstAttributeDataType` INT, `dstRequired` INT, `srcIsRoot` INT, `srcGeoRoot` INT, `dstAncestry` INT, `midId` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagRecommendChildV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagRecommendChildV` (`srcId` INT, `srcTypeId` INT, `srcTypeCode` INT, `srcTypeName` INT, `srcInternalTypeId` INT, `srcCanEdit` INT, `srcTypeCanSearch` INT, `srcTypeDisplayInObject` INT, `srcTypeDisplayInObjectList` INT, `srcTypeSorter` INT, `srcName` INT, `srcSorter` INT, `srcCanSearch` INT, `srcCanSearchRaw` INT, `srcDisplayInObject` INT, `srcDisplayInObjectRaw` INT, `srcDisplayInObjectList` INT, `srcDisplayInObjectListRaw` INT, `srcFactor` INT, `srcRatingPoints` INT, `srcEnabled` INT, `srcAttributeDataType` INT, `srcRequired` INT, `dstId` INT, `dstTypeId` INT, `dstTypeCode` INT, `dstTypeName` INT, `dstInternalTypeId` INT, `dstCanEdit` INT, `dstTypeCanSearch` INT, `dstTypeDisplayInObject` INT, `dstTypeDisplayInObjectList` INT, `dstTypeSorter` INT, `dstName` INT, `dstSorter` INT, `dstCanSearch` INT, `dstCanSearchRaw` INT, `dstDisplayInObject` INT, `dstDisplayInObjectRaw` INT, `dstDisplayInObjectList` INT, `dstDisplayInObjectListRaw` INT, `dstFactor` INT, `dstRatingPoints` INT, `dstEnabled` INT, `dstAttributeDataType` INT, `dstRequired` INT, `srcIsRoot` INT, `srcGeoRoot` INT, `dstAncestry` INT, `srcMetric` INT, `dstMetric` INT, `essential` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagParentV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagParentV` (`srcId` INT, `srcTypeId` INT, `srcTypeCode` INT, `srcTypeName` INT, `srcInternalTypeId` INT, `srcCanEdit` INT, `srcTypeCanSearch` INT, `srcTypeDisplayInObject` INT, `srcTypeDisplayInObjectList` INT, `srcTypeSorter` INT, `srcName` INT, `srcSorter` INT, `srcCanSearch` INT, `srcCanSearchRaw` INT, `srcDisplayInObject` INT, `srcDisplayInObjectRaw` INT, `srcDisplayInObjectList` INT, `srcDisplayInObjectListRaw` INT, `srcFactor` INT, `srcRatingPoints` INT, `srcEnabled` INT, `srcAttributeDataType` INT, `srcRequired` INT, `dstId` INT, `dstTypeId` INT, `dstTypeCode` INT, `dstTypeName` INT, `dstInternalTypeId` INT, `dstCanEdit` INT, `dstTypeCanSearch` INT, `dstTypeDisplayInObject` INT, `dstTypeDisplayInObjectList` INT, `dstTypeSorter` INT, `dstName` INT, `dstSorter` INT, `dstCanSearch` INT, `dstCanSearchRaw` INT, `dstDisplayInObject` INT, `dstDisplayInObjectRaw` INT, `dstDisplayInObjectList` INT, `dstDisplayInObjectListRaw` INT, `dstFactor` INT, `dstRatingPoints` INT, `dstEnabled` INT, `dstAttributeDataType` INT, `dstRequired` INT, `srcIsRoot` INT, `srcGeoRoot` INT, `srcAncestry` INT, `midId` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagRecommendParentV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagRecommendParentV` (`srcId` INT, `srcTypeId` INT, `srcTypeCode` INT, `srcTypeName` INT, `srcInternalTypeId` INT, `srcCanEdit` INT, `srcTypeCanSearch` INT, `srcTypeDisplayInObject` INT, `srcTypeDisplayInObjectList` INT, `srcTypeSorter` INT, `srcName` INT, `srcSorter` INT, `srcCanSearch` INT, `srcCanSearchRaw` INT, `srcDisplayInObject` INT, `srcDisplayInObjectRaw` INT, `srcDisplayInObjectList` INT, `srcDisplayInObjectListRaw` INT, `srcFactor` INT, `srcRatingPoints` INT, `srcEnabled` INT, `srcAttributeDataType` INT, `srcRequired` INT, `dstId` INT, `dstTypeId` INT, `dstTypeCode` INT, `dstTypeName` INT, `dstInternalTypeId` INT, `dstCanEdit` INT, `dstTypeCanSearch` INT, `dstTypeDisplayInObject` INT, `dstTypeDisplayInObjectList` INT, `dstTypeSorter` INT, `dstName` INT, `dstSorter` INT, `dstCanSearch` INT, `dstCanSearchRaw` INT, `dstDisplayInObject` INT, `dstDisplayInObjectRaw` INT, `dstDisplayInObjectList` INT, `dstDisplayInObjectListRaw` INT, `dstFactor` INT, `dstRatingPoints` INT, `dstEnabled` INT, `dstAttributeDataType` INT, `dstRequired` INT, `srcIsRoot` INT, `srcGeoRoot` INT, `srcAncestry` INT, `srcMetric` INT, `dstMetric` INT, `essential` INT); -- ----------------------------------------------------- -- Placeholder table for view `objectStatusV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `objectStatusV` (`id` INT, `name` INT, `public` INT, `userEditable` INT, `userDraftable` INT, `sorter` INT); -- ----------------------------------------------------- -- Placeholder table for view `attributeV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `attributeV` (`id` INT, `decimalMin` INT, `decimalMax` INT, `decimalRound` INT, `datetimeStorageId` INT, `textIsLong` INT); -- ----------------------------------------------------- -- Placeholder table for view `_nodeRecommendLink2V` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `_nodeRecommendLink2V` (`nodeLinkTypeId` INT, `nodeLinkTypeCode` INT, `srcNodeId` INT, `srcNodeTypeId` INT, `dstNodeId` INT, `dstNodeTypeId` INT, `essential` INT, `singleSrc` INT, `linked` INT, `canLink` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchTagV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchTagV` (`criterionId` INT, `valueLowNumeric` INT, `valueHighNumeric` INT, `valueLowDatetime` INT, `valueHighDatetime` INT, `resultId` INT, `collapsed` INT, `extraObjects` INT); -- ----------------------------------------------------- -- Placeholder table for view `attributeDatetimeStorageFormatV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `attributeDatetimeStorageFormatV` (`id` INT, `languageId` INT, `datetimeStorageId` INT, `storageFormat` INT, `name` INT, `outputFormat` INT, `outputFormatJs` INT); -- ----------------------------------------------------- -- Placeholder table for view `objectWithTagV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `objectWithTagV` (`srcId` INT, `srcTypeId` INT, `srcTypeCode` INT, `srcTypeName` INT, `srcInternalTypeId` INT, `srcCanEdit` INT, `srcTypeCanSearch` INT, `srcTypeDisplayInObject` INT, `srcTypeDisplayInObjectList` INT, `srcTypeSorter` INT, `srcName` INT, `srcSorter` INT, `srcCanSearch` INT, `srcCanSearchRaw` INT, `srcDisplayInObject` INT, `srcDisplayInObjectRaw` INT, `srcDisplayInObjectList` INT, `srcDisplayInObjectListRaw` INT, `srcFactor` INT, `srcRatingPoints` INT, `srcEnabled` INT, `srcAttributeDataType` INT, `srcAttributeCode` INT, `srcRequired` INT, `srcSortable` INT, `srcUofmPre` INT, `srcUofmPost` INT, `srcLanguageId` INT, `srcIsRoot` INT, `srcGeoRoot` INT, `srcDecimalMin` INT, `srcDecimalMax` INT, `srcDecimalRound` INT, `srcDatetimeStorageId` INT, `srcTextIsLong` INT, `srcDatetimeStorageFormat` INT, `srcDatetimeName` INT, `srcDatetimeOutputFormat` INT, `srcDatetimeOutputFormatJs` INT, `srcNumericValue` INT, `srcDatetimeValue` INT, `srcTextValue` INT, `linked` INT, `canLink` INT, `objectId` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeRootGeoV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeRootGeoV` (`id` INT, `nodeTypeId` INT, `forceSingleNode` INT, `name` INT, `isRoot` INT, `displayNode` INT, `typeCode` INT, `typeCanSearch` INT, `typeDisplayInObject` INT, `typeDisplayInObjectList` INT, `typeRequiredForObject` INT, `typeSorter` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT, `dstNodeId` INT, `metric` INT); -- ----------------------------------------------------- -- Placeholder table for view `attributeDatetimeFormatV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `attributeDatetimeFormatV` (`id` INT, `name` INT, `storageFormat` INT, `outputFormat` INT, `outputFormatJs` INT, `sorter` INT, `languageId` INT, `added` INT, `changed` INT); -- ----------------------------------------------------- -- Placeholder table for view `imageV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `imageV` (`id` INT, `imageId` INT, `nodeId` INT, `forceSinglePhoto` INT, `name` INT, `filenameOriginal` INT, `filenameFs` INT, `display` INT, `sorter` INT, `imageTypeId` INT, `videoType` INT, `url` INT, `extraId` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT); -- ----------------------------------------------------- -- Placeholder table for view `templateV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `templateV` (`nodeId` INT, `srcNodeTypeId` INT, `added` INT); -- ----------------------------------------------------- -- Placeholder table for view `_nodeRecommendLink3V` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `_nodeRecommendLink3V` (`nodeLinkTypeId` INT, `nodeLinkTypeCode` INT, `srcNodeId` INT, `srcNodeTypeId` INT, `dstNodeId` INT, `dstNodeTypeId` INT, `essential` INT, `singleSrc` INT, `linked` INT, `canLink` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeLinkChainV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeLinkChainV` (`nodeLinkTypeId` INT, `srcNodeId` INT, `midNodeId` INT, `dstNodeId` INT, `metric1` INT, `metric2` INT, `added1` INT, `added2` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeLinkForkSrcV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeLinkForkSrcV` (`nodeLinkTypeId` INT, `srcNodeId` INT, `dstNodeId1` INT, `dstNodeId2` INT, `metric1` INT, `metric2` INT, `added1` INT, `added2` INT); -- ----------------------------------------------------- -- Placeholder table for view `_nodeRecommendLink4V` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `_nodeRecommendLink4V` (`nodeLinkTypeId` INT, `nodeLinkTypeCode` INT, `srcNodeId` INT, `srcNodeTypeId` INT, `dstNodeId` INT, `dstNodeTypeId` INT, `essential` INT, `singleSrc` INT, `linked` INT, `canLink` INT); -- ----------------------------------------------------- -- Placeholder table for view `objectWithTagLinkedV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `objectWithTagLinkedV` (`srcId` INT, `srcTypeId` INT, `srcTypeCode` INT, `srcTypeName` INT, `srcInternalTypeId` INT, `srcCanEdit` INT, `srcTypeCanSearch` INT, `srcTypeDisplayInObject` INT, `srcTypeDisplayInObjectList` INT, `srcTypeSorter` INT, `srcName` INT, `srcSorter` INT, `srcCanSearch` INT, `srcCanSearchRaw` INT, `srcDisplayInObject` INT, `srcDisplayInObjectRaw` INT, `srcDisplayInObjectList` INT, `srcDisplayInObjectListRaw` INT, `srcFactor` INT, `srcRatingPoints` INT, `srcEnabled` INT, `srcAttributeDataType` INT, `srcAttributeCode` INT, `srcRequired` INT, `srcSortable` INT, `srcUofmPre` INT, `srcUofmPost` INT, `srcLanguageId` INT, `srcIsRoot` INT, `srcGeoRoot` INT, `srcDecimalMin` INT, `srcDecimalMax` INT, `srcDecimalRound` INT, `srcDatetimeStorageId` INT, `srcTextIsLong` INT, `srcDatetimeStorageFormat` INT, `srcDatetimeName` INT, `srcDatetimeOutputFormat` INT, `srcDatetimeOutputFormatJs` INT, `srcNumericValue` INT, `srcDatetimeValue` INT, `srcTextValue` INT, `linked` INT, `canLink` INT, `objectId` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeLinkChainTransitionV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeLinkChainTransitionV` (`nodeLinkTypeId` INT, `srcNodeId` INT, `midNodeId` INT, `dstNodeId` INT, `metric1` INT, `metric2` INT, `added1` INT, `added2` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeLinkDirectV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeLinkDirectV` (`_id` INT, `nodeLinkTypeId` INT, `srcNodeId` INT, `dstNodeId` INT, `metric` INT, `added` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeAncestryDataV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeAncestryDataV` (`srcNodeId` INT, `srcName` INT, `srcUofmPre` INT, `srcUofmPost` INT, `srcTypeId` INT, `srcInternalTypeId` INT, `srcTypeName` INT, `srcNumericValue` INT, `srcDatetimeValue` INT, `srcDatetimeOutputFormat` INT, `srcTextValue` INT, `dstNodeId` INT, `dstTypeId` INT, `languageId` INT, `languageIsDefault` INT, `ancestrySorter` INT); -- ----------------------------------------------------- -- Placeholder table for view `objectWithUserV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `objectWithUserV` (`objectId` INT); -- ----------------------------------------------------- -- Placeholder table for view `_nodeV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `_nodeV` (`id` INT, `nodeTypeId` INT, `forceSingleNode` INT, `forceSinglePhoto` INT, `name` INT, `isRoot` INT, `displayNode` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT); -- ----------------------------------------------------- -- Placeholder table for view `attributeSortV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `attributeSortV` (`id` INT, `typeName` INT, `typeCode` INT, `name` INT, `sorter` INT, `code` INT, `languageId` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchResultObjectSortedV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchResultObjectSortedV` (`sortAttributeId` INT, `sorterAsc` INT, `sorterDesc` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchAttributeSortV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchAttributeSortV` (`id` INT); -- ----------------------------------------------------- -- Placeholder table for view `zzzIntsV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `zzzIntsV` (`n` INT); -- ----------------------------------------------------- -- Placeholder table for view `zzzInts100V` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `zzzInts100V` (`n` INT); -- ----------------------------------------------------- -- Placeholder table for view `zzzInts1000V` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `zzzInts1000V` (`n` INT); -- ----------------------------------------------------- -- Placeholder table for view `zzzInts10000V` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `zzzInts10000V` (`n` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchResultSelectedV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchResultSelectedV` (`sessionId` INT, `objectId` INT, `added` INT); -- ----------------------------------------------------- -- Placeholder table for view `searchResultSelectedObjectV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `searchResultSelectedObjectV` (`sessionId` INT, `addedSelected` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagDirectChildV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagDirectChildV` (`srcId` INT, `srcTypeId` INT, `srcTypeCode` INT, `srcTypeName` INT, `srcInternalTypeId` INT, `srcCanEdit` INT, `srcTypeCanSearch` INT, `srcTypeDisplayInObject` INT, `srcTypeDisplayInObjectList` INT, `srcTypeSorter` INT, `srcName` INT, `srcSorter` INT, `srcCanSearch` INT, `srcCanSearchRaw` INT, `srcDisplayInObject` INT, `srcDisplayInObjectRaw` INT, `srcDisplayInObjectList` INT, `srcDisplayInObjectListRaw` INT, `srcFactor` INT, `srcRatingPoints` INT, `srcEnabled` INT, `srcAttributeDataType` INT, `srcRequired` INT, `dstId` INT, `dstTypeId` INT, `dstTypeCode` INT, `dstTypeName` INT, `dstInternalTypeId` INT, `dstCanEdit` INT, `dstTypeCanSearch` INT, `dstTypeDisplayInObject` INT, `dstTypeDisplayInObjectList` INT, `dstTypeSorter` INT, `dstName` INT, `dstSorter` INT, `dstCanSearch` INT, `dstCanSearchRaw` INT, `dstDisplayInObject` INT, `dstDisplayInObjectRaw` INT, `dstDisplayInObjectList` INT, `dstDisplayInObjectListRaw` INT, `dstFactor` INT, `dstRatingPoints` INT, `dstEnabled` INT, `dstAttributeDataType` INT, `dstRequired` INT, `srcIsRoot` INT, `srcGeoRoot` INT, `dstAncestry` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeAllowedChildTypeV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeAllowedChildTypeV` (`nodeId` INT, `srcNodeTypeId` INT, `dstNodeTypeId` INT, `essential` INT, `singleSrc` INT, `added` INT, `changed` INT); -- ----------------------------------------------------- -- Placeholder table for view `nodeAllowedParentTypeV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `nodeAllowedParentTypeV` (`nodeId` INT, `srcNodeTypeId` INT, `dstNodeTypeId` INT, `essential` INT, `singleSrc` INT, `added` INT, `changed` INT); -- ----------------------------------------------------- -- Placeholder table for view `storedTagDataV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `storedTagDataV` (`id` INT, `nodeTypeId` INT, `nodeTypeCode` INT, `name` INT, `prefix` INT, `suffix` INT, `added` INT, `changed` INT); -- ----------------------------------------------------- -- Placeholder table for view `moderationQueueV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `moderationQueueV` (`id` INT, `nodeId` INT, `comment1` INT, `comment2` INT, `resolved` INT, `typeName` INT, `typeCode` INT, `internalTypeId` INT, `name` INT, `languageId` INT, `tagName` INT, `tagPrefix` INT, `tagSuffix` INT, `objectAddress` INT, `objectStatus` INT, `nodeAdded` INT, `nodeAddedUserId` INT, `nodeAddedUserName` INT, `nodeAddedIp` INT, `nodeChanged` INT, `nodeChangedUserId` INT, `nodeChangedUserName` INT, `nodeChangedIp` INT, `added` INT, `addedUserId` INT, `addedUserName` INT, `addedIp` INT, `changed` INT, `changedUserId` INT, `changedUserName` INT, `changedIp` INT); -- ----------------------------------------------------- -- Placeholder table for view `tagCacheV` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagCacheV` (`id` INT, `tagNames` INT, `tagNamesSearch` INT, `tagNamesFullSearch` INT); -- ----------------------------------------------------- -- function __nodeWorkset_Cleanup -- ----------------------------------------------------- DROP function IF EXISTS `__nodeWorkset_Cleanup`; DELIMITER $$$ create function __nodeWorkset_Cleanup() returns int unsigned not deterministic begin delete from zzzNodeWorksetT where added < date_sub(now(), interval 1 day); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeWorkset_GetLevel -- ----------------------------------------------------- DROP function IF EXISTS `__nodeWorkset_GetLevel`; DELIMITER $$$ create function __nodeWorkset_GetLevel() returns int unsigned return coalesce(@__nodeWorksetLevel, 0)$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeWorkset_Start -- ----------------------------------------------------- DROP function IF EXISTS `__nodeWorkset_Start`; DELIMITER $$$ create function __nodeWorkset_Start() returns int unsigned not deterministic modifies sql data begin set @__nodeWorksetLevel = coalesce(@__nodeWorksetLevel, 0) + 1; if __nodeWorkset_GetLevel() = 1 then delete from zzzNodeWorksetT where connId = connection_id(); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeWorkset_Update -- ----------------------------------------------------- DROP function IF EXISTS `__nodeWorkset_Update`; DELIMITER $$$ create function __nodeWorkset_Update(node_id int unsigned, direction int, only_direction int) returns int unsigned comment 'direction=-1 - downwards; direction=1 - upwards; direction=0 - both; others - undefined; only_direction is the same, but controls if records added at all' not deterministic modifies sql data begin if __nodeWorkset_GetLevel() > 0 then insert zzzNodeWorksetT(nodeId, connId, isMain) values (node_id, connection_id(), 1) on duplicate key update isMain = 1; -- downwards from source node insert zzzNodeWorksetT(nodeId, connId, isMain) select l.srcNodeId, connection_id(), direction < 1 from nodeLinkT l where l.dstNodeId = node_id and metric > 0 and only_direction < 1 on duplicate key update isMain = isMain or (direction < 1); -- upwards from source node insert ignore zzzNodeWorksetT(nodeId, connId, isMain) select l.dstNodeId, connection_id(), direction > -1 from nodeLinkT l where l.srcNodeId = node_id and metric > 0 and only_direction > -1 on duplicate key update isMain = isMain or (direction > -1); end if; return node_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeWorkset_End -- ----------------------------------------------------- DROP function IF EXISTS `__nodeWorkset_End`; DELIMITER $$$ create function __nodeWorkset_End() returns int unsigned not deterministic modifies sql data begin if __nodeWorkset_GetLevel() = 1 then set @1 = __nodeWorkset_Cleanup(); delete from zzzNodeWorksetT where connId = connection_id(); end if; set @__nodeWorksetLevel = greatest(coalesce(@__nodeWorksetLevel, 0) - 1, 0); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_UpdateCreateExtraLinks -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_UpdateCreateExtraLinks`; DELIMITER $$$ create function __nodeLink_UpdateCreateExtraLinks() returns int unsigned not deterministic modifies sql data begin repeat insert nodeLinkT(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select l1.nodeLinkTypeId, l1.srcNodeId, l2.dstNodeId, (l1.metric + l2.metric) from nodeLinkT l1 join nodeLinkT l2 on l1.nodeLinkTypeId = l2.nodeLinkTypeId and l1.dstNodeId = l2.srcNodeId join zzzNodeWorksetT ws1 on l1.srcNodeId = ws1.nodeId join zzzNodeWorksetT ws2 on l2.dstNodeId = ws2.nodeId left join nodeLinkT l3 on l1.nodeLinkTypeId = l3.nodeLinkTypeId and l3.srcNodeId = l1.srcNodeId and l3.dstNodeId = l2.dstNodeId and l3.metric <= l1.metric + l2.metric where l1.srcNodeId != l2.dstNodeId and l1.metric > 0 and l2.metric > 0 and ws1.connId = connection_id() and ws2.connId = connection_id() and l3.srcNodeId is null on duplicate key update nodeLinkT.metric = least(nodeLinkT.metric, l1.metric + l2.metric); until row_count() < 1 end repeat; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_UpdateDeleteExtraLinks -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_UpdateDeleteExtraLinks`; DELIMITER $$$ create function __nodeLink_UpdateDeleteExtraLinks() returns int unsigned not deterministic modifies sql data begin declare row_cnt int unsigned default 0; create temporary table if not exists zzNodeLinkDelete ( nodeLinkTypeId int unsigned not null, srcNodeId int unsigned not null, dstNodeId int unsigned not null, metric int not null default 1, primary key(nodeLinkTypeId, srcNodeId, dstNodeId), unique(nodeLinkTypeId, dstNodeId, srcNodeId) ) engine=MEMORY; create temporary table if not exists zzNodeLinkDelete2 like zzNodeLinkDelete; delete from zzNodeLinkDelete; delete from zzNodeLinkDelete2; insert zzNodeLinkDelete(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select l.nodeLinkTypeId, l.srcNodeId, l.dstNodeId, l.metric from nodeLinkT l join zzzNodeWorksetT ws1 on l.srcNodeId = ws1.nodeId join zzzNodeWorksetT ws2 on l.dstNodeId = ws2.nodeId where l.metric > 1 and ws1.connId = connection_id() and ws2.connId = connection_id() and not exists ( select 1 from nodeLinkT l1 join nodeLinkT l2 on l1.nodeLinkTypeId = l2.nodeLinkTypeId and l1.dstNodeId = l2.srcNodeId where l1.nodeLinkTypeId = l.nodeLinkTypeId and l1.srcNodeId = l.srcNodeId and l2.dstNodeId = l.dstNodeId and l1.metric > 0 and l2.metric > 0 and l.metric = l1.metric + l2.metric); set row_cnt = row_count(); while row_cnt > 0 do insert ignore zzNodeLinkDelete2 select * from zzNodeLinkDelete ld; insert ignore zzNodeLinkDelete(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select l.nodeLinkTypeId, l.srcNodeId, l.dstNodeId, l.metric from nodeLinkT l join zzzNodeWorksetT ws1 on l.srcNodeId = ws1.nodeId join zzzNodeWorksetT ws2 on l.dstNodeId = ws2.nodeId join zzNodeLinkDelete2 l1 on l.nodeLinkTypeId = l1.nodeLinkTypeId and l.srcNodeId = l1.srcNodeId join nodeLinkT l2 on l.nodeLinkTypeId = l2.nodeLinkTypeId and l1.dstNodeId = l2.srcNodeId and l.dstNodeId = l2.dstNodeId where l.metric > 1 and l2.metric > 0 and l.metric = l1.metric + l2.metric and ws1.connId = connection_id() and ws2.connId = connection_id(); set row_cnt = row_count(); insert ignore zzNodeLinkDelete2 select * from zzNodeLinkDelete ld; insert ignore zzNodeLinkDelete(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select l.nodeLinkTypeId, l.srcNodeId, l.dstNodeId, l.metric from nodeLinkT l join zzzNodeWorksetT ws1 on l.srcNodeId = ws1.nodeId join zzzNodeWorksetT ws2 on l.dstNodeId = ws2.nodeId join nodeLinkT l1 on l.nodeLinkTypeId = l1.nodeLinkTypeId and l.srcNodeId = l1.srcNodeId join zzNodeLinkDelete2 l2 on l.nodeLinkTypeId = l2.nodeLinkTypeId and l1.dstNodeId = l2.srcNodeId and l.dstNodeId = l2.dstNodeId where l.metric > 1 and l1.metric > 0 and l.metric = l1.metric + l2.metric and ws1.connId = connection_id() and ws2.connId = connection_id(); set row_cnt = row_cnt + row_count(); end while; delete from nodeLinkT using nodeLinkT join zzNodeLinkDelete l on nodeLinkT.nodeLinkTypeId = l.nodeLinkTypeId and nodeLinkT.srcNodeId = l.srcNodeId and nodeLinkT.dstNodeId = l.dstNodeId and nodeLinkT.metric = l.metric; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_UpdateRefreshExtraLinks -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_UpdateRefreshExtraLinks`; DELIMITER $$$ create function __nodeLink_UpdateRefreshExtraLinks() returns int unsigned not deterministic modifies sql data begin declare deleted, added int unsigned; set deleted = __nodeLink_UpdateDeleteExtraLinks(); set added = __nodeLink_UpdateCreateExtraLinks(); return deleted + added; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_IsUpdateOn -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_IsUpdateOn`; DELIMITER $$$ create function nodeLink_IsUpdateOn() returns int unsigned not deterministic begin return (__nodeWorkset_GetLevel() > 0); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_UpdateWorkSet -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_UpdateWorkSet`; DELIMITER $$$ create function __nodeLink_UpdateWorkSet(node_id int unsigned, direction int, only_direction int) returns int unsigned comment 'direction=-1 - downwards; direction=1 - upwards; direction=0 - both; others - undefined' not deterministic begin return __nodeWorkset_Update(node_id, direction, only_direction); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_Create -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_Create`; DELIMITER $$$ create function __nodeLink_Create( link_code varchar(30) binary, src_id int unsigned, dst_id int unsigned, force_workset_ int ) returns int unsigned not deterministic modifies sql data begin declare res int unsigned; declare force_workset int default coalesce(force_workset_, 1); if not exists (select 1 from allowedNodeLinkT anl join nodeT src on anl.srcNodeTypeId = src.nodeTypeId join nodeT dst on anl.dstNodeTypeId = dst.nodeTypeId where src.id = src_id and dst.id = dst_id) then call raiseError2('nodeLink', 'create', src_id, dst_id, 'cannot create link between'); end if; insert nodeLinkT(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select nlt.id, src_id, dst_id, 1 from nodeLinkTypeT nlt join nodeLinkTypeT nltdef on nltdef.isDefault = 'y' where nlt.code = coalesce(link_code, nltdef.code) and not exists (select 1 from nodeLinkT l where l.nodeLinkTypeId = nlt.id and l.srcNodeId = src_id and l.dstNodeId = dst_id and l.metric <= 1) on duplicate key update nodeLinkT.metric = 1; set res = row_count(); if nodeLink_IsUpdateOn() = 1 and res > 0 then set @1 = __nodeLink_UpdateWorkSet(src_id, -1, if(force_workset, 0, -1)) and __nodeLink_UpdateWorkSet(dst_id, 1, if(force_workset, 0, 1)); end if; return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_Delete -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_Delete`; DELIMITER $$$ create function __nodeLink_Delete( link_code varchar(30) binary, src_id int unsigned, dst_id int unsigned, force_workset_ int ) returns int unsigned not deterministic modifies sql data begin declare res int unsigned; declare force_workset int default coalesce(force_workset_, 1); delete from nodeLinkT using nodeLinkT join nodeLinkTypeT nlt on nodeLinkT.nodeLinkTypeId = nlt.id join nodeLinkTypeT nltdef on nltdef.isDefault = 'y' where nlt.code = coalesce(link_code, nltdef.code) and nodeLinkT.srcNodeId = src_id and nodeLinkT.dstNodeId = dst_id and nodeLinkT.metric = 1; set res = row_count(); if nodeLink_IsUpdateOn() = 1 and res > 0 then set @1 = __nodeLink_UpdateWorkSet(src_id, -1, if(force_workset, 0, -1)) and __nodeLink_UpdateWorkSet(dst_id, 1, if(force_workset, 0, 1)); end if; return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_UpdateStart -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_UpdateStart`; DELIMITER $$$ create function nodeLink_UpdateStart() returns int unsigned not deterministic modifies sql data begin return __nodeWorkset_Start(); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_UpdateEnd -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_UpdateEnd`; DELIMITER $$$ create function nodeLink_UpdateEnd() returns int unsigned not deterministic modifies sql data begin if __nodeWorkset_GetLevel() = 1 then set @1 = __nodeLink_UpdateRefreshExtraLinks(); set @2 = __nodeAncestry_Update(); -- FORWARD: __object_UpdateRatings is defined in _080_object set @3 = __object_UpdateRatings(); -- FORWARD: __object_UpdateAddresses is defined in _080_object set @4 = __object_UpdateAddresses(); -- set flag for maintenance routine set @5 = const_SetI('search.cache.update', 1); end if; set @5 = __nodeWorkset_End(); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_CreateExtraLinks -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_CreateExtraLinks`; DELIMITER $$$ create function __nodeLink_CreateExtraLinks() returns int unsigned not deterministic modifies sql data begin declare row_cnt int unsigned default 0; repeat insert nodeLinkT(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select l1.nodeLinkTypeId, l1.srcNodeId, l2.dstNodeId, (l1.metric + l2.metric) from nodeLinkT l1 join nodeLinkT l2 on l1.nodeLinkTypeId = l2.nodeLinkTypeId and l1.dstNodeId = l2.srcNodeId left join nodeLinkT l3 on l3.nodeLinkTypeId = l1.nodeLinkTypeId and l3.srcNodeId = l1.srcNodeId and l3.dstNodeId = l2.dstNodeId and l3.metric <= l1.metric + l2.metric where l1.srcNodeId != l2.dstNodeId and l1.metric > 0 and l2.metric > 0 and l3.srcNodeId is null on duplicate key update nodeLinkT.metric = least(nodeLinkT.metric, l1.metric + l2.metric); set row_cnt = row_cnt + row_count(); until row_count() < 1 end repeat; return row_cnt; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_DeleteExtraLinks -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_DeleteExtraLinks`; DELIMITER $$$ create function __nodeLink_DeleteExtraLinks() returns int unsigned not deterministic modifies sql data begin declare row_cnt int unsigned default 0; create temporary table if not exists zzNodeLinkDelete ( nodeLinkTypeId int unsigned not null, srcNodeId int unsigned not null, dstNodeId int unsigned not null, metric int not null default 1, primary key(nodeLinkTypeId, srcNodeId, dstNodeId), unique(nodeLinkTypeId, dstNodeId, srcNodeId) ) engine=MEMORY; repeat delete from zzNodeLinkDelete; insert zzNodeLinkDelete(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select l.nodeLinkTypeId, l.srcNodeId, l.dstNodeId, l.metric from nodeLinkT l where l.metric > 1 and not exists ( select 1 from nodeLinkT l1 join nodeLinkT l2 on l1.nodeLinkTypeId = l2.nodeLinkTypeId and l1.dstNodeId = l2.srcNodeId where l1.nodeLinkTypeId = l.nodeLinkTypeId and l1.srcNodeId = l.srcNodeId and l2.dstNodeId = l.dstNodeId and l1.metric > 0 and l2.metric > 0 and l.metric = l1.metric + l2.metric); insert ignore zzNodeLinkDelete(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select l.nodeLinkTypeId, l.srcNodeId, l.dstNodeId, l.metric from nodeLinkT l join nodeLinkT l2 on l.nodeLinkTypeId = l2.nodeLinkTypeId and l.srcNodeId = l2.srcNodeId and l.dstNodeId = l2.dstNodeId and l.metric > l2.metric where l.metric > 1; delete from nodeLinkT using nodeLinkT join zzNodeLinkDelete l on nodeLinkT.nodeLinkTypeId = l.nodeLinkTypeId and nodeLinkT.srcNodeId = l.srcNodeId and nodeLinkT.dstNodeId = l.dstNodeId and nodeLinkT.metric = l.metric; set row_cnt = row_cnt + row_count(); until row_count() < 1 end repeat; return row_cnt; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_RefreshExtraLinks -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_RefreshExtraLinks`; DELIMITER $$$ create function __nodeLink_RefreshExtraLinks() returns int unsigned not deterministic modifies sql data begin declare deleted, added int unsigned; set deleted = __nodeLink_DeleteExtraLinks(); set added = __nodeLink_CreateExtraLinks(); return deleted + added; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_Create -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_Create`; DELIMITER $$$ create function nodeLink_Create( link_code varchar(30) binary, src_id int unsigned, dst_id int unsigned ) returns int unsigned not deterministic modifies sql data begin declare res int unsigned; set @1 = nodeLink_UpdateStart(); set res = __nodeLink_Create(link_code, src_id, dst_id, null); set @2 = nodeLink_UpdateEnd(); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_Delete -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_Delete`; DELIMITER $$$ create function nodeLink_Delete( link_code varchar(30) binary, src_id int unsigned, dst_id int unsigned ) returns int unsigned not deterministic modifies sql data begin declare res int unsigned; set @1 = nodeLink_UpdateStart(); set res = __nodeLink_Delete(link_code, src_id, dst_id, null); set @2 = nodeLink_UpdateEnd(); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __node_Create -- ----------------------------------------------------- DROP function IF EXISTS `__node_Create`; DELIMITER $$$ create function __node_Create( type_id_ int unsigned, type_code_ varchar(30) binary, name_ varchar(50) ) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned; declare type_id int unsigned default coalesce(type_id_, nodeType_GetByCode(type_code_)); -- FORWARD: user_CurrentId, user_CurrentName and user_CurrentIp are defined in _060_user insert nodeT( nodeTypeId, forceSinglePhoto, name, displayNode, addedUserId, addedUserName, addedIp, changedUserId, changedUserName, changedIp) select type_id, nt.forceSinglePhoto, name_, nt.displayNode, user_CurrentId(), user_CurrentName(), user_CurrentIp(), user_CurrentId(), user_CurrentName(), user_CurrentIp() from nodeTypeT nt where nt.id = type_id; set node_id = last_insert_id(); insert nodeLinkT(nodeLinkTypeId, srcNodeId, dstNodeId, metric) select nlt.id, node_id, node_id, 0 from nodeLinkTypeT nlt where nlt.forceSelfLink = 'y'; return node_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __node_Delete -- ----------------------------------------------------- DROP function IF EXISTS `__node_Delete`; DELIMITER $$$ create function __node_Delete(node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare res int unsigned default 0; set @4 = __node_CanUpdate(node_id_, 'delete'); if node_id_ is not null then set @1 = nodeLink_UpdateStart(); set @2 = __nodeLink_UpdateWorkSet(node_id_, 0, 0); delete from nodeT where id = node_id_; set res = row_count(); set @3 = nodeLink_UpdateEnd(); end if; return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeType_CanUpdate -- ----------------------------------------------------- DROP function IF EXISTS `__nodeType_CanUpdate`; DELIMITER $$$ create function __nodeType_CanUpdate(type_id_ int unsigned, action_ varchar(20)) returns int unsigned deterministic begin if (select canEditType from nodeTypeT where id = type_id_) != 'y' then call raiseError1('nodeType', action_, type_id_, 'cannot change uneditable node type'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeType_Touch -- ----------------------------------------------------- DROP function IF EXISTS `__nodeType_Touch`; DELIMITER $$$ create function __nodeType_Touch(type_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin update nodeTypeT set changed = current_timestamp() where id = type_id_; return type_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeType_Create -- ----------------------------------------------------- DROP function IF EXISTS `nodeType_Create`; DELIMITER $$$ create function nodeType_Create( internal_type_id_ varchar(10) binary, code_ varchar(30) binary, name_ varchar(50), can_have_photo_ enum('n', 'y'), can_have_rating_points_ enum('n', 'y'), can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), search_and_ enum('n', 'y'), required_for_object_ enum('n', 'y'), sorter_ int ) returns int unsigned not deterministic modifies sql data begin declare type_id int unsigned; insert nodeTypeT( internalTypeId, code, forceSinglePhoto, canEditType, canEditNode, canHavePhoto, canHaveRatingPoints, canLinkFrom, canLinkTo, canSearch, displayInObject, displayInObjectList, searchAnd, displayNode, requiredForObject, sorter) values ( internal_type_id_, code_, 'y', -- forceSinglePhoto 'y', -- canEditType 'y', -- canEditNode can_have_photo_, can_have_rating_points_, 'y', -- canLinkFrom 'y', -- canLinkTo can_search_, display_in_object_, display_in_object_list_, search_and_, 'y', -- displayNode required_for_object_, coalesce(sorter_, __nodeType_DefaultSorter())); set type_id = last_insert_id(); insert nodeTypeTL(id, languageId, name) select type_id, l.id, name_ from languageT l; return type_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeType_Delete -- ----------------------------------------------------- DROP function IF EXISTS `nodeType_Delete`; DELIMITER $$$ create function nodeType_Delete(type_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __nodeType_CanUpdate(type_id_, 'delete'); delete from nodeTypeT where id = type_id_; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeType_Update -- ----------------------------------------------------- DROP function IF EXISTS `nodeType_Update`; DELIMITER $$$ create function nodeType_Update( type_id_ int unsigned, can_have_photo_ enum('n', 'y'), can_have_rating_points_ enum('n', 'y'), can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), search_and_ enum('n', 'y'), required_for_object_ enum('n', 'y'), sorter_ int ) returns int unsigned not deterministic modifies sql data begin set @1 = __nodeType_CanUpdate(type_id_, 'update'); update nodeTypeT set canHavePhoto = coalesce(can_have_photo_, canHavePhoto), canHaveRatingPoints = coalesce(can_have_rating_points_, canHaveRatingPoints), canSearch = coalesce(can_search_, canSearch), displayInObject = coalesce(display_in_object_, displayInObject), displayInObjectList = coalesce(display_in_object_list_, displayInObjectList), searchAnd = coalesce(search_and_, searchAnd), requiredForObject = coalesce(required_for_object_, requiredForObject), sorter = coalesce(sorter_, sorter) where id = type_id_; -- FORWARD: __tag_UpdateDefaults is defined in _07_tag set @1 = __tag_UpdateDefaults(null, type_id_); return __nodeType_Touch(type_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __allowedNodeLink_CanLinkFrom -- ----------------------------------------------------- DROP function IF EXISTS `__allowedNodeLink_CanLinkFrom`; DELIMITER $$$ create function __allowedNodeLink_CanLinkFrom(node_type_id_ int unsigned) returns int unsigned deterministic begin if (select canLinkFrom from nodeTypeT where id = node_type_id_) != 'y' then call raiseError1('allowedNodeLink', 'linkFrom', node_type_id_, 'cannot create allowed link from the node type'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __allowedNodeLink_CanLinkTo -- ----------------------------------------------------- DROP function IF EXISTS `__allowedNodeLink_CanLinkTo`; DELIMITER $$$ create function __allowedNodeLink_CanLinkTo(node_type_id_ int unsigned) returns int unsigned deterministic begin if (select canLinkTo from nodeTypeT where id = node_type_id_) != 'y' then call raiseError1('allowedNodeLink', 'linkTo', node_type_id_, 'cannot create allowed link to the node type'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function allowedNodeLink_Create -- ----------------------------------------------------- DROP function IF EXISTS `allowedNodeLink_Create`; DELIMITER $$$ create function allowedNodeLink_Create( src_node_type_id_ int unsigned, dst_node_type_id_ int unsigned, essential_ enum('n', 'y'), single_src_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin set @1 = __allowedNodeLink_CanLinkFrom(src_node_type_id_) and __allowedNodeLink_CanLinkTo(dst_node_type_id_); insert allowedNodeLinkT ( srcNodeTypeId, dstNodeTypeId, essential, singleSrc) values ( src_node_type_id_, dst_node_type_id_, essential_, single_src_) on duplicate key update allowedNodeLinkT.essential = essential_, allowedNodeLinkT.singleSrc = single_src_; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function allowedNodeLink_Delete -- ----------------------------------------------------- DROP function IF EXISTS `allowedNodeLink_Delete`; DELIMITER $$$ create function allowedNodeLink_Delete( src_node_type_id_ int unsigned, dst_node_type_id_ int unsigned ) returns int unsigned not deterministic modifies sql data begin set @1 = __allowedNodeLink_CanLinkFrom(src_node_type_id_) and __allowedNodeLink_CanLinkTo(dst_node_type_id_); delete from allowedNodeLinkT where srcNodeTypeId = src_node_type_id_ and dstNodeTypeId = dst_node_type_id_; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function allowedNodeLink_Update -- ----------------------------------------------------- DROP function IF EXISTS `allowedNodeLink_Update`; DELIMITER $$$ create function allowedNodeLink_Update( src_node_type_id_ int unsigned, dst_node_type_id_ int unsigned, essential_ enum('n', 'y'), single_src_ enum('n', 'y') ) returns int unsigned begin update allowedNodeLinkT set essential = coalesce(essential_, essential), singleSrc = coalesce(single_src_, singleSrc), changed = current_timestamp() where srcNodeTypeId = src_node_type_id_ and dstNodeTypeId = dst_node_type_id_; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __user_ValidateId -- ----------------------------------------------------- DROP function IF EXISTS `__user_ValidateId`; DELIMITER $$$ create function __user_ValidateId(user_id_ int unsigned) returns int unsigned deterministic reads sql data begin declare user_id int unsigned; select u.id into user_id from userT u join nodeT n on u.id = n.id join nodeTypeT nt on n.nodeTypeId = nt.id where u.id = user_id_ and nt.internalTypeId = 'user'; if user_id is null then call raiseError1('user', 'validate', user_id_, 'user does not exist'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_Create -- ----------------------------------------------------- DROP function IF EXISTS `user_Create`; DELIMITER $$$ create function user_Create( name_ varchar(255), phone_ varchar(50), email_ varchar(255), login_ varchar(255), password_ varchar(100), role_id_ varchar(30) binary, enabled_ enum('n', 'y'), birthdate_ date, preferred_language_ char(3), token_ varchar(20) ) returns int unsigned not deterministic modifies sql data begin declare user_id int unsigned; set user_id = node_LinkDefaults(__node_Create(null, 'user', name_)); insert userT( id, name, phone, email, login, password, roleId, enabled, birthDate, preferredLanguage, token, phoneConfirmationCode, emailConfirmationCode) select user_id, trim(name_), trim(phone_), trim(email_), trim(login_), password_, coalesce(role_id_, ur.id), enabled_, birthdate_, preferred_language_, token_, '', '' from userRoleT ur where ur.isDefault = 'y'; return user_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_Delete -- ----------------------------------------------------- DROP function IF EXISTS `user_Delete`; DELIMITER $$$ create function user_Delete(user_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __user_ValidateId(user_id_); return __node_Delete(user_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeType_UpdateLocal -- ----------------------------------------------------- DROP function IF EXISTS `nodeType_UpdateLocal`; DELIMITER $$$ create function nodeType_UpdateLocal( type_id_ int unsigned, lang_id_ char(3), name_ varchar(50) ) returns int unsigned not deterministic modifies sql data begin set @1 = __nodeType_CanUpdate(type_id_, 'update'); insert nodeTypeTL(id, languageId, name) select type_id_, l.id, name_ from languageT l where l.id = coalesce(lang_id_, l.id) on duplicate key update nodeTypeTL.name = coalesce(name_, nodeTypeTL.name); return __nodeType_Touch(type_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_Update -- ----------------------------------------------------- DROP function IF EXISTS `user_Update`; DELIMITER $$$ create function user_Update( user_id_ int unsigned, name_ varchar(255), phone_ varchar(50), email_ varchar(255), reset_email_ enum('n', 'y'), login_ varchar(255), password_ varchar(100), role_id_ varchar(30) binary, enabled_ enum('n', 'y'), birthdate_ date, reset_birthdate_ enum('n', 'y'), preferred_language_ char(3), reset_preferred_language_ enum('n', 'y'), token_ varchar(20), reset_token_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin declare current_phone, new_phone varchar(50); declare current_email, new_email varchar(255); declare name__ varchar(255) default trim(name_); set @1 = __user_ValidateId(user_id_); select phone, email, trim(coalesce(phone_, phone)), if(reset_email_ = 'y', null, trim(coalesce(email_, email))) into current_phone, current_email, new_phone, new_email from userT where id = user_id_; set @2 = __node_Update(user_id_, name__); update userT set name = coalesce(name__, name), phone = new_phone, email = new_email, login = trim(coalesce(login_, login)), password = coalesce(password_, password), roleId = coalesce(role_id_, roleId), enabled = coalesce(enabled_, enabled), birthDate = if(reset_birthdate_ = 'y', null, coalesce(birthdate_, birthDate)), preferredLanguage = if(reset_preferred_language_ = 'y', null, coalesce(preferred_language_, preferredLanguage)), token = if(reset_token_ = 'y', null, coalesce(token_, token)), phoneConfirmationCode = if( phoneConfirmationCode is null and current_phone != new_phone and new_phone is not null, '', phoneConfirmationCode), emailConfirmationCode = if( emailConfirmationCode is null and current_email != new_email and new_email is not null, '', emailConfirmationCode) where id = user_id_; return user_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_SetConfirmationCode -- ----------------------------------------------------- DROP function IF EXISTS `user_SetConfirmationCode`; DELIMITER $$$ create function user_SetConfirmationCode( user_id_ int unsigned, phone_confirmation_code_ varchar(255), phone_confirmation_expiry_ datetime, reset_phone_code_ enum('n', 'y'), email_confirmation_code_ varchar(255), email_confirmation_expiry_ datetime, reset_email_code_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin set @1 = __user_ValidateId(user_id_); update userT set phoneConfirmationCode = if(reset_phone_code_ = 'y', null, coalesce(phone_confirmation_code_, phoneConfirmationCode)), phoneConfirmationExpiry = if(reset_phone_code_ = 'y', null, coalesce(phone_confirmation_expiry_, phoneConfirmationExpiry)), emailConfirmationCode = if(reset_email_code_ = 'y', null, coalesce(email_confirmation_code_, emailConfirmationCode)), emailConfirmationExpiry = if(reset_email_code_ = 'y', null, coalesce(email_confirmation_expiry_, emailConfirmationExpiry)) where id = user_id_; return user_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_CheckConfirmationCode -- ----------------------------------------------------- DROP function IF EXISTS `user_CheckConfirmationCode`; DELIMITER $$$ create function user_CheckConfirmationCode( user_id_ int unsigned, phone_confirmation_code_ varchar(255), email_confirmation_code_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare res, phone_confirmed, email_confirmed int unsigned; set @1 = __user_ValidateId(user_id_); select case when phone_confirmation_code_ is not null and phoneConfirmationCode = phone_confirmation_code_ and phoneConfirmationExpiry >= now() then 1 else 0 end, case when email_confirmation_code_ is not null and emailConfirmationCode = email_confirmation_code_ and emailConfirmationExpiry >= now() then 2 else 0 end into phone_confirmed, email_confirmed from userT where id = user_id_; set res = phone_confirmed | email_confirmed; return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_CurrentId -- ----------------------------------------------------- DROP function IF EXISTS `user_CurrentId`; DELIMITER $$$ create function user_CurrentId() returns int unsigned deterministic no sql return @__userId$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_SetOauth -- ----------------------------------------------------- DROP function IF EXISTS `user_SetOauth`; DELIMITER $$$ create function user_SetOauth( user_id_ int unsigned, provider_id_ varchar(30) binary, identity_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin set @1 = __user_ValidateId(user_id_); if identity_ is null then delete from userOauthT where userId = user_id_ and oauthProviderId = coalesce(provider_id_, oauthProviderId); else insert userOauthT(userId, oauthProviderId, identity) values(user_id_, provider_id_, identity_) on duplicate key update userOauthT.identity = identity_; end if; return user_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_Login -- ----------------------------------------------------- DROP function IF EXISTS `user_Login`; DELIMITER $$$ create function user_Login(user_id_ int unsigned, browser_langid_ char(3), user_ip_ varchar(40)) returns int unsigned not deterministic begin declare user_id int unsigned; declare user_name varchar(255); declare language_id char(3); set @1 = (user_id_ is null) or __user_ValidateId(user_id_); select u.id, u.preferredLanguage, u.name into user_id, language_id, user_name from userT u where u.id = user_id_ and u.enabled = 'y'; set @__userId = user_id; set @__userName = user_name; set @__userIp = user_ip_; set @__userLanguage = coalesce( language_id, (select id from languageT l where id = browser_langid_), (select id from languageT l where isDefault = 'y')); if user_id is null and user_id_ is not null then call raiseError1('user', 'login', user_id_, 'user is disabled'); end if; return user_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_CurrentLanguage -- ----------------------------------------------------- DROP function IF EXISTS `user_CurrentLanguage`; DELIMITER $$$ create function user_CurrentLanguage() returns char(3) deterministic no sql return @__userLanguage$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_ValidateId -- ----------------------------------------------------- DROP function IF EXISTS `__tag_ValidateId`; DELIMITER $$$ create function __tag_ValidateId(tag_id_ int unsigned) returns int unsigned deterministic begin declare tag_id int unsigned; select t.id into tag_id from tagT t join nodeT n on t.id = n.id join nodeTypeT nt on n.nodeTypeId = nt.id where t.id = tag_id_ and nt.internalTypeId = 'tag'; if tag_id is null then call raiseError1('tag', 'validate', tag_id_, 'tag does not exist'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_Create -- ----------------------------------------------------- DROP function IF EXISTS `__tag_Create`; DELIMITER $$$ create function __tag_Create( type_id_ int unsigned, type_code_ varchar(30) binary, internal_type_id_ varchar(10) binary, name_ varchar(255), sorter_ int, can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), factor_ double, rating_points_ int unsigned, enabled_ enum('n', 'y'), uofm_pre_ varchar(255), uofm_post_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare node_id, type_id int unsigned; declare name__ varchar(255); declare can_search__, display_in_object__, display_in_object_list__ enum('n', 'y'); declare sorter__ int default coalesce(sorter_, __tag_DefaultSorter()); declare enabled__ enum('n', 'y') default coalesce(enabled_, 'y'); declare real_type_id int unsigned default coalesce(type_id_, nodeType_GetByCode(type_code_)); select nt.id, __tag_CalcDefaults(nt.canSearch, nt.displayNode, can_search_, enabled__), __tag_CalcDefaults(nt.displayInObject, nt.displayNode, display_in_object_, enabled__), __tag_CalcDefaults(nt.displayInObjectList, nt.displayNode, display_in_object_list_, enabled__), coalesce(name_, ntl.name) into type_id, can_search__, display_in_object__, display_in_object_list__, name__ from nodeTypeT nt join nodeTypeTL ntl on nt.id = ntl.id join languageT l on ntl.languageId = l.id and l.isDefault = 'y' where nt.id = real_type_id and nt.internalTypeId = internal_type_id_; set node_id = node_LinkDefaults(__node_Create(type_id, null, name__)); insert tagT( id, sorter, canSearch, canSearchRaw, displayInObject, displayInObjectRaw, displayInObjectList, displayInObjectListRaw, factor, ratingPoints, enabled) values( node_id, sorter__, can_search__, can_search_, display_in_object__, display_in_object_, display_in_object_list__, display_in_object_list_, __tag_ClampFactor(coalesce(factor_, 1.0)), __tag_ClampRatingPoints(coalesce(rating_points_, 0)), enabled__); insert tagTL(id, languageId, name, uofmPre, uofmPost) select node_id, l.id, coalesce(name_, ntl.name), coalesce(uofm_pre_, ''), coalesce(uofm_post_, '') from languageT l join nodeTypeTL ntl on ntl.id = type_id and ntl.languageId = l.id; set @1 = __tag_UpdateCache(node_id); return node_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function tag_Create -- ----------------------------------------------------- DROP function IF EXISTS `tag_Create`; DELIMITER $$$ create function tag_Create( type_id_ int unsigned, type_code_ varchar(30) binary, name_ varchar(255), sorter_ int, can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), factor_ double, rating_points_ int unsigned, enabled_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data return tag_Create2(type_id_, type_code_, name_, sorter_, can_search_, display_in_object_, display_in_object_list_, factor_, rating_points_, enabled_, null, null)$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_Delete -- ----------------------------------------------------- DROP function IF EXISTS `__tag_Delete`; DELIMITER $$$ create function __tag_Delete(tag_id_ int unsigned) returns int unsigned not deterministic modifies sql data return __node_Delete(tag_id_)$$$ DELIMITER ; -- ----------------------------------------------------- -- function tag_Delete -- ----------------------------------------------------- DROP function IF EXISTS `tag_Delete`; DELIMITER $$$ create function tag_Delete(tag_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __tag_ValidateId(tag_id_); return __tag_Delete(tag_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_Update -- ----------------------------------------------------- DROP function IF EXISTS `__tag_Update`; DELIMITER $$$ create function __tag_Update( tag_id_ int unsigned, sorter_ int, can_search_ enum('n', 'y'), reset_can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), reset_display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), reset_display_in_object_list_ enum('n', 'y'), factor_ double, rating_points_ int unsigned, enabled_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin set @1 = __node_Update(tag_id_, null); update tagT set sorter = coalesce(sorter_, sorter), canSearchRaw = if(reset_can_search_ = 'y', null, coalesce(can_search_, canSearchRaw)), displayInObjectRaw = if(reset_display_in_object_ = 'y', null, coalesce(display_in_object_, displayInObjectRaw)), displayInObjectListRaw = if(reset_display_in_object_list_ = 'y', null, coalesce(display_in_object_list_, displayInObjectListRaw)), factor = __tag_ClampFactor(coalesce(factor_, factor)), ratingPoints = __tag_ClampRatingPoints(coalesce(rating_points_, ratingPoints)), enabled = coalesce(enabled_, enabled) where id = tag_id_; set @2 = __tag_UpdateDefaults(tag_id_, null); -- as of now - no __tag_UpdateCache here because cache does not depend on tagT return tag_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function tag_Update -- ----------------------------------------------------- DROP function IF EXISTS `tag_Update`; DELIMITER $$$ create function tag_Update( tag_id_ int unsigned, sorter_ int, can_search_ enum('n', 'y'), reset_can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), reset_display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), reset_display_in_object_list_ enum('n', 'y'), factor_ double, rating_points_ int unsigned, enabled_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin declare result int unsigned; set @1 = __tag_ValidateId(tag_id_); set result = __tag_Update( tag_id_, sorter_, can_search_, reset_can_search_, display_in_object_, reset_display_in_object_, display_in_object_list_, reset_display_in_object_list_, factor_, rating_points_, enabled_); set @2 = nodeLink_UpdateStart(); set @3 = __nodeLink_UpdateWorkSet(tag_id_, 1, 1); -- give a chance to update cache of objects set @4 = nodeLink_UpdateEnd(); return result; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_UpdateLocal -- ----------------------------------------------------- DROP function IF EXISTS `__tag_UpdateLocal`; DELIMITER $$$ create function __tag_UpdateLocal( tag_id_ int unsigned, lang_id_ char(3), name_ varchar(255), uofm_pre_ varchar(255), uofm_post_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin set @1 = __node_Update(tag_id_, (select name_ from languageT where id = coalesce(lang_id_, id) and isDefault = 'y')); insert tagTL(id, languageId, name, uofmPre, uofmPost) select tag_id_, l.id, coalesce(name_, ''), coalesce(uofm_pre_, ''), coalesce(uofm_post_, '') from languageT l where l.id = coalesce(lang_id_, l.id) on duplicate key update tagTL.name = coalesce(name_, tagTL.name), tagTL.uofmPre = coalesce(uofm_pre_, tagTL.uofmPre), tagTL.uofmPost = coalesce(uofm_post_, tagTL.uofmPost); set @2 = __tag_UpdateCache(tag_id_); return tag_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function tag_UpdateLocal -- ----------------------------------------------------- DROP function IF EXISTS `tag_UpdateLocal`; DELIMITER $$$ create function tag_UpdateLocal( tag_id_ int unsigned, lang_id_ char(3), name_ varchar(255) ) returns int unsigned not deterministic modifies sql data return tag_UpdateLocal2(tag_id_, lang_id_, name_, null, null)$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_ValidateId -- ----------------------------------------------------- DROP function IF EXISTS `__object_ValidateId`; DELIMITER $$$ -- validators create function __object_ValidateId(object_id_ int unsigned) returns int unsigned deterministic begin declare object_id int unsigned; select o.id into object_id from objectT o join nodeT n on o.id = n.id join nodeTypeT nt on n.nodeTypeId = nt.id where o.id = object_id_ and nt.internalTypeId = 'object'; if object_id is null then call raiseError1('object', 'validate', object_id_, 'object does not exist'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_AccessByUser -- ----------------------------------------------------- DROP function IF EXISTS `__object_AccessByUser`; DELIMITER $$$ create function __object_AccessByUser( object_id_ int unsigned, action_ enum('update', 'delete', 'status'), new_status_id_ char(10) binary ) returns int unsigned not deterministic begin if not ( __object_ValidateId(object_id_) and __object_AccessObjectByUser(object_id_, action_, new_status_id_) and __object_AccessByLoggedUser(object_id_)) then call raiseError1('object', action_, object_id_, concat('cannot perform "', action_, '" on object')); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_Create -- ----------------------------------------------------- DROP function IF EXISTS `object_Create`; DELIMITER $$$ create function object_Create( address_ text, description_ text, status_id_ char(10) binary, latitude_ decimal(12, 7), longitude_ decimal(12, 7), rating_ double, note_for_moderator_ text, note_for_user_ text ) returns int unsigned not deterministic modifies sql data begin declare object_id int unsigned; declare new_address text; declare rating__ double default __object_ClampRating(rating_); set new_address = coalesce(address_, ''); set object_id = node_LinkDefaults(__node_Create(null, 'object', substring(new_address, 1, 50))); insert objectT( id, address, description, statusId, rating, noteForModerator, noteForUser) select object_id, new_address, description_, coalesce(status_id_, os.id), rating__, note_for_moderator_, note_for_user_ from objectStatusT os where os.isDefault = 'y'; set @1 = __object_UpdateSortCacheRating2(object_id, rating__); set @2 = __object_UpdateSortCacheChanged2(object_id, null); set @3 = __coord_Update(object_id, latitude_, longitude_); return object_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_Delete -- ----------------------------------------------------- DROP function IF EXISTS `__object_Delete`; DELIMITER $$$ create function __object_Delete(object_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin return __node_Delete(object_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_Delete -- ----------------------------------------------------- DROP function IF EXISTS `object_Delete`; DELIMITER $$$ create function object_Delete(object_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __object_ValidateId(object_id_); return __object_Delete(object_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_DeleteByUser -- ----------------------------------------------------- DROP function IF EXISTS `object_DeleteByUser`; DELIMITER $$$ create function object_DeleteByUser(object_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __object_AccessByUser(object_id_, 'delete', null); return __object_Delete(object_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_Update -- ----------------------------------------------------- DROP function IF EXISTS `__object_Update`; DELIMITER $$$ create function __object_Update( object_id_ int unsigned, address_ text, description_ text, status_id_ char(10) binary, latitude_ decimal(12, 7), reset_latitude_ enum('n', 'y'), longitude_ decimal(12, 7), reset_longitude_ enum('n', 'y'), rating_ double, note_for_moderator_ text, reset_note_for_moderator_ enum('n', 'y'), note_for_user_ text, reset_note_for_user_ enum('n', 'y'), alias_ text ) returns int unsigned not deterministic modifies sql data begin set @1 = __node_Update(object_id_, substring(address_, 1, 50)); update objectT set address = coalesce(address_, address), description = coalesce(description_, description), statusId = coalesce(status_id_, statusId), rating = __object_ClampRating(coalesce(rating_, rating)), noteForModerator = if(reset_note_for_moderator_ = 'y', null, coalesce(note_for_moderator_, noteForModerator)), noteForUser = if(reset_note_for_user_ = 'y', null, coalesce(note_for_user_, noteForUser)), alias = if(alias_ = '', null, coalesce(alias_, alias)) where id = object_id_; set @2 = rating_ is not null and __object_UpdateSortCacheRating2(object_id_, null); -- assume we already have rating set if reset_latitude_ = 'y' and reset_longitude_ = 'y' then set @3 = __coord_Delete(object_id_); else set @4 = __coord_Update(object_id_, latitude_, longitude_); end if; return object_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_Update -- ----------------------------------------------------- DROP function IF EXISTS `object_Update`; DELIMITER $$$ create function object_Update( object_id_ int unsigned, address_ text, description_ text, status_id_ char(10) binary, latitude_ decimal(12, 7), reset_latitude_ enum('n', 'y'), longitude_ decimal(12, 7), reset_longitude_ enum('n', 'y'), rating_ double, note_for_moderator_ text, reset_note_for_moderator_ enum('n', 'y'), note_for_user_ text, reset_note_for_user_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin declare result int unsigned; set @1 = __object_ValidateId(object_id_); set result = __object_Update(object_id_, address_, description_, status_id_, latitude_, reset_latitude_, longitude_, reset_longitude_, rating_, note_for_moderator_, reset_note_for_moderator_, note_for_user_, reset_note_for_user_, null); set @2 = __object_UpdateSortCacheChanged2(object_id_, null); return result; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_UpdateByUser -- ----------------------------------------------------- DROP function IF EXISTS `object_UpdateByUser`; DELIMITER $$$ create function object_UpdateByUser( object_id_ int unsigned, address_ text, description_ text, latitude_ decimal(12, 7), reset_latitude_ enum('n', 'y'), longitude_ decimal(12, 7), reset_longitude_ enum('n', 'y'), note_for_user_ text, reset_note_for_user_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin declare result int unsigned; set @1 = __object_AccessByUser(object_id_, 'update', null); set result = __object_Update(object_id_, address_, description_, null, latitude_, reset_latitude_, longitude_, reset_longitude_, null, null, null, note_for_user_, reset_note_for_user_, null); set @2 = __object_UpdateSortCacheChanged2(object_id_, null); return result; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_SetStatusByUser -- ----------------------------------------------------- DROP function IF EXISTS `object_SetStatusByUser`; DELIMITER $$$ create function object_SetStatusByUser( object_id_ int unsigned, status_id_ char(10) binary ) returns int unsigned not deterministic modifies sql data begin declare result int unsigned; set @1 = __object_AccessByUser(object_id_, 'status', status_id_); set result = __object_Update(object_id_, null, null, status_id_, null, null, null, null, null, null, null, null, null, null); set @2 = __object_UpdateSortCacheChanged2(object_id_, null); return result; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_AccessObjectByUser -- ----------------------------------------------------- DROP function IF EXISTS `__object_AccessObjectByUser`; DELIMITER $$$ create function __object_AccessObjectByUser( object_id_ int unsigned, action_ enum('update', 'delete', 'status'), new_status_id_ char(10) binary ) returns int unsigned not deterministic begin declare editable, draftable enum('n', 'y'); select os.userEditable, os.userDraftable into editable, draftable from objectStatusT os join objectT o on os.id = o.statusId where o.id = object_id_; return case action_ when 'update' then editable = 'y' when 'delete' then editable = 'y' or draftable = 'y' when 'status' then case new_status_id_ when 'draft' then draftable = 'y' when 'review' then editable = 'y' else 0 end else 0 end; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_AccessByLoggedUser -- ----------------------------------------------------- DROP function IF EXISTS `__object_AccessByLoggedUser`; DELIMITER $$$ create function __object_AccessByLoggedUser(object_id_ int unsigned) returns int unsigned not deterministic return exists ( select 1 from nodeLinkT nl join nodeLinkTypeT nlt on nl.nodeLinkTypeId = nlt.id where nlt.code = 'owns' and nl.srcNodeId = user_CurrentId() and nl.dstNodeId = object_id_)$$$ DELIMITER ; -- ----------------------------------------------------- -- function testOddRaiseError -- ----------------------------------------------------- DROP function IF EXISTS `testOddRaiseError`; DELIMITER $$$ create function testOddRaiseError(n int) returns int not deterministic begin if (n % 2 = 1) then call raiseError1('testObject', 'testAction', n, '<-- this is odd!'); end if; return n; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure raiseError -- ----------------------------------------------------- DROP procedure IF EXISTS `raiseError`; DELIMITER $$$ create procedure raiseError(msg_ varchar(128)) begin declare msg varchar(128) default substring(msg_, 1, 128); signal sqlstate '45000' set message_text = msg; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure raiseError1 -- ----------------------------------------------------- DROP procedure IF EXISTS `raiseError1`; DELIMITER $$$ create procedure raiseError1( object_ varchar(30), action_ varchar(30), subject_ varchar(30), msg_ varchar(65)) begin call raiseError(concat_ws('|', coalesce(object_, ''), coalesce(action_, ''), coalesce(subject_, ''), coalesce(msg_, ''))); end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure raiseError2 -- ----------------------------------------------------- DROP procedure IF EXISTS `raiseError2`; DELIMITER $$$ create procedure raiseError2( object_ varchar(30), action_ varchar(30), subject1_ varchar(30), subject2_ varchar(30), msg_ varchar(65)) begin call raiseError(concat_ws('|', coalesce(object_, ''), coalesce(action_, ''), coalesce(subject1_, ''), coalesce(subject2_, ''), coalesce(msg_, ''))); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __node_CanUpdate -- ----------------------------------------------------- DROP function IF EXISTS `__node_CanUpdate`; DELIMITER $$$ create function __node_CanUpdate(node_id_ int unsigned, action_ varchar(20)) returns int unsigned deterministic begin if (select nt.canEditNode from nodeTypeT nt join nodeT n on nt.id = n.nodeTypeId where n.id = node_id_) != 'y' then call raiseError1('node', action_, node_id_, 'cannot change uneditable node'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeType_GetByCode -- ----------------------------------------------------- DROP function IF EXISTS `nodeType_GetByCode`; DELIMITER $$$ create function nodeType_GetByCode(code_ varchar(30) binary) returns int unsigned deterministic begin return (select nt.id from nodeTypeT nt where nt.code = code_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeType_UpdateCode -- ----------------------------------------------------- DROP function IF EXISTS `nodeType_UpdateCode`; DELIMITER $$$ create function nodeType_UpdateCode( type_id_ int unsigned, code_ varchar(30) binary ) returns int unsigned not deterministic modifies sql data begin set @1 = __nodeType_CanUpdate(type_id_, 'updateCode'); update nodeTypeT set code = code_ where id = type_id_; return __nodeType_Touch(type_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __executeSQL -- ----------------------------------------------------- DROP procedure IF EXISTS `__executeSQL`; DELIMITER $$$ create procedure __executeSQL(sql_query_ mediumtext) modifies sql data begin set @executeSQL_q = sql_query_; prepare executeSQL_stmt from @executeSQL_q; execute executeSQL_stmt; deallocate prepare executeSQL_stmt; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function node_LinkDefaults -- ----------------------------------------------------- DROP function IF EXISTS `node_LinkDefaults`; DELIMITER $$$ create function node_LinkDefaults(node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __node_LinkDefaults('owns', node_id_); return node_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function externalData_UpdateTags -- ----------------------------------------------------- DROP function IF EXISTS `externalData_UpdateTags`; DELIMITER $$$ create function externalData_UpdateTags( external_data_source_id_ varchar(30) binary, dataset_code_ varchar(255), force_update_ int unsigned ) returns varchar(50) not deterministic modifies sql data begin declare number_added, number_changed, number_disabled int unsigned; declare force_update int unsigned default coalesce(force_update_, 0); declare parent_node_id int unsigned default ( select edd.nodeId from externalDataSourceDatasetT edd where edd.externalDataSourceId = external_data_source_id_ and edd.code = dataset_code_); declare no_parent_node int unsigned default (parent_node_id is null); drop temporary table if exists externalDataInserted; create temporary table externalDataInserted( tagId int unsigned not null primary key ) engine=MEMORY; -- insert missing ones and link created tags set number_added = __externalData_CreateTags(external_data_source_id_, no_parent_node, parent_node_id); -- update names set number_changed = __externalData_UpdateTagNames(external_data_source_id_, no_parent_node, parent_node_id, force_update); -- disable "deleted" set number_disabled = __externalData_DisableTags(external_data_source_id_, no_parent_node, parent_node_id, force_update); drop temporary table externalDataInserted; return concat_ws('|', number_added, number_changed, number_disabled); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __external_OSM_UpdateLocal -- ----------------------------------------------------- DROP function IF EXISTS `__external_OSM_UpdateLocal`; DELIMITER $$$ -- -------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------- -- OSM import -- -------------------------------------------------------------------------------- -- import process: -- 1) load data infile into temp table - ONE entity (city/district/etc at a time) -- 2) convert temp table -> externalDataT/externalDataTL by running external_OSM_Import -- 3) run externalData_UpdateTags -- temp table format for streets: -- 1) id - internal OSM way identifier, unique within OSM, but one street may have several ids -- 2) highway - highway label, no use for us -- 3) name_ukr - default name (ukrainian), also it is the local key, so we need to group by this field -- 4) name_rus - russian name -- 5) name_eng - english name /* create table tmpOsmDataT( id varchar(50) not null, highway varchar(100), name_ukr varchar(255), name_rus varchar(255), name_eng varchar(255), primary key(id), index(name_ukr) ) engine=InnoDB; load data local infile '' replace into table tmpOsmDataT character set utf8 columns terminated by '\t' lines terminated by '\r\n' ignore 1 lines; -------------------------------- truncate table tmpOsmDataT; load data local infile '/home/castor/public_html/m2.te.ua/ternopil-streets.txt' replace into table tmpOsmDataT character set utf8 columns terminated by '\t' lines terminated by '\r\n' ignore 1 lines; call external_OSM_Import('ternopil', 'street'); truncate table tmpOsmDataT; load data local infile '/home/castor/public_html/m2.te.ua/kyiv-suburbs.txt' replace into table tmpOsmDataT character set utf8 columns terminated by '\t' lines terminated by '\r\n' ignore 1 lines; call external_OSM_Import('kyiv', 'neighborhood'); truncate table tmpOsmDataT; load data local infile '/home/castor/public_html/m2.te.ua/kyiv-streets.txt' replace into table tmpOsmDataT character set utf8 columns terminated by '\t' lines terminated by '\r\n' ignore 1 lines; call external_OSM_Import('kyiv', 'street'); truncate table tmpOsmDataT; */ create function __external_OSM_UpdateLocal( external_data_id_ int unsigned, lang_id_ char(3), name_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin if name_ is not null then insert externalDataTL(id, languageId, name) values(external_data_id_, lang_id_, name_) on duplicate key update externalDataTL.name = name_; end if; return external_data_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __external_OSM_UpdateName -- ----------------------------------------------------- DROP procedure IF EXISTS `__external_OSM_UpdateName`; DELIMITER $$$ create procedure __external_OSM_UpdateName(parent_node_id_ int unsigned, type_code_ varchar(30) binary) modifies sql data begin declare sql_tmpl varchar(2000) default 'insert zzzDevNullExternalDataT(n) select __external_OSM_UpdateLocal(ed.id, ''{{0}}'', nullif(tod.name_{{0}}, '''')) from externalDataT ed join tmpOsmDataT tod on ed.externalKey = tod.name_ukr where ed.externalDataSourceId = ''osm'' and ed.parentNodeId = {{1}} and ed.typeCode = ''{{2}}'' and ed.enabled = ''y'' group by tod.name_ukr'; declare sql_tmpl2 varchar(2000); set sql_tmpl2 = replace(replace(sql_tmpl, '{{1}}', parent_node_id_), '{{2}}', type_code_); call __externalData_IterateLanguage(sql_tmpl2, '{{0}}'); end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure external_OSM_Import -- ----------------------------------------------------- DROP procedure IF EXISTS `external_OSM_Import`; DELIMITER $$$ create procedure external_OSM_Import( dictionary_id_ varchar(255) binary, type_code_ varchar(30) binary) modifies sql data begin declare parent_node_id int unsigned default ( select edd.nodeId from externalDataSourceDatasetT edd where edd.externalDataSourceId = 'osm' and edd.code = dictionary_id_); -- insert insert externalDataT( externalDataSourceId, parentNodeId, externalKey, typeCode, enabled) select 'osm', parent_node_id, tod.name_ukr, type_code_, 'y' from tmpOsmDataT tod where not exists ( select 1 from externalDataT ed where ed.externalDataSourceId = 'osm' and ed.parentNodeId = parent_node_id and ed.typeCode = type_code_ and ed.externalKey = tod.name_ukr) group by tod.name_ukr; -- disable update externalDataT ed set ed.enabled = 'n' where ed.externalDataSourceId = 'osm' and ed.parentNodeId = parent_node_id and ed.typeCode = type_code_ and not exists (select 1 from tmpOsmDataT tod where tod.name_ukr = ed.externalKey); -- update names call __external_OSM_UpdateName(parent_node_id, type_code_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function external_OSM_Help -- ----------------------------------------------------- DROP function IF EXISTS `external_OSM_Help`; DELIMITER $$$ create function external_OSM_Help() returns varchar(20000) begin return ''; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure initScript_Start -- ----------------------------------------------------- DROP procedure IF EXISTS `initScript_Start`; DELIMITER $$$ create procedure initScript_Start() modifies sql data begin start transaction; call __initScript_010Root(); call __initScript_015Templates(); call __initScript_020Users(); call __initScript_030Cities(); call __initScript_040Amenities(); call __initScript_050HiddenAttributes(); commit; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_Create2 -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_Create2`; DELIMITER $$$ create function nodeLink_Create2( link_code varchar(30) binary, src_id int unsigned, dst_id int unsigned ) returns int unsigned not deterministic modifies sql data begin set @1 = nodeLink_Create(link_code, src_id, dst_id); return dst_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __externalData_UpdateTagNames -- ----------------------------------------------------- DROP function IF EXISTS `__externalData_UpdateTagNames`; DELIMITER $$$ create function __externalData_UpdateTagNames( external_data_source_id_ varchar(30) binary, no_parent_node_ int unsigned, parent_node_id_ int unsigned, force_update_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare result int unsigned; drop temporary table if exists externalDataUpdateLocal; create temporary table externalDataUpdateLocal( nodeId int unsigned not null primary key ) engine=MEMORY; insert ignore externalDataUpdateLocal(nodeId) select ed.tagId from externalDataT ed join nodeT n on ed.tagId = n.id left join externalDataInserted edi on ed.tagId = edi.tagId where ed.externalDataSourceId = external_data_source_id_ and (no_parent_node_ or ed.parentNodeId = parent_node_id_) and ed.enabled = 'y' and (force_update_ or ed.changed > n.changed or edi.tagId is not null); insert zzzDevNullExternalDataT(n) select tag_UpdateLocal(ed.tagId, l.id, edl.name) from externalDataT ed join externalDataUpdateLocal edul on ed.tagId = edul.nodeId join languageT l on 1=1 left join externalDataTL edl on ed.id = edl.id and l.id = edl.languageId where ed.externalDataSourceId = external_data_source_id_ and (no_parent_node_ or ed.parentNodeId = parent_node_id_) and ed.enabled = 'y'; set result = row_count() / (select count(*) from languageT); drop temporary table externalDataUpdateLocal; return result; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __externalData_DisableTags -- ----------------------------------------------------- DROP function IF EXISTS `__externalData_DisableTags`; DELIMITER $$$ create function __externalData_DisableTags( external_data_source_id_ varchar(30) binary, no_parent_node_ int unsigned, parent_node_id_ int unsigned, force_update_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare result int unsigned; drop temporary table if exists externalDataDisable; create temporary table externalDataDisable( tagId int unsigned not null primary key ) engine=MEMORY; insert externalDataDisable(tagId) select ed.tagId from externalDataT ed join nodeT n on ed.tagId = n.id where ed.externalDataSourceId = external_data_source_id_ and (no_parent_node_ or ed.parentNodeId = parent_node_id_) and ed.enabled = 'n' and (force_update_ or ed.changed > n.changed); set @1 = nodeLink_UpdateStart(); -- prevent from redundant cache updates insert zzzDevNullExternalDataT(n) select tag_Update(tagId, null, null, null, null, null, null, null, null, null, 'n') -- disable and exclude from search from externalDataDisable; set result = row_count(); set @2 = nodeLink_UpdateEnd(); drop temporary table externalDataDisable; return result; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __externalData_CreateTags -- ----------------------------------------------------- DROP function IF EXISTS `__externalData_CreateTags`; DELIMITER $$$ create function __externalData_CreateTags( external_data_source_id_ varchar(30) binary, no_parent_node_ int unsigned, parent_node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare result int unsigned; set @1 = nodeLink_UpdateStart(); /*update externalDataT ed set ed.tagId = __externalData_TagHelper( nodeLink_Relink2( 'owns', ed.parentNodeId, tag_Create(null, ed.typeCode, ed.externalKey, null, null, null, null, null, null, ed.enabled))) where ed.externalDataSourceId = external_data_source_id_ and ed.tagId is null and (no_parent_node_ or ed.parentNodeId = parent_node_id_) and ed.enabled = 'y';*/ update externalDataT ed set ed.tagId = __externalData_TagHelper( tag_Create(null, ed.typeCode, ed.externalKey, null, null, null, null, null, null, ed.enabled)) where ed.externalDataSourceId = external_data_source_id_ and ed.tagId is null and (no_parent_node_ or ed.parentNodeId = parent_node_id_) and ed.enabled = 'y'; set result = row_count(); -- consider only inserted insert zzzDevNullExternalDataT(n) select nodeLink_Relink('owns', coalesce(parentEd.tagId, if(no_parent_node_, null, parent_node_id_)), ed.tagId) from externalDataT ed join externalDataInserted edi on ed.tagId = edi.tagId left join externalDataT parentEd on ed.externalParentKey = parentEd.externalKey; set @2 = nodeLink_UpdateEnd(); return result; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __externalData_TagHelper -- ----------------------------------------------------- DROP function IF EXISTS `__externalData_TagHelper`; DELIMITER $$$ create function __externalData_TagHelper(tag_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin insert ignore externalDataInserted(tagId) -- externalDataInserted created in externalData_UpdateTags values(tag_id_); return tag_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_CreateByUser -- ----------------------------------------------------- DROP function IF EXISTS `object_CreateByUser`; DELIMITER $$$ create function object_CreateByUser( address_ text, description_ text, status_id_ char(10) binary, latitude_ decimal(12, 7), longitude_ decimal(12, 7), note_for_moderator_ text, note_for_user_ text ) returns int unsigned not deterministic modifies sql data begin return nodeLink_Create2( 'owns', user_CurrentId(), object_Create( address_, description_, status_id_, latitude_, longitude_, 0, note_for_moderator_, note_for_user_)); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_Relink -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_Relink`; DELIMITER $$$ create function nodeLink_Relink( link_code_ varchar(30) binary, src_id_ int unsigned, dst_id_ int unsigned ) returns int unsigned comment 'links src_id and dst_id, detects and removes unnecessary linking' not deterministic modifies sql data begin declare res int unsigned default 1; if src_id_ = dst_id_ then return 1; end if; set @1 = __nodeLink_DestinationStart(); set @2 = __nodeLink_DestinationAdd(dst_id_); set res = __nodeLink_Relink(link_code_, src_id_); set @3 = __nodeLink_DestinationEnd(); return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_Relink2 -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_Relink2`; DELIMITER $$$ create function nodeLink_Relink2( link_code_ varchar(30) binary, src_id_ int unsigned, dst_id_ int unsigned ) returns int unsigned comment 'calls nodeLink_Relink and returns dst_id' not deterministic modifies sql data begin set @1 = nodeLink_Relink(link_code_, src_id_, dst_id_); return dst_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_ResetLinks -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_ResetLinks`; DELIMITER $$$ create function nodeLink_ResetLinks( link_code_ varchar(30) binary, root_type_code_ varchar(30) binary, dst_id_ int unsigned, recreate_root_links_ int ) returns int unsigned not deterministic modifies sql data begin declare link_code varchar(30) binary; declare link_id int unsigned; declare recreate_root_links int default coalesce(recreate_root_links_, 1); select nlt.id, nlt.code into link_id, link_code from nodeLinkTypeT nlt join nodeLinkTypeT nltdef on nltdef.isDefault = 'y' where nlt.code = coalesce(link_code_, nltdef.code); drop temporary table if exists nodeLinkResetLinksDeletes; create temporary table nodeLinkResetLinksDeletes( srcNodeId int unsigned, primary key(srcNodeId) ) engine=MEMORY; insert nodeLinkResetLinksDeletes(srcNodeId) select nl.srcNodeId from nodeLinkT nl where nl.nodeLinkTypeId = link_id and nl.dstNodeId = dst_id_ and nl.metric = 1; /* and exists( select 1 from nodeLinkT nl2 join nodeV n2 on nl2.srcNodeId = n2.id where nl2.nodeLinkTypeId = link_id and nl2.dstNodeId = nl.srcNodeId and nl2.metric > 0 and n2.isRoot = 'y' and n2.typeCode = coalesce(root_type_code_, n2.typeCode));*/ set @1 = nodeLink_UpdateStart(); insert zzzDevNullLinkT(n) select __nodeLink_Delete(link_code, nlrld.srcNodeId, dst_id_, null) from nodeLinkResetLinksDeletes nlrld; set @2 = recreate_root_links and __node_LinkDefaults(link_code, dst_id_); set @3 = nodeLink_UpdateEnd(); drop temporary table nodeLinkResetLinksDeletes; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __node_LinkDefaults -- ----------------------------------------------------- DROP function IF EXISTS `__node_LinkDefaults`; DELIMITER $$$ create function __node_LinkDefaults(link_code_ varchar(30) binary, node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare link_code varchar(30) binary; declare link_id int unsigned; select nlt.id, nlt.code into link_id, link_code from nodeLinkTypeT nlt join nodeLinkTypeT nltdef on nltdef.isDefault = 'y' where nlt.code = coalesce(link_code_, nltdef.code); drop temporary table if exists nodeLinkDefaultsTmp; create temporary table nodeLinkDefaultsTmp( src_id int unsigned, dst_id int unsigned, primary key(src_id, dst_id) ) engine=MEMORY; insert nodeLinkDefaultsTmp(src_id, dst_id) select rootnode.id, n.id from nodeT rootnode join allowedNodeLinkT anl on rootnode.nodeTypeId = anl.srcNodeTypeId join nodeT n on anl.dstNodeTypeId = n.nodeTypeId and n.id = node_id_ left join templateT t on n.id = t.dstNodeId where rootnode.isRoot = 'y' and t.dstNodeId is null and not exists ( select 1 from nodeLinkT nl where nl.nodeLinkTypeId = link_id and nl.srcNodeId = rootnode.id and nl.dstNodeId = n.id and nl.metric = 1); set @1 = nodeLink_UpdateStart(); insert zzzDevNullNodeT(n) select __nodeLink_Create(link_code, src_id, dst_id, 0) from nodeLinkDefaultsTmp; set @2 = nodeLink_UpdateEnd(); drop temporary table nodeLinkDefaultsTmp; return node_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function tag_CreateDef -- ----------------------------------------------------- DROP function IF EXISTS `tag_CreateDef`; DELIMITER $$$ create function tag_CreateDef( type_id_ int unsigned, type_code_ varchar(30) binary, name_ varchar(255) ) returns int unsigned not deterministic modifies sql data return tag_Create(type_id_, type_code_, name_, null, null, null, null, null, null, null)$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_Unlink -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_Unlink`; DELIMITER $$$ create function nodeLink_Unlink( link_code_ varchar(30) binary, src_id_ int unsigned, dst_id_ int unsigned ) returns int unsigned comment 'unlinks src_id and dst_id, links dst_id to parents of src_id' not deterministic modifies sql data begin declare res int unsigned default 1; if src_id_ = dst_id_ then return 1; end if; set @1 = __nodeLink_DestinationStart(); set @2 = __nodeLink_DestinationAdd(dst_id_); set res = __nodeLink_Unlink(link_code_, src_id_, 1); set @3 = __nodeLink_DestinationEnd(); return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_Unlink2 -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_Unlink2`; DELIMITER $$$ create function nodeLink_Unlink2( link_code_ varchar(30) binary, src_id_ int unsigned, dst_id_ int unsigned ) returns int unsigned comment 'calls nodeLink_Unlink and returns dst_id' not deterministic modifies sql data begin set @1 = nodeLink_Unlink(link_code_, src_id_, dst_id_); return dst_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeAncestry_Update -- ----------------------------------------------------- DROP function IF EXISTS `__nodeAncestry_Update`; DELIMITER $$$ create function __nodeAncestry_Update() returns int unsigned not deterministic modifies sql data begin insert nodeAncestryT(id, languageId, tagNames) select nad.dstNodeId, nad.languageId, group_concat( concat_ws( 0xb, nad.srcTypeId, nad.srcTypeName, string_ConcatSmart( ' ', nad.srcUofmPre, if( nad.srcInternalTypeId = 'attribute', coalesce( nad.srcNumericValue, date_format(nad.srcDatetimeValue, nad.srcDatetimeOutputFormat), replace(replace(nad.srcTextValue, 0xb, ''), '\0', ''), ''), nad.srcName), nad.srcUofmPost)) order by nad.ancestrySorter, nad.srcTypeName, nad.srcName separator '\0') tag_names from nodeAncestryDataV nad join zzzNodeWorksetV nws on nad.dstNodeId = nws.nodeId where nws.isMain = 1 group by nad.dstNodeId, nad.languageId on duplicate key update nodeAncestryT.tagNames = values(tagNames); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeAncestry_UpdateAll -- ----------------------------------------------------- DROP function IF EXISTS `__nodeAncestry_UpdateAll`; DELIMITER $$$ create function __nodeAncestry_UpdateAll(reset_data_ int) returns int unsigned not deterministic modifies sql data comment 'updates all nodes ancestry; to be called by hand when needed' begin delete from nodeAncestryT where coalesce(reset_data_, 0); insert nodeAncestryT(id, languageId, tagNames) select nad.dstNodeId, nad.languageId, group_concat( concat_ws( 0xb, nad.srcTypeId, nad.srcTypeName, string_ConcatSmart( ' ', nad.srcUofmPre, if( nad.srcInternalTypeId = 'attribute', coalesce( nad.srcNumericValue, date_format(nad.srcDatetimeValue, nad.srcDatetimeOutputFormat), replace(replace(nad.srcTextValue, 0xb, ''), '\0', ''), ''), nad.srcName), nad.srcUofmPost)) order by nad.ancestrySorter, nad.srcTypeName, nad.srcName separator '\0') tag_names from nodeAncestryDataV nad group by nad.dstNodeId, nad.languageId on duplicate key update nodeAncestryT.tagNames = values(tagNames); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_ValidateId -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_ValidateId`; DELIMITER $$$ create function __attribute_ValidateId(attribute_id_ int unsigned) returns int unsigned deterministic begin declare attribute_id int unsigned; select a.id into attribute_id from attributeT a join tagT t on a.id = t.id join nodeT n on a.id = n.id join nodeTypeT nt on n.nodeTypeId = nt.id where a.id = attribute_id_ and nt.internalTypeId = 'attribute'; if attribute_id is null then call raiseError1('attribute', 'validate', attribute_id_, 'attribute does not exist'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_ValidateIdDataType -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_ValidateIdDataType`; DELIMITER $$$ create function __attribute_ValidateIdDataType( attribute_id_ int unsigned, type_name_ varchar(10) binary ) returns int unsigned deterministic begin set @1 = __attribute_ValidateId(attribute_id_); if (select a.dataTypeId from attributeT a where a.id = attribute_id_) != type_name_ then call raiseError2('attribute', 'typecheck', attribute_id_, type_name_, 'attribute mismatching type'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_ClampValueNumeric -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_ClampValueNumeric`; DELIMITER $$$ create function __attribute_ClampValueNumeric(attribute_id_ int unsigned, value_ decimal(22, 6)) returns decimal(22, 6) deterministic begin declare res decimal(22, 6); select round( greatest( least( value_, coalesce(a.decimalMax, value_)), coalesce(a.decimalMin, value_)), a.decimalRound) into res from attributeNumericT a where a.id = attribute_id_; return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_ClampValueDatetime -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_ClampValueDatetime`; DELIMITER $$$ create function __attribute_ClampValueDatetime(attribute_id_ int unsigned, value_ datetime) returns datetime deterministic begin declare res datetime; select cast(date_format(value_, adf.storageFormat) as datetime) into res from attributeDatetimeT a join attributeDatetimeFormatT adf on a.datetimeStorageId = adf.id where a.id = attribute_id_; return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_Create -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_Create`; DELIMITER $$$ create function __attribute_Create( type_id_ int unsigned, type_code_ varchar(30) binary, name_ varchar(255), sorter_ int, can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), data_type_id_ varchar(10) binary, code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y'), uofm_pre_ varchar(255), uofm_post_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare attribute_id int unsigned; set attribute_id = __tag_Create(type_id_, type_code_, 'attribute', name_, sorter_, can_search_, display_in_object_, display_in_object_list_, factor_, null, enabled_, uofm_pre_, uofm_post_); insert attributeT(id, dataTypeId, code, required, sortable) values(attribute_id, data_type_id_, nullif(code_, ''), required_, sortable_); set @1 = __attribute_UpdateCache(attribute_id); return attribute_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_SetNumeric -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_SetNumeric`; DELIMITER $$$ create function __attribute_SetNumeric( attribute_id_ int unsigned, decimal_min_ decimal(22, 6), reset_decimal_min_ enum('n', 'y'), decimal_max_ decimal(22, 6), reset_decimal_max_ enum('n', 'y'), decimal_round_ int ) returns int unsigned not deterministic modifies sql data begin insert attributeNumericT( id, decimalMin, decimalMax, decimalRound) values( attribute_id_, decimal_min_, decimal_max_, decimal_round_) on duplicate key update attributeNumericT.decimalMin = if(reset_decimal_min_ = 'y', null, coalesce(decimal_min_, attributeNumericT.decimalMin)), attributeNumericT.decimalMax = if(reset_decimal_max_ = 'y', null, coalesce(decimal_max_, attributeNumericT.decimalMax)), attributeNumericT.decimalRound = coalesce(decimal_round_, attributeNumericT.decimalRound); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_SetDatetime -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_SetDatetime`; DELIMITER $$$ create function __attribute_SetDatetime( attribute_id_ int unsigned, datetime_storage_id_ varchar(10) binary ) returns int unsigned not deterministic modifies sql data begin insert attributeDatetimeT( id, datetimeStorageId) values( attribute_id_, datetime_storage_id_) on duplicate key update attributeDatetimeT.datetimeStorageId = coalesce(datetime_storage_id_, attributeDatetimeT.datetimeStorageId); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_SetText -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_SetText`; DELIMITER $$$ create function __attribute_SetText( attribute_id_ int unsigned, text_is_long_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin insert attributeTextT( id, textIsLong) values( attribute_id_, text_is_long_) on duplicate key update attributeTextT.textIsLong = coalesce(text_is_long_, attributeTextT.textIsLong); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_CreateNumeric -- ----------------------------------------------------- DROP function IF EXISTS `attribute_CreateNumeric`; DELIMITER $$$ create function attribute_CreateNumeric( type_id_ int unsigned, type_code_ varchar(30) binary, name_ varchar(255), sorter_ int, can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y'), uofm_pre_ varchar(255), uofm_post_ varchar(255), decimal_min_ decimal(22, 6), decimal_max_ decimal(22, 6), decimal_round_ int ) returns int unsigned not deterministic modifies sql data begin declare attribute_id int unsigned; set attribute_id = __attribute_Create( type_id_, type_code_, name_, sorter_, can_search_, display_in_object_, display_in_object_list_, factor_, enabled_, 'numeric', code_, required_, sortable_, uofm_pre_, uofm_post_); set @1 = __attribute_SetNumeric(attribute_id, decimal_min_, null, decimal_max_, null, decimal_round_); return attribute_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_CreateDatetime -- ----------------------------------------------------- DROP function IF EXISTS `attribute_CreateDatetime`; DELIMITER $$$ create function attribute_CreateDatetime( type_id_ int unsigned, type_code_ varchar(30) binary, name_ varchar(255), sorter_ int, can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y'), uofm_pre_ varchar(255), uofm_post_ varchar(255), datetime_storage_id_ varchar(10) binary ) returns int unsigned not deterministic modifies sql data begin declare attribute_id int unsigned; set attribute_id = __attribute_Create( type_id_, type_code_, name_, sorter_, can_search_, display_in_object_, display_in_object_list_, factor_, enabled_, 'datetime', code_, required_, sortable_, uofm_pre_, uofm_post_); set @1 = __attribute_SetDatetime(attribute_id, datetime_storage_id_); return attribute_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_CreateText -- ----------------------------------------------------- DROP function IF EXISTS `attribute_CreateText`; DELIMITER $$$ create function attribute_CreateText( type_id_ int unsigned, type_code_ varchar(30) binary, name_ varchar(255), sorter_ int, can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y'), uofm_pre_ varchar(255), uofm_post_ varchar(255), text_is_long_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin declare attribute_id int unsigned; set attribute_id = __attribute_Create( type_id_, type_code_, name_, sorter_, can_search_, display_in_object_, display_in_object_list_, factor_, enabled_, 'text', code_, required_, sortable_, uofm_pre_, uofm_post_); set @1 = __attribute_SetText(attribute_id, text_is_long_); return attribute_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_Delete -- ----------------------------------------------------- DROP function IF EXISTS `attribute_Delete`; DELIMITER $$$ create function attribute_Delete(attribute_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __attribute_ValidateId(attribute_id_); return __tag_Delete(attribute_id_); -- call ancestor function end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_Update -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_Update`; DELIMITER $$$ create function __attribute_Update( attribute_id_ int unsigned, sorter_ int, can_search_ enum('n', 'y'), reset_can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), reset_display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), reset_display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin set @1 = __tag_Update( attribute_id_, sorter_, can_search_, reset_can_search_, display_in_object_, reset_display_in_object_, display_in_object_list_, reset_display_in_object_list_, factor_, null, enabled_); update attributeT set code = if(code_ = '', null, coalesce(code_, code)), required = coalesce(required_, required), sortable = coalesce(sortable_, sortable) where id = attribute_id_; -- as of now - no __attribute_UpdateCache here because cache does not depend on attributeT return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_Update -- ----------------------------------------------------- DROP function IF EXISTS `attribute_Update`; DELIMITER $$$ create function attribute_Update( attribute_id_ int unsigned, sorter_ int, can_search_ enum('n', 'y'), reset_can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), reset_display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), reset_display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin set @1 = __attribute_ValidateId(attribute_id_); set @2 = __attribute_Update( attribute_id_, sorter_, can_search_, reset_can_search_, display_in_object_, reset_display_in_object_, display_in_object_list_, reset_display_in_object_list_, factor_, enabled_, code_, required_, sortable_); set @3 = __object_UpdateSortCache(null, attribute_id_, null); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_UpdateNumericValues -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_UpdateNumericValues`; DELIMITER $$$ create function __attribute_UpdateNumericValues(attribute_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin update attributeValueNumericT set value = __attribute_ClampValueNumeric(attribute_id_, valueRaw) where attributeId = attribute_id_; return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_UpdateNumeric -- ----------------------------------------------------- DROP function IF EXISTS `attribute_UpdateNumeric`; DELIMITER $$$ create function attribute_UpdateNumeric( attribute_id_ int unsigned, sorter_ int, can_search_ enum('n', 'y'), reset_can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), reset_display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), reset_display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y'), decimal_min_ decimal(22, 6), reset_decimal_min_ enum('n', 'y'), decimal_max_ decimal(22, 6), reset_decimal_max_ enum('n', 'y'), decimal_round_ int ) returns int unsigned not deterministic modifies sql data begin set @1 = __attribute_ValidateIdDataType(attribute_id_, 'numeric'); set @2 = __attribute_Update( attribute_id_, sorter_, can_search_, reset_can_search_, display_in_object_, reset_display_in_object_, display_in_object_list_, reset_display_in_object_list_, factor_, enabled_, code_, required_, sortable_); set @3 = __attribute_SetNumeric(attribute_id_, decimal_min_, reset_decimal_min_, decimal_max_, reset_decimal_max_, decimal_round_); set @4 = __attribute_UpdateNumericValues(attribute_id_); set @5 = __object_UpdateSortCache(null, attribute_id_, null); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_UpdateDatetimeValues -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_UpdateDatetimeValues`; DELIMITER $$$ create function __attribute_UpdateDatetimeValues(attribute_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin update attributeValueDatetimeT set value = __attribute_ClampValueDatetime(attribute_id_, valueRaw) where attributeId = attribute_id_; return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_UpdateDatetime -- ----------------------------------------------------- DROP function IF EXISTS `attribute_UpdateDatetime`; DELIMITER $$$ create function attribute_UpdateDatetime( attribute_id_ int unsigned, sorter_ int, can_search_ enum('n', 'y'), reset_can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), reset_display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), reset_display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y'), datetime_storage_id_ varchar(10) binary ) returns int unsigned not deterministic modifies sql data begin set @1 = __attribute_ValidateIdDataType(attribute_id_, 'datetime'); set @2 = __attribute_Update( attribute_id_, sorter_, can_search_, reset_can_search_, display_in_object_, reset_display_in_object_, display_in_object_list_, reset_display_in_object_list_, factor_, enabled_, code_, required_, sortable_); set @3 = __attribute_SetDatetime(attribute_id_, datetime_storage_id_); set @4 = __attribute_UpdateDatetimeValues(attribute_id_); set @5 = __object_UpdateSortCache(null, attribute_id_, null); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_UpdateText -- ----------------------------------------------------- DROP function IF EXISTS `attribute_UpdateText`; DELIMITER $$$ create function attribute_UpdateText( attribute_id_ int unsigned, sorter_ int, can_search_ enum('n', 'y'), reset_can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), reset_display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), reset_display_in_object_list_ enum('n', 'y'), factor_ double, enabled_ enum('n', 'y'), code_ varchar(30) binary, required_ enum('n', 'y'), sortable_ enum('n', 'y'), text_is_long_ enum('n', 'y') ) returns int unsigned not deterministic modifies sql data begin set @1 = __attribute_ValidateIdDataType(attribute_id_, 'text'); set @2 = __attribute_Update( attribute_id_, sorter_, can_search_, reset_can_search_, display_in_object_, reset_display_in_object_, display_in_object_list_, reset_display_in_object_list_, factor_, enabled_, code_, required_, sortable_); set @3 = __attribute_SetText(attribute_id_, text_is_long_); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_UpdateLocal -- ----------------------------------------------------- DROP function IF EXISTS `attribute_UpdateLocal`; DELIMITER $$$ create function attribute_UpdateLocal( attribute_id_ int unsigned, lang_id_ char(3), name_ varchar(255), uofm_pre_ varchar(255), uofm_post_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin set @1 = __attribute_ValidateId(attribute_id_); set @2 = __tag_UpdateLocal(attribute_id_, lang_id_, name_, uofm_pre_, uofm_post_); set @3 = __attribute_UpdateCache(attribute_id_); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_ValidateValueByType -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_ValidateValueByType`; DELIMITER $$$ create function __attribute_ValidateValueByType( data_type_ varchar(10) binary, value_numeric_ decimal(22, 6), value_datetime_ datetime, value_text_ text ) returns int unsigned deterministic begin if (data_type_ = 'numeric' and value_numeric_ is null) then call raiseError2('attribute', 'validateValue', attribute_id_, 'numeric', 'no numeric value'); elseif (data_type_ = 'datetime' and value_datetime_ is null) then call raiseError2('attribute', 'validateValue', attribute_id_, 'datetime', 'no datetime value'); elseif (data_type_ = 'text' and value_text_ is null) then call raiseError2('attribute', 'validateValue', attribute_id_, 'text', 'no text value'); end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_SetValueNumeric -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_SetValueNumeric`; DELIMITER $$$ create function __attribute_SetValueNumeric( attribute_id_ int unsigned, object_id_ int unsigned, value_numeric_ decimal(22, 6) ) returns int unsigned not deterministic modifies sql data begin if value_numeric_ is null then delete from attributeValueNumericT where attributeId = attribute_id_ and objectId = object_id_; else insert attributeValueNumericT(attributeId, objectId, value, valueRaw) values(attribute_id_, object_id_, __attribute_ClampValueNumeric(attribute_id_, value_numeric_), value_numeric_) on duplicate key update attributeValueNumericT.value = __attribute_ClampValueNumeric(attribute_id_, value_numeric_), attributeValueNumericT.valueRaw = value_numeric_; end if; return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_SetValueDatetime -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_SetValueDatetime`; DELIMITER $$$ create function __attribute_SetValueDatetime( attribute_id_ int unsigned, object_id_ int unsigned, value_datetime_ datetime ) returns int unsigned not deterministic modifies sql data begin if value_datetime_ is null then delete from attributeValueDatetimeT where attributeId = attribute_id_ and objectId = object_id_; else insert attributeValueDatetimeT(attributeId, objectId, value, valueRaw) values(attribute_id_, object_id_, __attribute_ClampValueDatetime(attribute_id_, value_datetime_), value_datetime_) on duplicate key update attributeValueDatetimeT.value = __attribute_ClampValueDatetime(attribute_id_, value_datetime_), attributeValueDatetimeT.valueRaw = value_datetime_; end if; return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_SetValueText -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_SetValueText`; DELIMITER $$$ create function __attribute_SetValueText( attribute_id_ int unsigned, object_id_ int unsigned, lang_id_ char(3), value_text_ text ) returns int unsigned not deterministic modifies sql data begin if value_text_ is null then delete from attributeValueTextT where attributeId = attribute_id_ and objectId = object_id_; else insert attributeValueTextT(attributeId, objectId, languageId, value) select attribute_id_, object_id_, l.id, value_text_ from languageT l where l.id = coalesce(lang_id_, l.id) on duplicate key update attributeValueTextT.value = value_text_; end if; return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_SetLink -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_SetLink`; DELIMITER $$$ create function __attribute_SetLink( attribute_id_ int unsigned, object_id_ int unsigned, do_link_setup_ int unsigned ) returns int unsigned not deterministic modifies sql data begin if do_link_setup_ then set @1 = nodeLink_UpdateStart(); set @2 = nodeLink_Relink(null, attribute_id_, object_id_); set @3 = __nodeLink_UpdateWorkSet(attribute_id_, -1, 0) and __nodeLink_UpdateWorkSet(object_id_, 1, 0); set @4 = nodeLink_UpdateEnd(); else set @1 = nodeLink_Unlink(null, attribute_id_, object_id_); end if; return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_SetValueNumeric -- ----------------------------------------------------- DROP function IF EXISTS `attribute_SetValueNumeric`; DELIMITER $$$ create function attribute_SetValueNumeric( attribute_id_ int unsigned, object_id_ int unsigned, value_numeric_ decimal(22, 6) ) returns int unsigned not deterministic modifies sql data begin set @1 = __attribute_ValidateIdDataType(attribute_id_, 'numeric') and __object_ValidateId(object_id_); set @3 = __attribute_SetValueNumeric(attribute_id_, object_id_, value_numeric_); set @2 = __attribute_SetLink(attribute_id_, object_id_, value_numeric_ is not null); set @4 = __object_UpdateSortCache(object_id_, attribute_id_, value_numeric_); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_SetValueDatetime -- ----------------------------------------------------- DROP function IF EXISTS `attribute_SetValueDatetime`; DELIMITER $$$ create function attribute_SetValueDatetime( attribute_id_ int unsigned, object_id_ int unsigned, value_datetime_ datetime ) returns int unsigned not deterministic modifies sql data begin set @1 = __attribute_ValidateIdDataType(attribute_id_, 'datetime') and __object_ValidateId(object_id_); set @3 = __attribute_SetValueDatetime(attribute_id_, object_id_, value_datetime_); set @2 = __attribute_SetLink(attribute_id_, object_id_, value_datetime_ is not null); set @4 = __object_UpdateSortCache(object_id_, attribute_id_, datetime_ToDouble(value_datetime_)); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_SetValueText -- ----------------------------------------------------- DROP function IF EXISTS `attribute_SetValueText`; DELIMITER $$$ create function attribute_SetValueText( attribute_id_ int unsigned, object_id_ int unsigned, lang_id_ char(3), value_text_ text ) returns int unsigned not deterministic modifies sql data begin declare val text default if(value_text_ = '', null, value_text_); set @1 = __attribute_ValidateIdDataType(attribute_id_, 'text') and __object_ValidateId(object_id_); set @3 = __attribute_SetValueText(attribute_id_, object_id_, lang_id_, val); set @2 = __attribute_SetLink(attribute_id_, object_id_, val is not null); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_SetValue -- ----------------------------------------------------- DROP function IF EXISTS `attribute_SetValue`; DELIMITER $$$ create function attribute_SetValue( attribute_id_ int unsigned, object_id_ int unsigned, lang_id_ char(3), value_ text ) returns int unsigned not deterministic modifies sql data begin declare data_type varchar(10) default (select dataTypeId from attributeT where id = attribute_id_); declare val text default if(value_ = '', null, value_); set @1 = __attribute_ValidateId(attribute_id_) and __object_ValidateId(object_id_); case data_type when 'numeric' then set @3 = __attribute_SetValueNumeric(attribute_id_, object_id_, cast(val as decimal(22, 6))); set @4 = __object_UpdateSortCache(object_id_, attribute_id_, cast(val as decimal(22, 6))); when 'datetime' then set @3 = __attribute_SetValueDatetime(attribute_id_, object_id_, cast(val as datetime)); set @4 = __object_UpdateSortCache(object_id_, attribute_id_, datetime_ToDouble(cast(val as datetime))); else set @3 = __attribute_SetValueText(attribute_id_, object_id_, lang_id_, val); end case; set @2 = __attribute_SetLink(attribute_id_, object_id_, val is not null); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_ResetLinks2 -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_ResetLinks2`; DELIMITER $$$ create function nodeLink_ResetLinks2( link_code_ varchar(30) binary, root_type_code_ varchar(30) binary, dst_id_ int unsigned, recreate_root_links_ int ) returns int unsigned comment 'calls nodeLink_ResetLinks and returns dst_id' not deterministic modifies sql data begin set @1 = nodeLink_ResetLinks(link_code_, root_type_code_, dst_id_, recreate_root_links_); return dst_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_DuplicateInternal -- ----------------------------------------------------- DROP function IF EXISTS `__tag_DuplicateInternal`; DELIMITER $$$ create function __tag_DuplicateInternal(tag_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare new_id int unsigned; set new_id = node_LinkDefaults(__node_Duplicate(tag_id_)); insert tagT( id, sorter, canSearch, canSearchRaw, displayInObject, displayInObjectRaw, displayInObjectList, displayInObjectListRaw, factor, ratingPoints, enabled) select new_id, t.sorter, t.canSearch, t.canSearchRaw, t.displayInObject, t.displayInObjectRaw, t.displayInObjectList, t.displayInObjectListRaw, t.factor, t.ratingPoints, t.enabled from tagT t where t.id = tag_id_; insert tagTL(id, languageId, name, uofmPre, uofmPost) select new_id, tl.languageId, tl.name, tl.uofmPre, tl.uofmPost from tagTL tl where tl.id = tag_id_; insert tagCacheT(id, tagNames, tagNamesSearch, tagNamesFullSearch) select new_id, tc.tagNames, tc.tagNamesSearch, tc.tagNamesFullSearch from tagCacheT tc where tc.id = tag_id_; return new_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_Duplicate -- ----------------------------------------------------- DROP function IF EXISTS `__tag_Duplicate`; DELIMITER $$$ create function __tag_Duplicate(tag_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __tag_ValidateId(tag_id_); return __tag_DuplicateInternal(tag_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_Duplicate -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_Duplicate`; DELIMITER $$$ create function __attribute_Duplicate(attribute_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare new_id int unsigned; set @1 = __attribute_ValidateId(attribute_id_); set new_id = __tag_DuplicateInternal(attribute_id_); insert attributeT(id, dataTypeId, code, required, sortable) select new_id, a.dataTypeId, null, a.required, a.sortable from attributeT a where a.id = attribute_id_; insert attributeCacheT(id, attributeNames, attributeNamesSearch) select new_id, ac.attributeNames, ac.attributeNamesSearch from attributeCacheT ac where ac.id = attribute_id_; insert attributeNumericT(id, decimalMin, decimalMax, decimalRound) select new_id, an.decimalMin, an.decimalMax, an.decimalRound from attributeNumericT an where an.id = attribute_id_; insert attributeDatetimeT(id, datetimeStorageId) select new_id, ad.datetimeStorageId from attributeDatetimeT ad where ad.id = attribute_id_; insert attributeTextT(id, textIsLong) select new_id, ax.textIsLong from attributeTextT ax where ax.id = attribute_id_; return new_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function template_Create -- ----------------------------------------------------- DROP function IF EXISTS `template_Create`; DELIMITER $$$ create function template_Create( type_id_ int unsigned, type_code_ varchar(30) binary, node_id_ int unsigned ) returns int unsigned comment 'template takes ownership on node_id_' not deterministic modifies sql data begin declare type_id int unsigned default coalesce(type_id_, nodeType_GetByCode(type_code_)); -- FORWARD: nodeLink_ResetLinks2 is defined in _95_extraUtils insert templateT(srcNodeTypeId, dstNodeId, dstNodeTypeId) select type_id, nodeLink_ResetLinks2(null, null, node_id_, false), n.nodeTypeId from nodeT n where n.id = node_id_; return type_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function template_Delete -- ----------------------------------------------------- DROP function IF EXISTS `template_Delete`; DELIMITER $$$ create function template_Delete( type_id_ int unsigned, type_code_ varchar(30) binary, node_id_ int unsigned ) returns int unsigned not deterministic modifies sql data begin declare type_id int unsigned default coalesce(type_id_, nodeType_GetByCode(type_code_)); set @1 = nodeLink_UpdateStart(); insert zzzDevNullTemplateT(n) select __node_Delete(t.dstNodeId) from templateT t where t.srcNodeTypeId = type_id and t.dstNodeId = coalesce(node_id_, t.dstNodeId); set @2 = nodeLink_UpdateEnd(); -- deleted nodes will delete templateT record because of FK constraints /*delete from templateT where srcNodeTypeId = type_id and dstNodeId = coalesce(node_id_, dstNodeId);*/ return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __template_DuplicateNode -- ----------------------------------------------------- DROP function IF EXISTS `__template_DuplicateNode`; DELIMITER $$$ create function __template_DuplicateNode(node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare res int unsigned; declare internal_type_id varchar(10) binary; select nt.internalTypeId into internal_type_id from nodeT n join nodeTypeT nt on n.nodeTypeId = nt.id where n.id = node_id_; case internal_type_id when 'tag' then set res = __tag_Duplicate(node_id_); when 'attribute' then set res = __attribute_Duplicate(node_id_); else call raiseError1('template', 'duplicate', internal_type_id, 'cannot duplicate node of this type'); end case; return res; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function template_CreateSubs -- ----------------------------------------------------- DROP function IF EXISTS `template_CreateSubs`; DELIMITER $$$ create function template_CreateSubs(node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare type_id int unsigned default (select n.nodeTypeId from nodeT n where n.id = node_id_); set @1 = nodeLink_UpdateStart(); insert zzzDevNullTemplateT(n) select nodeLink_Relink(null, node_id_, __template_DuplicateNode(t.dstNodeId)) from templateT t where t.srcNodeTypeId = type_id; set @2 = nodeLink_UpdateEnd(); return node_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function sorter_Set -- ----------------------------------------------------- DROP function IF EXISTS `sorter_Set`; DELIMITER $$$ create function sorter_Set(sorter_value_ int, sorter_increment_ int) returns int not deterministic begin set @__sorterValue = coalesce(sorter_value_, @__sorterValue); set @__sorterIncrement = coalesce(sorter_increment_, @__sorterIncrement); return @__sorterValue; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function sorter_Get -- ----------------------------------------------------- DROP function IF EXISTS `sorter_Get`; DELIMITER $$$ create function sorter_Get() returns int not deterministic begin declare result int default @__sorterValue; set @__sorterValue = @__sorterValue + @__sorterIncrement; return result; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function sorter_GetIncrement -- ----------------------------------------------------- DROP function IF EXISTS `sorter_GetIncrement`; DELIMITER $$$ create function sorter_GetIncrement() returns int deterministic return @__sorterIncrement$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeType_DefaultSorter -- ----------------------------------------------------- DROP function IF EXISTS `__nodeType_DefaultSorter`; DELIMITER $$$ create function __nodeType_DefaultSorter() returns int not deterministic begin -- CONST: sorter step return coalesce(sorter_Get(), sorter_Set(coalesce((select max(sorter) from nodeTypeT), 0) + 10, 10)); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_DefaultSorter -- ----------------------------------------------------- DROP function IF EXISTS `__tag_DefaultSorter`; DELIMITER $$$ create function __tag_DefaultSorter() returns int not deterministic begin -- CONST: sorter step return coalesce(sorter_Get(), sorter_Set(coalesce((select max(sorter) from tagT), 0) + 10, 10)); end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __initScript_010Root -- ----------------------------------------------------- DROP procedure IF EXISTS `__initScript_010Root`; DELIMITER $$$ create procedure __initScript_010Root() modifies sql data begin set @1 = tag_CreateDef(null, 'rootgeo', null); -- all default values set @1 = tag_CreateDef(null, 'rootamenity', null); set @1 = tag_CreateDef(null, 'rootsubmission', null); set @1 = tag_CreateDef(null, 'rootuser', null); update nodeT n set n.isRoot = 'y' where n.forceSingleNode = 'y'; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __initScript_015Templates -- ----------------------------------------------------- DROP procedure IF EXISTS `__initScript_015Templates`; DELIMITER $$$ create procedure __initScript_015Templates() modifies sql data begin -- house numbers set @a1 = attribute_CreateText( null, 'geoattribute', 'Номер будинку', null, -- sorter null, -- can_search null, -- display_in_object null, -- display_in_object_list null, -- factor 'y', -- enabled null, -- code 'y', -- required 'n', -- sortable '', -- uofm_pre '', -- uofm_post 'n'); -- text_is_long set @1 = attribute_UpdateLocal(attribute_UpdateLocal(@a1, 'rus', 'Номер дома', null, null), 'eng', 'House Number', null, null); set @2 = template_Create(null, 'street', @a1); end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __initScript_020Users -- ----------------------------------------------------- DROP procedure IF EXISTS `__initScript_020Users`; DELIMITER $$$ create procedure __initScript_020Users() modifies sql data begin set @1 = user_Create( 'Lazar Manager', '+380977907993', 'user@dev.adaptainc.com', 'lazar', '$2y$13$lNcXZwxiGH4nAXSpe6V63./22ZApYkLY48cFXlQnCTQzJLuPKiO82', 'user', 'y', '1986-08-28', 'ukr', null); set @1 = user_Create( 'Lazar Manager', null, 'manager@dev.adaptainc.com', 'lazar_manager', '$2y$13$lNcXZwxiGH4nAXSpe6V63./22ZApYkLY48cFXlQnCTQzJLuPKiO82', 'manager', 'y', null, 'ukr', null); set @1 = user_Create( 'Lazar Admin', null, 'admin@dev.adaptainc.com', 'lazar_admin', '$2y$13$lNcXZwxiGH4nAXSpe6V63./22ZApYkLY48cFXlQnCTQzJLuPKiO82', 'admin', 'y', null, 'ukr', null); set @u1 = user_Create( 'Борис Заїка', null, null, 'vkontakte_Borey', '$2y$13$gfU5gFaAQw0XOZ406XZ1TORd6UpOMHWh/sFflHQDrux1.le/TESDu', 'admin', 'y', null, null, null); set @1 = user_SetOauth(@u1, 'vkontakte', 'http://vk.com/id14198259'); end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __initScript_030Cities -- ----------------------------------------------------- DROP procedure IF EXISTS `__initScript_030Cities`; DELIMITER $$$ create procedure __initScript_030Cities() modifies sql data begin -- Ternopil set @city_id = tag_CreateDef(null, 'locality', 'Тернопіль'); set @city_id = tag_UpdateLocal(tag_UpdateLocal(@city_id, 'rus', 'Тернополь'), 'eng', 'Ternopil'); update externalDataSourceDatasetT set nodeId = @city_id where externalDataSourceId = 'osm' and code = 'ternopil'; -- Ternopil neighborhoods set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Центр')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Центр'), 'eng', 'Central'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Оболоня (базар)')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Оболоня (базар)'), 'eng', 'Obolonya (marketplace)'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Березовиця')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Березовица'), 'eng', 'Berezovytsya'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Дружба')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Дружба'), 'eng', 'Druzhba'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Кутківці')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Кутковцы'), 'eng', 'Kutkivtsi'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Пронятин')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Пронятин'), 'eng', 'Pronyatyn'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Новий Світ')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Новый Свет'), 'eng', 'Novy Svit'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Промисловий')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Промышленный'), 'eng', 'Industrial'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Північний')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Северный'), 'eng', 'Northern (Pivnichny)'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Аляска')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Аляска'), 'eng', 'Alaska'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Сонячний (БАМ)')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Солнечный (БАМ)'), 'eng', 'Sonyachny (BAM)'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Канада')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Канада'), 'eng', 'Canada'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Східний масив')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Восточный массив'), 'eng', 'Eastern neighborhood'); set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Старий Парк')); set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Старый Парк'), 'eng', 'Old Park (Stary Park)'); -- Kyiv set @city_id = tag_CreateDef(null, 'locality', 'Київ'); set @city_id = tag_UpdateLocal(tag_UpdateLocal(@city_id, 'rus', 'Киев'), 'eng', 'Kyiv'); update externalDataSourceDatasetT set nodeId = @city_id where externalDataSourceId = 'osm' and code = 'kyiv'; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __initScript_040Amenities -- ----------------------------------------------------- DROP procedure IF EXISTS `__initScript_040Amenities`; DELIMITER $$$ create procedure __initScript_040Amenities() modifies sql data begin -- estate types set @estate_apt = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Квартира'), 'rus', 'Квартира'), 'eng', 'Apartment'); set @estate_cott = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Дім'), 'rus', 'Дом'), 'eng', 'Cottage'); set @estate_ofc = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Офіс'), 'rus', 'Офис'), 'eng', 'Office'); set @estate_com = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Комерційна нерухомість'), 'rus', 'Коммерческая недвижимость'), 'eng', 'Commercial Estate'); set @estate_gar = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Гараж'), 'rus', 'Гараж'), 'eng', 'Garage'); -- submission types set @subm_buy = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'submissiontype', 'Купити'), 'rus', 'Купить'), 'eng', 'Buy'); set @subm_rent1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'submissiontype', 'Оренда подобова'), 'rus', 'Аренда посуточная'), 'eng', 'Short-term Rent'); set @subm_rentm = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'submissiontype', 'Оренда довгострокова'), 'rus', 'Аренда долгосрочная'), 'eng', 'Rent (Long-term)'); -- wall materials set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Цегла'), 'rus', 'Кирпич'), 'eng', 'Brick'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Силікатна цегла'), 'rus', 'Силикатный кирпич'), 'eng', 'Silicate Brick'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Бетонна панель'), 'rus', 'Бетонная панель'), 'eng', 'Concrete Panel'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Газобетонний блок'), 'rus', 'Газобетонный блок'), 'eng', 'Aerocrete Block'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Сендвіч панель'), 'rus', 'Сендвич панель'), 'eng', 'Sandwich Panel'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); -- roofing materials set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'roofmaterial', 'Металева'), 'rus', 'Металлическая'), 'eng', 'Metal'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'roofmaterial', 'Металочерепиця'), 'rus', 'Металочерепица'), 'eng', 'Metal Tiles'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'roofmaterial', 'Керамічна черепиця'), 'rus', 'Керамическая черепица'), 'eng', 'Ceramic Tiles'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'roofmaterial', 'Руберойд'), 'rus', 'Рубероид'), 'eng', 'Tar Roofing'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1); -- supplies set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'supply', 'Електрика'), 'rus', 'Электричество'), 'eng', 'Electricity'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'supply', 'Газ'), 'rus', 'Газ'), 'eng', 'Natural Gas'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'supply', 'Водогін'), 'rus', 'Водопровод'), 'eng', 'Water Supply'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'supply', 'Каналізація'), 'rus', 'Канализация'), 'eng', 'Sewer'); set @2 = nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); -- amenities set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Меблі'), 'rus', 'Мебель'), 'eng', 'Furniture'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Холодильник'), 'rus', 'Холодильник'), 'eng', 'Refrigerator'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Мікрохвильова піч'), 'rus', 'Микроволновая печь'), 'eng', 'Microwave Oven'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Індивідуальне опалення'), 'rus', 'Индивидуальное отопление'), 'eng', 'Home heating'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Інтернет/Wi-Fi'), 'rus', 'Интернет/Wi-Fi'), 'eng', 'Internet/Wi-Fi'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Телефон (міський)'), 'rus', 'Телефон (городской)'), 'eng', 'Telephone (wired)'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Сантехніка'), 'rus', 'Сантехника'), 'eng', 'Plumbing'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Євроремонт'), 'rus', 'Евроремонт'), 'eng', 'Remodeled/Renovated'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_cott, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Оглядова яма'), 'rus', 'Смотровая яма'), 'eng', 'Inspection Pit'); set @2 = nodeLink_Relink2(null, @estate_gar, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); -- set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'extamenity', 'Конс''єрж'), 'rus', 'Консьерж'), 'eng', 'Concierge'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'extamenity', 'Ліфт'), 'rus', 'Лифт'), 'eng', 'Elevator'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'extamenity', 'Парковка'), 'rus', 'Парковка'), 'eng', 'Parking Lot'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @estate_ofc, @u1) and nodeLink_Relink2(null, @estate_com, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rent1, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'extamenity', 'Дитячий майданчик'), 'rus', 'Детская площадка'), 'eng', 'Playground'); set @2 = nodeLink_Relink2(null, @estate_apt, @u1) and nodeLink_Relink2(null, @subm_buy, @u1) and nodeLink_Relink2(null, @subm_rentm, @u1); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __node_Duplicate -- ----------------------------------------------------- DROP function IF EXISTS `__node_Duplicate`; DELIMITER $$$ create function __node_Duplicate(node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare new_id, type_id int unsigned; declare display_node enum('n', 'y'); declare name varchar(50); select n.nodeTypeId, n.name, n.displayNode into type_id, name, display_node from nodeT n where n.id = node_id_; set new_id = __node_Create(type_id, null, name); update nodeT n set n.displayNode = display_node where n.id = new_id; return new_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __image_DefaultSorter -- ----------------------------------------------------- DROP function IF EXISTS `__image_DefaultSorter`; DELIMITER $$$ -- object and user specific image code is in _08_object create function __image_DefaultSorter() returns int not deterministic begin -- CONST: sorter step return coalesce(sorter_Get(), sorter_Set(coalesce((select max(sorter) from imageT), 0) + 10, 10)); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_Create -- ----------------------------------------------------- DROP function IF EXISTS `image_Create`; DELIMITER $$$ create function image_Create( node_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int ) returns int unsigned not deterministic modifies sql data begin set @1 = node_id_ is not null and __node_CanUpdate(node_id_, 'imagecreate'); return __image_Create(node_id_, name_, filename_original_, filename_fs_, display_, sorter_, null, null, null, null); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __image_Delete -- ----------------------------------------------------- DROP function IF EXISTS `__image_Delete`; DELIMITER $$$ create function __image_Delete(image_id_ int unsigned, node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin delete from imageT where id = image_id_; set @1 = (row_count() > 0) and node_id_ is not null and __node_Update(node_id_, null); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_Delete -- ----------------------------------------------------- DROP function IF EXISTS `image_Delete`; DELIMITER $$$ create function image_Delete(image_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned default (select nodeId from imageT where id = image_id_); set @1 = node_id is not null and __node_CanUpdate(node_id, 'imagedelete'); return __image_Delete(image_id_, node_id); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __image_Update -- ----------------------------------------------------- DROP function IF EXISTS `__image_Update`; DELIMITER $$$ create function __image_Update( image_id_ int unsigned, node_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int, image_type_id_ char(10) binary, video_type_ varchar(50), url_ varchar(255), extra_id_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin set @1 = node_id_ is not null and __node_Update(node_id_, null); update imageT set name = coalesce(name_, name), filenameOriginal = coalesce(filename_original_, filenameOriginal), filenameFs = coalesce(filename_fs_, filenameFs), display = coalesce(display_, display), sorter = coalesce(sorter_, sorter), imageTypeId = coalesce(image_type_id_, imageTypeId), videoType = coalesce(video_type_, videoType), url = coalesce(url_, url), extraId = coalesce(extra_id_, extraId), changed = current_timestamp(), changedUserId = user_CurrentId(), changedUserName = user_CurrentName(), changedIp = user_CurrentIp() where id = image_id_; return image_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_Update -- ----------------------------------------------------- DROP function IF EXISTS `image_Update`; DELIMITER $$$ create function image_Update( image_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int ) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned default (select nodeId from imageT where id = image_id_); set @1 = node_id is not null and __node_CanUpdate(node_id, 'imageupdate'); return __image_Update(image_id_, node_id, name_, filename_original_, filename_fs_, display_, sorter_, null, null, null, null); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_CreateByUserForObject -- ----------------------------------------------------- DROP function IF EXISTS `image_CreateByUserForObject`; DELIMITER $$$ create function image_CreateByUserForObject( node_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int ) returns int unsigned not deterministic modifies sql data begin set @1 = __object_AccessByUser(node_id_, 'update', null); return __image_Create(node_id_, name_, filename_original_, filename_fs_, display_, sorter_, null, null, null, null); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_DeleteByUserForObject -- ----------------------------------------------------- DROP function IF EXISTS `image_DeleteByUserForObject`; DELIMITER $$$ create function image_DeleteByUserForObject(image_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned default (select nodeId from imageT where id = image_id_); set @1 = __object_AccessByUser(node_id, 'update', null); return __image_Delete(image_id_, node_id); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_UpdateByUserForObject -- ----------------------------------------------------- DROP function IF EXISTS `image_UpdateByUserForObject`; DELIMITER $$$ create function image_UpdateByUserForObject( image_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int ) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned default (select nodeId from imageT where id = image_id_); set @1 = __object_AccessByUser(node_id, 'update', null); return __image_Update(image_id_, node_id, name_, filename_original_, filename_fs_, display_, sorter_, null, null, null, null); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_CalcDefaults -- ----------------------------------------------------- DROP function IF EXISTS `__tag_CalcDefaults`; DELIMITER $$$ create function __tag_CalcDefaults( type_field_ enum('n', 'y'), -- not nullable type_display_node_ enum('n', 'y'), -- not nullable field_raw_ enum('n', 'y'), -- nullable enabled_ enum('n', 'y') -- not nullable (hopefully) ) returns enum('n', 'y') deterministic begin return if(enabled_ = 'y' and type_display_node_ = 'y', coalesce(field_raw_, type_field_, 'n'), 'n'); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_UpdateDefaults -- ----------------------------------------------------- DROP function IF EXISTS `__tag_UpdateDefaults`; DELIMITER $$$ create function __tag_UpdateDefaults(tag_id_ int unsigned, type_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin if tag_id_ is null and type_id_ is null then return 1; end if; update tagT t join nodeT n on t.id = n.id join nodeTypeT nt on n.nodeTypeId = nt.id set t.canSearch = __tag_CalcDefaults(nt.canSearch, n.displayNode, t.canSearchRaw, t.enabled), t.displayInObject = __tag_CalcDefaults(nt.displayInObject, n.displayNode, t.displayInObjectRaw, t.enabled), t.displayInObjectList = __tag_CalcDefaults(nt.displayInObjectList, n.displayNode, t.displayInObjectListRaw, t.enabled) where t.id = coalesce(tag_id_, t.id) and nt.id = coalesce(type_id_, nt.id); return coalesce(tag_id_, 1); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_ClampFactor -- ----------------------------------------------------- DROP function IF EXISTS `__tag_ClampFactor`; DELIMITER $$$ create function __tag_ClampFactor(factor_ double) returns double deterministic -- CONST: tag factor min/max limits return greatest(0.1, factor_)$$$ DELIMITER ; -- ----------------------------------------------------- -- function __coord_Update -- ----------------------------------------------------- DROP function IF EXISTS `__coord_Update`; DELIMITER $$$ -- coordT code create function __coord_Update( node_id_ int unsigned, latitude_ decimal(12, 7), longitude_ decimal(12, 7) ) returns int unsigned not deterministic modifies sql data begin insert coordT(nodeId, latitude, longitude) select node_id_, latitude_, longitude_ from dual where latitude_ is not null and longitude_ is not null on duplicate key update coordT.latitude = coalesce(latitude_, coordT.latitude), coordT.longitude = coalesce(longitude_, coordT.longitude); return node_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function coord_Update -- ----------------------------------------------------- DROP function IF EXISTS `coord_Update`; DELIMITER $$$ create function coord_Update( node_id_ int unsigned, latitude_ decimal(12, 7), longitude_ decimal(12, 7) ) returns int unsigned not deterministic modifies sql data begin set @1 = __node_Update(node_id_, null); return __coord_Update(node_id_, latitude_, longitude_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __image_Create -- ----------------------------------------------------- DROP function IF EXISTS `__image_Create`; DELIMITER $$$ create function __image_Create( node_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int, image_type_id_ char(10) binary, video_type_ varchar(50), url_ varchar(255), extra_id_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare image_id int unsigned default(select i.id from imageT i where i.nodeId = node_id_ and i.forceSinglePhoto = 'y'); -- if the node_id has the image and the node_id can have only 1 image - detach the current image from the node set @1 = image_id is not null and __image_UpdateNodeId(image_id, node_id_, null); -- FORWARD: user_CurrentId, user_CurrentName and user_CurrentIp are defined in _060_user insert imageT( nodeId, forceSinglePhoto, name, filenameOriginal, filenameFs, display, sorter, imageTypeId, videoType, url, extraId, addedUserId, addedUserName, addedIp, changedUserId, changedUserName, changedIp) values ( node_id_, (select n.forceSinglePhoto from nodeT n where n.id = node_id_), name_, filename_original_, filename_fs_, display_, coalesce(sorter_, __image_DefaultSorter()), coalesce(image_type_id_, (select it.id from imageTypeT it where it.isDefault = 'y')), coalesce(video_type_, ''), coalesce(url_, ''), coalesce(extra_id_, ''), user_CurrentId(), user_CurrentName(), user_CurrentIp(), user_CurrentId(), user_CurrentName(), user_CurrentIp()); set image_id = last_insert_id(); set @2 = node_id_ is not null and __node_Update(node_id_, null); return image_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __image_UpdateNodeId -- ----------------------------------------------------- DROP function IF EXISTS `__image_UpdateNodeId`; DELIMITER $$$ create function __image_UpdateNodeId( image_id_ int unsigned, previous_node_id_ int unsigned, node_id_ int unsigned ) returns int unsigned not deterministic modifies sql data begin set @1 = previous_node_id_ is not null and __node_Update(previous_node_id_, null); set @2 = node_id_ is not null and __node_Update(node_id_, null); update imageT set nodeId = node_id_, forceSinglePhoto = (select n.forceSinglePhoto from nodeT n where n.id = node_id_), changed = current_timestamp(), changedUserId = user_CurrentId(), changedUserName = user_CurrentName(), changedIp = user_CurrentIp() where id = image_id_; return image_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_UpdateNodeId -- ----------------------------------------------------- DROP function IF EXISTS `image_UpdateNodeId`; DELIMITER $$$ create function image_UpdateNodeId( image_id_ int unsigned, node_id_ int unsigned ) returns int unsigned not deterministic modifies sql data begin declare previous_node_id int unsigned default(select i.nodeId from imageT i where i.id = image_id_); set @1 = previous_node_id is not null and __node_CanUpdate(previous_node_id, 'imageupdate'); set @2 = node_id_ is not null and __node_CanUpdate(node_id_, 'imageupdate'); return __image_UpdateNodeId(image_id_, previous_node_id, node_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_ClampRatingPoints -- ----------------------------------------------------- DROP function IF EXISTS `__tag_ClampRatingPoints`; DELIMITER $$$ create function __tag_ClampRatingPoints(rating_points_ int unsigned) returns int unsigned deterministic -- CONST: rating points min limit return greatest(0, rating_points_)$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_ClampRating -- ----------------------------------------------------- DROP function IF EXISTS `__object_ClampRating`; DELIMITER $$$ create function __object_ClampRating(rating_ double) returns double deterministic -- CONST: object rating min/max limits return greatest(0.0, least(1.0, rating_))$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateRating -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateRating`; DELIMITER $$$ create function __object_UpdateRating( object_id_ int unsigned, selected_ int unsigned, total_ int unsigned ) returns int unsigned not deterministic modifies sql data begin update objectT o set o.rating = __object_UpdateSortCacheRating2( o.id, coalesce(__object_ClampRating(selected_ / greatest(total_, 1)), 0)) where o.id = object_id_; return object_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateRatings -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateRatings`; DELIMITER $$$ create function __object_UpdateRatings() returns int unsigned not deterministic modifies sql data begin drop temporary table if exists objectUpdateRatingsData; create temporary table objectUpdateRatingsData( objectId int unsigned not null primary key, selectedPoints int not null, totalPoints int not null ) engine=MEMORY; insert objectUpdateRatingsData(objectId, selectedPoints, totalPoints) select o.id, sum(if(nrl.linked = 1, srctag.ratingPoints, 0)), sum(srctag.ratingPoints) from objectT o join zzzNodeWorksetV workset on o.id = workset.nodeId join _nodeRecommendLink4V nrl on o.id = nrl.dstNodeId join tagT srctag on nrl.srcNodeId = srctag.id join nodeT srcnode on srctag.id = srcnode.id join nodeTypeT nodetype on srcnode.nodeTypeId = nodetype.id where workset.isMain = 1 and nodetype.canHaveRatingPoints = 'y' group by o.id; insert zzzDevNullObjectT(n) select __object_UpdateRating(objectId, selectedPoints, totalPoints) from objectUpdateRatingsData; drop temporary table objectUpdateRatingsData; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateAllRatings -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateAllRatings`; DELIMITER $$$ create function __object_UpdateAllRatings() returns int unsigned not deterministic modifies sql data comment 'updates all object ratings; to be called manually' begin drop temporary table if exists objectUpdateAllRatingsData; create temporary table objectUpdateAllRatingsData( objectId int unsigned not null primary key, selectedPoints int not null, totalPoints int not null ) engine=MEMORY; insert objectUpdateAllRatingsData(objectId, selectedPoints, totalPoints) select o.id, sum(if(nrl.linked = 1, srctag.ratingPoints, 0)), sum(srctag.ratingPoints) from objectT o join _nodeRecommendLink4V nrl on o.id = nrl.dstNodeId join tagT srctag on nrl.srcNodeId = srctag.id join nodeT srcnode on srctag.id = srcnode.id join nodeTypeT nodetype on srcnode.nodeTypeId = nodetype.id where nodetype.canHaveRatingPoints = 'y' group by o.id; insert zzzDevNullObjectT(n) select __object_UpdateRating(objectId, selectedPoints, totalPoints) from objectUpdateAllRatingsData; drop temporary table objectUpdateAllRatingsData; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateAddresses -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateAddresses`; DELIMITER $$$ create function __object_UpdateAddresses() returns int unsigned not deterministic modifies sql data comment 'updates both address and alias' begin drop temporary table if exists objectUpdateAddressesData; create temporary table objectUpdateAddressesData( objectId int unsigned not null primary key, address text null, alias text null ) engine=MyISAM; -- CONST: address field separator insert objectUpdateAddressesData(objectId, address) select o.id, group_concat( string_ConcatSmart( ' ', nad.srcUofmPre, if( nad.srcInternalTypeId = 'attribute', coalesce( nad.srcNumericValue, date_format(nad.srcDatetimeValue, nad.srcDatetimeOutputFormat), nad.srcTextValue, ''), nad.srcName), nad.srcUofmPost) order by nad.ancestrySorter, nad.srcTypeName, nad.srcName separator ', ') addr from objectT o join zzzNodeWorksetV nws on o.id = nws.nodeId left join nodeAncestryDataV nad on o.id = nad.dstNodeId and nad.languageIsDefault = 'y' where nws.isMain = 1 group by o.id; -- CONST: address field separator and language id insert objectUpdateAddressesData(objectId, alias) select o.id, concat_ws( '-', o.id, group_concat( string_ConcatSmart( ' ', nad.srcUofmPre, if( nad.srcInternalTypeId = 'attribute', coalesce( nad.srcNumericValue, date_format(nad.srcDatetimeValue, nad.srcDatetimeOutputFormat), nad.srcTextValue, ''), nad.srcName), nad.srcUofmPost) order by nad.ancestrySorter, nad.srcTypeName, nad.srcName separator '-')) alias_ from objectT o join zzzNodeWorksetV nws on o.id = nws.nodeId left join nodeAncestryDataV nad on o.id = nad.dstNodeId and nad.languageId = 'eng' where nws.isMain = 1 group by o.id on duplicate key update objectUpdateAddressesData.alias = values(alias); update objectT o join objectUpdateAddressesData ouad on o.id = ouad.objectId set o.address = coalesce(ouad.address, ''), o.alias = string_Alphanumeric(coalesce(ouad.alias, '')); drop temporary table objectUpdateAddressesData; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateAllAddresses -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateAllAddresses`; DELIMITER $$$ create function __object_UpdateAllAddresses() returns int unsigned not deterministic modifies sql data comment 'updates all object addresses and aliases; to be called manually' begin drop temporary table if exists objectUpdateAllAddressesData; create temporary table objectUpdateAllAddressesData( objectId int unsigned not null primary key, address text null, alias text null ) engine=MyISAM; -- CONST: address field separator insert objectUpdateAllAddressesData(objectId, address) select o.id, group_concat( string_ConcatSmart( ' ', nad.srcUofmPre, if( nad.srcInternalTypeId = 'attribute', coalesce( nad.srcNumericValue, date_format(nad.srcDatetimeValue, nad.srcDatetimeOutputFormat), nad.srcTextValue, ''), nad.srcName), nad.srcUofmPost) order by nad.ancestrySorter, nad.srcTypeName, nad.srcName separator ', ') addr from objectT o left join nodeAncestryDataV nad on o.id = nad.dstNodeId and nad.languageIsDefault = 'y' group by o.id; -- CONST: address field separator and language id insert objectUpdateAllAddressesData(objectId, alias) select o.id, concat_ws( '-', o.id, group_concat( string_ConcatSmart( ' ', nad.srcUofmPre, if( nad.srcInternalTypeId = 'attribute', coalesce( nad.srcNumericValue, date_format(nad.srcDatetimeValue, nad.srcDatetimeOutputFormat), nad.srcTextValue, ''), nad.srcName), nad.srcUofmPost) order by nad.ancestrySorter, nad.srcTypeName, nad.srcName separator '-')) alias_ from objectT o left join nodeAncestryDataV nad on o.id = nad.dstNodeId and nad.languageId = 'eng' group by o.id on duplicate key update objectUpdateAllAddressesData.alias = values(alias); update objectT o join objectUpdateAllAddressesData ouaad on o.id = ouaad.objectId set o.address = coalesce(ouaad.address, ''), o.alias = string_Alphanumeric(coalesce(ouaad.alias, '')); drop temporary table objectUpdateAllAddressesData; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __initScript_050HiddenAttributes -- ----------------------------------------------------- DROP procedure IF EXISTS `__initScript_050HiddenAttributes`; DELIMITER $$$ create procedure __initScript_050HiddenAttributes() modifies sql data begin -- by rating sort set @1 = attribute_CreateNumeric( null, 'hiddenattribute', 'Рейтинг', -100000001, -- sorter null, -- can_search null, -- display_in_object null, -- display_in_object_list 0, -- factor 'y', -- enabled '__byrating', -- code 'n', -- required 'y', -- sortable '', -- uofm_pre '', -- uofm_post 0, -- decimal_min 0, -- decimal_max 0); -- decimal_round set @2 = attribute_UpdateLocal(attribute_UpdateLocal(@1, 'rus', 'Рейтинг', null, null), 'eng', 'Rating', null, null); -- by changed sort set @1 = attribute_CreateNumeric( null, 'hiddenattribute', 'Дата оновлення', -100000000, -- sorter null, -- can_search null, -- display_in_object null, -- display_in_object_list 0, -- factor 'y', -- enabled '__bychanged', -- code 'n', -- required 'y', -- sortable '', -- uofm_pre '', -- uofm_post 0, -- decimal_min 0, -- decimal_max 0); -- decimal_round set @2 = attribute_UpdateLocal(attribute_UpdateLocal(@1, 'rus', 'Дата обновления', null, null), 'eng', 'Date', null, null); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function string_Alphanumeric -- ----------------------------------------------------- DROP function IF EXISTS `string_Alphanumeric`; DELIMITER $$$ create function string_Alphanumeric(s varchar(2048)) returns varchar(2048) deterministic return __string_QuoteOut(s, 'alias', '-')$$$ DELIMITER ; -- ----------------------------------------------------- -- function datetime_ToDouble -- ----------------------------------------------------- DROP function IF EXISTS `datetime_ToDouble`; DELIMITER $$$ create function datetime_ToDouble(t datetime) returns double deterministic return to_days(t) + (time_to_sec(t) + 0.0) / 86400.0$$$ DELIMITER ; -- ----------------------------------------------------- -- function __coord_Delete -- ----------------------------------------------------- DROP function IF EXISTS `__coord_Delete`; DELIMITER $$$ create function __coord_Delete( node_id_ int unsigned ) returns int unsigned not deterministic modifies sql data begin delete from coordT where nodeId = node_id_; return node_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function coord_Delete -- ----------------------------------------------------- DROP function IF EXISTS `coord_Delete`; DELIMITER $$$ create function coord_Delete( node_id_ int unsigned ) returns int unsigned not deterministic modifies sql data begin set @1 = __node_Update(node_id_, null); return __coord_Delete(node_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateSortCache -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateSortCache`; DELIMITER $$$ create function __object_UpdateSortCache( object_id_ int unsigned, attribute_id_ int unsigned, value_ double ) returns int unsigned not deterministic modifies sql data comment 'using not documented trick of "order by -field desc" to put nulls last' begin declare sortable int unsigned default (select a.sortable = 'y' from attributeT a where a.id = attribute_id_); if object_id_ is null then if sortable then insert cacheObjectSortT(objectId, attributeId, sorterAsc, sorterDesc) select objectn.id, attribute_id_, - coalesce(value_, avn.value), coalesce(value_, avn.value) from attributeT a join attributeValueNumericT avn on a.id = avn.attributeId join objectT objectn on avn.objectId = objectn.id where a.id = attribute_id_ and a.dataTypeId = 'numeric' on duplicate key update cacheObjectSortT.sorterAsc = values(sorterAsc), cacheObjectSortT.sorterDesc = values(sorterDesc); insert cacheObjectSortT(objectId, attributeId, sorterAsc, sorterDesc) select objectd.id, attribute_id_, - coalesce(value_, datetime_ToDouble(avd.value)), coalesce(value_, datetime_ToDouble(avd.value)) from attributeT a join attributeValueDatetimeT avd on a.id = avd.attributeId join objectT objectd on avd.objectId = objectd.id where a.id = attribute_id_ and a.dataTypeId = 'datetime' on duplicate key update cacheObjectSortT.sorterAsc = values(sorterAsc), cacheObjectSortT.sorterDesc = values(sorterDesc); else delete from cacheObjectSortT where attributeId = attribute_id_; end if; else if sortable then insert cacheObjectSortT(objectId, attributeId, sorterAsc, sorterDesc) select o.id, a.id, - coalesce(value_, avn.value, datetime_ToDouble(avd.value)), coalesce(value_, avn.value, datetime_ToDouble(avd.value)) from attributeT a join objectT o on 1=1 left join attributeValueNumericT avn on a.id = avn.attributeId and o.id = avn.objectId left join attributeValueDatetimeT avd on a.id = avd.attributeId and o.id = avd.objectId where a.id = attribute_id_ and o.id = object_id_ on duplicate key update cacheObjectSortT.sorterAsc = values(sorterAsc), cacheObjectSortT.sorterDesc = values(sorterDesc); else delete from cacheObjectSortT where objectId = object_id_ and attributeId = attribute_id_; end if; end if; return object_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateSortCache2 -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateSortCache2`; DELIMITER $$$ create function __object_UpdateSortCache2( object_id_ int unsigned, attribute_id_ int unsigned, value_ double ) returns double not deterministic modifies sql data comment 'calls __object_UpdateSortCache and returns value_' begin set @1 = __object_UpdateSortCache(object_id_, attribute_id_, value_); return value_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateAllSortCache -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateAllSortCache`; DELIMITER $$$ create function __object_UpdateAllSortCache() returns int unsigned not deterministic modifies sql data comment 'updates all sort caches; to be called manually' begin -- special attribute - rating; update all ratings as a side effect set @1 = __object_UpdateAllRatings(); -- special attribute - last changed date insert zzzDevNullObjectT(n) select coalesce(__object_UpdateSortCacheChanged2(o.id, null), 0) from objectT o; -- all other attributes -- this query will select special attributes as well, -- but won't update anything because special attributes have no attributeValueNumericT and attributeValueDatetimeT insert zzzDevNullObjectT(n) select coalesce(__object_UpdateSortCache(null, a.id, null), 0) from attributeT a where a.sortable = 'y'; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function attribute_GetByCode -- ----------------------------------------------------- DROP function IF EXISTS `attribute_GetByCode`; DELIMITER $$$ create function attribute_GetByCode(code_ varchar(30) binary) returns int unsigned deterministic return (select a.id from attributeT a where a.code = code_)$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateSortCacheRating2 -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateSortCacheRating2`; DELIMITER $$$ create function __object_UpdateSortCacheRating2( object_id_ int unsigned, value_ double ) returns double not deterministic modifies sql data begin -- NOTE: descending sort by default - note minus sign return - __object_UpdateSortCache2( object_id_, attribute_GetByCode('__byrating'), - coalesce( value_, (select o.rating from objectT o where o.id = object_id_))); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __object_UpdateSortCacheChanged2 -- ----------------------------------------------------- DROP function IF EXISTS `__object_UpdateSortCacheChanged2`; DELIMITER $$$ create function __object_UpdateSortCacheChanged2( object_id_ int unsigned, changed_ timestamp ) returns double not deterministic modifies sql data begin -- NOTE: descending sort by default - note minus sign return - __object_UpdateSortCache2( object_id_, attribute_GetByCode('__bychanged'), - datetime_ToDouble( coalesce( changed_, (select n.changed from nodeT n where n.id = object_id_)))); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_CurrentName -- ----------------------------------------------------- DROP function IF EXISTS `user_CurrentName`; DELIMITER $$$ create function user_CurrentName() returns varchar(255) deterministic no sql return @__userName$$$ DELIMITER ; -- ----------------------------------------------------- -- function user_CurrentIp -- ----------------------------------------------------- DROP function IF EXISTS `user_CurrentIp`; DELIMITER $$$ create function user_CurrentIp() returns varchar(40) deterministic no sql return @__userIp$$$ DELIMITER ; -- ----------------------------------------------------- -- function __node_Update -- ----------------------------------------------------- DROP function IF EXISTS `__node_Update`; DELIMITER $$$ create function __node_Update(node_id_ int unsigned, name_ varchar(50)) returns int unsigned not deterministic modifies sql data begin set @1 = __node_CanUpdate(node_id_, 'update'); update nodeT set name = coalesce(name_, name), changed = current_timestamp(), changedUserId = user_CurrentId(), changedUserName = user_CurrentName(), changedIp = user_CurrentIp() where id = node_id_; return node_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_UpdateType -- ----------------------------------------------------- DROP function IF EXISTS `image_UpdateType`; DELIMITER $$$ create function image_UpdateType( image_id_ int unsigned, image_type_id_ char(10) binary, video_type_ varchar(50), url_ varchar(255), extra_id_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned default (select nodeId from imageT where id = image_id_); set @1 = node_id is not null and __node_CanUpdate(node_id, 'imageupdate'); return __image_Update(image_id_, node_id, null, null, null, null, null, image_type_id_, video_type_, url_, extra_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_UpdateTypeByUserForObject -- ----------------------------------------------------- DROP function IF EXISTS `image_UpdateTypeByUserForObject`; DELIMITER $$$ create function image_UpdateTypeByUserForObject( image_id_ int unsigned, image_type_id_ char(10) binary, video_type_ varchar(50), url_ varchar(255), extra_id_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned default (select nodeId from imageT where id = image_id_); set @1 = __object_AccessByUser(node_id, 'update', null); return __image_Update(image_id_, node_id, null, null, null, null, null, image_type_id_, video_type_, url_, extra_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __string_QuoteOut -- ----------------------------------------------------- DROP function IF EXISTS `__string_QuoteOut`; DELIMITER $$$ create function __string_QuoteOut( s varchar(2048), purp varchar(10), rpl varchar(1) ) returns varchar(2048) deterministic begin declare l int default char_length(s); set @__stringQuoteOutHelperPrevC = null; -- init return ( select group_concat( __string_QuoteOutHelper( coalesce(vc.replacement, vc.id, rpl), coalesce(vc.forceSingle, 'y') = 'y') order by i.n separator '') from zzzInts10000V i left join zzzValidCharT vc on substring(s, i.n + 1, 1) = vc.id and vc.purpose = purp where i.n < l); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function string_Normalize -- ----------------------------------------------------- DROP function IF EXISTS `string_Normalize`; DELIMITER $$$ create function string_Normalize(s varchar(2048)) returns varchar(2048) deterministic return __string_QuoteOut(s, 'norm', '')$$$ DELIMITER ; -- ----------------------------------------------------- -- function __string_QuoteOutHelper -- ----------------------------------------------------- DROP function IF EXISTS `__string_QuoteOutHelper`; DELIMITER $$$ create function __string_QuoteOutHelper(c_ varchar(1) binary, single_ int) returns varchar(1) not deterministic begin if single_ then if coalesce(@__stringQuoteOutHelperPrevC, '') = c_ then return ''; else set @__stringQuoteOutHelperPrevC = c_; return c_; end if; else set @__stringQuoteOutHelperPrevC = c_; return c_; end if; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __tag_UpdateCache -- ----------------------------------------------------- DROP function IF EXISTS `__tag_UpdateCache`; DELIMITER $$$ create function __tag_UpdateCache(tag_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin insert tagCacheT(id, tagNames, tagNamesSearch, tagNamesFullSearch) select tl.id, group_concat(concat_ws(0xb, tl.languageId, tl.name) separator '\0'), group_concat(concat_ws(0xb, tl.languageId, string_Normalize(tl.name)) separator '\0'), concat_ws( ' ', group_concat(string_Normalize(tl.name) separator ' '), ( select group_concat( string_Normalize( if( nad.srcInternalTypeId = 'attribute', coalesce( nad.srcNumericValue, date_format(nad.srcDatetimeValue, nad.srcDatetimeOutputFormat), nad.srcTextValue, ''), nad.srcName)) order by nad.ancestrySorter, nad.srcTypeName, nad.srcName separator ' ') from nodeAncestryDataV nad where nad.dstNodeId = tl.id )) from tagTL tl where tl.id = coalesce(tag_id_, tl.id) group by tl.id on duplicate key update tagCacheT.tagNames = values(tagNames), tagCacheT.tagNamesSearch = values(tagNamesSearch), tagCacheT.tagNamesFullSearch = values(tagNamesFullSearch); return tag_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __attribute_UpdateCache -- ----------------------------------------------------- DROP function IF EXISTS `__attribute_UpdateCache`; DELIMITER $$$ create function __attribute_UpdateCache(attribute_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin insert attributeCacheT(id, attributeNames, attributeNamesSearch) select tl.id, group_concat(concat_ws(0xb, tl.languageId, tl.uofmPre, tl.uofmPost) separator '\0'), group_concat(concat_ws(0xb, tl.languageId, string_Normalize(tl.uofmPre), string_Normalize(tl.uofmPost)) separator '\0') from attributeT a join tagTL tl on a.id = tl.id where tl.id = coalesce(attribute_id_, tl.id) group by tl.id on duplicate key update attributeCacheT.attributeNames = values(attributeNames), attributeCacheT.attributeNamesSearch = values(attributeNamesSearch); return attribute_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_CreateEx -- ----------------------------------------------------- DROP function IF EXISTS `image_CreateEx`; DELIMITER $$$ create function image_CreateEx( node_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int, image_type_id_ char(10) binary, video_type_ varchar(50), url_ varchar(255), extra_id_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin set @1 = node_id_ is not null and __node_CanUpdate(node_id_, 'imagecreate'); return __image_Create(node_id_, name_, filename_original_, filename_fs_, display_, sorter_, image_type_id_, video_type_, url_, extra_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_UpdateEx -- ----------------------------------------------------- DROP function IF EXISTS `image_UpdateEx`; DELIMITER $$$ create function image_UpdateEx( image_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int, image_type_id_ char(10) binary, video_type_ varchar(50), url_ varchar(255), extra_id_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned default (select nodeId from imageT where id = image_id_); set @1 = node_id is not null and __node_CanUpdate(node_id, 'imageupdate'); return __image_Update(image_id_, node_id, name_, filename_original_, filename_fs_, display_, sorter_, image_type_id_, video_type_, url_, extra_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_CreateByUserForObjectEx -- ----------------------------------------------------- DROP function IF EXISTS `image_CreateByUserForObjectEx`; DELIMITER $$$ create function image_CreateByUserForObjectEx( node_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int, image_type_id_ char(10) binary, video_type_ varchar(50), url_ varchar(255), extra_id_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin set @1 = __object_AccessByUser(node_id_, 'update', null); return __image_Create(node_id_, name_, filename_original_, filename_fs_, display_, sorter_, image_type_id_, video_type_, url_, extra_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function image_UpdateByUserForObjectEx -- ----------------------------------------------------- DROP function IF EXISTS `image_UpdateByUserForObjectEx`; DELIMITER $$$ create function image_UpdateByUserForObjectEx( image_id_ int unsigned, name_ varchar(255), filename_original_ varchar(255), filename_fs_ varchar(255), display_ enum('n', 'y'), sorter_ int, image_type_id_ char(10) binary, video_type_ varchar(50), url_ varchar(255), extra_id_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned default (select nodeId from imageT where id = image_id_); set @1 = __object_AccessByUser(node_id, 'update', null); return __image_Update(image_id_, node_id, name_, filename_original_, filename_fs_, display_, sorter_, image_type_id_, video_type_, url_, extra_id_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_Select -- ----------------------------------------------------- DROP function IF EXISTS `object_Select`; DELIMITER $$$ create function object_Select(object_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin if search_CurrentId() is not null then insert ignore searchResultSelectedT(sessionId, objectId) values (search_CurrentId(), object_id_); end if; if user_CurrentId() is not null then set @1 = nodeLink_Create('fav', user_CurrentId(), object_id_); end if; return object_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_Deselect -- ----------------------------------------------------- DROP function IF EXISTS `object_Deselect`; DELIMITER $$$ create function object_Deselect(object_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare user_id int unsigned default user_CurrentId(); if search_CurrentId() is not null then delete from searchResultSelectedT where sessionId = search_CurrentId() and objectId = coalesce(object_id_, objectId); end if; if user_id is not null then drop temporary table if exists objectDeselectData; create temporary table objectDeselectData(objectId int unsigned not null primary key) engine=MEMORY; insert objectDeselectData(objectId) select nl.dstNodeId from nodeLinkT nl join nodeLinkTypeT nlt on nl.nodeLinkTypeId = nlt.id where nl.srcNodeId = user_id and nl.dstNodeId = coalesce(object_id_, nl.dstNodeId) and nl.metric = 1 and nlt.code = 'fav'; set @1 = nodeLink_UpdateStart(); insert zzzDevNullObjectT(n) select __nodeLink_Delete('fav', user_id, oddata.objectId, null) from objectDeselectData oddata; set @2 = nodeLink_UpdateEnd(); drop temporary table objectDeselectData; end if; return object_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function object_SelectSync -- ----------------------------------------------------- DROP function IF EXISTS `object_SelectSync`; DELIMITER $$$ create function object_SelectSync() returns int unsigned not deterministic modifies sql data comment 'should be run when user logs in' begin declare user_id int unsigned default user_CurrentId(); declare session_id bigint unsigned default search_CurrentId(); if user_id is not null and session_id is not null then -- session list -> profile list drop temporary table if exists objectSelectSyncData; create temporary table objectSelectSyncData(objectId int unsigned not null primary key) engine=MEMORY; insert objectSelectSyncData(objectId) select srs.objectId from searchResultSelectedT srs where srs.sessionId = session_id and not exists( select 1 from nodeLinkT nl join nodeLinkTypeT nlt on nl.nodeLinkTypeId = nlt.id where nl.srcNodeId = user_id and nl.dstNodeId = srs.objectId and nl.metric = 1 and nlt.code = 'fav'); set @1 = nodeLink_UpdateStart(); insert zzzDevNullObjectT(n) select __nodeLink_Create('fav', user_id, ossd.objectId) from objectSelectSyncData ossd; set @2 = nodeLink_UpdateEnd(); drop temporary table objectSelectSyncData; -- profile list -> session list insert searchResultSelectedT(sessionId, objectId, added) select session_id, nl.dstNodeId, nl.added from nodeLinkT nl join nodeLinkTypeT nlt on nl.nodeLinkTypeId = nlt.id where nl.srcNodeId = user_id and nl.metric = 1 and nlt.code = 'fav' on duplicate key update searchResultSelectedT.added = nl.added; end if; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure analyzeAll -- ----------------------------------------------------- DROP procedure IF EXISTS `analyzeAll`; DELIMITER $$$ create procedure analyzeAll(db_name_ varchar(100), write_log_ int) modifies sql data begin declare q mediumtext; declare db_name__ varchar(100) default coalesce(db_name_, database()); declare sess_id bigint unsigned default uuid_short(); if coalesce(write_log_, 1) then insert _maintenanceLogT(sessId, msg) values (sess_id, concat('analyze all for ', db_name__,' started')); end if; set @@group_concat_max_len = 262144; select concat('analyze table ', group_concat(t.TABLE_NAME)) into q from information_schema.TABLES t where t.TABLE_SCHEMA = db_name__ and t.TABLE_TYPE = 'BASE TABLE'; call __executeSQL(q); if coalesce(write_log_, 1) then insert _maintenanceLogT(sessId, msg) values (sess_id, concat('analyze all for ', db_name__,' finished')); end if; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure optimizeAll -- ----------------------------------------------------- DROP procedure IF EXISTS `optimizeAll`; DELIMITER $$$ create procedure optimizeAll(db_name_ varchar(100), write_log_ int) modifies sql data begin declare q mediumtext; declare db_name__ varchar(100) default coalesce(db_name_, database()); declare sess_id bigint unsigned default uuid_short(); if coalesce(write_log_, 1) then insert _maintenanceLogT(sessId, msg) values (sess_id, concat('optimize all for ', db_name__,' started')); end if; set @@group_concat_max_len = 262144; select concat('optimize table ', group_concat(t.TABLE_NAME)) into q from information_schema.TABLES t where t.TABLE_SCHEMA = db_name__ and t.TABLE_TYPE = 'BASE TABLE' and t.`ENGINE` = 'InnoDB' and t.TABLE_NAME != '_maintenanceLogT'; call __executeSQL(q); if coalesce(write_log_, 1) then insert _maintenanceLogT(sessId, msg) values (sess_id, concat('optimize all for ', db_name__,' finished')); end if; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_DestinationStart -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_DestinationStart`; DELIMITER $$$ create function __nodeLink_DestinationStart() returns int unsigned not deterministic modifies sql data begin drop temporary table if exists __nodeLinkDestinationT; create temporary table __nodeLinkDestinationT(nodeId int unsigned not null primary key) engine=MEMORY; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_DestinationAdd -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_DestinationAdd`; DELIMITER $$$ create function __nodeLink_DestinationAdd(node_id int unsigned) returns int unsigned not deterministic modifies sql data begin insert ignore __nodeLinkDestinationT(nodeId) values (node_id); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_DestinationEnd -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_DestinationEnd`; DELIMITER $$$ create function __nodeLink_DestinationEnd() returns int unsigned not deterministic modifies sql data begin drop temporary table if exists __nodeLinkDestinationT; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_Unlink -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_Unlink`; DELIMITER $$$ create function __nodeLink_Unlink( link_code_ varchar(30) binary, src_id_ int unsigned, unlink_from_src_id_ int unsigned -- if true - unlink from src_id as well; otherwise - will keep the link to src_id_ ) returns int unsigned comment 'unlinks src_id and all nodes in __nodeLinkDestinationT' not deterministic modifies sql data begin declare link_code varchar(30) binary; declare link_id int unsigned; declare min_metric, link_to_parent int; declare unlink_from_src_id int unsigned default coalesce(unlink_from_src_id_, 1); select nlt.id, nlt.code into link_id, link_code from nodeLinkTypeT nlt join nodeLinkTypeT nltdef on nltdef.isDefault = 'y' where nlt.code = coalesce(link_code_, nltdef.code); drop temporary table if exists nodeLinkUnlinkDeletes; drop temporary table if exists nodeLinkUnlinkSrc; drop temporary table if exists nodeLinkUnlinkDst; drop temporary table if exists __nodeLinkDestination2T; create temporary table nodeLinkUnlinkDeletes( srcNodeId int unsigned not null, dstNodeId int unsigned not null, primary key(srcNodeId, dstNodeId) ) engine=MEMORY; create temporary table nodeLinkUnlinkSrc( nodeId int unsigned not null primary key, nodeTypeId int unsigned not null, index(nodeTypeId) ) engine=MEMORY; create temporary table nodeLinkUnlinkDst( nodeId int unsigned not null primary key, nodeTypeId int unsigned not null, index(nodeTypeId) ) engine=MEMORY; create temporary table __nodeLinkDestination2T like __nodeLinkDestinationT; insert __nodeLinkDestination2T(nodeId) select nodeId from __nodeLinkDestinationT; -- add nodes to remove list - child for src_id and parent for dst_id, but with special condition insert nodeLinkUnlinkDeletes(srcNodeId, dstNodeId) select nl.srcNodeId, nl.dstNodeId from nodeLinkT nl join nodeT n on nl.srcNodeId = n.id join __nodeLinkDestinationT nld on nl.dstNodeId = nld.nodeId where nl.nodeLinkTypeId = link_id and nl.metric = 1 and n.isRoot = 'n' and (unlink_from_src_id or n.id != src_id_) and exists ( select 1 from nodeLinkT nl1 where nl1.nodeLinkTypeId = link_id and nl1.srcNodeId = src_id_ and nl1.dstNodeId = nl.srcNodeId and nl1.metric > 0) -- check if node in question is linked to other nodes of different types and (select count(distinct n21.nodeTypeId) from nodeLinkT nl21 join nodeT n21 on nl21.srcNodeId = n21.id where nl21.nodeLinkTypeId = link_id and nl21.dstNodeId = nl.srcNodeId and nl21.metric = 1) > (select count(distinct n22.nodeTypeId) from nodeLinkForkSrcV nl22 join nodeT n22 on nl22.srcNodeId = n22.id join __nodeLinkDestination2T nld2 on nl22.dstNodeId2 = nld2.nodeId where nl22.nodeLinkTypeId = link_id and nl22.srcNodeId != src_id_ and nl22.dstNodeId1 = nl.srcNodeId and nl22.metric1 = 1 and nl22.metric2 = 1); -- fill in table with all parents insert nodeLinkUnlinkSrc(nodeId, nodeTypeId) select n.id, n.nodeTypeId from nodeT n where n.id = src_id_ and n.isRoot = 'n' and unlink_from_src_id; -- insert only intermediate nodes - children for src and parents for dst insert nodeLinkUnlinkSrc(nodeId, nodeTypeId) select nl.midNodeId, anl.srcNodeTypeId from nodeLinkChainTransitionV nl join allowedNodeLinkByNodeV anl on nl.midNodeId = anl.srcNodeId and nl.dstNodeId = anl.dstNodeId join nodeT n on nl.midNodeId = n.id join __nodeLinkDestinationT nld on nl.dstNodeId = nld.nodeId where nl.nodeLinkTypeId = link_id and nl.srcNodeId = src_id_ and anl.singleSrc = 'y' and n.isRoot = 'n'; -- fill in table with all children insert nodeLinkUnlinkDst(nodeId, nodeTypeId) select n.id, n.nodeTypeId from nodeT n join __nodeLinkDestinationT nld on n.id = nld.nodeId; insert nodeLinkUnlinkDst(nodeId, nodeTypeId) select nl.dstNodeId, anl.dstNodeTypeId from nodeLinkT nl join allowedNodeLinkByNodeV anl on nl.srcNodeId = anl.srcNodeId and nl.dstNodeId = anl.dstNodeId join __nodeLinkDestinationT nld on nl.srcNodeId = nld.nodeId where nl.nodeLinkTypeId = link_id and nl.metric = 1 and anl.singleSrc = 'y'; -- add src to dst link if allowed insert ignore nodeLinkUnlinkDeletes(srcNodeId, dstNodeId) select nl.srcNodeId, nl.dstNodeId from nodeLinkT nl join __nodeLinkDestinationT nld on nl.dstNodeId = nld.nodeId where nl.nodeLinkTypeId = link_id and nl.srcNodeId = src_id_ and unlink_from_src_id; -- fill all valid combinations from src and dst sets, so all singleSrc='y' nodes will be unlinked insert ignore nodeLinkUnlinkDeletes(srcNodeId, dstNodeId) select nl.srcNodeId, nl.dstNodeId from nodeLinkT nl join nodeLinkUnlinkSrc src on nl.srcNodeId = src.nodeId join nodeLinkUnlinkDst dst on nl.dstNodeId = dst.nodeId join allowedNodeLinkT anl on src.nodeTypeId = anl.srcNodeTypeId and dst.nodeTypeId = anl.dstNodeTypeId where nl.nodeLinkTypeId = link_id and nl.metric = 1 and anl.singleSrc = 'y'; -- go and unlink set @1 = nodeLink_UpdateStart(); insert zzzDevNullLinkT(n) select __nodeLink_Delete(link_code, nlud.srcNodeId, nlud.dstNodeId, null) from nodeLinkUnlinkDeletes nlud; -- FORWARD: __node_LinkDefaults is defined in _03_node -- set @2 = __node_LinkDefaults(link_code, dst_ id_); set @3 = nodeLink_UpdateEnd(); drop temporary table nodeLinkUnlinkDeletes; drop temporary table nodeLinkUnlinkSrc; drop temporary table nodeLinkUnlinkDst; drop temporary table __nodeLinkDestination2T; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_RelocateStart -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_RelocateStart`; DELIMITER $$$ create function nodeLink_RelocateStart() returns int unsigned not deterministic modifies sql data begin set @1 = __nodeLink_DestinationStart(); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_RelocateAddNode -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_RelocateAddNode`; DELIMITER $$$ create function nodeLink_RelocateAddNode(node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __nodeLink_DestinationAdd(node_id_); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function nodeLink_RelocateEnd -- ----------------------------------------------------- DROP function IF EXISTS `nodeLink_RelocateEnd`; DELIMITER $$$ create function nodeLink_RelocateEnd(new_parent_node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin -- __nodeLink_DestinationStart is called in nodeLink_RelocateStart insert zzzDevNullT(n) select __nodeLink_Unlink(null, rootnode.id, 0) from nodeT rootnode where rootnode.isRoot = 'y'; set @1 = __nodeLink_Relink(null, new_parent_node_id_); set @2 = __nodeLink_DestinationEnd(); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __nodeLink_Relink -- ----------------------------------------------------- DROP function IF EXISTS `__nodeLink_Relink`; DELIMITER $$$ create function __nodeLink_Relink( link_code_ varchar(30) binary, src_id_ int unsigned ) returns int unsigned comment 'links src_id and all nodes in __nodeLinkDestinationT, detects and removes unnecessary linking' not deterministic modifies sql data begin -- NOTE: __nodeLinkDestinationT table must be created and filled in by caller declare link_code varchar(30) binary; declare link_id int unsigned; select nlt.id, nlt.code into link_id, link_code from nodeLinkTypeT nlt join nodeLinkTypeT nltdef on nltdef.isDefault = 'y' where nlt.code = coalesce(link_code_, nltdef.code); drop temporary table if exists nodeLinkRelinkInserts; drop temporary table if exists nodeLinkRelinkSrc; drop temporary table if exists nodeLinkRelinkDst; create temporary table nodeLinkRelinkInserts( srcNodeId int unsigned not null, dstNodeId int unsigned not null, primary key(srcNodeId, dstNodeId) ) engine=MEMORY; create temporary table nodeLinkRelinkSrc( nodeId int unsigned not null primary key, nodeTypeId int unsigned not null, index(nodeTypeId) ) engine=MEMORY; create temporary table nodeLinkRelinkDst( nodeId int unsigned not null primary key, nodeTypeId int unsigned not null, index(nodeTypeId) ) engine=MEMORY; -- fill in table with all parents insert nodeLinkRelinkSrc(nodeId, nodeTypeId) select n.id, n.nodeTypeId from nodeT n where n.id = src_id_; insert ignore nodeLinkRelinkSrc(nodeId, nodeTypeId) select nl.srcNodeId, anl.srcNodeTypeId from nodeLinkT nl join allowedNodeLinkByNodeV anl on nl.srcNodeId = anl.srcNodeId and nl.dstNodeId = anl.dstNodeId where nl.nodeLinkTypeId = link_id and nl.dstNodeId = src_id_ and nl.metric = 1 and anl.singleSrc = 'y'; -- fill in table with all children insert nodeLinkRelinkDst(nodeId, nodeTypeId) select n.id, n.nodeTypeId from nodeT n join __nodeLinkDestinationT nld on n.id = nld.nodeId; insert ignore nodeLinkRelinkDst(nodeId, nodeTypeId) select nl.dstNodeId, anl.dstNodeTypeId from nodeLinkT nl join allowedNodeLinkByNodeV anl on nl.srcNodeId = anl.srcNodeId and nl.dstNodeId = anl.dstNodeId join __nodeLinkDestinationT nld on nl.srcNodeId = nld.nodeId where nl.nodeLinkTypeId = link_id and nl.metric = 1 and anl.singleSrc = 'y'; -- add src and dst nodes to the list insert nodeLinkRelinkInserts(srcNodeId, dstNodeId) select anl.srcNodeId, anl.dstNodeId from allowedNodeLinkByNodeV anl join __nodeLinkDestinationT nld on anl.dstNodeId = nld.nodeId where anl.srcNodeId = src_id_; -- fill all valid combinations from src and dst sets, so all singleSrc='y' nodes will be linked insert ignore nodeLinkRelinkInserts(srcNodeId, dstNodeId) select src.nodeId, dst.nodeId from nodeLinkRelinkSrc src join allowedNodeLinkT anl on src.nodeTypeId = anl.srcNodeTypeId join nodeLinkRelinkDst dst on anl.dstNodeTypeId = dst.nodeTypeId left join nodeLinkT exilink on exilink.nodeLinkTypeId = link_id and src.nodeId = exilink.srcNodeId and dst.nodeId = exilink.dstNodeId and exilink.metric = 1 where anl.singleSrc = 'y' and exilink.metric is null; -- go and link set @1 = nodeLink_UpdateStart(); insert zzzDevNullLinkT(n) select __nodeLink_Create(link_code, nlri.srcNodeId, nlri.dstNodeId, null) from nodeLinkRelinkInserts nlri; set @2 = nodeLink_UpdateEnd(); drop temporary table nodeLinkRelinkInserts; drop temporary table nodeLinkRelinkSrc; drop temporary table nodeLinkRelinkDst; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function search_CurrentId -- ----------------------------------------------------- DROP function IF EXISTS `search_CurrentId`; DELIMITER $$$ create function search_CurrentId() returns bigint unsigned deterministic return @__searchId$$$ DELIMITER ; -- ----------------------------------------------------- -- function search_Reset -- ----------------------------------------------------- DROP function IF EXISTS `search_Reset`; DELIMITER $$$ create function search_Reset() returns int unsigned not deterministic modifies sql data begin delete from searchCriterionT where sessionId = search_CurrentId(); delete from searchSessionT where added < date_sub(now(), interval 1 day); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function search_StartSession -- ----------------------------------------------------- DROP function IF EXISTS `search_StartSession`; DELIMITER $$$ create function search_StartSession(sid_ varchar(100) binary, reset_params_ int unsigned) returns bigint unsigned not deterministic modifies sql data begin insert searchSessionT(sid) values(sid_) on duplicate key update searchSessionT.added = now(); select id into @__searchId from searchSessionT where sid = sid_; set @1 = coalesce(reset_params_, 1) and search_Reset(); return search_CurrentId(); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __search_SetTag -- ----------------------------------------------------- DROP function IF EXISTS `__search_SetTag`; DELIMITER $$$ create function __search_SetTag( session_id_ bigint unsigned, node_id_ int unsigned, force_node_ int, return_node_id_ int ) returns bigint unsigned not deterministic modifies sql data begin declare node_id, node_type_id int unsigned; declare internal_type_id varchar(10) binary; declare force_node int default coalesce(force_node_, 0); declare criterion_id bigint unsigned; select n.id, if(nt.searchAnd = 'y', null, nt.id), nt.internalTypeId -- attributes must have searchAnd = y into node_id, node_type_id, internal_type_id from nodeT n join nodeTypeT nt on n.nodeTypeId = nt.id left join tagT t on n.id = t.id where n.id = node_id_ and (force_node or t.canSearch is null or t.canSearch = 'y'); if node_id is not null then insert ignore searchCriterionT(sessionId, nodeId, nodeTypeId, internalTypeId) values (session_id_, node_id, node_type_id, internal_type_id); -- cannot use last_insert_id because it won't work if inserting duplicate values for sessionId and nodeId select sc.id into criterion_id from searchCriterionT sc where sc.sessionId = session_id_ and sc.nodeId = node_id; end if; return if(coalesce(return_node_id_, 0), node_id_, criterion_id); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function search_SetTag -- ----------------------------------------------------- DROP function IF EXISTS `search_SetTag`; DELIMITER $$$ create function search_SetTag(node_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin set @1 = __search_SetTag(search_CurrentId(), node_id_, null, null); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function search_SetAttributeNumeric -- ----------------------------------------------------- DROP function IF EXISTS `search_SetAttributeNumeric`; DELIMITER $$$ create function search_SetAttributeNumeric( attr_id_ int unsigned, value_low_ decimal(22, 6), value_high_ decimal(22, 6) ) returns int unsigned not deterministic modifies sql data begin declare criterion_id bigint unsigned default __search_SetTag(search_CurrentId(), attr_id_, null, null); insert searchCriterionNumericT( searchCriterionId, valueLow, valueHigh) select criterion_id, __attribute_ClampValueNumeric(attr_id_, value_low_), __attribute_ClampValueNumeric(attr_id_, value_high_) from attributeT a where a.id = attr_id_ and criterion_id is not null and a.dataTypeId = 'numeric' on duplicate key update searchCriterionNumericT.valueLow = __attribute_ClampValueNumeric(attr_id_, value_low_), searchCriterionNumericT.valueHigh = __attribute_ClampValueNumeric(attr_id_, value_high_); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function search_SetAttributeDatetime -- ----------------------------------------------------- DROP function IF EXISTS `search_SetAttributeDatetime`; DELIMITER $$$ create function search_SetAttributeDatetime( attr_id_ int unsigned, value_low_ datetime, value_high_ datetime ) returns int unsigned not deterministic modifies sql data begin declare criterion_id bigint unsigned default __search_SetTag(search_CurrentId(), attr_id_, null, null); insert searchCriterionDatetimeT( searchCriterionId, valueLow, valueHigh) select criterion_id, __attribute_ClampValueDatetime(attr_id_, value_low_), __attribute_ClampValueDatetime(attr_id_, value_high_) from attributeT a where a.id = attr_id_ and criterion_id is not null and a.dataTypeId = 'datetime' on duplicate key update searchCriterionDatetimeT.valueLow = __attribute_ClampValueDatetime(attr_id_, value_low_), searchCriterionDatetimeT.valueHigh = __attribute_ClampValueDatetime(attr_id_, value_high_); return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __search_RectifyCriteria -- ----------------------------------------------------- DROP function IF EXISTS `__search_RectifyCriteria`; DELIMITER $$$ create function __search_RectifyCriteria(session_id_ bigint unsigned) returns int unsigned not deterministic modifies sql data begin -- insert parent nodes into criteria for those nodes, whose linking is singleSrc=y drop temporary table if exists searchRectifyCriteriaInserts; create temporary table searchRectifyCriteriaInserts( nodeId int unsigned not null primary key ) engine=MEMORY; insert ignore searchRectifyCriteriaInserts(nodeId) select nl.srcNodeId from searchCriterionT sc join nodeLinkTypeT nlt on nlt.isDefault = 'y' join tagT dst_tag on sc.nodeId = dst_tag.id -- only tags and attributes join nodeLinkT nl on nlt.id = nl.nodeLinkTypeId and sc.nodeId = nl.dstNodeId join tagT src_tag on nl.srcNodeId = src_tag.id join allowedNodeLinkByNodeV anl on nl.srcNodeId = anl.srcNodeId and nl.dstNodeId = anl.dstNodeId left join searchCriterionT exicriterion on sc.sessionId = exicriterion.sessionId and nl.srcNodeId = exicriterion.nodeId where sc.sessionId = session_id_ and nl.metric = 1 and anl.singleSrc = 'y' and exicriterion.nodeId is null; insert ignore zzzDevNullSearchT(n) select __search_SetTag(session_id_, srci.nodeId, null, 1) from searchRectifyCriteriaInserts srci; drop temporary table searchRectifyCriteriaInserts; -- remove not needed nodes from criteria drop temporary table if exists searchRectifyCriteriaDeletes; create temporary table searchRectifyCriteriaDeletes( nodeId int unsigned not null primary key ) engine=MEMORY; -- empty attribute criteria insert ignore searchRectifyCriteriaDeletes(nodeId) select sc.nodeId from searchCriterionNumericT scn join searchCriterionT sc on scn.searchCriterionId = sc.id where sc.sessionId = session_id_ and scn.valueLow is null and scn.valueHigh is null; insert ignore searchRectifyCriteriaDeletes(nodeId) select sc.nodeId from searchCriterionDatetimeT scd join searchCriterionT sc on scd.searchCriterionId = sc.id where sc.sessionId = session_id_ and scd.valueLow is null and scd.valueHigh is null; -- remove unneeded criteria delete from searchCriterionT using searchCriterionT join searchRectifyCriteriaDeletes srcd on searchCriterionT.nodeId = srcd.nodeId where searchCriterionT.sessionId = session_id_; drop temporary table searchRectifyCriteriaDeletes; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __search_RectifyCriteriaPost -- ----------------------------------------------------- DROP function IF EXISTS `__search_RectifyCriteriaPost`; DELIMITER $$$ create function __search_RectifyCriteriaPost(session_id_ bigint unsigned) returns int unsigned not deterministic modifies sql data begin delete from searchCriterionT using searchCriterionT join tagT tag on searchCriterionT.nodeId = tag.id left join searchResultT sr on searchCriterionT.nodeId = sr.nodeId and searchCriterionT.sessionId = sr.sessionId where searchCriterionT.sessionId = session_id_ and sr.nodeId is null; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __search_SetDefaultResult -- ----------------------------------------------------- DROP function IF EXISTS `__search_SetDefaultResult`; DELIMITER $$$ create function __search_SetDefaultResult(session_id_ bigint unsigned) returns int unsigned not deterministic modifies sql data begin -- NOTE: moved to __search_UpdateResultCache /* insert searchResultT(sessionId, nodeId, collapsed) select session_id_, t.id, 'y' from tagT t join nodeT n on t.id = n.id join nodeTypeT nt on n.nodeTypeId = nt.id join nodeRootLinkV nrl on t.id = nrl.dstNodeId and nrl.metric = 1 left join nodeLinkChainTransitionV nl on nl.nodeLinkTypeId = nrl.nodeLinkTypeId and nl.srcNodeId = nrl.id and nl.dstNodeId = t.id where t.canSearch = 'y' and (nrl.typeRequiredForObject = 'y' or nt.requiredForObject = 'y') and nrl.displayNode = 'y' and nl.srcNodeId is null on duplicate key update collapsed = 'y';*/ insert ignore searchResultT(sessionId, nodeId, collapsed) select session_id_, o.id, 'n' from objectT o join searchCriterionT sc on o.id = sc.nodeId join objectStatusT os on o.statusId = os.id where sc.sessionId = session_id_ and os.public = 'y'; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __search_CheckRequiredForObject -- ----------------------------------------------------- DROP function IF EXISTS `__search_CheckRequiredForObject`; DELIMITER $$$ create function __search_CheckRequiredForObject(session_id_ bigint unsigned) returns int unsigned comment 'must be called after __search_RectifyCriteria' not deterministic begin declare total_required, criterion_required, parent_required int unsigned; select count(*) into total_required from nodeTypeT where requiredForObject = 'y'; select count(distinct nt.id) into criterion_required from searchCriterionT sc join nodeT n on sc.nodeId = n.id join nodeTypeT nt on n.nodeTypeId = nt.id where sc.sessionId = session_id_ and nt.canSearch = 'y' and nt.requiredForObject = 'y'; select count(distinct nt.id) into parent_required from searchCriterionT sc join nodeLinkOwnsV nlo on sc.nodeId = nlo.dstNodeId join nodeT n on nlo.srcNodeId = n.id join nodeTypeT nt on n.nodeTypeId = nt.id where sc.sessionId = session_id_ and nlo.metric = 1 and nt.canSearch = 'n' and nt.requiredForObject = 'y'; return (criterion_required + parent_required) = total_required; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __search_SearchTags -- ----------------------------------------------------- DROP procedure IF EXISTS `__search_SearchTags`; DELIMITER $$$ create procedure __search_SearchTags( session_id_ bigint unsigned, count_notnull_ int, count_null_ int) modifies sql data begin -- add searchable tags which don't have parents -- NOTE: moved to __search_UpdateResultCache /*if constS('search.server.version') = '5.5' then insert ignore searchResultT(sessionId, nodeId) select session_id_, n.id from nodeT n join nodeLinkTypeT nlt on nlt.isDefault = 'y' join nodeTypeT nt on n.nodeTypeId = nt.id join tagT t on n.id = t.id and t.canSearch = 'y' where nt.requiredForObject = 'n' and not exists( select 1 from nodeLinkT nl join nodeT nonrootnode on nl.srcNodeId = nonrootnode.id join tagT nonroottag on nonrootnode.id = nonroottag.id where nl.nodeLinkTypeId = nlt.id and nl.dstNodeId = n.id and nl.metric = 1 and nonrootnode.isRoot = 'n'); else insert ignore searchResultT(sessionId, nodeId) select session_id_, n.id from nodeT n join nodeLinkTypeT nlt on nlt.isDefault = 'y' join nodeTypeT nt on n.nodeTypeId = nt.id join tagT t on n.id = t.id and t.canSearch = 'y' left join ( select nl.nodeLinkTypeId, nl.dstNodeId from nodeLinkT nl join nodeT nonrootnode on nl.srcNodeId = nonrootnode.id join tagT nonroottag on nonrootnode.id = nonroottag.id where nl.metric = 1 and nonrootnode.isRoot = 'n' ) as ne on ne.nodeLinkTypeId = nlt.id and ne.dstNodeId = n.id where nt.requiredForObject = 'n' and ne.dstNodeId is null; end if;*/ insert ignore searchResultT(sessionId, nodeId) select session_id_, n.id from nodeT n join nodeLinkTypeT nlt on nlt.isDefault = 'y' join tagT t on n.id = t.id and t.canSearch = 'y' join nodeLinkT nl1 on nl1.nodeLinkTypeId = nlt.id and nl1.dstNodeId = n.id and nl1.metric = 1 join searchCriterionT sc1 on nl1.srcNodeId = sc1.nodeId and sc1.sessionId = session_id_ left join nodeLinkT nl2 on nl2.nodeLinkTypeId = nlt.id and nl2.dstNodeId = n.id and nl2.metric = 1 left join tagT t2 on nl2.srcNodeId = t2.id and t2.canSearch = 'y' left join nodeT n2 on t2.id = n2.id group by n.id having count(distinct n2.nodeTypeId) = count(distinct sc1.nodeTypeId); end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __search_Prepare -- ----------------------------------------------------- DROP procedure IF EXISTS `__search_Prepare`; DELIMITER $$$ create procedure __search_Prepare(session_id_ bigint unsigned) modifies sql data begin drop temporary table if exists searchTemp; create temporary table searchTemp( nodeId int unsigned not null primary key, relevancy double not null default 0.0, index(relevancy) ); drop temporary table if exists searchUpdateExtraObjectsData; create temporary table searchUpdateExtraObjectsData( tagId int unsigned not null primary key, cnt int unsigned not null default 0 ); drop temporary table if exists searchCriterionNumericTemp; create temporary table searchCriterionNumericTemp( objectId int unsigned not null, nodeId int unsigned not null, primary key(objectId, nodeId) ); drop temporary table if exists searchCriterionDatetimeTemp; create temporary table searchCriterionDatetimeTemp( objectId int unsigned not null, nodeId int unsigned not null, primary key(objectId, nodeId) ); insert searchUpdateExtraObjectsData(tagId, cnt) select tagresult.nodeId, 0 from searchResultT tagresult where tagresult.sessionId = session_id_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __search_Finalize -- ----------------------------------------------------- DROP procedure IF EXISTS `__search_Finalize`; DELIMITER $$$ create procedure __search_Finalize(session_id_ bigint unsigned) modifies sql data begin update searchResultT sr join searchUpdateExtraObjectsData sueod on sr.nodeId = sueod.tagId set sr.extraObjects = sueod.cnt where sr.sessionId = session_id_; drop temporary table searchCriterionDatetimeTemp; drop temporary table searchCriterionNumericTemp; drop temporary table searchUpdateExtraObjectsData; drop temporary table searchTemp; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __search_SearchObjects1 -- ----------------------------------------------------- DROP procedure IF EXISTS `__search_SearchObjects1`; DELIMITER $$$ create procedure __search_SearchObjects1( session_id_ bigint unsigned, count_notnull_ int, sum_null_ double, sum_null_tolerance_ double, count_numerics_ int, count_datetimes_ int) modifies sql data begin -- CONST: 2 limits for lists - when criteria are empty and when they aren't -- declare limit_dataset int unsigned default if(count_notnull_ > 0, 500, 10); declare count_numerics int default greatest(count_numerics_, 1); declare count_datetimes int default greatest(count_datetimes_, 1); -- NOTE: searchCriterionNumericTemp created in __search_Prepare insert searchCriterionNumericTemp(objectId, nodeId) select avn.objectId, avn.attributeId from attributeValueNumericT avn join objectT o on avn.objectId = o.id join objectStatusT os on o.statusId = os.id join searchCriterionT sc on avn.attributeId = sc.nodeId join searchCriterionNumericT scn on sc.id = scn.searchCriterionId where sc.sessionId = session_id_ and os.public = 'y' and avn.value >= coalesce(scn.valueLow, avn.value) and avn.value <= coalesce(scn.valueHigh, avn.value); -- NOTE: searchCriterionDatetimeTemp created in __search_Prepare insert searchCriterionDatetimeTemp(objectId, nodeId) select avd.objectId, avd.attributeId from attributeValueDatetimeT avd join objectT o on avd.objectId = o.id join objectStatusT os on o.statusId = os.id join searchCriterionT sc on avd.attributeId = sc.nodeId join searchCriterionDatetimeT scd on sc.id = scd.searchCriterionId where sc.sessionId = session_id_ and os.public = 'y' and avd.value >= coalesce(scd.valueLow, avd.value) and avd.value <= coalesce(scd.valueHigh, avd.value); -- NOTE: searchTemp created in __search_Prepare insert ignore searchTemp(nodeId, relevancy) select n.id, ( (coalesce(sum(t5.factor), sum_null_tolerance_) / sum_null_ -- sum_null_ must be sanitized to be != 0 + (count(scn7.nodeId) / count_numerics) + (count(scd9.nodeId) / count_datetimes)) / 3) relevancy from nodeT n join nodeLinkTypeT nlt on nlt.isDefault = 'y' join objectT o on n.id = o.id join objectStatusT os on o.statusId = os.id left join nodeLinkT nl5 on nlt.id = nl5.nodeLinkTypeId and n.id = nl5.dstNodeId and nl5.metric = 1 left join searchCriterionT sc5 on nl5.srcNodeId = sc5.nodeId and sc5.sessionId = session_id_ and sc5.nodeTypeId is null and sc5.internalTypeId = 'tag' left join tagT t5 on sc5.nodeId = t5.id left join searchCriterionNumericTemp scn7 on n.id = scn7.objectId left join searchCriterionDatetimeTemp scd9 on n.id = scd9.objectId where os.public = 'y' group by n.id having relevancy >= sum_null_tolerance_; -- order by 2 desc, o.rating desc -- limit limit_dataset; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __search_SearchObjects2 -- ----------------------------------------------------- DROP procedure IF EXISTS `__search_SearchObjects2`; DELIMITER $$$ create procedure __search_SearchObjects2( session_id_ bigint unsigned, count_notnull_ int, sum_null_ double, sum_null_tolerance_ double, count_numerics_ int, count_datetimes_ int) modifies sql data begin declare limit_dataset int unsigned default if( count_notnull_ > 0, constI('search.limit.criteria.notempty'), constI('search.limit.criteria.empty')); if count_notnull_ > 0 then -- NOTE: searchTemp created in __search_Prepare insert ignore searchResultT(sessionId, nodeId, relevancy) select session_id_, st.nodeId, st.relevancy from searchTemp st join nodeLinkTypeT nlt on nlt.isDefault = 'y' join objectT o on st.nodeId = o.id join nodeLinkT nl3 on nlt.id = nl3.nodeLinkTypeId and st.nodeId = nl3.dstNodeId and nl3.metric = 1 join searchCriterionT sc3 on nl3.srcNodeId = sc3.nodeId and sc3.nodeTypeId is not null and sc3.internalTypeId = 'tag' where sc3.sessionId = session_id_ group by st.nodeId, st.relevancy having count(distinct sc3.nodeTypeId) = count_notnull_ order by st.relevancy desc, o.rating desc limit limit_dataset; else -- NOTE: searchTemp created in __search_Prepare insert ignore searchResultT(sessionId, nodeId, relevancy) select session_id_, st.nodeId, st.relevancy from searchTemp st join objectT o on st.nodeId = o.id order by st.relevancy desc, o.rating desc limit limit_dataset; end if; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __search_UpdateExtraObjects -- ----------------------------------------------------- DROP procedure IF EXISTS `__search_UpdateExtraObjects`; DELIMITER $$$ create procedure __search_UpdateExtraObjects(session_id_ bigint unsigned) modifies sql data begin -- TODO: review if we need 2 queries if exists(select 1 from searchCriterionT where sessionId = session_id_) then insert searchUpdateExtraObjectsData(tagId, cnt) select tagresult.nodeId, 1 from searchResultT tagresult join nodeLinkTypeT nlt on nlt.isDefault = 'y' join tagT t on tagresult.nodeId = t.id join nodeLinkT nl on nlt.id = nl.nodeLinkTypeId and t.id = nl.srcNodeId and nl.metric = 1 join searchTemp st on nl.dstNodeId = st.nodeId join nodeLinkT nl2 on nlt.id = nl2.nodeLinkTypeId and nl.dstNodeId = nl2.dstNodeId and nl2.metric = 1 join searchCriterionT criterion2 on tagresult.sessionId = criterion2.sessionId and nl2.srcNodeId = criterion2.nodeId where tagresult.sessionId = session_id_ group by tagresult.nodeId on duplicate key update cnt = 1; else insert searchUpdateExtraObjectsData(tagId, cnt) select tagresult.nodeId, 1 from searchResultT tagresult join nodeLinkTypeT nlt on nlt.isDefault = 'y' join tagT t on tagresult.nodeId = t.id join nodeLinkT nl on nlt.id = nl.nodeLinkTypeId and t.id = nl.srcNodeId and nl.metric = 1 join searchTemp st on nl.dstNodeId = st.nodeId where tagresult.sessionId = session_id_ group by tagresult.nodeId on duplicate key update cnt = 1; end if; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __search_UpdateSortCache -- ----------------------------------------------------- DROP procedure IF EXISTS `__search_UpdateSortCache`; DELIMITER $$$ create procedure __search_UpdateSortCache(session_id_ bigint unsigned) modifies sql data begin drop temporary table if exists searchUpdateSortCacheData; create temporary table searchUpdateSortCacheData( objectId int unsigned not null, attributeId int unsigned not null, primary key(objectId, attributeId) ) engine=MEMORY; insert searchUpdateSortCacheData(objectId, attributeId) select o.id, sas.id from searchResultV sr join objectT o on sr.nodeId = o.id join searchAttributeSortV sas on 1=1 left join cacheObjectSortT os on o.id = os.objectId and sas.id = os.attributeId where os.objectId is null; insert zzzDevNullSearchT(n) select __object_UpdateSortCache(suscd.objectId, suscd.attributeId, null) from searchUpdateSortCacheData suscd; drop temporary table searchUpdateSortCacheData; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __externalData_IterateLanguage -- ----------------------------------------------------- DROP procedure IF EXISTS `__externalData_IterateLanguage`; DELIMITER $$$ create procedure __externalData_IterateLanguage(sql_tmpl varchar(2000), repl varchar(10)) modifies sql data begin declare lang_id char(3); declare sql_query varchar(2000); declare done int unsigned default 0; declare cur cursor for select l.id from languageT l; declare continue handler for not found set done = 1; open cur; main_loop: loop fetch cur into lang_id; if done then leave main_loop; end if; set sql_query = replace(sql_tmpl, repl, lang_id); call __executeSQL(sql_query); end loop; close cur; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure external_Admter_Import -- ----------------------------------------------------- DROP procedure IF EXISTS `external_Admter_Import`; DELIMITER $$$ create procedure external_Admter_Import() modifies sql data begin -- insert insert externalDataT( externalDataSourceId, externalParentKey, externalKey, typeCode, enabled) select 'admter', if(tad.district_koatuu != '', tad.district_koatuu, if(tad.oblast_koatuu != '', tad.oblast_koatuu, null)), tad.koatuu, eat.typeCode, 'y' from tmpAdmterDataT tad join externalAdmterTypeT eat on tad.type = eat.id join nodeTypeT nt on eat.typeCode = nt.code where not exists ( select 1 from externalDataT ed where ed.externalDataSourceId = 'admter' and ed.typeCode = eat.typeCode and ed.externalKey = tad.koatuu) group by tad.koatuu; -- disable update externalDataT ed set ed.enabled = 'n' where ed.externalDataSourceId = 'admter' and not exists (select 1 from tmpAdmterDataT tad where tad.koatuu = ed.externalKey); -- update names call __external_Admter_UpdateName(); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __external_TagData_Insert -- ----------------------------------------------------- DROP function IF EXISTS `__external_TagData_Insert`; DELIMITER $$$ -- -------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------- -- Streets import -- -------------------------------------------------------------------------------- -- import process: -- 1) load data infile into temp table - whole streets table -- 2) convert temp table -> storedTagDataT/storedTagDataTL by running external_TagData_ImportStreets -- temp table format for streets - tmpStreetDataT: -- id - internal id; it is expected it should be consistent over the time - streets won't change their IDs -- name_ukr -- name_rus -- name_eng /* load data local infile replace into table tmpStreetDataT character set utf8 columns terminated by '\t' lines terminated by '\n'; -- ------- truncate table tmpStreetDataT; load data local infile '/home/castor/public_html/m2.te.ua/trunk/db/all-streets-01.tsv' replace into table tmpStreetDataT character set utf8 columns terminated by '\t' lines terminated by '\n'; call external_TagData_ImportStreets(); */ create function __external_TagData_Insert(node_type_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare id int unsigned; insert storedTagDataT(nodeTypeId) values (node_type_id_); set id = last_insert_id(); return id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __external_TagData_ImportStreetNames -- ----------------------------------------------------- DROP procedure IF EXISTS `__external_TagData_ImportStreetNames`; DELIMITER $$$ create procedure __external_TagData_ImportStreetNames() modifies sql data begin declare sql_tmpl varchar(2000) default 'insert storedTagDataTL(id, languageId, name) select stds.external_id, ''{{0}}'', stds.name_{{0}} from storedTagDataStreetT stds where stds.external_id is not null on duplicate key update storedTagDataTL.name = stds.name_{{0}}'; call __externalData_IterateLanguage(sql_tmpl, '{{0}}'); end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure external_TagData_ImportStreets -- ----------------------------------------------------- DROP procedure IF EXISTS `external_TagData_ImportStreets`; DELIMITER $$$ create procedure external_TagData_ImportStreets() modifies sql data begin declare node_type_id int unsigned default (select id from nodeTypeT where code = 'street'); -- updating storedTagDataStreetT table -- delete missing records, match by id delete from storedTagDataStreetT using storedTagDataStreetT left join tmpStreetDataT sd on storedTagDataStreetT.id = sd.id where sd.id is null; -- insert/update new records insert storedTagDataStreetT(id, name_ukr, name_rus, name_eng) select sd.id, sd.name_ukr, sd.name_rus, sd.name_eng from tmpStreetDataT sd on duplicate key update storedTagDataStreetT.name_ukr = sd.name_ukr, storedTagDataStreetT.name_rus = sd.name_rus, storedTagDataStreetT.name_eng = sd.name_eng; -- updating storedTagDataT -- delete missing records delete from storedTagDataT using storedTagDataT join nodeTypeT nt on storedTagDataT.nodeTypeId = nt.id left join storedTagDataStreetT stds on storedTagDataT.id = stds.external_id where nt.code = 'street' and stds.id is null; -- insert/update records update storedTagDataStreetT set external_id = __external_TagData_Insert(node_type_id) where external_id is null; -- update storedTagDataTL call __external_TagData_ImportStreetNames(); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function external_CreateEntity -- ----------------------------------------------------- DROP function IF EXISTS `external_CreateEntity`; DELIMITER $$$ create function external_CreateEntity(stored_id_ int unsigned, parent_id_ int unsigned) returns int unsigned not deterministic modifies sql data begin declare node_id int unsigned; declare node_type_id int unsigned; declare internal_type_id varchar(10); select nt.id, nt.internalTypeId into node_type_id, internal_type_id from nodeTypeT nt join storedTagDataT std on nt.id = std.nodeTypeId where std.id = stored_id_; if (internal_type_id = 'tag') then set node_id = tag_Create(node_type_id, null, '', null, null, null, null, null, null, null); insert zzzDevNullExternalDataT(n) select tag_UpdateLocal(node_id, l.id, stdl.name) from languageT l join storedTagDataTL stdl on l.id = stdl.languageId where stdl.id = stored_id_; end if; if (parent_id_ is not null) then set @1 = nodeLink_Relink(null, parent_id_, node_id); end if; return node_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure __external_Admter_UpdateName -- ----------------------------------------------------- DROP procedure IF EXISTS `__external_Admter_UpdateName`; DELIMITER $$$ -- -------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------- -- Admter import -- -------------------------------------------------------------------------------- -- import process: -- 1) load data infile into temp table - whole Admter DB -- 2) convert temp table -> externalDataT/externalDataTL by running external_Admter_Import -- 3) run externalData_UpdateTags -- temp table format for Admter - tmpAdmterDataT: -- id - internal Admter id; it is unknown if objects retain their id when Admter DB version is upgraded -- parentId - parent id; 0 for oblasts -- koatuu - KOATUU code -- ukrName -- rusName -- engName -- oblast_koatuu - the KOATUU code of oblast this oject belongs to -- district_koatuu - the KOATUU code of raion this oject belongs to -- adminCenterId - id of administrative center; for oblast and raion - the id of "main city/town" -- type - locality type: 2 - oblast; 3 - raion; 4 - city district; 5 - village council; 6 - city; 7 - s.m.t; 8 - village; 9 - hamlet /* load data local infile '' replace into table tmpAdmterDataT character set utf8 columns terminated by ',' optionally enclosed by '"' lines terminated by '\n'; -------------------------------- truncate table tmpAdmterDataT; load data local infile '/home/castor/public_html/m2.te.ua/trunk/db/admter_object3.txt' replace into table tmpAdmterDataT character set utf8 columns terminated by ',' optionally enclosed by '"' lines terminated by '\n'; call external_Admter_Import(); */ create procedure __external_Admter_UpdateName() modifies sql data begin declare sql_tmpl varchar(2000) default 'insert externalDataTL(id, languageId, name) select ed.id, ''{{0}}'', tad.{{0}}Name from externalDataT ed join tmpAdmterDataT tad on ed.externalKey = tad.koatuu where ed.externalDataSourceId = ''admter'' and ed.enabled = ''y'' on duplicate key update externalDataTL.name = tad.{{0}}Name'; call __externalData_IterateLanguage(sql_tmpl, '{{0}}'); end$$$ DELIMITER ; -- ----------------------------------------------------- -- function moderationQueue_Create -- ----------------------------------------------------- DROP function IF EXISTS `moderationQueue_Create`; DELIMITER $$$ create function moderationQueue_Create(node_id int unsigned, comment_ varchar(255)) returns int unsigned not deterministic modifies sql data begin declare queue_id int unsigned; insert moderationQueueT( nodeId, comment1, resolved, addedUserId, addedUserName, addedIp, changedUserId, changedUserName, changedIp) values ( node_id, coalesce(comment_, ''), 'n', user_CurrentId(), user_CurrentName(), user_CurrentIp(), user_CurrentId(), user_CurrentName(), user_CurrentIp()); set queue_id = last_insert_id(); return queue_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function moderationQueue_Resolve -- ----------------------------------------------------- DROP function IF EXISTS `moderationQueue_Resolve`; DELIMITER $$$ create function moderationQueue_Resolve(queue_id int unsigned, comment_ varchar(255)) returns int unsigned not deterministic modifies sql data begin update moderationQueueT set resolved = 'y', comment2 = coalesce(comment_, '') where id = queue_id; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function constS -- ----------------------------------------------------- DROP function IF EXISTS `constS`; DELIMITER $$$ create function constS(name_ varchar(255)) returns varchar(255) deterministic return (select valueString from constT where id = name_)$$$ DELIMITER ; -- ----------------------------------------------------- -- function constI -- ----------------------------------------------------- DROP function IF EXISTS `constI`; DELIMITER $$$ create function constI(name_ varchar(255)) returns int deterministic return (select valueInt from constT where id = name_)$$$ DELIMITER ; -- ----------------------------------------------------- -- function constF -- ----------------------------------------------------- DROP function IF EXISTS `constF`; DELIMITER $$$ create function constF(name_ varchar(255)) returns double deterministic return (select valueFloat from constT where id = name_)$$$ DELIMITER ; -- ----------------------------------------------------- -- function maintenance_GetLockName -- ----------------------------------------------------- DROP function IF EXISTS `maintenance_GetLockName`; DELIMITER $$$ create function maintenance_GetLockName() returns varchar(50) deterministic return concat(database(), '.maintenance')$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure maintenance_5minute -- ----------------------------------------------------- DROP procedure IF EXISTS `maintenance_5minute`; DELIMITER $$$ create procedure maintenance_5minute(write_log_ int) modifies sql data begin declare lock_name varchar(50) default maintenance_GetLockName(); declare sess_id bigint unsigned default uuid_short(); declare write_log int default coalesce(write_log_, 1); if get_lock(lock_name, 1) then if write_log then insert _maintenanceLogT(sessId, msg) values (sess_id, concat('maintenance_5minute started')); end if; if coalesce(constI('search.cache.update'), 1) then -- FORWARD: __search_UpdateResultCache is defined in _110_search set @1 = __search_UpdateResultCache() and const_SetI('search.cache.update', 0); if write_log then insert _maintenanceLogT(sessId, msg) values (sess_id, concat('maintenance_5minute - search cache updated')); end if; end if; if write_log then insert _maintenanceLogT(sessId, msg) values (sess_id, concat('maintenance_5minute finished')); end if; set @0 = release_lock(lock_name); else if write_log then insert _maintenanceLogT(sessId, msg) values (sess_id, concat('maintenance_5minute could not start - another instance running')); end if; end if; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function const_SetS -- ----------------------------------------------------- DROP function IF EXISTS `const_SetS`; DELIMITER $$$ create function const_SetS(name_ varchar(255), value_ varchar(255)) returns varchar(255) not deterministic modifies sql data begin insert constT(id, valueString) values (name_, value_) on duplicate key update valueString = value_; return value_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function const_SetI -- ----------------------------------------------------- DROP function IF EXISTS `const_SetI`; DELIMITER $$$ create function const_SetI(name_ varchar(255), value_ int) returns int not deterministic modifies sql data begin insert constT(id, valueInt) values (name_, value_) on duplicate key update valueInt = value_; return value_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function const_SetF -- ----------------------------------------------------- DROP function IF EXISTS `const_SetF`; DELIMITER $$$ create function const_SetF(name_ varchar(255), value_ double) returns double not deterministic modifies sql data begin insert constT(id, valueFloat) values (name_, value_) on duplicate key update valueFloat = value_; return value_; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __search_SetCachedResult -- ----------------------------------------------------- DROP function IF EXISTS `__search_SetCachedResult`; DELIMITER $$$ create function __search_SetCachedResult(session_id_ bigint unsigned) returns int unsigned not deterministic modifies sql data begin insert ignore searchResultT(sessionId, nodeId) select session_id_, nodeId from cacheSearchDefaultResultT; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __search_UpdateResultCache -- ----------------------------------------------------- DROP function IF EXISTS `__search_UpdateResultCache`; DELIMITER $$$ create function __search_UpdateResultCache() returns int unsigned not deterministic modifies sql data begin drop temporary table if exists searchUpdateResultCacheData; create temporary table searchUpdateResultCacheData(nodeId int unsigned not null primary key); -- from __search_SetDefaultResult insert ignore searchUpdateResultCacheData(nodeId) select t.id from tagT t join nodeT n on t.id = n.id join nodeTypeT nt on n.nodeTypeId = nt.id join nodeRootLinkV nrl on t.id = nrl.dstNodeId and nrl.metric = 1 left join nodeLinkChainTransitionV nl on nl.nodeLinkTypeId = nrl.nodeLinkTypeId and nl.srcNodeId = nrl.id and nl.dstNodeId = t.id where t.canSearch = 'y' and (nrl.typeRequiredForObject = 'y' or nt.requiredForObject = 'y') and nrl.displayNode = 'y' and nl.srcNodeId is null; -- from __search_SearchTags if constS('search.server.version') = '5.5' then insert ignore searchUpdateResultCacheData(nodeId) select n.id from nodeT n join nodeLinkTypeT nlt on nlt.isDefault = 'y' join nodeTypeT nt on n.nodeTypeId = nt.id join tagT t on n.id = t.id and t.canSearch = 'y' where nt.requiredForObject = 'n' and not exists( select 1 from nodeLinkT nl join nodeT nonrootnode on nl.srcNodeId = nonrootnode.id join tagT nonroottag on nonrootnode.id = nonroottag.id where nl.nodeLinkTypeId = nlt.id and nl.dstNodeId = n.id and nl.metric = 1 and nonrootnode.isRoot = 'n'); else insert ignore searchUpdateResultCacheData(nodeId) select n.id from nodeT n join nodeLinkTypeT nlt on nlt.isDefault = 'y' join nodeTypeT nt on n.nodeTypeId = nt.id join tagT t on n.id = t.id and t.canSearch = 'y' left join ( select nl.nodeLinkTypeId, nl.dstNodeId from nodeLinkT nl join nodeT nonrootnode on nl.srcNodeId = nonrootnode.id join tagT nonroottag on nonrootnode.id = nonroottag.id where nl.metric = 1 and nonrootnode.isRoot = 'n' ) as ne on ne.nodeLinkTypeId = nlt.id and ne.dstNodeId = n.id where nt.requiredForObject = 'n' and ne.dstNodeId is null; end if; -- update search result cache table delete from cacheSearchDefaultResultT using cacheSearchDefaultResultT left join searchUpdateResultCacheData surcd on cacheSearchDefaultResultT.nodeId = surcd.nodeId where surcd.nodeId is null; insert ignore cacheSearchDefaultResultT(nodeId) select surcd.nodeId from searchUpdateResultCacheData surcd; drop temporary table searchUpdateResultCacheData; return 1; end$$$ DELIMITER ; -- ----------------------------------------------------- -- procedure search_Search -- ----------------------------------------------------- DROP procedure IF EXISTS `search_Search`; DELIMITER $$$ create procedure search_Search() modifies sql data begin declare session_id bigint unsigned default search_CurrentId(); declare count_notnull, count_null, count_numerics, count_datetimes int; -- search_objects int; declare sum_null double; start transaction; set @1 = __search_RectifyCriteria(session_id); select count(distinct sc.nodeTypeId) into count_notnull from searchCriterionT sc where sc.sessionId = session_id and sc.nodeTypeId is not null and sc.internalTypeId = 'tag'; select count(*), greatest(coalesce(sum(t.factor), 0.001), 0.001) into count_null, sum_null from searchCriterionT sc join tagT t on sc.nodeId = t.id where sc.sessionId = session_id and sc.nodeTypeId is null and sc.internalTypeId = 'tag'; select count(*) into count_numerics from searchCriterionT sc join searchCriterionNumericT scn on sc.id = scn.searchCriterionId where sc.sessionId = session_id; select count(*) into count_datetimes from searchCriterionT sc join searchCriterionDatetimeT scd on sc.id = scd.searchCriterionId where sc.sessionId = session_id; -- set search_objects = __search_CheckRequiredForObject(session_id); delete from searchResultT where sessionId = session_id; set @1 = __search_SetCachedResult(session_id); call __search_SearchTags(session_id, count_notnull, count_null); set @2 = __search_SetDefaultResult(session_id); set @3 = __search_RectifyCriteriaPost(session_id); call __search_Prepare(session_id); -- CONST: sum_null_tolerance_ is 0.001 call __search_SearchObjects1(session_id, count_notnull, sum_null, 0.001, count_numerics, count_datetimes); call __search_UpdateExtraObjects(session_id); -- CONST: sum_null_tolerance_ is 0.001 call __search_SearchObjects2(session_id, count_notnull, sum_null, 0.001, count_numerics, count_datetimes); call __search_UpdateSortCache(session_id); call __search_Finalize(session_id); commit; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function __string_ConcatSmart -- ----------------------------------------------------- DROP function IF EXISTS `__string_ConcatSmart`; DELIMITER $$$ create function __string_ConcatSmart(s1 varchar(255), s varchar(255), s2 varchar(255)) returns varchar(1024) deterministic return if(s != '', concat(coalesce(s1, ''), s, coalesce(s2, '')), '')$$$ DELIMITER ; -- ----------------------------------------------------- -- function string_ConcatSmart -- ----------------------------------------------------- DROP function IF EXISTS `string_ConcatSmart`; DELIMITER $$$ create function string_ConcatSmart(sep varchar(50), s1 varchar(255), s varchar(255), s2 varchar(255)) returns varchar(1024) deterministic return __string_ConcatSmart(__string_ConcatSmart('', s1, sep), s, __string_ConcatSmart(sep, s2, ''))$$$ DELIMITER ; -- ----------------------------------------------------- -- function tag_Create2 -- ----------------------------------------------------- DROP function IF EXISTS `tag_Create2`; DELIMITER $$$ create function tag_Create2( type_id_ int unsigned, type_code_ varchar(30) binary, name_ varchar(255), sorter_ int, can_search_ enum('n', 'y'), display_in_object_ enum('n', 'y'), display_in_object_list_ enum('n', 'y'), factor_ double, rating_points_ int unsigned, enabled_ enum('n', 'y'), uofm_pre_ varchar(255), uofm_post_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin declare tag_id int unsigned; set tag_id = __tag_Create( type_id_, type_code_, 'tag', name_, sorter_, can_search_, display_in_object_, display_in_object_list_, factor_, rating_points_, enabled_, uofm_pre_, uofm_post_); -- FORWARD: template_CreateSubs is defined in _12_template set @1 = template_CreateSubs(tag_id); return tag_id; end$$$ DELIMITER ; -- ----------------------------------------------------- -- function tag_UpdateLocal2 -- ----------------------------------------------------- DROP function IF EXISTS `tag_UpdateLocal2`; DELIMITER $$$ create function tag_UpdateLocal2( tag_id_ int unsigned, lang_id_ char(3), name_ varchar(255), uofm_pre_ varchar(255), uofm_post_ varchar(255) ) returns int unsigned not deterministic modifies sql data begin set @1 = __tag_ValidateId(tag_id_); return __tag_UpdateLocal(tag_id_, lang_id_, name_, uofm_pre_, uofm_post_); end$$$ DELIMITER ; -- ----------------------------------------------------- -- View `zzzNodeWorksetV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `zzzNodeWorksetV` ; DROP TABLE IF EXISTS `zzzNodeWorksetV`; CREATE OR REPLACE VIEW `zzzNodeWorksetV` AS select * from zzzNodeWorksetT where connId = connection_id(); -- ----------------------------------------------------- -- View `nodeTypeV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeTypeV` ; DROP TABLE IF EXISTS `nodeTypeV`; CREATE OR REPLACE VIEW nodeTypeV AS select nt.id, ntl.name, nt.code, nt.internalTypeId, nt.forceSinglePhoto, nt.canEditType, nt.canEditNode, nt.canHavePhoto, nt.canHaveRatingPoints, nt.canLinkFrom, nt.canLinkTo, nt.canSearch, nt.displayInObject, nt.displayInObjectList, nt.searchAnd, nt.displayNode, nt.requiredForObject, nt.sorter, ntl.languageId, nt.added, nt.changed from nodeTypeT nt left join languageT l on l.isDefault = 'y' left join nodeTypeTL ntl on nt.id = ntl.id and ntl.languageId = coalesce(user_CurrentLanguage(), l.id); -- ----------------------------------------------------- -- View `nodeTypeVL` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeTypeVL` ; DROP TABLE IF EXISTS `nodeTypeVL`; CREATE OR REPLACE VIEW nodeTypeVL AS select ntl.* from nodeTypeTL ntl; -- ----------------------------------------------------- -- View `userV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `userV` ; DROP TABLE IF EXISTS `userV`; CREATE OR REPLACE VIEW userV AS select u.*, n.added, n.addedUserId, n.addedUserName, n.addedIp, n.changed, n.changedUserId, n.changedUserName, n.changedIp from userT u join _nodeV n on u.id = n.id; -- ----------------------------------------------------- -- View `userOauthV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `userOauthV` ; DROP TABLE IF EXISTS `userOauthV`; CREATE OR REPLACE VIEW userOauthV AS select * from userOauthT; -- ----------------------------------------------------- -- View `allowedNodeLinkCanCreateV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `allowedNodeLinkCanCreateV` ; DROP TABLE IF EXISTS `allowedNodeLinkCanCreateV`; CREATE OR REPLACE VIEW allowedNodeLinkCanCreateV AS select nt1.id srcNodeTypeId, nt2.id dstNodeTypeId from nodeTypeT nt1 join nodeTypeT nt2 on 1=1 where nt1.canLinkFrom = 'y' and nt2.canLinkTo = 'y' and not exists (select 1 from allowedNodeLinkT anl where anl.srcNodeTypeId = nt1.id and anl.dstNodeTypeId = nt2.id); -- ----------------------------------------------------- -- View `tagV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagV` ; DROP TABLE IF EXISTS `tagV`; CREATE OR REPLACE VIEW tagV as select t.id, n.nodeTypeId typeId, n.forceSingleNode, n.isRoot, n.typeCode, n.typeName, n.internalTypeId, n.canEditNode typeCanEdit, n.canHavePhoto typeCanHavePhoto, n.canHaveRatingPoints typeCanHaveRatingPoints, n.canSearch typeCanSearch, n.displayInObject typeDisplayInObject, n.displayInObjectList typeDisplayInObjectList, n.searchAnd typeSearchAnd, n.requiredForObject typeRequiredForObject, n.sorter typeSorter, tl.name, t.sorter, t.canSearch, t.canSearchRaw, t.displayInObject, t.displayInObjectRaw, t.displayInObjectList, t.displayInObjectListRaw, t.factor, t.ratingPoints, t.enabled, a.dataTypeId attributeDataType, a.code attributeCode, a.required, a.sortable, tl.uofmPre, tl.uofmPost, hasgeoroot.n geoRoot, n.languageId, n.added, n.addedUserId, n.addedUserName, n.addedIp, n.changed, n.changedUserId, n.changedUserName, n.changedIp from tagT t join nodeV n on t.id = n.id left join tagTL tl on t.id = tl.id and n.languageId = tl.languageId left join attributeT a on t.id = a.id left join zzzIntsT hasgeoroot on hasgeoroot.n = 1 and exists (select 1 from nodeRootGeoV rootgeo where rootgeo.dstNodeId = n.id); -- ----------------------------------------------------- -- View `tagVL` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagVL` ; DROP TABLE IF EXISTS `tagVL`; CREATE OR REPLACE VIEW tagVL AS select * from tagTL; -- ----------------------------------------------------- -- View `allowedNodeLinkV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `allowedNodeLinkV` ; DROP TABLE IF EXISTS `allowedNodeLinkV`; CREATE OR REPLACE VIEW allowedNodeLinkV AS select * from allowedNodeLinkT; -- ----------------------------------------------------- -- View `searchResultV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchResultV` ; DROP TABLE IF EXISTS `searchResultV`; CREATE OR REPLACE VIEW searchResultV AS select sessionId, nodeId, collapsed, extraObjects, relevancy from searchResultT sr where sr.sessionId = search_CurrentId(); -- ----------------------------------------------------- -- View `searchCriterionV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchCriterionV` ; DROP TABLE IF EXISTS `searchCriterionV`; CREATE OR REPLACE VIEW searchCriterionV AS select sc.nodeId from searchCriterionT sc where sc.sessionId = search_CurrentId(); -- ----------------------------------------------------- -- View `searchCriterionNumericV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchCriterionNumericV` ; DROP TABLE IF EXISTS `searchCriterionNumericV`; CREATE OR REPLACE VIEW searchCriterionNumericV AS select sc.nodeId, scn.valueLow, scn.valueHigh from searchCriterionNumericT scn join searchCriterionT sc on scn.searchCriterionId = sc.id where sc.sessionId = search_CurrentId(); -- ----------------------------------------------------- -- View `searchCriterionDatetimeV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchCriterionDatetimeV` ; DROP TABLE IF EXISTS `searchCriterionDatetimeV`; CREATE OR REPLACE VIEW searchCriterionDatetimeV AS select sc.nodeId, scd.valueLow, scd.valueHigh from searchCriterionDatetimeT scd join searchCriterionT sc on scd.searchCriterionId = sc.id where sc.sessionId = search_CurrentId(); -- ----------------------------------------------------- -- View `nodeV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeV` ; DROP TABLE IF EXISTS `nodeV`; CREATE OR REPLACE VIEW nodeV AS select n.id, n.nodeTypeId, n.forceSingleNode, n.name, n.isRoot, nt.name typeName, nt.code typeCode, nt.internalTypeId, nt.canEditType, nt.canEditNode, nt.canHavePhoto, nt.canHaveRatingPoints, nt.canLinkFrom, nt.canLinkTo, nt.canSearch, nt.displayInObject, nt.displayInObjectList, nt.searchAnd, nt.requiredForObject, nt.sorter, nt.languageId, n.added, n.addedUserId, n.addedUserName, n.addedIp, n.changed, n.changedUserId, n.changedUserName, n.changedIp from _nodeV n join nodeTypeV nt on n.nodeTypeId = nt.id; -- ----------------------------------------------------- -- View `nodeLinkV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeLinkV` ; DROP TABLE IF EXISTS `nodeLinkV`; CREATE OR REPLACE VIEW nodeLinkV AS select nlt.id nodeLinkTypeId, nlt.code, nlt.isDefault, nl.srcNodeId, nl.dstNodeId, nl.metric, nl.added from nodeLinkT nl join nodeLinkTypeT nlt on nl.nodeLinkTypeId = nlt.id; -- ----------------------------------------------------- -- View `nodeLinkOwnsV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeLinkOwnsV` ; DROP TABLE IF EXISTS `nodeLinkOwnsV`; -- ugly hack here - nodeLinkTypeId hardcoded! CREATE OR REPLACE VIEW nodeLinkOwnsV AS select nl.nodeLinkTypeId, nl.srcNodeId, nl.dstNodeId, nl.metric, nl.added from nodeLinkT nl where nl.nodeLinkTypeId = 1 and nl.metric > 0; -- ----------------------------------------------------- -- View `allowedNodeLinkByNodeV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `allowedNodeLinkByNodeV` ; DROP TABLE IF EXISTS `allowedNodeLinkByNodeV`; CREATE OR REPLACE VIEW allowedNodeLinkByNodeV AS select srcNode.id srcNodeId, srcNode.nodeTypeId srcNodeTypeId, srcNode.displayNode srcDisplayNode, dstNode.id dstNodeId, dstNode.nodeTypeId dstNodeTypeId, dstNode.displayNode dstDisplayNode, anl.essential, anl.singleSrc, anl.added, anl.changed from allowedNodeLinkT anl join nodeT srcNode on anl.srcNodeTypeId = srcNode.nodeTypeId join nodeT dstNode on anl.dstNodeTypeId = dstNode.nodeTypeId; -- ----------------------------------------------------- -- View `nodeRootLinkV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeRootLinkV` ; DROP TABLE IF EXISTS `nodeRootLinkV`; CREATE OR REPLACE VIEW nodeRootLinkV AS select rootnode.id, rootnode.nodeTypeId, rootnode.forceSingleNode, rootnode.name, rootnode.isRoot, rootnode.displayNode, rootnodetype.code typeCode, rootnodetype.canSearch typeCanSearch, rootnodetype.displayInObject typeDisplayInObject, rootnodetype.displayInObjectList typeDisplayInObjectList, rootnodetype.requiredForObject typeRequiredForObject, rootnodetype.sorter typeSorter, rootnode.added, rootnode.addedUserId, rootnode.addedUserName, rootnode.addedIp, rootnode.changed, rootnode.changedUserId, rootnode.changedUserName, rootnode.changedIp, rootlink.nodeLinkTypeId, rootlink.dstNodeId, rootlink.metric from nodeT rootnode join nodeTypeT rootnodetype on rootnode.nodeTypeId = rootnodetype.id join nodeLinkOwnsV rootlink on rootnode.id = rootlink.srcNodeId where rootnode.isRoot = 'y'; -- ----------------------------------------------------- -- View `objectV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `objectV` ; DROP TABLE IF EXISTS `objectV`; CREATE OR REPLACE VIEW objectV AS select o.id, o.address, o.description, o.statusId, osl.name statusName, os.public, os.userEditable, os.userDraftable, c.latitude, c.longitude, o.rating, o.noteForModerator, o.noteForUser, o.alias, n.languageId, n.added, n.addedUserId, n.addedUserName, n.addedIp, n.changed, n.changedUserId, n.changedUserName, n.changedIp from objectT o join nodeV n on o.id = n.id join objectStatusT os on o.statusId = os.id left join objectStatusTL osl on o.statusId = osl.id and n.languageId = osl.languageId left join coordT c on o.id = c.nodeId; -- ----------------------------------------------------- -- View `objectForUserV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `objectForUserV` ; DROP TABLE IF EXISTS `objectForUserV`; CREATE OR REPLACE VIEW objectForUserV AS select o.* from objectV o where exists ( select 1 from nodeLinkOwnsV nlo where nlo.srcNodeId = user_CurrentId() and nlo.dstNodeId = o.id); -- ----------------------------------------------------- -- View `_nodeRecommendLinkV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `_nodeRecommendLinkV` ; DROP TABLE IF EXISTS `_nodeRecommendLinkV`; CREATE OR REPLACE VIEW _nodeRecommendLinkV as select nlt.id nodeLinkTypeId, nlt.code nodeLinkTypeCode, srcnode.id srcNodeId, srcnode.nodeTypeId srcNodeTypeId, srclink.metric srcMetric, minsrclink.metric srcMin, srclink.srcNodeId viaNodeId, dstnode.id dstNodeId, dstnode.nodeTypeId dstNodeTypeId, dstlink.metric dstMetric, mindstlink.metric dstMin, anl.essential, nolink.metric existingMetric, i.n singleSrcExists from nodeT srcnode join nodeLinkTypeT nlt on 1=1 join nodeLinkT srclink on srcnode.id = srclink.dstNodeId and srclink.metric > 0 and nlt.id = srclink.nodeLinkTypeId -- join nodeT nn on srclink.srcNodeId = nn.id join nodeLinkT dstlink on srclink.srcNodeId = dstlink.srcNodeId and dstlink.metric > 0 and dstlink.nodeLinkTypeId = nlt.id join nodeT dstnode on dstlink.dstNodeId = dstnode.id and srcnode.id != dstnode.id join allowedNodeLinkT anl on srcnode.nodeTypeId = anl.srcNodeTypeId and dstnode.nodeTypeId = anl.dstNodeTypeId left join nodeLinkT minsrclink on nlt.id = minsrclink.nodeLinkTypeId and srcnode.id = minsrclink.dstNodeId and minsrclink.metric > 0 and minsrclink.metric < srclink.metric left join nodeLinkT mindstlink on nlt.id = mindstlink.nodeLinkTypeId and dstnode.id = mindstlink.dstNodeId and minsrclink.srcNodeId = mindstlink.srcNodeId and mindstlink.metric > 0 and mindstlink.metric < dstlink.metric left join nodeLinkT nolink on srcnode.id = nolink.srcNodeId and dstnode.id = nolink.dstNodeId and nolink.nodeLinkTypeId = nlt.id left join zzzIntsT i on i.n = 1 and anl.singleSrc = 'y' and exists( select 1 from nodeLinkT exilink join nodeT exinode on exilink.srcNodeId = exinode.id where exilink.nodeLinkTypeId = nlt.id and exilink.dstNodeId = dstnode.id and exilink.metric > 0 and exinode.nodeTypeId = srcnode.nodeTypeId); -- ----------------------------------------------------- -- View `nodeRecommendLinkV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeRecommendLinkV` ; DROP TABLE IF EXISTS `nodeRecommendLinkV`; CREATE OR REPLACE VIEW nodeRecommendLinkV as select nrl.nodeLinkTypeId, nrl.nodeLinkTypeCode, nrl.srcNodeId, nrl.srcNodeTypeId, 1 srcMetric, 1 viaNodeId, nrl.dstNodeId, nrl.dstNodeTypeId, 1 dstMetric, nrl.essential, nrl.singleSrc from _nodeRecommendLink4V nrl where nrl.canLink = 1; -- ----------------------------------------------------- -- View `tagForAdminV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagForAdminV` ; DROP TABLE IF EXISTS `tagForAdminV`; create OR REPLACE view tagForAdminV as select t.*, tc.tagNames, tc.tagNamesSearch, tc.tagNamesFullSearch, ac.attributeNames, ac.attributeNamesSearch from tagV t left join tagCacheT tc on t.id = tc.id left join attributeCacheT ac on t.id = ac.id; -- ----------------------------------------------------- -- View `nodeAncestryV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeAncestryV` ; DROP TABLE IF EXISTS `nodeAncestryV`; create OR REPLACE view nodeAncestryV as select na.id nodeId, na.tagNames tagName from nodeAncestryT na join languageT l on isDefault = 'y' where na.languageId = coalesce(user_CurrentLanguage(), l.id); -- ----------------------------------------------------- -- View `searchResultTagV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchResultTagV` ; DROP TABLE IF EXISTS `searchResultTagV`; create OR REPLACE view searchResultTagV as select t.*, sr.* from tagV t join searchResultV sr on t.id = sr.nodeId; -- ----------------------------------------------------- -- View `searchResultObjectV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchResultObjectV` ; DROP TABLE IF EXISTS `searchResultObjectV`; create OR REPLACE view searchResultObjectV as select o.*, sr.sessionId, sr.relevancy, sc.nodeId criterionObjectId from objectV o join searchResultV sr on o.id = sr.nodeId left join searchCriterionT sc on o.id = sc.nodeId and sr.sessionId = sc.sessionId where o.public = 'y'; -- ----------------------------------------------------- -- View `tagChildV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagChildV` ; DROP TABLE IF EXISTS `tagChildV`; create OR REPLACE view tagChildV as select src.id srcId, src.typeId srcTypeId, src.typeCode srcTypeCode, src.typeName srcTypeName, src.internalTypeId srcInternalTypeId, src.typeCanEdit srcCanEdit, src.typeCanSearch srcTypeCanSearch, src.typeDisplayInObject srcTypeDisplayInObject, src.typeDisplayInObjectList srcTypeDisplayInObjectList, src.typeSorter srcTypeSorter, src.name srcName, src.sorter srcSorter, src.canSearch srcCanSearch, src.canSearchRaw srcCanSearchRaw, src.displayInObject srcDisplayInObject, src.displayInObjectRaw srcDisplayInObjectRaw, src.displayInObjectList srcDisplayInObjectList, src.displayInObjectListRaw srcDisplayInObjectListRaw, src.factor srcFactor, src.ratingPoints srcRatingPoints, src.enabled srcEnabled, src.attributeDataType srcAttributeDataType, src.required srcRequired, dst.id dstId, dst.typeId dstTypeId, dst.typeCode dstTypeCode, dst.typeName dstTypeName, dst.internalTypeId dstInternalTypeId, dst.typeCanEdit dstCanEdit, dst.typeCanSearch dstTypeCanSearch, dst.typeDisplayInObject dstTypeDisplayInObject, dst.typeDisplayInObjectList dstTypeDisplayInObjectList, dst.typeSorter dstTypeSorter, dst.name dstName, dst.sorter dstSorter, dst.canSearch dstCanSearch, dst.canSearchRaw dstCanSearchRaw, dst.displayInObject dstDisplayInObject, dst.displayInObjectRaw dstDisplayInObjectRaw, dst.displayInObjectList dstDisplayInObjectList, dst.displayInObjectListRaw dstDisplayInObjectListRaw, dst.factor dstFactor, dst.ratingPoints dstRatingPoints, dst.enabled dstEnabled, dst.attributeDataType dstAttributeDataType, dst.required dstRequired, src.isRoot srcIsRoot, src.geoRoot srcGeoRoot, na.tagNames dstAncestry, nlct.midNodeId midId from tagV src join nodeLinkOwnsV nlo on src.id = nlo.srcNodeId and nlo.metric = 1 join tagV dst on nlo.dstNodeId = dst.id left join nodeLinkChainTransitionV nlct on nlo.nodeLinkTypeId = nlct.nodeLinkTypeId and src.id = nlct.srcNodeId and dst.id = nlct.dstNodeId left join nodeLinkChainTransitionV exinlct on nlo.nodeLinkTypeId = exinlct.nodeLinkTypeId and src.id = exinlct.srcNodeId and dst.id = exinlct.dstNodeId and nlct.midNodeId > exinlct.midNodeId left join nodeAncestryT na on dst.id = na.id and dst.languageId = na.languageId where src.isRoot = 'n' and exinlct.midNodeId is null; -- ----------------------------------------------------- -- View `tagRecommendChildV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagRecommendChildV` ; DROP TABLE IF EXISTS `tagRecommendChildV`; create OR REPLACE view tagRecommendChildV as select src.id srcId, src.typeId srcTypeId, src.typeCode srcTypeCode, src.typeName srcTypeName, src.internalTypeId srcInternalTypeId, src.typeCanEdit srcCanEdit, src.typeCanSearch srcTypeCanSearch, src.typeDisplayInObject srcTypeDisplayInObject, src.typeDisplayInObjectList srcTypeDisplayInObjectList, src.typeSorter srcTypeSorter, src.name srcName, src.sorter srcSorter, src.canSearch srcCanSearch, src.canSearchRaw srcCanSearchRaw, src.displayInObject srcDisplayInObject, src.displayInObjectRaw srcDisplayInObjectRaw, src.displayInObjectList srcDisplayInObjectList, src.displayInObjectListRaw srcDisplayInObjectListRaw, src.factor srcFactor, src.ratingPoints srcRatingPoints, src.enabled srcEnabled, src.attributeDataType srcAttributeDataType, src.required srcRequired, dst.id dstId, dst.typeId dstTypeId, dst.typeCode dstTypeCode, dst.typeName dstTypeName, dst.internalTypeId dstInternalTypeId, dst.typeCanEdit dstCanEdit, dst.typeCanSearch dstTypeCanSearch, dst.typeDisplayInObject dstTypeDisplayInObject, dst.typeDisplayInObjectList dstTypeDisplayInObjectList, dst.typeSorter dstTypeSorter, dst.name dstName, dst.sorter dstSorter, dst.canSearch dstCanSearch, dst.canSearchRaw dstCanSearchRaw, dst.displayInObject dstDisplayInObject, dst.displayInObjectRaw dstDisplayInObjectRaw, dst.displayInObjectList dstDisplayInObjectList, dst.displayInObjectListRaw dstDisplayInObjectListRaw, dst.factor dstFactor, dst.ratingPoints dstRatingPoints, dst.enabled dstEnabled, dst.attributeDataType dstAttributeDataType, dst.required dstRequired, src.isRoot srcIsRoot, src.geoRoot srcGeoRoot, na.tagNames dstAncestry, nrl.srcMetric, nrl.dstMetric, nrl.essential from tagV src left join nodeRecommendLinkV nrl on src.id = nrl.srcNodeId left join tagV dst on nrl.dstNodeId = dst.id left join nodeAncestryT na on dst.id = na.id and dst.languageId = na.languageId where src.isRoot = 'n'; -- ----------------------------------------------------- -- View `tagParentV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagParentV` ; DROP TABLE IF EXISTS `tagParentV`; create OR REPLACE view tagParentV as select src.id srcId, src.typeId srcTypeId, src.typeCode srcTypeCode, src.typeName srcTypeName, src.internalTypeId srcInternalTypeId, src.typeCanEdit srcCanEdit, src.typeCanSearch srcTypeCanSearch, src.typeDisplayInObject srcTypeDisplayInObject, src.typeDisplayInObjectList srcTypeDisplayInObjectList, src.typeSorter srcTypeSorter, src.name srcName, src.sorter srcSorter, src.canSearch srcCanSearch, src.canSearchRaw srcCanSearchRaw, src.displayInObject srcDisplayInObject, src.displayInObjectRaw srcDisplayInObjectRaw, src.displayInObjectList srcDisplayInObjectList, src.displayInObjectListRaw srcDisplayInObjectListRaw, src.factor srcFactor, src.ratingPoints srcRatingPoints, src.enabled srcEnabled, src.attributeDataType srcAttributeDataType, src.required srcRequired, dst.id dstId, dst.typeId dstTypeId, dst.typeCode dstTypeCode, dst.typeName dstTypeName, dst.internalTypeId dstInternalTypeId, dst.typeCanEdit dstCanEdit, dst.typeCanSearch dstTypeCanSearch, dst.typeDisplayInObject dstTypeDisplayInObject, dst.typeDisplayInObjectList dstTypeDisplayInObjectList, dst.typeSorter dstTypeSorter, dst.name dstName, dst.sorter dstSorter, dst.canSearch dstCanSearch, dst.canSearchRaw dstCanSearchRaw, dst.displayInObject dstDisplayInObject, dst.displayInObjectRaw dstDisplayInObjectRaw, dst.displayInObjectList dstDisplayInObjectList, dst.displayInObjectListRaw dstDisplayInObjectListRaw, dst.factor dstFactor, dst.ratingPoints dstRatingPoints, dst.enabled dstEnabled, dst.attributeDataType dstAttributeDataType, dst.required dstRequired, src.isRoot srcIsRoot, src.geoRoot srcGeoRoot, na.tagNames srcAncestry, nlct.midNodeId midId from tagV dst join nodeLinkOwnsV nlo on dst.id = nlo.dstNodeId and nlo.metric = 1 join tagV src on nlo.srcNodeId = src.id left join nodeLinkChainTransitionV nlct on nlo.nodeLinkTypeId = nlct.nodeLinkTypeId and src.id = nlct.srcNodeId and dst.id = nlct.dstNodeId left join nodeLinkChainTransitionV exinlct on nlo.nodeLinkTypeId = exinlct.nodeLinkTypeId and src.id = exinlct.srcNodeId and dst.id = exinlct.dstNodeId and nlct.midNodeId > exinlct.midNodeId left join nodeAncestryT na on src.id = na.id and src.languageId = na.languageId where src.isRoot = 'n' and exinlct.midNodeId is null; -- ----------------------------------------------------- -- View `tagRecommendParentV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagRecommendParentV` ; DROP TABLE IF EXISTS `tagRecommendParentV`; create OR REPLACE view tagRecommendParentV as select src.id srcId, src.typeId srcTypeId, src.typeCode srcTypeCode, src.typeName srcTypeName, src.internalTypeId srcInternalTypeId, src.typeCanEdit srcCanEdit, src.typeCanSearch srcTypeCanSearch, src.typeDisplayInObject srcTypeDisplayInObject, src.typeDisplayInObjectList srcTypeDisplayInObjectList, src.typeSorter srcTypeSorter, src.name srcName, src.sorter srcSorter, src.canSearch srcCanSearch, src.canSearchRaw srcCanSearchRaw, src.displayInObject srcDisplayInObject, src.displayInObjectRaw srcDisplayInObjectRaw, src.displayInObjectList srcDisplayInObjectList, src.displayInObjectListRaw srcDisplayInObjectListRaw, src.factor srcFactor, src.ratingPoints srcRatingPoints, src.enabled srcEnabled, src.attributeDataType srcAttributeDataType, src.required srcRequired, dst.id dstId, dst.typeId dstTypeId, dst.typeCode dstTypeCode, dst.typeName dstTypeName, dst.internalTypeId dstInternalTypeId, dst.typeCanEdit dstCanEdit, dst.typeCanSearch dstTypeCanSearch, dst.typeDisplayInObject dstTypeDisplayInObject, dst.typeDisplayInObjectList dstTypeDisplayInObjectList, dst.typeSorter dstTypeSorter, dst.name dstName, dst.sorter dstSorter, dst.canSearch dstCanSearch, dst.canSearchRaw dstCanSearchRaw, dst.displayInObject dstDisplayInObject, dst.displayInObjectRaw dstDisplayInObjectRaw, dst.displayInObjectList dstDisplayInObjectList, dst.displayInObjectListRaw dstDisplayInObjectListRaw, dst.factor dstFactor, dst.ratingPoints dstRatingPoints, dst.enabled dstEnabled, dst.attributeDataType dstAttributeDataType, dst.required dstRequired, src.isRoot srcIsRoot, src.geoRoot srcGeoRoot, na.tagNames srcAncestry, nrl.srcMetric, nrl.dstMetric, nrl.essential from tagV dst left join nodeRecommendLinkV nrl on dst.id = nrl.dstNodeId left join tagV src on nrl.srcNodeId = src.id left join nodeAncestryT na on src.id = na.id and src.languageId = na.languageId where src.isRoot = 'n'; -- ----------------------------------------------------- -- View `objectStatusV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `objectStatusV` ; DROP TABLE IF EXISTS `objectStatusV`; CREATE OR REPLACE VIEW objectStatusV AS select os.id, osl.name, os.public, os.userEditable, os.userDraftable, os.sorter from objectStatusT os left join languageT l on l.isDefault = 'y' left join objectStatusTL osl ON osl.id = os.id and osl.languageId = coalesce(user_CurrentLanguage(), l.id); -- ----------------------------------------------------- -- View `attributeV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `attributeV` ; DROP TABLE IF EXISTS `attributeV`; CREATE OR REPLACE VIEW attributeV as -- extra fields to be joined to tagV select a.id, an.decimalMin, an.decimalMax, an.decimalRound, ad.datetimeStorageId, ax.textIsLong from attributeT a left join attributeNumericT an on a.id = an.id left join attributeDatetimeT ad on a.id = ad.id left join attributeTextT ax on a.id = ax.id; -- ----------------------------------------------------- -- View `_nodeRecommendLink2V` -- ----------------------------------------------------- DROP VIEW IF EXISTS `_nodeRecommendLink2V` ; DROP TABLE IF EXISTS `_nodeRecommendLink2V`; CREATE OR REPLACE VIEW _nodeRecommendLink2V as select nlt.id nodeLinkTypeId, nlt.code nodeLinkTypeCode, srcnode.id srcNodeId, srcnode.nodeTypeId srcNodeTypeId, dstnode.id dstNodeId, dstnode.nodeTypeId dstNodeTypeId, anl.essential, anl.singleSrc, islinked.n linked, canlink.n canLink from nodeT srcnode join nodeLinkTypeT nlt on nlt.isDefault = 'y' join allowedNodeLinkT anl on srcnode.nodeTypeId = anl.srcNodeTypeId join nodeT dstnode on anl.dstNodeTypeId = dstnode.nodeTypeId and srcnode.id != dstnode.id left join nodeLinkT linksingle on linksingle.nodeLinkTypeId = nlt.id and linksingle.srcNodeId = srcnode.id and linksingle.dstNodeId = dstnode.id and anl.singleSrc = 'y' left join nodeLinkT linkmult on linkmult.nodeLinkTypeId = nlt.id and linkmult.srcNodeId = srcnode.id and linkmult.dstNodeId = dstnode.id and linkmult.metric = 1 and anl.singleSrc = 'n' left join zzzIntsT islinked on islinked.n = 1 and (linksingle.metric is not null or linkmult.metric is not null) left join zzzIntsT canlink1 on canlink1.n = 1 and anl.singleSrc = 'n' and linkmult.metric is null and (select count(distinct n1.nodeTypeId) from nodeLinkT nl1 join nodeT n1 on nl1.srcNodeId = n1.id where nl1.nodeLinkTypeId = nlt.id and nl1.dstNodeId = srcnode.id and nl1.metric = 1) = (select count(distinct n2.nodeTypeId) from nodeLinkT nl21 join nodeT n2 on nl21.srcNodeId = n2.id join nodeLinkT nl22 on n2.id = nl22.srcNodeId where nl21.nodeLinkTypeId = nlt.id and nl21.dstNodeId = srcnode.id and nl21.metric = 1 and nl22.nodeLinkTypeId = nlt.id and nl22.dstNodeId = dstnode.id and nl22.metric = 1) left join zzzIntsT canlink3 on canlink3.n = 1 and anl.singleSrc = 'y' and linksingle.metric is null and not exists( select 1 from nodeLinkT nl3 join nodeT n3 on nl3.srcNodeId = n3.id where nl3.nodeLinkTypeId = nlt.id and nl3.dstNodeId = dstnode.id and nl3.metric > 0 and n3.nodeTypeId = srcnode.nodeTypeId) and exists(select 1 from nodeLinkT nl41 join nodeLinkT nl42 on nl41.nodeLinkTypeId = nl42.nodeLinkTypeId and nl41.srcNodeId = nl42.srcNodeId join nodeT n4 on nl41.srcNodeId = n4.id join allowedNodeLinkT anl4 on n4.nodeTypeId = anl4.srcNodeTypeId left join nodeLinkT exilink41 on nl41.nodeLinkTypeId = exilink41.nodeLinkTypeId and nl41.dstNodeId = exilink41.dstNodeId and exilink41.metric > 0 and exilink41.metric < nl41.metric left join nodeLinkT exilink42 on nl42.nodeLinkTypeId = exilink42.nodeLinkTypeId and nl42.dstNodeId = exilink42.dstNodeId and exilink41.srcNodeId = exilink42.srcNodeId and exilink42.metric > 0 and exilink42.metric < nl42.metric where nl41.nodeLinkTypeId = nlt.id and nl41.dstNodeId = srcnode.id and nl41.metric > 0 and nl42.dstNodeId = dstnode.id and nl42.metric > 0 and n4.isRoot = 'n' and (exilink41.metric is null or exilink42.metric is null) and anl4.dstNodeTypeId = dstnode.nodeTypeId and anl4.singleSrc = anl.singleSrc) left join zzzIntsT canlink4 on canlink4.n = 1 and anl.singleSrc = 'y' and linksingle.metric is null and canlink3.n is null and exists(select 1 from nodeLinkT nl51 join nodeLinkT nl52 on nl51.nodeLinkTypeId = nl52.nodeLinkTypeId and nl51.srcNodeId = nl52.srcNodeId where nl51.nodeLinkTypeId = nlt.id and nl51.dstNodeId = srcnode.id and nl51.metric = 1 and nl52.dstNodeId = dstnode.id and nl52.metric = 1) left join zzzIntsT canlink on canlink.n = 1 and (canlink1.n = 1 or canlink3.n = 1 or canlink4.n = 1) left join templateT srcTemplate on srcnode.id = srcTemplate.dstNodeId left join templateT dstTemplate on dstnode.id = dstTemplate.dstNodeId where srcTemplate.dstNodeId is null and dstTemplate.dstNodeId is null and (canlink.n = 1 or islinked.n = 1); -- ----------------------------------------------------- -- View `searchTagV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchTagV` ; DROP TABLE IF EXISTS `searchTagV`; create OR REPLACE view searchTagV as select t.*, sc.nodeId criterionId, scn.valueLow valueLowNumeric, scn.valueHigh valueHighNumeric, scd.valueLow valueLowDatetime, scd.valueHigh valueHighDatetime, sr.nodeId resultId, sr.collapsed, sr.extraObjects from tagV t left join searchCriterionV sc on t.id = sc.nodeId left join searchCriterionNumericV scn on t.id = scn.nodeId left join searchCriterionDatetimeV scd on t.id = scd.nodeId left join searchResultV sr on t.id = sr.nodeId; -- ----------------------------------------------------- -- View `attributeDatetimeStorageFormatV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `attributeDatetimeStorageFormatV` ; DROP TABLE IF EXISTS `attributeDatetimeStorageFormatV`; CREATE OR REPLACE VIEW attributeDatetimeStorageFormatV as -- more extra fields to be joined to attributeV (and tagV) select ad.id, adfl.languageId, ad.datetimeStorageId, adf.storageFormat, adfl.name, adfl.outputFormat, adfl.outputFormatJs from attributeDatetimeT ad join attributeDatetimeFormatT adf on ad.datetimeStorageId = adf.id join attributeDatetimeFormatTL adfl on adf.id = adfl.id; -- ----------------------------------------------------- -- View `objectWithTagV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `objectWithTagV` ; DROP TABLE IF EXISTS `objectWithTagV`; create OR REPLACE view objectWithTagV as select t.id srcId, t.typeId srcTypeId, t.typeCode srcTypeCode, t.typeName srcTypeName, t.internalTypeId srcInternalTypeId, t.typeCanEdit srcCanEdit, t.typeCanSearch srcTypeCanSearch, t.typeDisplayInObject srcTypeDisplayInObject, t.typeDisplayInObjectList srcTypeDisplayInObjectList, t.typeSorter srcTypeSorter, t.name srcName, t.sorter srcSorter, t.canSearch srcCanSearch, t.canSearchRaw srcCanSearchRaw, t.displayInObject srcDisplayInObject, t.displayInObjectRaw srcDisplayInObjectRaw, t.displayInObjectList srcDisplayInObjectList, t.displayInObjectListRaw srcDisplayInObjectListRaw, t.factor srcFactor, t.ratingPoints srcRatingPoints, t.enabled srcEnabled, t.attributeDataType srcAttributeDataType, t.attributeCode srcAttributeCode, t.required srcRequired, t.sortable srcSortable, t.uofmPre srcUofmPre, t.uofmPost srcUofmPost, t.languageId srcLanguageId, t.isRoot srcIsRoot, t.geoRoot srcGeoRoot, a.decimalMin srcDecimalMin, a.decimalMax srcDecimalMax, a.decimalRound srcDecimalRound, a.datetimeStorageId srcDatetimeStorageId, a.textIsLong srcTextIsLong, adsf.storageFormat srcDatetimeStorageFormat, adsf.name srcDatetimeName, adsf.outputFormat srcDatetimeOutputFormat, adsf.outputFormatJs srcDatetimeOutputFormatJs, avn.value srcNumericValue, avd.value srcDatetimeValue, avt.value srcTextValue, nrl.linked, nrl.canLink, o.id objectId from objectT o join _nodeRecommendLink4V nrl on o.id = nrl.dstNodeId join tagV t on nrl.srcNodeId = t.id left join attributeV a on t.id = a.id left join attributeDatetimeStorageFormatV adsf on a.id = adsf.id and t.languageId = adsf.languageId left join attributeValueNumericT avn on a.id = avn.attributeId and o.id = avn.objectId left join attributeValueDatetimeT avd on a.id = avd.attributeId and o.id = avd.objectId left join attributeValueTextT avt on a.id = avt.attributeId and o.id = avt.objectId and t.languageId = avt.languageId; -- ----------------------------------------------------- -- View `nodeRootGeoV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeRootGeoV` ; DROP TABLE IF EXISTS `nodeRootGeoV`; create OR REPLACE view nodeRootGeoV as select rootlink.id, rootlink.nodeTypeId, rootlink.forceSingleNode, rootlink.name, rootlink.isRoot, rootlink.displayNode, rootlink.typeCode, rootlink.typeCanSearch, rootlink.typeDisplayInObject, rootlink.typeDisplayInObjectList, rootlink.typeRequiredForObject, rootlink.typeSorter, rootlink.added, rootlink.addedUserId, rootlink.addedUserName, rootlink.addedIp, rootlink.changed, rootlink.changedUserId, rootlink.changedUserName, rootlink.changedIp, rootlink.dstNodeId, rootlink.metric from nodeRootLinkV rootlink where rootlink.typeCode = 'rootgeo'; -- ----------------------------------------------------- -- View `attributeDatetimeFormatV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `attributeDatetimeFormatV` ; DROP TABLE IF EXISTS `attributeDatetimeFormatV`; create OR REPLACE view attributeDatetimeFormatV as -- to be used as list of available datetime storage formats select adf.id, adfl.name, adf.storageFormat, adfl.outputFormat, adfl.outputFormatJs, adf.sorter, adfl.languageId, adf.added, adf.changed from attributeDatetimeFormatT adf left join languageT l on l.isDefault = 'y' left join attributeDatetimeFormatTL adfl on adf.id = adfl.id and adfl.languageId = coalesce(user_CurrentLanguage(), l.id); -- ----------------------------------------------------- -- View `imageV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `imageV` ; DROP TABLE IF EXISTS `imageV`; create OR REPLACE view imageV as select img.id, img.id imageId, img.nodeId, img.forceSinglePhoto, img.name, img.filenameOriginal, img.filenameFs, img.display, img.sorter, img.imageTypeId, img.videoType, img.url, img.extraId, img.added, img.addedUserId, img.addedUserName, img.addedIp, img.changed, img.changedUserId, img.changedUserName, img.changedIp from imageT img; -- ----------------------------------------------------- -- View `templateV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `templateV` ; DROP TABLE IF EXISTS `templateV`; create OR REPLACE view templateV as select node.id nodeId, tmpl.srcNodeTypeId, tmpl.added from nodeT node left join templateT tmpl on node.id = tmpl.dstNodeId; -- ----------------------------------------------------- -- View `_nodeRecommendLink3V` -- ----------------------------------------------------- DROP VIEW IF EXISTS `_nodeRecommendLink3V` ; DROP TABLE IF EXISTS `_nodeRecommendLink3V`; CREATE OR REPLACE VIEW _nodeRecommendLink3V as select nlt.id nodeLinkTypeId, nlt.code nodeLinkTypeCode, srcnode.id srcNodeId, srcnode.nodeTypeId srcNodeTypeId, dstnode.id dstNodeId, dstnode.nodeTypeId dstNodeTypeId, anl.essential, anl.singleSrc, link.metric linked, canlink.n canLink from nodeT srcnode join nodeLinkTypeT nlt on nlt.isDefault = 'y' join allowedNodeLinkT anl on srcnode.nodeTypeId = anl.srcNodeTypeId join nodeT dstnode on anl.dstNodeTypeId = dstnode.nodeTypeId and srcnode.id != dstnode.id left join nodeLinkT link on nlt.id = link.nodeLinkTypeId and srcnode.id = link.srcNodeId and dstnode.id = link.dstNodeId and link.metric = 1 left join zzzIntsT canlink1 on canlink1.n = 1 and link.metric is null and anl.singleSrc = 'n' and (select count(distinct n1.nodeTypeId) from nodeLinkT nl1 join nodeT n1 on nl1.srcNodeId = n1.id where nl1.nodeLinkTypeId = nlt.id and nl1.dstNodeId = srcnode.id and nl1.metric = 1) = (select count(distinct n2.nodeTypeId) from nodeLinkT nl21 join nodeT n2 on nl21.srcNodeId = n2.id join nodeLinkT nl22 on n2.id = nl22.srcNodeId where nl21.nodeLinkTypeId = nlt.id and nl21.dstNodeId = srcnode.id and nl21.metric = 1 and nl22.nodeLinkTypeId = nlt.id and nl22.dstNodeId = dstnode.id and nl22.metric = 1) left join zzzIntsT canlink3 on canlink3.n = 1 and link.metric is null and anl.singleSrc = 'y' -- check if already linked to the node of the same type and not exists( select 1 from nodeLinkT nl3 join nodeT n3 on nl3.srcNodeId = n3.id where nl3.nodeLinkTypeId = nlt.id and nl3.dstNodeId = dstnode.id and nl3.metric = 1 and n3.nodeTypeId = srcnode.nodeTypeId) -- check if srcnode.id and dstnode.id have common parent node, with special conditions and exists( select 1 from nodeLinkT nl41 join nodeLinkT nl42 on nl41.nodeLinkTypeId = nl42.nodeLinkTypeId and nl41.srcNodeId = nl42.srcNodeId join nodeT n4 on nl41.srcNodeId = n4.id join allowedNodeLinkT anl4 on n4.nodeTypeId = anl4.srcNodeTypeId where nl41.nodeLinkTypeId = nlt.id and nl41.dstNodeId = srcnode.id and nl41.metric = 1 and nl42.dstNodeId = dstnode.id and nl42.metric = 1 and (anl4.essential = 'y' -- if the link is not essential make sure we are not stepping over the srcnode.id or not exists( select 1 from nodeLinkT exilink41 join nodeLinkT exilink42 on exilink41.nodeLinkTypeId = exilink42.nodeLinkTypeId and exilink41.dstNodeId = exilink42.srcNodeId where nl41.nodeLinkTypeId = exilink41.nodeLinkTypeId and nl41.srcNodeId = exilink41.srcNodeId and nl41.dstNodeId != exilink41.dstNodeId and exilink42.dstNodeId = nl41.dstNodeId)) and anl4.dstNodeTypeId = dstnode.nodeTypeId and anl4.singleSrc = anl.singleSrc -- and make sure we use the nearest common parent, i.e. there are no more common parents up the tree and not exists( select 1 from nodeLinkT exilink43 join nodeLinkT exilink44 on exilink43.nodeLinkTypeId = exilink44.nodeLinkTypeId and exilink43.dstNodeId = exilink44.srcNodeId where nl42.nodeLinkTypeId = exilink43.nodeLinkTypeId and nl42.srcNodeId = exilink43.srcNodeId and nl42.dstNodeId != exilink43.dstNodeId and exilink44.dstNodeId = nl42.dstNodeId)) left join zzzIntsT canlink on canlink.n = 1 and (canlink1.n = 1 or canlink3.n = 1) left join templateT srcTemplate on srcnode.id = srcTemplate.dstNodeId left join templateT dstTemplate on dstnode.id = dstTemplate.dstNodeId where srcTemplate.dstNodeId is null and dstTemplate.dstNodeId is null and (canlink.n = 1 or link.metric = 1); -- ----------------------------------------------------- -- View `nodeLinkChainV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeLinkChainV` ; DROP TABLE IF EXISTS `nodeLinkChainV`; create OR REPLACE view nodeLinkChainV as select chain1.nodeLinkTypeId, chain1.srcNodeId, chain1.dstNodeId midNodeId, chain2.dstNodeId, chain1.metric metric1, chain2.metric metric2, chain1.added added1, chain2.added added2 from nodeLinkT chain1 join nodeLinkT chain2 on chain1.nodeLinkTypeId = chain2.nodeLinkTypeId and chain1.dstNodeId = chain2.srcNodeId; -- ----------------------------------------------------- -- View `nodeLinkForkSrcV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeLinkForkSrcV` ; DROP TABLE IF EXISTS `nodeLinkForkSrcV`; create OR REPLACE view nodeLinkForkSrcV as select fork1.nodeLinkTypeId, fork1.srcNodeId, fork1.dstNodeId dstNodeId1, fork2.dstNodeId dstNodeId2, fork1.metric metric1, fork2.metric metric2, fork1.added added1, fork2.added added2 from nodeLinkT fork1 join nodeLinkT fork2 on fork1.nodeLinkTypeId = fork2.nodeLinkTypeId and fork1.srcNodeId = fork2.srcNodeId; -- ----------------------------------------------------- -- View `_nodeRecommendLink4V` -- ----------------------------------------------------- DROP VIEW IF EXISTS `_nodeRecommendLink4V` ; DROP TABLE IF EXISTS `_nodeRecommendLink4V`; CREATE OR REPLACE VIEW _nodeRecommendLink4V as select nlt.id nodeLinkTypeId, nlt.code nodeLinkTypeCode, srcnode.id srcNodeId, srcnode.nodeTypeId srcNodeTypeId, dstnode.id dstNodeId, dstnode.nodeTypeId dstNodeTypeId, anl.essential, anl.singleSrc, link.metric linked, canlink.n canLink from nodeT srcnode join nodeLinkTypeT nlt on nlt.isDefault = 'y' join allowedNodeLinkT anl on srcnode.nodeTypeId = anl.srcNodeTypeId join nodeT dstnode on anl.dstNodeTypeId = dstnode.nodeTypeId and srcnode.id != dstnode.id left join nodeLinkT link on nlt.id = link.nodeLinkTypeId and srcnode.id = link.srcNodeId and dstnode.id = link.dstNodeId and link.metric = 1 left join zzzIntsT canlink1 on canlink1.n = 1 and link.metric is null and anl.singleSrc = 'n' and (select count(distinct n1.nodeTypeId) from nodeLinkT nl1 join nodeT n1 on nl1.srcNodeId = n1.id where nl1.nodeLinkTypeId = nlt.id and nl1.dstNodeId = srcnode.id and nl1.metric = 1) = (select count(distinct n2.nodeTypeId) from nodeLinkForkSrcV nl2 join nodeT n2 on nl2.srcNodeId = n2.id where nl2.nodeLinkTypeId = nlt.id and nl2.dstNodeId1 = srcnode.id and nl2.metric1 = 1 and nl2.dstNodeId2 = dstnode.id and nl2.metric2 = 1) left join zzzIntsT canlink3 on canlink3.n = 1 and link.metric is null and anl.singleSrc = 'y' -- check if already linked to the node of the same type and not exists( select 1 from nodeLinkT nl3 join nodeT n3 on nl3.srcNodeId = n3.id where nl3.nodeLinkTypeId = nlt.id and nl3.dstNodeId = dstnode.id and nl3.metric = 1 and n3.nodeTypeId = srcnode.nodeTypeId) -- check if srcnode.id and dstnode.id have common parent node, with special conditions and exists( select 1 from nodeLinkForkSrcV nl4 join nodeT n4 on nl4.srcNodeId = n4.id join allowedNodeLinkT anl4 on n4.nodeTypeId = anl4.srcNodeTypeId where nl4.nodeLinkTypeId = nlt.id and nl4.dstNodeId1 = srcnode.id and nl4.metric1 = 1 and nl4.dstNodeId2 = dstnode.id and nl4.metric2 = 1 and anl4.dstNodeTypeId = dstnode.nodeTypeId and anl4.singleSrc = anl.singleSrc and (anl4.essential = 'y' -- if the link is not essential make sure we are not stepping over the srcnode.id or not exists( select 1 from nodeLinkChainTransitionV exilink41 where nl4.nodeLinkTypeId = exilink41.nodeLinkTypeId and nl4.srcNodeId = exilink41.srcNodeId and nl4.dstNodeId1 = exilink41.dstNodeId)) -- and make sure we use the nearest common parent, i.e. there are no more common parents up the tree and not exists( select 1 from nodeLinkChainTransitionV exilink42 where nl4.nodeLinkTypeId = exilink42.nodeLinkTypeId and nl4.srcNodeId = exilink42.srcNodeId and nl4.dstNodeId2 = exilink42.dstNodeId)) left join zzzIntsT canlink on canlink.n = 1 and (canlink1.n = 1 or canlink3.n = 1) left join templateT srcTemplate on srcnode.id = srcTemplate.dstNodeId left join templateT dstTemplate on dstnode.id = dstTemplate.dstNodeId left join exceptNodeLinkNodeNodeTypeT exceptNodeNodeType on srcnode.id = exceptNodeNodeType.srcNodeId and dstnode.nodeTypeId = exceptNodeNodeType.dstNodeTypeId where srcTemplate.dstNodeId is null and dstTemplate.dstNodeId is null and exceptNodeNodeType.srcNodeId is null and (canlink.n = 1 or link.metric = 1); -- ----------------------------------------------------- -- View `objectWithTagLinkedV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `objectWithTagLinkedV` ; DROP TABLE IF EXISTS `objectWithTagLinkedV`; create OR REPLACE view objectWithTagLinkedV as select t.id srcId, t.typeId srcTypeId, t.typeCode srcTypeCode, t.typeName srcTypeName, t.internalTypeId srcInternalTypeId, t.typeCanEdit srcCanEdit, t.typeCanSearch srcTypeCanSearch, t.typeDisplayInObject srcTypeDisplayInObject, t.typeDisplayInObjectList srcTypeDisplayInObjectList, t.typeSorter srcTypeSorter, t.name srcName, t.sorter srcSorter, t.canSearch srcCanSearch, t.canSearchRaw srcCanSearchRaw, t.displayInObject srcDisplayInObject, t.displayInObjectRaw srcDisplayInObjectRaw, t.displayInObjectList srcDisplayInObjectList, t.displayInObjectListRaw srcDisplayInObjectListRaw, t.factor srcFactor, t.ratingPoints srcRatingPoints, t.enabled srcEnabled, t.attributeDataType srcAttributeDataType, t.attributeCode srcAttributeCode, t.required srcRequired, t.sortable srcSortable, t.uofmPre srcUofmPre, t.uofmPost srcUofmPost, t.languageId srcLanguageId, t.isRoot srcIsRoot, t.geoRoot srcGeoRoot, a.decimalMin srcDecimalMin, a.decimalMax srcDecimalMax, a.decimalRound srcDecimalRound, a.datetimeStorageId srcDatetimeStorageId, a.textIsLong srcTextIsLong, adsf.storageFormat srcDatetimeStorageFormat, adsf.name srcDatetimeName, adsf.outputFormat srcDatetimeOutputFormat, adsf.outputFormatJs srcDatetimeOutputFormatJs, avn.value srcNumericValue, avd.value srcDatetimeValue, avt.value srcTextValue, 1 linked, null canLink, o.id objectId from objectT o join nodeT n on o.id = n.id join nodeLinkOwnsV nlo on o.id = nlo.dstNodeId join tagV t on nlo.srcNodeId = t.id left join attributeV a on t.id = a.id left join attributeDatetimeStorageFormatV adsf on a.id = adsf.id and t.languageId = adsf.languageId left join attributeValueNumericT avn on a.id = avn.attributeId and o.id = avn.objectId left join attributeValueDatetimeT avd on a.id = avd.attributeId and o.id = avd.objectId left join attributeValueTextT avt on a.id = avt.attributeId and o.id = avt.objectId and t.languageId = avt.languageId left join exceptNodeLinkNodeNodeTypeT exceptNodeNodeType on t.id = exceptNodeNodeType.srcNodeId and n.nodeTypeId = exceptNodeNodeType.dstNodeTypeId where nlo.metric = 1 and exceptNodeNodeType.srcNodeId is null; -- ----------------------------------------------------- -- View `nodeLinkChainTransitionV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeLinkChainTransitionV` ; DROP TABLE IF EXISTS `nodeLinkChainTransitionV`; create OR REPLACE view nodeLinkChainTransitionV as select nodeLinkTypeId, srcNodeId, midNodeId, dstNodeId, metric1, metric2, added1, added2 from nodeLinkChainV where srcNodeId != midNodeId and midNodeId != dstNodeId and metric1 = 1 and metric2 = 1; -- ----------------------------------------------------- -- View `nodeLinkDirectV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeLinkDirectV` ; DROP TABLE IF EXISTS `nodeLinkDirectV`; create OR REPLACE view nodeLinkDirectV as select * from nodeLinkT directlink where directlink.metric = 1 and not exists( select 1 from nodeLinkChainTransitionV exilink where directlink.nodeLinkTypeId = exilink.nodeLinkTypeId and directlink.srcNodeId = exilink.srcNodeId and directlink.dstNodeId = exilink.dstNodeId); -- ----------------------------------------------------- -- View `nodeAncestryDataV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeAncestryDataV` ; DROP TABLE IF EXISTS `nodeAncestryDataV`; create OR REPLACE view nodeAncestryDataV as select srcNode.id srcNodeId, tl.name srcName, tl.uofmPre srcUofmPre, tl.uofmPost srcUofmPost, nt.id srcTypeId, nt.internalTypeId srcInternalTypeId, ntl.name srcTypeName, avn.value srcNumericValue, avd.value srcDatetimeValue, adfl.outputFormat srcDatetimeOutputFormat, avt.value srcTextValue, dstNode.id dstNodeId, dstNode.nodeTypeId dstTypeId, l.id languageId, l.isDefault languageIsDefault, nas.sorter ancestrySorter from nodeT dstNode join languageT l on 1=1 join nodeLinkTypeT nlt on nlt.isDefault = 'y' join nodeLinkT nl on nlt.id = nl.nodeLinkTypeId and dstNode.id = nl.dstNodeId join nodeT srcNode on nl.srcNodeId = srcNode.id join nodeAncestrySourceT nas on dstNode.nodeTypeId = nas.nodeTypeId and srcNode.nodeTypeId = nas.srcNodeTypeId join nodeTypeT nt on srcNode.nodeTypeId = nt.id join nodeTypeTL ntl on srcNode.nodeTypeId = ntl.id and l.id = ntl.languageId join tagTL tl on srcNode.id = tl.id and l.id = tl.languageId left join attributeValueNumericT avn on srcNode.id = avn.attributeId and dstNode.id = avn.objectId left join attributeValueDatetimeT avd on srcNode.id = avd.attributeId and dstNode.id = avd.objectId left join attributeDatetimeT ad on avd.attributeId = ad.id left join attributeDatetimeFormatTL adfl on ad.datetimeStorageId = adfl.id and l.id = adfl.languageId left join attributeValueTextT avt on srcNode.id = avt.attributeId and dstNode.id = avt.objectId and l.id = avt.languageId where srcNode.displayNode = 'y' and nl.metric = 1; -- ----------------------------------------------------- -- View `objectWithUserV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `objectWithUserV` ; DROP TABLE IF EXISTS `objectWithUserV`; create OR REPLACE view objectWithUserV as select u.*, o.id objectId from userV u join nodeLinkOwnsV nlo on u.id = nlo.srcNodeId right join objectT o on nlo.dstNodeId = o.id; -- ----------------------------------------------------- -- View `_nodeV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `_nodeV` ; DROP TABLE IF EXISTS `_nodeV`; create OR REPLACE view _nodeV as select * from nodeT where displayNode = 'y'; -- ----------------------------------------------------- -- View `attributeSortV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `attributeSortV` ; DROP TABLE IF EXISTS `attributeSortV`; create OR REPLACE view attributeSortV as -- intentionally disregard nodeT.displayNode in this view select n.id, nt.name typeName, nt.code typeCode, tl.name, t.sorter, a.code, nt.languageId, n.added, n.addedUserId, n.addedUserName, n.addedIp, n.changed, n.changedUserId, n.changedUserName, n.changedIp from nodeT n join nodeTypeV nt on n.nodeTypeId = nt.id join tagT t on n.id = t.id join tagTL tl on t.id = tl.id and nt.languageId = tl.languageId join attributeT a on t.id = a.id where t.enabled = 'y' and a.sortable = 'y'; -- ----------------------------------------------------- -- View `searchResultObjectSortedV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchResultObjectSortedV` ; DROP TABLE IF EXISTS `searchResultObjectSortedV`; create OR REPLACE view searchResultObjectSortedV as select sro.*, os.attributeId sortAttributeId, os.sorterAsc, os.sorterDesc from searchResultObjectV sro join cacheObjectSortT os on sro.id = os.objectId; -- ----------------------------------------------------- -- View `searchAttributeSortV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchAttributeSortV` ; DROP TABLE IF EXISTS `searchAttributeSortV`; create OR REPLACE view searchAttributeSortV as select * from attributeSortV aso where exists( select 1 from searchResultV sr join cacheObjectSortT os on sr.nodeId = os.objectId where os.attributeId = aso.id); -- ----------------------------------------------------- -- View `zzzIntsV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `zzzIntsV` ; DROP TABLE IF EXISTS `zzzIntsV`; create OR REPLACE view zzzIntsV as select 0 as n union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9; -- ----------------------------------------------------- -- View `zzzInts100V` -- ----------------------------------------------------- DROP VIEW IF EXISTS `zzzInts100V` ; DROP TABLE IF EXISTS `zzzInts100V`; create OR REPLACE view zzzInts100V as select (i1.n + i2.n * 10) n from zzzIntsV i1 join zzzIntsV i2 on 1=1; -- ----------------------------------------------------- -- View `zzzInts1000V` -- ----------------------------------------------------- DROP VIEW IF EXISTS `zzzInts1000V` ; DROP TABLE IF EXISTS `zzzInts1000V`; create OR REPLACE view zzzInts1000V as select (i1.n + i2.n * 10) n from zzzIntsV i1 join zzzInts100V i2 on 1=1; -- ----------------------------------------------------- -- View `zzzInts10000V` -- ----------------------------------------------------- DROP VIEW IF EXISTS `zzzInts10000V` ; DROP TABLE IF EXISTS `zzzInts10000V`; create OR REPLACE view zzzInts10000V as select (i1.n + i2.n * 100) n from zzzInts100V i1 join zzzInts100V i2 on 1=1; -- ----------------------------------------------------- -- View `searchResultSelectedV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchResultSelectedV` ; DROP TABLE IF EXISTS `searchResultSelectedV`; create OR REPLACE view searchResultSelectedV as select * from searchResultSelectedT srs where srs.sessionId = search_CurrentId(); -- ----------------------------------------------------- -- View `searchResultSelectedObjectV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `searchResultSelectedObjectV` ; DROP TABLE IF EXISTS `searchResultSelectedObjectV`; create OR REPLACE view searchResultSelectedObjectV as select o.*, srs.sessionId, srs.added addedSelected from objectV o join searchResultSelectedV srs on o.id = srs.objectId where o.public = 'y'; -- ----------------------------------------------------- -- View `tagDirectChildV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagDirectChildV` ; DROP TABLE IF EXISTS `tagDirectChildV`; create OR REPLACE view tagDirectChildV as select src.id srcId, src.typeId srcTypeId, src.typeCode srcTypeCode, src.typeName srcTypeName, src.internalTypeId srcInternalTypeId, src.typeCanEdit srcCanEdit, src.typeCanSearch srcTypeCanSearch, src.typeDisplayInObject srcTypeDisplayInObject, src.typeDisplayInObjectList srcTypeDisplayInObjectList, src.typeSorter srcTypeSorter, src.name srcName, src.sorter srcSorter, src.canSearch srcCanSearch, src.canSearchRaw srcCanSearchRaw, src.displayInObject srcDisplayInObject, src.displayInObjectRaw srcDisplayInObjectRaw, src.displayInObjectList srcDisplayInObjectList, src.displayInObjectListRaw srcDisplayInObjectListRaw, src.factor srcFactor, src.ratingPoints srcRatingPoints, src.enabled srcEnabled, src.attributeDataType srcAttributeDataType, src.required srcRequired, dst.id dstId, dst.typeId dstTypeId, dst.typeCode dstTypeCode, dst.typeName dstTypeName, dst.internalTypeId dstInternalTypeId, dst.typeCanEdit dstCanEdit, dst.typeCanSearch dstTypeCanSearch, dst.typeDisplayInObject dstTypeDisplayInObject, dst.typeDisplayInObjectList dstTypeDisplayInObjectList, dst.typeSorter dstTypeSorter, dst.name dstName, dst.sorter dstSorter, dst.canSearch dstCanSearch, dst.canSearchRaw dstCanSearchRaw, dst.displayInObject dstDisplayInObject, dst.displayInObjectRaw dstDisplayInObjectRaw, dst.displayInObjectList dstDisplayInObjectList, dst.displayInObjectListRaw dstDisplayInObjectListRaw, dst.factor dstFactor, dst.ratingPoints dstRatingPoints, dst.enabled dstEnabled, dst.attributeDataType dstAttributeDataType, dst.required dstRequired, src.isRoot srcIsRoot, src.geoRoot srcGeoRoot, na.tagNames dstAncestry from tagV src join nodeLinkOwnsV nlo on src.id = nlo.srcNodeId and nlo.metric = 1 join tagV dst on nlo.dstNodeId = dst.id left join nodeLinkChainTransitionV nlct on nlo.nodeLinkTypeId = nlct.nodeLinkTypeId and src.id = nlct.srcNodeId and dst.id = nlct.dstNodeId left join nodeAncestryT na on dst.id = na.id and dst.languageId = na.languageId where nlct.midNodeId is null; -- ----------------------------------------------------- -- View `nodeAllowedChildTypeV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeAllowedChildTypeV` ; DROP TABLE IF EXISTS `nodeAllowedChildTypeV`; create OR REPLACE view nodeAllowedChildTypeV as select n.id nodeId, anl.srcNodeTypeId, anl.dstNodeTypeId, anl.essential, anl.singleSrc, anl.added, anl.changed from nodeT n join allowedNodeLinkT anl on n.nodeTypeId = anl.srcNodeTypeId; -- ----------------------------------------------------- -- View `nodeAllowedParentTypeV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `nodeAllowedParentTypeV` ; DROP TABLE IF EXISTS `nodeAllowedParentTypeV`; create OR REPLACE view nodeAllowedParentTypeV as select n.id nodeId, anl.srcNodeTypeId, anl.dstNodeTypeId, anl.essential, anl.singleSrc, anl.added, anl.changed from nodeT n join allowedNodeLinkT anl on n.nodeTypeId = anl.dstNodeTypeId; -- ----------------------------------------------------- -- View `storedTagDataV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `storedTagDataV` ; DROP TABLE IF EXISTS `storedTagDataV`; create OR REPLACE view storedTagDataV as select std.id, std.nodeTypeId, nt.code nodeTypeCode, stdl.name, stdl.prefix, stdl.suffix, std.added, std.changed from storedTagDataT std join nodeTypeT nt on std.nodeTypeId = nt.id left join languageT l on l.isDefault = 'y' left join storedTagDataTL stdl on std.id = stdl.id and stdl.languageId = coalesce(user_CurrentLanguage(), l.id); -- ----------------------------------------------------- -- View `moderationQueueV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `moderationQueueV` ; DROP TABLE IF EXISTS `moderationQueueV`; create OR REPLACE view moderationQueueV as select q.id, q.nodeId, q.comment1, q.comment2, q.resolved, n.typeName, n.typeCode, n.internalTypeId, n.name, n.languageId, tl.name tagName, tl.uofmPre tagPrefix, tl.uofmPost tagSuffix, o.address objectAddress, osl.name objectStatus, n.added nodeAdded, n.addedUserId nodeAddedUserId, n.addedUserName nodeAddedUserName, n.addedIp nodeAddedIp, n.changed nodeChanged, n.changedUserId nodeChangedUserId, n.changedUserName nodeChangedUserName, n.changedIp nodeChangedIp, q.added, q.addedUserId, q.addedUserName, q.addedIp, q.changed, q.changedUserId, q.changedUserName, q.changedIp from moderationQueueT q join nodeV n on q.nodeId = n.id left join tagTL tl on n.id = tl.id and n.languageId = tl.languageId left join objectT o on n.id = o.id left join objectStatusTL osl on o.statusId = osl.id and n.languageId = osl.languageId; -- ----------------------------------------------------- -- View `tagCacheV` -- ----------------------------------------------------- DROP VIEW IF EXISTS `tagCacheV` ; DROP TABLE IF EXISTS `tagCacheV`; create OR REPLACE view tagCacheV as select tc.id, tc.tagNames, tc.tagNamesSearch, tc.tagNamesFullSearch from tagCacheT tc; DELIMITER $$$ DROP TRIGGER IF EXISTS `nodeTypeT_bi` $$$ CREATE TRIGGER `nodeTypeT_bi` BEFORE INSERT ON `nodeTypeT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.added = now(); set new.forceSingleType = (select it.forceSingleType from internalTypeT it where it.id = new.internalTypeId); set new.code = if(new.forceSingleType = 'y', new.internalTypeId, new.code); end $$$ DROP TRIGGER IF EXISTS `nodeT_bi` $$$ CREATE TRIGGER `nodeT_bi` BEFORE INSERT ON `nodeT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.added = now(); set new.forceSingleNode = (select nt.forceSingleNode from nodeTypeT nt where nt.id = new.nodeTypeId); end$$$ DROP TRIGGER IF EXISTS `nodeLinkTypeT_bi` $$$ CREATE TRIGGER `nodeLinkTypeT_bi` BEFORE INSERT ON `nodeLinkTypeT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `languageT_bi` $$$ CREATE TRIGGER `languageT_bi` BEFORE INSERT ON `languageT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `allowedNodeLinkT_bi` $$$ CREATE TRIGGER `allowedNodeLinkT_bi` BEFORE INSERT ON `allowedNodeLinkT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `objectStatusT_bi` $$$ CREATE TRIGGER `objectStatusT_bi` BEFORE INSERT ON `objectStatusT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `imageT_bi` $$$ CREATE TRIGGER `imageT_bi` BEFORE INSERT ON `imageT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `attributeValueNumericT_bi` $$$ CREATE TRIGGER `attributeValueNumericT_bi` BEFORE INSERT ON `attributeValueNumericT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `attributeDatetimeFormatT_bi` $$$ CREATE TRIGGER `attributeDatetimeFormatT_bi` BEFORE INSERT ON `attributeDatetimeFormatT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `attributeValueDatetimeT_bi` $$$ CREATE TRIGGER `attributeValueDatetimeT_bi` BEFORE INSERT ON `attributeValueDatetimeT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `attributeValueTextT_bi` $$$ CREATE TRIGGER `attributeValueTextT_bi` BEFORE INSERT ON `attributeValueTextT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `templateT_bi` $$$ CREATE TRIGGER `templateT_bi` BEFORE INSERT ON `templateT` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one begin set new.dstNodeTypeId = coalesce(new.dstNodeTypeId, (select nodeTypeId from nodeT n where n.id = new.dstNodeId)); end$$$ DROP TRIGGER IF EXISTS `zzzNodeWorksetT_bi` $$$ CREATE TRIGGER `zzzNodeWorksetT_bi` BEFORE INSERT ON `zzzNodeWorksetT` FOR EACH ROW begin set new.connId = connection_id(); end$$$ DROP TRIGGER IF EXISTS `oauthProviderT_bi` $$$ CREATE TRIGGER `oauthProviderT_bi` BEFORE INSERT ON `oauthProviderT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `userOauthT_bi` $$$ CREATE TRIGGER `userOauthT_bi` BEFORE INSERT ON `userOauthT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `externalDataSourceT_bi` $$$ CREATE TRIGGER `externalDataSourceT_bi` BEFORE INSERT ON `externalDataSourceT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `externalDataT_bi` $$$ CREATE TRIGGER `externalDataT_bi` BEFORE INSERT ON `externalDataT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `externalDataSourceDatasetT_bi` $$$ CREATE TRIGGER `externalDataSourceDatasetT_bi` BEFORE INSERT ON `externalDataSourceDatasetT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `externalOsmDictionaryT_bi` $$$ CREATE TRIGGER `externalOsmDictionaryT_bi` BEFORE INSERT ON `externalOsmDictionaryT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `nodeAncestrySourceT_bi` $$$ CREATE TRIGGER `nodeAncestrySourceT_bi` BEFORE INSERT ON `nodeAncestrySourceT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `storedTagDataT_bi` $$$ CREATE TRIGGER `storedTagDataT_bi` BEFORE INSERT ON `storedTagDataT` FOR EACH ROW begin set new.added = now(); end$$$ DROP TRIGGER IF EXISTS `moderationQueueT_bi` $$$ CREATE DEFINER = CURRENT_USER TRIGGER `moderationQueueT_bi` BEFORE INSERT ON `moderationQueueT` FOR EACH ROW begin set new.added = now(); end$$$ DELIMITER ; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; -- ----------------------------------------------------- -- Data for table `internalTypeT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `internalTypeT` (`id`, `forceSingleType`, `added`) VALUES ('user', 'y', NULL); INSERT INTO `internalTypeT` (`id`, `forceSingleType`, `added`) VALUES ('object', 'y', NULL); INSERT INTO `internalTypeT` (`id`, `forceSingleType`, `added`) VALUES ('tag', NULL, NULL); INSERT INTO `internalTypeT` (`id`, `forceSingleType`, `added`) VALUES ('attribute', NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `nodeTypeT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (1, NULL, 'user', 'y', 'user', 'y', 'n', 'y', 'y', 'n', 'y', 'y', 'n', 'n', 'n', 'n', 'y', 'n', 1, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (2, NULL, 'object', 'y', 'object', NULL, 'n', 'y', 'y', 'n', 'n', 'y', 'n', 'n', 'n', 'n', 'y', 'n', 2, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (3, 'y', 'tag', NULL, 'rootgeo', 'y', 'n', 'n', 'n', 'n', 'y', 'n', 'n', 'n', 'n', 'n', 'y', 'y', 3, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (4, 'y', 'tag', NULL, 'rootamenity', 'y', 'n', 'n', 'n', 'n', 'y', 'n', 'n', 'n', 'n', 'n', 'y', 'n', 4, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (5, 'y', 'tag', NULL, 'rootsubmission', 'y', 'n', 'n', 'n', 'n', 'y', 'n', 'n', 'n', 'n', 'n', 'y', 'n', 5, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (6, 'y', 'tag', NULL, 'rootuser', 'y', 'n', 'n', 'n', 'n', 'y', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 6, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (7, NULL, 'tag', NULL, 'locality', 'y', 'n', 'y', 'n', 'n', 'y', 'y', 'y', 'n', 'n', 'n', 'y', 'n', 30, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (8, NULL, 'tag', NULL, 'neighborhood', 'y', 'n', 'y', 'n', 'n', 'y', 'y', 'y', 'n', 'n', 'n', 'y', 'n', 40, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (9, NULL, 'tag', NULL, 'street', 'y', 'n', 'y', 'n', 'n', 'y', 'y', 'n', 'n', 'n', 'n', 'y', 'n', 50, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (10, NULL, 'tag', NULL, 'amenity', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'n', 80, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (11, NULL, 'tag', NULL, 'estatetype', 'y', 'y', 'y', 'y', 'n', 'y', 'y', 'y', 'y', 'y', 'n', 'y', 'y', 20, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (12, NULL, 'tag', NULL, 'submissiontype', 'y', 'y', 'y', 'n', 'n', 'y', 'y', 'y', 'y', 'y', 'n', 'y', 'y', 10, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (13, NULL, 'tag', NULL, 'wallmaterial', 'y', 'y', 'y', 'y', 'n', 'y', 'y', 'y', 'y', 'y', 'n', 'y', 'n', 100, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (14, NULL, 'tag', NULL, 'roofmaterial', 'y', 'y', 'y', 'y', 'n', 'y', 'y', 'y', 'y', 'y', 'n', 'y', 'n', 110, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (15, NULL, 'tag', NULL, 'supply', 'y', 'y', 'y', 'y', 'n', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'n', 120, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (16, NULL, 'tag', NULL, 'extamenity', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'n', 90, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (17, NULL, 'attribute', NULL, 'geoattribute', 'y', 'n', 'y', 'n', 'n', 'y', 'y', 'n', 'n', 'n', 'y', 'y', 'n', 60, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (18, NULL, 'attribute', NULL, 'genericattribute', 'y', 'y', 'y', 'n', 'n', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'n', 70, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (19, NULL, 'attribute', NULL, 'hiddenattribute', 'y', 'n', 'y', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'y', 'n', 'n', 7, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (20, NULL, 'tag', NULL, 'prohibit', 'y', 'y', 'y', 'y', 'n', 'y', 'y', 'n', 'y', 'y', 'y', 'y', 'n', 85, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (21, NULL, 'tag', NULL, 'oblast', 'y', 'n', 'y', 'n', 'n', 'y', 'y', 'y', 'n', 'n', 'n', 'y', 'n', 25, NULL, NULL); INSERT INTO `nodeTypeT` (`id`, `forceSingleNode`, `internalTypeId`, `forceSingleType`, `code`, `forceSinglePhoto`, `canEditType`, `canEditNode`, `canHavePhoto`, `canHaveRatingPoints`, `canLinkFrom`, `canLinkTo`, `canSearch`, `displayInObject`, `displayInObjectList`, `searchAnd`, `displayNode`, `requiredForObject`, `sorter`, `added`, `changed`) VALUES (22, NULL, 'tag', NULL, 'raion', 'y', 'n', 'y', 'n', 'n', 'y', 'y', 'y', 'n', 'n', 'n', 'y', 'n', 26, NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `nodeLinkTypeT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `nodeLinkTypeT` (`id`, `code`, `forceSelfLink`, `isDefault`, `added`, `changed`) VALUES (1, 'owns', 'n', 'y', NULL, NULL); INSERT INTO `nodeLinkTypeT` (`id`, `code`, `forceSelfLink`, `isDefault`, `added`, `changed`) VALUES (2, 'fav', 'n', NULL, NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `languageT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `languageT` (`id`, `name`, `sorter`, `isDefault`, `added`, `changed`) VALUES ('ukr', 'Українська', 1, 'y', NULL, NULL); INSERT INTO `languageT` (`id`, `name`, `sorter`, `isDefault`, `added`, `changed`) VALUES ('rus', 'Русский', 2, NULL, NULL, NULL); INSERT INTO `languageT` (`id`, `name`, `sorter`, `isDefault`, `added`, `changed`) VALUES ('eng', 'English', 3, NULL, NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `nodeTypeTL` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (1, 'ukr', 'користувач'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (1, 'rus', 'пользователь'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (1, 'eng', 'user'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (2, 'ukr', 'об\'єкт'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (2, 'rus', 'объект'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (2, 'eng', 'object'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (3, 'ukr', 'Розміщення'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (3, 'rus', 'Расположение'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (3, 'eng', 'Location'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (4, 'ukr', 'Різновиди та зручності'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (4, 'rus', 'Разновидности и удобства'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (4, 'eng', 'Types and Amenities'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (5, 'ukr', 'Мета'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (5, 'rus', 'Цель'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (5, 'eng', 'Purpose'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (6, 'ukr', 'всі користувачі'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (6, 'rus', 'все пользователи'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (6, 'eng', 'all users'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (7, 'ukr', 'Населений пункт'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (7, 'rus', 'Населенный пункт'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (7, 'eng', 'Locality'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (8, 'ukr', 'Масив/Район'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (8, 'rus', 'Массив/Район'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (8, 'eng', 'Neighbourhood'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (9, 'ukr', 'Вулиця'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (9, 'rus', 'Улица'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (9, 'eng', 'Street'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (10, 'ukr', 'Зручності'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (10, 'rus', 'Удобства'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (10, 'eng', 'Amenities'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (11, 'ukr', 'Вид'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (11, 'rus', 'Вид'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (11, 'eng', 'Type'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (12, 'ukr', 'Мета'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (12, 'rus', 'Цель'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (12, 'eng', 'Purpose'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (13, 'ukr', 'Матеріал стін'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (13, 'rus', 'Материал стен'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (13, 'eng', 'Wall Material'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (14, 'ukr', 'Матеріал покрівлі'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (14, 'rus', 'Материал накрытия'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (14, 'eng', 'Roofing Material'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (15, 'ukr', 'Комунікації'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (15, 'rus', 'Коммуникации'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (15, 'eng', 'Supplies'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (16, 'ukr', 'Зовнішні зручності'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (16, 'rus', 'Внешние удобства'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (16, 'eng', 'External Amenities'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (17, 'ukr', 'Географічний атрибут'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (17, 'rus', 'Географический аттрибут'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (17, 'eng', 'Location Attribute'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (18, 'ukr', 'Загальні параметри'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (18, 'rus', 'Общие параметры'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (18, 'eng', 'Basic Parameters'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (19, 'ukr', 'Скриті атрибути'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (19, 'rus', 'Скрытые атрибуты'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (19, 'eng', 'Hidden Attributes'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (20, 'ukr', 'Не можна'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (20, 'rus', 'Нельзя'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (20, 'eng', 'Prohibited'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (21, 'ukr', 'Область'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (21, 'rus', 'Область'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (21, 'eng', 'Oblast'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (22, 'ukr', 'Район'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (22, 'rus', 'Район'); INSERT INTO `nodeTypeTL` (`id`, `languageId`, `name`) VALUES (22, 'eng', 'Raion'); COMMIT; -- ----------------------------------------------------- -- Data for table `allowedNodeLinkT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (3, 7, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (3, 8, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (3, 9, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (7, 8, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (7, 9, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (8, 9, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (6, 1, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (3, 2, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 2, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 2, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (7, 2, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (9, 2, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 11, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 10, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (11, 10, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 12, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (11, 2, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (10, 2, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 2, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 10, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 10, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 13, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 14, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 13, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 14, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (11, 13, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (11, 14, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 13, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 14, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (13, 2, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (14, 2, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 15, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 15, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (11, 15, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 15, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (15, 2, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 16, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (11, 16, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 16, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 16, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (16, 2, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (1, 2, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (3, 17, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (7, 17, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (9, 17, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (17, 2, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 18, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 18, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (11, 18, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 18, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (18, 2, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (8, 2, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 11, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 11, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (4, 20, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (11, 20, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (5, 20, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (12, 20, 'n', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (20, 2, 'y', 'n', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (3, 21, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (3, 22, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (21, 7, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (21, 8, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (21, 9, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (21, 17, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (21, 2, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (21, 22, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (22, 7, 'y', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (22, 8, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (22, 9, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (22, 17, 'n', 'y', NULL, NULL); INSERT INTO `allowedNodeLinkT` (`srcNodeTypeId`, `dstNodeTypeId`, `essential`, `singleSrc`, `added`, `changed`) VALUES (22, 2, 'y', 'y', NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `userRoleT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `userRoleT` (`id`, `isDefault`, `added`) VALUES ('user', 'y', NULL); INSERT INTO `userRoleT` (`id`, `isDefault`, `added`) VALUES ('manager', NULL, NULL); INSERT INTO `userRoleT` (`id`, `isDefault`, `added`) VALUES ('admin', NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `objectStatusT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `objectStatusT` (`id`, `public`, `userEditable`, `userDraftable`, `isDefault`, `sorter`, `added`, `changed`) VALUES ('draft', 'n', 'y', 'n', 'y', 1, NULL, NULL); INSERT INTO `objectStatusT` (`id`, `public`, `userEditable`, `userDraftable`, `isDefault`, `sorter`, `added`, `changed`) VALUES ('review', 'y', 'n', 'y', NULL, 2, NULL, NULL); INSERT INTO `objectStatusT` (`id`, `public`, `userEditable`, `userDraftable`, `isDefault`, `sorter`, `added`, `changed`) VALUES ('approved', 'y', 'n', 'y', NULL, 3, NULL, NULL); INSERT INTO `objectStatusT` (`id`, `public`, `userEditable`, `userDraftable`, `isDefault`, `sorter`, `added`, `changed`) VALUES ('rejected', 'n', 'n', 'y', NULL, 4, NULL, NULL); INSERT INTO `objectStatusT` (`id`, `public`, `userEditable`, `userDraftable`, `isDefault`, `sorter`, `added`, `changed`) VALUES ('blocked', 'n', 'n', 'n', NULL, 5, NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `objectStatusTL` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('draft', 'ukr', 'Чорновик'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('draft', 'rus', 'Черновик'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('draft', 'eng', 'Draft'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('review', 'ukr', 'На розгляді'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('review', 'rus', 'На рассмотрении'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('review', 'eng', 'Reviewed'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('approved', 'ukr', 'Підтверджено'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('approved', 'rus', 'Подтверждено'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('approved', 'eng', 'Approved'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('rejected', 'ukr', 'Відхилено'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('rejected', 'rus', 'Отклонено'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('rejected', 'eng', 'Rejected'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('blocked', 'ukr', 'Заблоковано'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('blocked', 'rus', 'Заблокировано'); INSERT INTO `objectStatusTL` (`id`, `languageId`, `name`) VALUES ('blocked', 'eng', 'Blocked'); COMMIT; -- ----------------------------------------------------- -- Data for table `imageTypeT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `imageTypeT` (`id`, `isDefault`, `added`) VALUES ('image', 'y', NULL); INSERT INTO `imageTypeT` (`id`, `isDefault`, `added`) VALUES ('panorama', NULL, NULL); INSERT INTO `imageTypeT` (`id`, `isDefault`, `added`) VALUES ('video', NULL, NULL); INSERT INTO `imageTypeT` (`id`, `isDefault`, `added`) VALUES ('logo', NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `internalDataTypeT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `internalDataTypeT` (`id`, `added`) VALUES ('numeric', NULL); INSERT INTO `internalDataTypeT` (`id`, `added`) VALUES ('datetime', NULL); INSERT INTO `internalDataTypeT` (`id`, `added`) VALUES ('text', NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `attributeDatetimeFormatT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `attributeDatetimeFormatT` (`id`, `storageFormat`, `sorter`, `added`, `changed`) VALUES ('year', '%Y-01-01 00:00:00', 3, NULL, NULL); INSERT INTO `attributeDatetimeFormatT` (`id`, `storageFormat`, `sorter`, `added`, `changed`) VALUES ('yearmonth', '%Y-%m-01 00:00:00', 2, NULL, NULL); INSERT INTO `attributeDatetimeFormatT` (`id`, `storageFormat`, `sorter`, `added`, `changed`) VALUES ('date', '%Y-%m-%d 00:00:00', 1, NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `attributeDatetimeFormatTL` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('year', 'ukr', 'рік', '%Y', 'yyyy'); INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('year', 'rus', 'год', '%Y', 'yyyy'); INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('year', 'eng', 'year only', '%Y', 'yyyy'); INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('yearmonth', 'ukr', 'рік і місяць', '%m.%Y', 'MM.yyyy'); INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('yearmonth', 'rus', 'год и месяц', '%m.%Y', 'MM.yyyy'); INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('yearmonth', 'eng', 'year and month', '%m/%Y', 'MM/yyyy'); INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('date', 'ukr', 'дата', '%d.%m.%Y', 'dd.MM.yyyy'); INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('date', 'rus', 'дата', '%d.%m.%Y', 'dd.MM.yyyy'); INSERT INTO `attributeDatetimeFormatTL` (`id`, `languageId`, `name`, `outputFormat`, `outputFormatJs`) VALUES ('date', 'eng', 'date', '%Y/%m/%d', 'yyyy/MM/dd'); COMMIT; -- ----------------------------------------------------- -- Data for table `oauthProviderT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `oauthProviderT` (`id`, `added`, `changed`) VALUES ('google', NULL, NULL); INSERT INTO `oauthProviderT` (`id`, `added`, `changed`) VALUES ('vkontakte', NULL, NULL); INSERT INTO `oauthProviderT` (`id`, `added`, `changed`) VALUES ('facebook', NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `externalDataSourceT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `externalDataSourceT` (`id`, `name`, `added`, `changed`) VALUES ('osm', 'OpenStreetMap', NULL, NULL); INSERT INTO `externalDataSourceT` (`id`, `name`, `added`, `changed`) VALUES ('admter', 'Admter Database', NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `externalDataSourceDatasetT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `externalDataSourceDatasetT` (`externalDataSourceId`, `code`, `nodeId`, `added`, `changed`) VALUES ('osm', 'ternopil', 0, NULL, NULL); INSERT INTO `externalDataSourceDatasetT` (`externalDataSourceId`, `code`, `nodeId`, `added`, `changed`) VALUES ('osm', 'kyiv', 0, NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `externalOsmDictionaryT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `externalOsmDictionaryT` (`externalDataSourceId`, `code`, `boundingWayIds`, `added`, `changed`) VALUES ('osm', 'ternopil', '3058686', NULL, NULL); INSERT INTO `externalOsmDictionaryT` (`externalDataSourceId`, `code`, `boundingWayIds`, `added`, `changed`) VALUES ('osm', 'kyiv', '421866', NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `zzzIntsT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `zzzIntsT` (`n`) VALUES (0); INSERT INTO `zzzIntsT` (`n`) VALUES (1); INSERT INTO `zzzIntsT` (`n`) VALUES (2); INSERT INTO `zzzIntsT` (`n`) VALUES (3); INSERT INTO `zzzIntsT` (`n`) VALUES (4); INSERT INTO `zzzIntsT` (`n`) VALUES (5); INSERT INTO `zzzIntsT` (`n`) VALUES (6); INSERT INTO `zzzIntsT` (`n`) VALUES (7); INSERT INTO `zzzIntsT` (`n`) VALUES (8); INSERT INTO `zzzIntsT` (`n`) VALUES (9); COMMIT; -- ----------------------------------------------------- -- Data for table `nodeAncestrySourceT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (2, 9, 20, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (2, 7, 40, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (8, 7, 20, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (9, 7, 20, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (9, 8, 10, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (2, 17, 30, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (2, 22, 50, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (2, 21, 60, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (7, 22, 10, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (7, 21, 20, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (8, 22, 30, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (8, 21, 40, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (9, 22, 30, NULL, NULL); INSERT INTO `nodeAncestrySourceT` (`nodeTypeId`, `srcNodeTypeId`, `sorter`, `added`, `changed`) VALUES (9, 21, 40, NULL, NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `zzzValidCharT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('0', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('1', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('2', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('3', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('4', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('5', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('6', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('7', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('8', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('9', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES (' ', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('A', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('B', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('C', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('D', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('E', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('F', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('G', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('H', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('I', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('J', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('K', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('L', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('M', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('N', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('O', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('P', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Q', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('R', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('S', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('T', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('U', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('V', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('W', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('X', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Y', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Z', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('a', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('b', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('c', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('d', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('e', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('f', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('g', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('h', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('i', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('j', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('k', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('l', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('m', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('n', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('o', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('p', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('q', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('r', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('s', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('t', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('u', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('v', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('w', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('x', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('y', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('z', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('А', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Б', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('В', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Г', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ґ', 'norm', 'Г', 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Д', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Е', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Є', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ж', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('З', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('И', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('І', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ї', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Й', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('К', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Л', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('М', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Н', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('О', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('П', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Р', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('С', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Т', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('У', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ф', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Х', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ц', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ч', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ш', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Щ', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ь', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ю', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Я', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ё', 'norm', 'Е', 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Ы', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Э', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('а', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('б', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('в', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('г', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ґ', 'norm', 'г', 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('д', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('е', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('є', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ж', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('з', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('и', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('і', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ї', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('й', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('к', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('л', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('м', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('н', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('о', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('п', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('р', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('с', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('т', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('у', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ф', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('х', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ц', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ч', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ш', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('щ', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ь', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ю', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('я', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ё', 'norm', 'е', 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('ы', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('э', 'norm', NULL, 'y'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('0', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('1', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('2', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('3', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('4', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('5', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('6', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('7', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('8', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('9', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('A', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('B', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('C', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('D', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('E', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('F', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('G', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('H', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('I', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('J', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('K', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('L', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('M', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('N', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('O', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('P', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Q', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('R', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('S', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('T', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('U', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('V', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('W', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('X', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Y', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('Z', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('a', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('b', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('c', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('d', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('e', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('f', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('g', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('h', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('i', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('j', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('k', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('l', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('m', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('n', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('o', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('p', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('q', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('r', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('s', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('t', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('u', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('v', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('w', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('x', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('y', 'alias', NULL, 'n'); INSERT INTO `zzzValidCharT` (`id`, `purpose`, `replacement`, `forceSingle`) VALUES ('z', 'alias', NULL, 'n'); COMMIT; -- ----------------------------------------------------- -- Data for table `exceptNodeLinkNodeNodeTypeT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `exceptNodeLinkNodeNodeTypeT` (`srcNodeId`, `dstNodeTypeId`, `comment`, `added`) VALUES (6744, 2, 'exception for Find Route', NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `externalAdmterTypeT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `externalAdmterTypeT` (`id`, `typeCode`, `added`) VALUES (2, 'oblast', NULL); INSERT INTO `externalAdmterTypeT` (`id`, `typeCode`, `added`) VALUES (3, 'raion', NULL); INSERT INTO `externalAdmterTypeT` (`id`, `typeCode`, `added`) VALUES (4, 'neighborhood', NULL); INSERT INTO `externalAdmterTypeT` (`id`, `typeCode`, `added`) VALUES (5, 'villagecouncil', NULL); INSERT INTO `externalAdmterTypeT` (`id`, `typeCode`, `added`) VALUES (6, 'locality', NULL); INSERT INTO `externalAdmterTypeT` (`id`, `typeCode`, `added`) VALUES (7, 'locality', NULL); INSERT INTO `externalAdmterTypeT` (`id`, `typeCode`, `added`) VALUES (8, 'locality', NULL); INSERT INTO `externalAdmterTypeT` (`id`, `typeCode`, `added`) VALUES (9, 'locality', NULL); COMMIT; -- ----------------------------------------------------- -- Data for table `externalAdmterTypeTL` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (2, 'ukr', '', 'область'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (2, 'rus', '', 'область'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (2, 'eng', '', 'oblast'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (3, 'ukr', '', 'район'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (3, 'rus', '', 'район'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (3, 'eng', '', 'raion'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (4, 'ukr', '', 'район'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (4, 'rus', '', 'район'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (4, 'eng', '', 'district'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (5, 'ukr', '', 'сільська рада'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (5, 'rus', '', 'сельский совет'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (5, 'eng', '', 'village council'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (6, 'ukr', '', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (6, 'rus', '', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (6, 'eng', '', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (7, 'ukr', '', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (7, 'rus', '', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (7, 'eng', '', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (8, 'ukr', 'с.', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (8, 'rus', 'с.', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (8, 'eng', '', 'village'); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (9, 'ukr', 'с-ще', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (9, 'rus', 'пос.', ''); INSERT INTO `externalAdmterTypeTL` (`id`, `languageId`, `prefix`, `suffix`) VALUES (9, 'eng', '', 'hamlet'); COMMIT; -- ----------------------------------------------------- -- Data for table `constT` -- ----------------------------------------------------- START TRANSACTION; INSERT INTO `constT` (`id`, `comment`, `valueString`, `valueInt`, `valueFloat`) VALUES ('search.server.version', 'used in search - \"5.5\" forces to use 5.5 friendly code', '5.5', NULL, NULL); INSERT INTO `constT` (`id`, `comment`, `valueString`, `valueInt`, `valueFloat`) VALUES ('search.limit.criteria.empty', NULL, NULL, 10, NULL); INSERT INTO `constT` (`id`, `comment`, `valueString`, `valueInt`, `valueFloat`) VALUES ('search.limit.criteria.notempty', NULL, NULL, 500, NULL); COMMIT;