From 813ee4579e23d4259d4197f77d7189ed8407f1e3 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Mon, 21 Sep 2026 14:48:19 -0500 Subject: [PATCH 01/17] Resolve test db missing data --- .../populate_allowed_child_entity_type.sql | 1 + db/sql/test/populate_allowed_entity_type.sql | 1 + .../populate_allowed_entity_type_domain.sql | 1 + .../test/populate_allowed_property_domain.sql | 3 + ...pulate_allowed_property_metadata_value.sql | 1 + .../test/populate_allowed_property_value.sql | 1 + db/sql/test/populate_attachment.sql | 1 + db/sql/test/populate_connector.sql | 1 + db/sql/test/populate_connector_property.sql | 1 + db/sql/test/populate_connector_type.sql | 1 + db/sql/test/populate_domain.sql | 1 + db/sql/test/populate_entity_info.sql | 88 +++++++++++++++++++ db/sql/test/populate_entity_type.sql | 1 + db/sql/test/populate_item.sql | 85 ++++++++++++++++++ db/sql/test/populate_item_category.sql | 1 + .../test/populate_item_category_item_type.sql | 1 + db/sql/test/populate_item_connector.sql | 1 + .../test/populate_item_connector_property.sql | 1 + db/sql/test/populate_item_element.sql | 88 +++++++++++++++++++ db/sql/test/populate_item_element_history.sql | 88 +++++++++++++++++++ db/sql/test/populate_item_element_list.sql | 1 + db/sql/test/populate_item_element_log.sql | 12 +++ .../test/populate_item_element_property.sql | 5 ++ .../populate_item_element_relationship.sql | 1 + ...late_item_element_relationship_history.sql | 1 + ...ate_item_element_relationship_property.sql | 1 + db/sql/test/populate_item_entity_type.sql | 82 +++++++++++++++++ db/sql/test/populate_item_item_category.sql | 1 + db/sql/test/populate_item_item_project.sql | 1 + db/sql/test/populate_item_item_type.sql | 1 + db/sql/test/populate_item_project.sql | 1 + db/sql/test/populate_item_resource.sql | 1 + db/sql/test/populate_item_source.sql | 1 + db/sql/test/populate_item_type.sql | 14 +++ db/sql/test/populate_list.sql | 1 + db/sql/test/populate_log.sql | 23 +++++ db/sql/test/populate_log_attachment.sql | 1 + db/sql/test/populate_log_level.sql | 1 + db/sql/test/populate_log_reaction.sql | 13 +++ db/sql/test/populate_log_topic.sql | 1 + db/sql/test/populate_property_metadata.sql | 14 +++ .../populate_property_metadata_history.sql | 6 ++ db/sql/test/populate_property_type.sql | 4 +- .../test/populate_property_type_category.sql | 1 + .../test/populate_property_type_handler.sql | 1 + .../test/populate_property_type_metadata.sql | 1 + db/sql/test/populate_property_value.sql | 5 ++ .../test/populate_property_value_history.sql | 3 + db/sql/test/populate_reaction.sql | 1 + db/sql/test/populate_relationship_type.sql | 1 + .../populate_relationship_type_handler.sql | 1 + db/sql/test/populate_resource_type.sql | 1 + .../test/populate_resource_type_category.sql | 1 + db/sql/test/populate_role_type.sql | 1 + db/sql/test/populate_setting_type.sql | 1 + db/sql/test/populate_source.sql | 1 + db/sql/test/populate_system_log.sql | 10 +++ db/sql/test/populate_user_group.sql | 4 +- db/sql/test/populate_user_group_list.sql | 1 + db/sql/test/populate_user_group_setting.sql | 1 + db/sql/test/populate_user_info.sql | 4 +- db/sql/test/populate_user_list.sql | 1 + db/sql/test/populate_user_role.sql | 1 + db/sql/test/populate_user_session.sql | 1 + db/sql/test/populate_user_setting.sql | 1 + db/sql/test/populate_user_user_group.sql | 4 +- 66 files changed, 597 insertions(+), 4 deletions(-) diff --git a/db/sql/test/populate_allowed_child_entity_type.sql b/db/sql/test/populate_allowed_child_entity_type.sql index ce378f177..3e265dfb1 100644 --- a/db/sql/test/populate_allowed_child_entity_type.sql +++ b/db/sql/test/populate_allowed_child_entity_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `allowed_child_entity_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `allowed_child_entity_type` DISABLE KEYS */; INSERT INTO `allowed_child_entity_type` VALUES (1,1), diff --git a/db/sql/test/populate_allowed_entity_type.sql b/db/sql/test/populate_allowed_entity_type.sql index 31941ee47..a0c9f1525 100644 --- a/db/sql/test/populate_allowed_entity_type.sql +++ b/db/sql/test/populate_allowed_entity_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `allowed_entity_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `allowed_entity_type` DISABLE KEYS */; /*!40000 ALTER TABLE `allowed_entity_type` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_allowed_entity_type_domain.sql b/db/sql/test/populate_allowed_entity_type_domain.sql index 783c8f6ac..3a930f0a5 100644 --- a/db/sql/test/populate_allowed_entity_type_domain.sql +++ b/db/sql/test/populate_allowed_entity_type_domain.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `allowed_entity_type_domain` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `allowed_entity_type_domain` DISABLE KEYS */; INSERT INTO `allowed_entity_type_domain` VALUES (1,1), diff --git a/db/sql/test/populate_allowed_property_domain.sql b/db/sql/test/populate_allowed_property_domain.sql index 7f45a2e20..d5d997e59 100644 --- a/db/sql/test/populate_allowed_property_domain.sql +++ b/db/sql/test/populate_allowed_property_domain.sql @@ -4,6 +4,9 @@ -- LOCK TABLES `allowed_property_domain` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `allowed_property_domain` DISABLE KEYS */; +INSERT INTO `allowed_property_domain` VALUES +(3,1); /*!40000 ALTER TABLE `allowed_property_domain` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_allowed_property_metadata_value.sql b/db/sql/test/populate_allowed_property_metadata_value.sql index 5b9807004..973da6fb4 100644 --- a/db/sql/test/populate_allowed_property_metadata_value.sql +++ b/db/sql/test/populate_allowed_property_metadata_value.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `allowed_property_metadata_value` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `allowed_property_metadata_value` DISABLE KEYS */; /*!40000 ALTER TABLE `allowed_property_metadata_value` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_allowed_property_value.sql b/db/sql/test/populate_allowed_property_value.sql index fa61fe611..ae16932e4 100644 --- a/db/sql/test/populate_allowed_property_value.sql +++ b/db/sql/test/populate_allowed_property_value.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `allowed_property_value` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `allowed_property_value` DISABLE KEYS */; /*!40000 ALTER TABLE `allowed_property_value` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_attachment.sql b/db/sql/test/populate_attachment.sql index faa858203..5b7e4300c 100644 --- a/db/sql/test/populate_attachment.sql +++ b/db/sql/test/populate_attachment.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `attachment` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `attachment` DISABLE KEYS */; /*!40000 ALTER TABLE `attachment` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_connector.sql b/db/sql/test/populate_connector.sql index e2c853917..7e2a315ac 100644 --- a/db/sql/test/populate_connector.sql +++ b/db/sql/test/populate_connector.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `connector` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `connector` DISABLE KEYS */; /*!40000 ALTER TABLE `connector` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_connector_property.sql b/db/sql/test/populate_connector_property.sql index e04abb328..9e96b37bb 100644 --- a/db/sql/test/populate_connector_property.sql +++ b/db/sql/test/populate_connector_property.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `connector_property` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `connector_property` DISABLE KEYS */; /*!40000 ALTER TABLE `connector_property` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_connector_type.sql b/db/sql/test/populate_connector_type.sql index b557c9c22..c3498cc28 100644 --- a/db/sql/test/populate_connector_type.sql +++ b/db/sql/test/populate_connector_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `connector_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `connector_type` DISABLE KEYS */; /*!40000 ALTER TABLE `connector_type` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_domain.sql b/db/sql/test/populate_domain.sql index bb94aee0e..1515074e4 100644 --- a/db/sql/test/populate_domain.sql +++ b/db/sql/test/populate_domain.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `domain` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `domain` DISABLE KEYS */; INSERT INTO `domain` VALUES (1,'Logbook','Item domain to maintain logbooks.',NULL,'UID','System',NULL); diff --git a/db/sql/test/populate_entity_info.sql b/db/sql/test/populate_entity_info.sql index b67caf222..b84cd2f74 100644 --- a/db/sql/test/populate_entity_info.sql +++ b/db/sql/test/populate_entity_info.sql @@ -4,6 +4,94 @@ -- LOCK TABLES `entity_info` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `entity_info` DISABLE KEYS */; +INSERT INTO `entity_info` VALUES +(1,1,1,1,'2024-08-23 09:19:18',1,'2024-08-29 14:46:49',1,NULL,NULL), +(2,1,1,1,'2024-08-23 09:20:04',1,'2024-08-23 09:20:29',1,NULL,NULL), +(3,2,2,1,'2024-08-23 10:00:52',2,'2024-08-23 10:00:52',2,NULL,NULL), +(4,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(5,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(6,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(7,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(8,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(9,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(10,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(11,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(12,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(13,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(14,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(15,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(16,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(17,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(18,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(19,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(20,2,2,1,'2024-08-23 10:00:53',2,'2024-08-23 10:00:53',2,NULL,NULL), +(21,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(22,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(23,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(24,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(25,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(26,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(27,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(28,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(29,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(30,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(31,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(32,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(33,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(34,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(35,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(36,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(37,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(38,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(39,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(40,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(41,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(42,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(43,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(44,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(45,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(46,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(47,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(48,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(49,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(50,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(51,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(52,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(53,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(54,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(55,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(56,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(57,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(58,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(59,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(60,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(61,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(62,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(63,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(64,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(65,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(66,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(67,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(68,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(69,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(70,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(71,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(72,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(73,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(74,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(75,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(76,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(77,2,2,1,'2024-08-23 10:00:54',2,'2024-08-23 10:00:54',2,NULL,NULL), +(78,1,1,1,'2024-08-29 14:47:08',1,'2024-08-29 14:48:30',1,NULL,NULL), +(79,1,1,1,'2024-08-29 14:47:27',1,'2024-08-29 14:47:27',1,NULL,NULL), +(80,1,1,1,'2024-08-29 14:47:33',1,'2024-08-29 14:47:33',1,NULL,NULL), +(81,1,1,1,'2024-08-29 14:47:46',1,'2024-08-29 14:47:46',1,NULL,NULL), +(82,1,1,1,'2024-08-29 14:47:50',1,'2024-08-29 14:47:50',1,NULL,NULL), +(83,1,1,1,'2024-08-29 14:47:54',1,'2024-08-29 14:47:54',1,NULL,NULL), +(84,1,1,1,'2024-08-29 14:48:01',1,'2024-08-29 14:48:01',1,NULL,NULL), +(85,1,1,1,'2024-08-29 14:56:17',1,'2024-08-29 14:56:17',1,NULL,NULL), +(86,2,2,1,'2025-02-14 08:36:54',1,'2025-02-14 09:13:45',1,NULL,NULL); /*!40000 ALTER TABLE `entity_info` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_entity_type.sql b/db/sql/test/populate_entity_type.sql index f8f621c2d..e743653b7 100644 --- a/db/sql/test/populate_entity_type.sql +++ b/db/sql/test/populate_entity_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `entity_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `entity_type` DISABLE KEYS */; INSERT INTO `entity_type` VALUES (1,'Template','Template',NULL,'classification for template items',NULL,NULL,NULL,NULL,NULL,1), diff --git a/db/sql/test/populate_item.sql b/db/sql/test/populate_item.sql index ff8b8cca5..997ee51bf 100644 --- a/db/sql/test/populate_item.sql +++ b/db/sql/test/populate_item.sql @@ -4,6 +4,91 @@ -- LOCK TABLES `item` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item` DISABLE KEYS */; +INSERT INTO `item` VALUES +(1,1,'Test Template Copy',NULL,NULL,NULL,NULL), +(2,1,'Test Template Per Entry',NULL,NULL,NULL,NULL), +(3,1,'test_doc_0',NULL,'','',NULL), +(4,1,'test_doc_1',NULL,'','',NULL), +(5,1,'test_doc_2',NULL,'','',NULL), +(6,1,'test_doc_3',NULL,'','',NULL), +(7,1,'test_doc_4',NULL,'','',NULL), +(8,1,'test_doc_5',NULL,'','',NULL), +(9,1,'test_doc_6',NULL,'','',NULL), +(10,1,'test_doc_7',NULL,'','',NULL), +(11,1,'test_doc_8',NULL,'','',NULL), +(12,1,'test_doc_9',NULL,'','',NULL), +(13,1,'test_doc_10',NULL,'','',NULL), +(14,1,'test_doc_11',NULL,'','',NULL), +(15,1,'test_doc_12',NULL,'','',NULL), +(16,1,'test_doc_13',NULL,'','',NULL), +(17,1,'test_doc_14',NULL,'','',NULL), +(18,1,'test_doc_15',NULL,'','',NULL), +(19,1,'test_doc_16',NULL,'','',NULL), +(20,1,'test_doc_17',NULL,'','',NULL), +(21,1,'test_doc_18',NULL,'','',NULL), +(22,1,'test_doc_19',NULL,'','',NULL), +(23,1,'test_doc_20',NULL,'','',NULL), +(24,1,'test_doc_21',NULL,'','',NULL), +(25,1,'test_doc_22',NULL,'','',NULL), +(26,1,'test_doc_23',NULL,'','',NULL), +(27,1,'test_doc_24',NULL,'','',NULL), +(28,1,'test_doc_25',NULL,'','',NULL), +(29,1,'test_doc_26',NULL,'','',NULL), +(30,1,'test_doc_27',NULL,'','',NULL), +(31,1,'test_doc_28',NULL,'','',NULL), +(32,1,'test_doc_29',NULL,'','',NULL), +(33,1,'test_doc_30',NULL,'','',NULL), +(34,1,'test_doc_31',NULL,'','',NULL), +(35,1,'test_doc_32',NULL,'','',NULL), +(36,1,'test_doc_33',NULL,'','',NULL), +(37,1,'test_doc_34',NULL,'','',NULL), +(38,1,'test_doc_35',NULL,'','',NULL), +(39,1,'test_doc_36',NULL,'','',NULL), +(40,1,'test_doc_37',NULL,'','',NULL), +(41,1,'test_doc_38',NULL,'','',NULL), +(42,1,'test_doc_39',NULL,'','',NULL), +(43,1,'test_doc_40',NULL,'','',NULL), +(44,1,'test_doc_41',NULL,'','',NULL), +(45,1,'test_doc_42',NULL,'','',NULL), +(46,1,'test_doc_43',NULL,'','',NULL), +(47,1,'test_doc_44',NULL,'','',NULL), +(48,1,'test_doc_45',NULL,'','',NULL), +(49,1,'test_doc_46',NULL,'','',NULL), +(50,1,'test_doc_47',NULL,'','',NULL), +(51,1,'test_doc_48',NULL,'','',NULL), +(52,1,'test_doc_49',NULL,'','',NULL), +(53,1,'test_doc_50',NULL,'','',NULL), +(54,1,'test_doc_51',NULL,'','',NULL), +(55,1,'test_doc_52',NULL,'','',NULL), +(56,1,'test_doc_53',NULL,'','',NULL), +(57,1,'test_doc_54',NULL,'','',NULL), +(58,1,'test_doc_55',NULL,'','',NULL), +(59,1,'test_doc_56',NULL,'','',NULL), +(60,1,'test_doc_57',NULL,'','',NULL), +(61,1,'test_doc_58',NULL,'','',NULL), +(62,1,'test_doc_59',NULL,'','',NULL), +(63,1,'test_doc_60',NULL,'','',NULL), +(64,1,'test_doc_61',NULL,'','',NULL), +(65,1,'test_doc_62',NULL,'','',NULL), +(66,1,'test_doc_63',NULL,'','',NULL), +(67,1,'test_doc_64',NULL,'','',NULL), +(68,1,'test_doc_65',NULL,'','',NULL), +(69,1,'test_doc_66',NULL,'','',NULL), +(70,1,'test_doc_67',NULL,'','',NULL), +(71,1,'test_doc_68',NULL,'','',NULL), +(72,1,'test_doc_69',NULL,'','',NULL), +(73,1,'test_doc_70',NULL,'','',NULL), +(74,1,'test_doc_71',NULL,'','',NULL), +(75,1,'test_doc_72',NULL,'','',NULL), +(76,1,'test_doc_73',NULL,'','',NULL), +(77,1,'test_doc_74',NULL,'','',NULL), +(78,1,'Test Template Sections + Copy',NULL,NULL,NULL,NULL), +(79,1,'Section 1',NULL,'','78',NULL), +(80,1,'Section 2',NULL,'','78',NULL), +(81,1,'Section 3',NULL,'','78',NULL), +(82,1,'Sample log document',NULL,'','',NULL), +(83,1,'Log Document With Entries',NULL,'','',NULL); /*!40000 ALTER TABLE `item` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_category.sql b/db/sql/test/populate_item_category.sql index fa19188d3..cc8b3eef4 100644 --- a/db/sql/test/populate_item_category.sql +++ b/db/sql/test/populate_item_category.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_category` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_category` DISABLE KEYS */; /*!40000 ALTER TABLE `item_category` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_category_item_type.sql b/db/sql/test/populate_item_category_item_type.sql index 2bbb3158e..955495ee3 100644 --- a/db/sql/test/populate_item_category_item_type.sql +++ b/db/sql/test/populate_item_category_item_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_category_item_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_category_item_type` DISABLE KEYS */; /*!40000 ALTER TABLE `item_category_item_type` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_connector.sql b/db/sql/test/populate_item_connector.sql index 5a433c4c9..5e33c4c4d 100644 --- a/db/sql/test/populate_item_connector.sql +++ b/db/sql/test/populate_item_connector.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_connector` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_connector` DISABLE KEYS */; /*!40000 ALTER TABLE `item_connector` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_connector_property.sql b/db/sql/test/populate_item_connector_property.sql index 6143d03f2..ed355121f 100644 --- a/db/sql/test/populate_item_connector_property.sql +++ b/db/sql/test/populate_item_connector_property.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_connector_property` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_connector_property` DISABLE KEYS */; /*!40000 ALTER TABLE `item_connector_property` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_element.sql b/db/sql/test/populate_item_element.sql index cc57791cb..7296dc70c 100644 --- a/db/sql/test/populate_item_element.sql +++ b/db/sql/test/populate_item_element.sql @@ -4,6 +4,94 @@ -- LOCK TABLES `item_element` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_element` DISABLE KEYS */; +INSERT INTO `item_element` VALUES +(1,NULL,1,NULL,NULL,NULL,NULL,0,1,'',NULL,1), +(2,NULL,2,NULL,NULL,NULL,NULL,0,1,'',NULL,2), +(3,NULL,3,NULL,NULL,NULL,NULL,0,1,NULL,NULL,3), +(4,NULL,4,NULL,NULL,NULL,NULL,0,1,NULL,NULL,4), +(5,NULL,5,NULL,NULL,NULL,NULL,0,1,NULL,NULL,5), +(6,NULL,6,NULL,NULL,NULL,NULL,0,1,NULL,NULL,6), +(7,NULL,7,NULL,NULL,NULL,NULL,0,1,NULL,NULL,7), +(8,NULL,8,NULL,NULL,NULL,NULL,0,1,NULL,NULL,8), +(9,NULL,9,NULL,NULL,NULL,NULL,0,1,NULL,NULL,9), +(10,NULL,10,NULL,NULL,NULL,NULL,0,1,NULL,NULL,10), +(11,NULL,11,NULL,NULL,NULL,NULL,0,1,NULL,NULL,11), +(12,NULL,12,NULL,NULL,NULL,NULL,0,1,NULL,NULL,12), +(13,NULL,13,NULL,NULL,NULL,NULL,0,1,NULL,NULL,13), +(14,NULL,14,NULL,NULL,NULL,NULL,0,1,NULL,NULL,14), +(15,NULL,15,NULL,NULL,NULL,NULL,0,1,NULL,NULL,15), +(16,NULL,16,NULL,NULL,NULL,NULL,0,1,NULL,NULL,16), +(17,NULL,17,NULL,NULL,NULL,NULL,0,1,NULL,NULL,17), +(18,NULL,18,NULL,NULL,NULL,NULL,0,1,NULL,NULL,18), +(19,NULL,19,NULL,NULL,NULL,NULL,0,1,NULL,NULL,19), +(20,NULL,20,NULL,NULL,NULL,NULL,0,1,NULL,NULL,20), +(21,NULL,21,NULL,NULL,NULL,NULL,0,1,NULL,NULL,21), +(22,NULL,22,NULL,NULL,NULL,NULL,0,1,NULL,NULL,22), +(23,NULL,23,NULL,NULL,NULL,NULL,0,1,NULL,NULL,23), +(24,NULL,24,NULL,NULL,NULL,NULL,0,1,NULL,NULL,24), +(25,NULL,25,NULL,NULL,NULL,NULL,0,1,NULL,NULL,25), +(26,NULL,26,NULL,NULL,NULL,NULL,0,1,NULL,NULL,26), +(27,NULL,27,NULL,NULL,NULL,NULL,0,1,NULL,NULL,27), +(28,NULL,28,NULL,NULL,NULL,NULL,0,1,NULL,NULL,28), +(29,NULL,29,NULL,NULL,NULL,NULL,0,1,NULL,NULL,29), +(30,NULL,30,NULL,NULL,NULL,NULL,0,1,NULL,NULL,30), +(31,NULL,31,NULL,NULL,NULL,NULL,0,1,NULL,NULL,31), +(32,NULL,32,NULL,NULL,NULL,NULL,0,1,NULL,NULL,32), +(33,NULL,33,NULL,NULL,NULL,NULL,0,1,NULL,NULL,33), +(34,NULL,34,NULL,NULL,NULL,NULL,0,1,NULL,NULL,34), +(35,NULL,35,NULL,NULL,NULL,NULL,0,1,NULL,NULL,35), +(36,NULL,36,NULL,NULL,NULL,NULL,0,1,NULL,NULL,36), +(37,NULL,37,NULL,NULL,NULL,NULL,0,1,NULL,NULL,37), +(38,NULL,38,NULL,NULL,NULL,NULL,0,1,NULL,NULL,38), +(39,NULL,39,NULL,NULL,NULL,NULL,0,1,NULL,NULL,39), +(40,NULL,40,NULL,NULL,NULL,NULL,0,1,NULL,NULL,40), +(41,NULL,41,NULL,NULL,NULL,NULL,0,1,NULL,NULL,41), +(42,NULL,42,NULL,NULL,NULL,NULL,0,1,NULL,NULL,42), +(43,NULL,43,NULL,NULL,NULL,NULL,0,1,NULL,NULL,43), +(44,NULL,44,NULL,NULL,NULL,NULL,0,1,NULL,NULL,44), +(45,NULL,45,NULL,NULL,NULL,NULL,0,1,NULL,NULL,45), +(46,NULL,46,NULL,NULL,NULL,NULL,0,1,NULL,NULL,46), +(47,NULL,47,NULL,NULL,NULL,NULL,0,1,NULL,NULL,47), +(48,NULL,48,NULL,NULL,NULL,NULL,0,1,NULL,NULL,48), +(49,NULL,49,NULL,NULL,NULL,NULL,0,1,NULL,NULL,49), +(50,NULL,50,NULL,NULL,NULL,NULL,0,1,NULL,NULL,50), +(51,NULL,51,NULL,NULL,NULL,NULL,0,1,NULL,NULL,51), +(52,NULL,52,NULL,NULL,NULL,NULL,0,1,NULL,NULL,52), +(53,NULL,53,NULL,NULL,NULL,NULL,0,1,NULL,NULL,53), +(54,NULL,54,NULL,NULL,NULL,NULL,0,1,NULL,NULL,54), +(55,NULL,55,NULL,NULL,NULL,NULL,0,1,NULL,NULL,55), +(56,NULL,56,NULL,NULL,NULL,NULL,0,1,NULL,NULL,56), +(57,NULL,57,NULL,NULL,NULL,NULL,0,1,NULL,NULL,57), +(58,NULL,58,NULL,NULL,NULL,NULL,0,1,NULL,NULL,58), +(59,NULL,59,NULL,NULL,NULL,NULL,0,1,NULL,NULL,59), +(60,NULL,60,NULL,NULL,NULL,NULL,0,1,NULL,NULL,60), +(61,NULL,61,NULL,NULL,NULL,NULL,0,1,NULL,NULL,61), +(62,NULL,62,NULL,NULL,NULL,NULL,0,1,NULL,NULL,62), +(63,NULL,63,NULL,NULL,NULL,NULL,0,1,NULL,NULL,63), +(64,NULL,64,NULL,NULL,NULL,NULL,0,1,NULL,NULL,64), +(65,NULL,65,NULL,NULL,NULL,NULL,0,1,NULL,NULL,65), +(66,NULL,66,NULL,NULL,NULL,NULL,0,1,NULL,NULL,66), +(67,NULL,67,NULL,NULL,NULL,NULL,0,1,NULL,NULL,67), +(68,NULL,68,NULL,NULL,NULL,NULL,0,1,NULL,NULL,68), +(69,NULL,69,NULL,NULL,NULL,NULL,0,1,NULL,NULL,69), +(70,NULL,70,NULL,NULL,NULL,NULL,0,1,NULL,NULL,70), +(71,NULL,71,NULL,NULL,NULL,NULL,0,1,NULL,NULL,71), +(72,NULL,72,NULL,NULL,NULL,NULL,0,1,NULL,NULL,72), +(73,NULL,73,NULL,NULL,NULL,NULL,0,1,NULL,NULL,73), +(74,NULL,74,NULL,NULL,NULL,NULL,0,1,NULL,NULL,74), +(75,NULL,75,NULL,NULL,NULL,NULL,0,1,NULL,NULL,75), +(76,NULL,76,NULL,NULL,NULL,NULL,0,1,NULL,NULL,76), +(77,NULL,77,NULL,NULL,NULL,NULL,0,1,NULL,NULL,77), +(78,NULL,78,NULL,NULL,NULL,NULL,0,1,'',NULL,78), +(79,'E1',78,79,NULL,NULL,NULL,0,1,NULL,NULL,80), +(80,NULL,79,NULL,NULL,NULL,NULL,0,1,'',NULL,79), +(81,NULL,80,NULL,NULL,NULL,NULL,0,1,'',NULL,81), +(82,'E2',78,80,NULL,NULL,NULL,0,1,NULL,NULL,82), +(83,NULL,81,NULL,NULL,NULL,NULL,0,1,'',NULL,83), +(84,'E3',78,81,NULL,NULL,NULL,0,1,NULL,NULL,84), +(85,NULL,82,NULL,NULL,NULL,NULL,0,1,NULL,NULL,85), +(86,NULL,83,NULL,NULL,NULL,NULL,0,1,NULL,NULL,86); /*!40000 ALTER TABLE `item_element` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_element_history.sql b/db/sql/test/populate_item_element_history.sql index d82d4b238..b1997933c 100644 --- a/db/sql/test/populate_item_element_history.sql +++ b/db/sql/test/populate_item_element_history.sql @@ -4,6 +4,94 @@ -- LOCK TABLES `item_element_history` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_element_history` DISABLE KEYS */; +INSERT INTO `item_element_history` VALUES +(1,NULL,1,'Test Template Copy',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 09:19:18',1), +(2,NULL,2,'Test Template Per Entry',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 09:20:04',1), +(3,NULL,3,'test_doc_0',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:52',2), +(4,NULL,4,'test_doc_1',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(5,NULL,5,'test_doc_2',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(6,NULL,6,'test_doc_3',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(7,NULL,7,'test_doc_4',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(8,NULL,8,'test_doc_5',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(9,NULL,9,'test_doc_6',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(10,NULL,10,'test_doc_7',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(11,NULL,11,'test_doc_8',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(12,NULL,12,'test_doc_9',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(13,NULL,13,'test_doc_10',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(14,NULL,14,'test_doc_11',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(15,NULL,15,'test_doc_12',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(16,NULL,16,'test_doc_13',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(17,NULL,17,'test_doc_14',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(18,NULL,18,'test_doc_15',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(19,NULL,19,'test_doc_16',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(20,NULL,20,'test_doc_17',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:53',2), +(21,NULL,21,'test_doc_18',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(22,NULL,22,'test_doc_19',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(23,NULL,23,'test_doc_20',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(24,NULL,24,'test_doc_21',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(25,NULL,25,'test_doc_22',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(26,NULL,26,'test_doc_23',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(27,NULL,27,'test_doc_24',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(28,NULL,28,'test_doc_25',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(29,NULL,29,'test_doc_26',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(30,NULL,30,'test_doc_27',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(31,NULL,31,'test_doc_28',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(32,NULL,32,'test_doc_29',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(33,NULL,33,'test_doc_30',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(34,NULL,34,'test_doc_31',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(35,NULL,35,'test_doc_32',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(36,NULL,36,'test_doc_33',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(37,NULL,37,'test_doc_34',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(38,NULL,38,'test_doc_35',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(39,NULL,39,'test_doc_36',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(40,NULL,40,'test_doc_37',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(41,NULL,41,'test_doc_38',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(42,NULL,42,'test_doc_39',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(43,NULL,43,'test_doc_40',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(44,NULL,44,'test_doc_41',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(45,NULL,45,'test_doc_42',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(46,NULL,46,'test_doc_43',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(47,NULL,47,'test_doc_44',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(48,NULL,48,'test_doc_45',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(49,NULL,49,'test_doc_46',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(50,NULL,50,'test_doc_47',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(51,NULL,51,'test_doc_48',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(52,NULL,52,'test_doc_49',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(53,NULL,53,'test_doc_50',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(54,NULL,54,'test_doc_51',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(55,NULL,55,'test_doc_52',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(56,NULL,56,'test_doc_53',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(57,NULL,57,'test_doc_54',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(58,NULL,58,'test_doc_55',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(59,NULL,59,'test_doc_56',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(60,NULL,60,'test_doc_57',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(61,NULL,61,'test_doc_58',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(62,NULL,62,'test_doc_59',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(63,NULL,63,'test_doc_60',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(64,NULL,64,'test_doc_61',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(65,NULL,65,'test_doc_62',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(66,NULL,66,'test_doc_63',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(67,NULL,67,'test_doc_64',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(68,NULL,68,'test_doc_65',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(69,NULL,69,'test_doc_66',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(70,NULL,70,'test_doc_67',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(71,NULL,71,'test_doc_68',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(72,NULL,72,'test_doc_69',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(73,NULL,73,'test_doc_70',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(74,NULL,74,'test_doc_71',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(75,NULL,75,'test_doc_72',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(76,NULL,76,'test_doc_73',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(77,NULL,77,'test_doc_74',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-23 10:00:54',2), +(78,NULL,78,'Test Template Sections',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-29 14:47:08',1), +(79,'E1',79,'Test Template Sections',78,'Section 1',79,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-29 14:47:33',1), +(80,NULL,80,'Section 1',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,'',NULL,'2024-08-29 14:47:33',1), +(81,NULL,81,'Section 2',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,'',NULL,'2024-08-29 14:47:50',1), +(82,'E2',82,'Test Template Sections',78,'Section 2',80,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-29 14:47:50',1), +(83,NULL,83,'Section 3',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,'',NULL,'2024-08-29 14:48:01',1), +(84,'E3',84,'Test Template Sections',78,'Section 3',81,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-29 14:48:01',1), +(85,NULL,85,'Sample log document',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2024-08-29 14:56:17',1), +(86,NULL,86,'Log Document With Entries',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,NULL,NULL,'2025-02-14 08:36:54',1); /*!40000 ALTER TABLE `item_element_history` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_element_list.sql b/db/sql/test/populate_item_element_list.sql index 89e2a51c4..88bb51bc3 100644 --- a/db/sql/test/populate_item_element_list.sql +++ b/db/sql/test/populate_item_element_list.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_element_list` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_element_list` DISABLE KEYS */; /*!40000 ALTER TABLE `item_element_list` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_element_log.sql b/db/sql/test/populate_item_element_log.sql index e67e69ffd..470162183 100644 --- a/db/sql/test/populate_item_element_log.sql +++ b/db/sql/test/populate_item_element_log.sql @@ -4,6 +4,18 @@ -- LOCK TABLES `item_element_log` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_element_log` DISABLE KEYS */; +INSERT INTO `item_element_log` VALUES +(1,10), +(1,14), +(1,15), +(1,16), +(2,13), +(80,19), +(83,22), +(86,27), +(86,30), +(86,31); /*!40000 ALTER TABLE `item_element_log` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_element_property.sql b/db/sql/test/populate_item_element_property.sql index 694b7130d..553541d45 100644 --- a/db/sql/test/populate_item_element_property.sql +++ b/db/sql/test/populate_item_element_property.sql @@ -4,6 +4,11 @@ -- LOCK TABLES `item_element_property` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_element_property` DISABLE KEYS */; +INSERT INTO `item_element_property` VALUES +(1,1), +(2,2), +(78,3); /*!40000 ALTER TABLE `item_element_property` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_element_relationship.sql b/db/sql/test/populate_item_element_relationship.sql index b383743fa..8af59799a 100644 --- a/db/sql/test/populate_item_element_relationship.sql +++ b/db/sql/test/populate_item_element_relationship.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_element_relationship` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_element_relationship` DISABLE KEYS */; /*!40000 ALTER TABLE `item_element_relationship` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_element_relationship_history.sql b/db/sql/test/populate_item_element_relationship_history.sql index 0a734ff18..2e1307ca7 100644 --- a/db/sql/test/populate_item_element_relationship_history.sql +++ b/db/sql/test/populate_item_element_relationship_history.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_element_relationship_history` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_element_relationship_history` DISABLE KEYS */; /*!40000 ALTER TABLE `item_element_relationship_history` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_element_relationship_property.sql b/db/sql/test/populate_item_element_relationship_property.sql index 3f0cddd01..2bb36ed15 100644 --- a/db/sql/test/populate_item_element_relationship_property.sql +++ b/db/sql/test/populate_item_element_relationship_property.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_element_relationship_property` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_element_relationship_property` DISABLE KEYS */; /*!40000 ALTER TABLE `item_element_relationship_property` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_entity_type.sql b/db/sql/test/populate_item_entity_type.sql index 894492d80..1ad99c4a1 100644 --- a/db/sql/test/populate_item_entity_type.sql +++ b/db/sql/test/populate_item_entity_type.sql @@ -4,6 +4,88 @@ -- LOCK TABLES `item_entity_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_entity_type` DISABLE KEYS */; +INSERT INTO `item_entity_type` VALUES +(1,1), +(2,1), +(3,4), +(4,4), +(5,4), +(6,4), +(7,4), +(8,4), +(9,4), +(10,4), +(11,4), +(12,4), +(13,4), +(14,4), +(15,4), +(16,4), +(17,4), +(18,4), +(19,4), +(20,4), +(21,4), +(22,4), +(23,4), +(24,4), +(25,4), +(26,4), +(27,4), +(28,4), +(29,4), +(30,4), +(31,4), +(32,4), +(33,4), +(34,4), +(35,4), +(36,4), +(37,4), +(38,4), +(39,4), +(40,4), +(41,4), +(42,4), +(43,4), +(44,4), +(45,4), +(46,4), +(47,4), +(48,4), +(49,4), +(50,4), +(51,4), +(52,4), +(53,4), +(54,4), +(55,4), +(56,4), +(57,4), +(58,4), +(59,4), +(60,4), +(61,4), +(62,4), +(63,4), +(64,4), +(65,4), +(66,4), +(67,4), +(68,4), +(69,4), +(70,4), +(71,4), +(72,4), +(73,4), +(74,4), +(75,4), +(76,4), +(77,4), +(78,1), +(82,5), +(83,5); /*!40000 ALTER TABLE `item_entity_type` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_item_category.sql b/db/sql/test/populate_item_item_category.sql index 8afc4d550..aeb3adeaa 100644 --- a/db/sql/test/populate_item_item_category.sql +++ b/db/sql/test/populate_item_item_category.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_item_category` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_item_category` DISABLE KEYS */; /*!40000 ALTER TABLE `item_item_category` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_item_project.sql b/db/sql/test/populate_item_item_project.sql index 5129b7a54..9be6b2f02 100644 --- a/db/sql/test/populate_item_item_project.sql +++ b/db/sql/test/populate_item_item_project.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_item_project` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_item_project` DISABLE KEYS */; /*!40000 ALTER TABLE `item_item_project` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_item_type.sql b/db/sql/test/populate_item_item_type.sql index c4a70fd63..79b985e03 100644 --- a/db/sql/test/populate_item_item_type.sql +++ b/db/sql/test/populate_item_item_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_item_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_item_type` DISABLE KEYS */; /*!40000 ALTER TABLE `item_item_type` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_project.sql b/db/sql/test/populate_item_project.sql index 7e00a4248..0ab80a924 100644 --- a/db/sql/test/populate_item_project.sql +++ b/db/sql/test/populate_item_project.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_project` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_project` DISABLE KEYS */; INSERT INTO `item_project` VALUES (1,'Sample',NULL); diff --git a/db/sql/test/populate_item_resource.sql b/db/sql/test/populate_item_resource.sql index c8e4b027a..47bc18847 100644 --- a/db/sql/test/populate_item_resource.sql +++ b/db/sql/test/populate_item_resource.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_resource` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_resource` DISABLE KEYS */; /*!40000 ALTER TABLE `item_resource` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_source.sql b/db/sql/test/populate_item_source.sql index 8f56f434d..f9e802ff9 100644 --- a/db/sql/test/populate_item_source.sql +++ b/db/sql/test/populate_item_source.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `item_source` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_source` DISABLE KEYS */; /*!40000 ALTER TABLE `item_source` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_item_type.sql b/db/sql/test/populate_item_type.sql index 1b937a60f..a5ab7c500 100644 --- a/db/sql/test/populate_item_type.sql +++ b/db/sql/test/populate_item_type.sql @@ -4,6 +4,20 @@ -- LOCK TABLES `item_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `item_type` DISABLE KEYS */; +INSERT INTO `item_type` VALUES +(1,'RF',NULL,1,NULL), +(2,'Software',NULL,1,NULL), +(3,'SR',NULL,1,NULL), +(4,'Feedback',NULL,1,NULL), +(5,'Linac',NULL,1,NULL), +(6,'PAR',NULL,1,NULL), +(7,'Booster',NULL,1,NULL), +(8,'Other',NULL,1,NULL), +(9,'LEA',NULL,1,NULL), +(10,'Laser',NULL,1,NULL), +(11,'Insertion Device',NULL,1,NULL), +(12,'ITS',NULL,1,NULL); /*!40000 ALTER TABLE `item_type` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_list.sql b/db/sql/test/populate_list.sql index b94fdc1fb..950d4d0d8 100644 --- a/db/sql/test/populate_list.sql +++ b/db/sql/test/populate_list.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `list` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `list` DISABLE KEYS */; /*!40000 ALTER TABLE `list` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_log.sql b/db/sql/test/populate_log.sql index 197375511..08d8f7379 100644 --- a/db/sql/test/populate_log.sql +++ b/db/sql/test/populate_log.sql @@ -4,6 +4,29 @@ -- LOCK TABLES `log` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `log` DISABLE KEYS */; +INSERT INTO `log` VALUES +(10,'Sample Init Log','2024-08-23 09:19:40','2024-08-23 09:19:40',1,1,'2024-08-23 09:19:40',NULL,NULL,NULL), +(13,'Per Entry Log','2024-08-23 09:20:17','2024-08-23 09:20:17',1,1,'2024-08-23 09:20:17',NULL,NULL,NULL), +(14,'Another test entry','2024-08-29 14:46:20','2024-08-29 14:46:20',1,1,'2024-08-29 14:46:20',NULL,NULL,NULL), +(15,'A third one as well','2024-08-29 14:46:27','2024-08-29 14:46:27',1,1,'2024-08-29 14:46:27',NULL,NULL,NULL), +(16,'How \r\n\r\nAbout \r\n\r\nMultiple \r\n\r\nLines','2024-08-29 14:46:40','2024-08-29 14:46:40',1,1,'2024-08-29 14:46:40',NULL,NULL,NULL), +(17,'User: logr | Created: Test Template Sections [Item Id: 78]','2024-08-29 14:47:22','2024-08-29 14:47:22',1,1,NULL,NULL,NULL,NULL), +(18,'User: logr | Updated: Test Template Sections [Item Id: 78]','2024-08-29 14:47:33','2024-08-29 14:47:33',1,1,NULL,NULL,NULL,NULL), +(19,'Section 1 Entry','2024-08-29 14:47:34','2024-08-29 14:47:34',1,1,'2024-08-29 14:47:34',NULL,NULL,NULL), +(20,'User: logr | Updated: Test Template Sections [Item Id: 78]','2024-08-29 14:47:50','2024-08-29 14:47:50',1,1,NULL,NULL,NULL,NULL), +(21,'User: logr | Updated: Test Template Sections [Item Id: 78]','2024-08-29 14:48:01','2024-08-29 14:48:01',1,1,NULL,NULL,NULL,NULL), +(22,'Section 3 Entry','2024-08-29 14:48:09','2024-08-29 14:48:09',1,1,'2024-08-29 14:48:09',NULL,NULL,NULL), +(23,'User: logr | Updated: Test Template Sections + Copy [Item Id: 78]','2024-08-29 14:48:30','2024-08-29 14:48:30',1,1,NULL,NULL,NULL,NULL), +(24,'User: logr | Updated: Test Template Sections + Copy [Item Id: 78]','2024-08-29 14:48:30','2024-08-29 14:48:30',1,1,NULL,NULL,NULL,NULL), +(25,'User: logr | Created: Sample log document [Item Id: 82]','2024-08-29 14:56:36','2024-08-29 14:56:36',1,1,NULL,NULL,NULL,NULL), +(26,'User: logr | Created: Log Document With Entries [Item Id: 83]','2025-02-14 08:37:06','2025-02-14 08:37:06',1,1,NULL,NULL,NULL,NULL), +(27,'Top level entry with reactions and replies','2025-02-14 08:37:23','2025-02-14 08:37:23',1,1,'2025-02-14 08:37:23',NULL,NULL,NULL), +(28,'Reply','2025-02-14 08:38:00','2025-02-14 08:38:00',1,1,'2025-02-14 08:38:00',NULL,27,NULL), +(29,'Reply with reaction','2025-02-14 08:38:09','2025-02-14 08:38:09',1,1,'2025-02-14 08:38:09',NULL,27,NULL), +(30,'Entry with reactions','2025-02-14 08:38:21','2025-02-14 08:38:21',1,1,'2025-02-14 08:38:21',NULL,NULL,NULL), +(31,'Entry with reply','2025-02-14 08:38:46','2025-02-14 08:38:46',1,1,'2025-02-14 08:38:46',NULL,NULL,NULL), +(32,'Reply','2025-02-14 08:39:01','2025-02-14 08:39:01',1,1,'2025-02-14 08:39:01',NULL,31,NULL); /*!40000 ALTER TABLE `log` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_log_attachment.sql b/db/sql/test/populate_log_attachment.sql index 13987ee80..134eeecce 100644 --- a/db/sql/test/populate_log_attachment.sql +++ b/db/sql/test/populate_log_attachment.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `log_attachment` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `log_attachment` DISABLE KEYS */; /*!40000 ALTER TABLE `log_attachment` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_log_level.sql b/db/sql/test/populate_log_level.sql index e7156f5ba..549e139fa 100644 --- a/db/sql/test/populate_log_level.sql +++ b/db/sql/test/populate_log_level.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `log_level` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `log_level` DISABLE KEYS */; INSERT INTO `log_level` VALUES (1,'Spares Warning',NULL), diff --git a/db/sql/test/populate_log_reaction.sql b/db/sql/test/populate_log_reaction.sql index c10fcfafa..12b3a0821 100644 --- a/db/sql/test/populate_log_reaction.sql +++ b/db/sql/test/populate_log_reaction.sql @@ -4,6 +4,19 @@ -- LOCK TABLES `log_reaction` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `log_reaction` DISABLE KEYS */; +INSERT INTO `log_reaction` VALUES +(27,1,1), +(27,2,1), +(27,3,1), +(27,4,1), +(27,5,1), +(29,1,1), +(30,1,1), +(30,2,1), +(30,3,1), +(30,4,1), +(30,5,1); /*!40000 ALTER TABLE `log_reaction` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_log_topic.sql b/db/sql/test/populate_log_topic.sql index 42686c019..c91211155 100644 --- a/db/sql/test/populate_log_topic.sql +++ b/db/sql/test/populate_log_topic.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `log_topic` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `log_topic` DISABLE KEYS */; INSERT INTO `log_topic` VALUES (1,'General',NULL); diff --git a/db/sql/test/populate_property_metadata.sql b/db/sql/test/populate_property_metadata.sql index d2bb43843..11063d5a8 100644 --- a/db/sql/test/populate_property_metadata.sql +++ b/db/sql/test/populate_property_metadata.sql @@ -4,6 +4,20 @@ -- LOCK TABLES `property_metadata` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `property_metadata` DISABLE KEYS */; +INSERT INTO `property_metadata` VALUES +(1,1,'logLockout','0.0'), +(2,1,'docLockout','0.0'), +(3,1,'showTimestamps','true'), +(4,1,'logMode','copy'), +(5,2,'showTimestamps','true'), +(6,2,'docLockout','0.0'), +(7,2,'logMode','template per entry'), +(8,2,'logLockout','0.0'), +(9,3,'showTimestamps','true'), +(10,3,'logMode','copy'), +(11,3,'docLockout','0.0'), +(12,3,'logLockout','0.0'); /*!40000 ALTER TABLE `property_metadata` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_property_metadata_history.sql b/db/sql/test/populate_property_metadata_history.sql index c6566dd59..a3effd0b6 100644 --- a/db/sql/test/populate_property_metadata_history.sql +++ b/db/sql/test/populate_property_metadata_history.sql @@ -4,6 +4,12 @@ -- LOCK TABLES `property_metadata_history` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `property_metadata_history` DISABLE KEYS */; +INSERT INTO `property_metadata_history` VALUES +(1,1,'docLockout','0.0'), +(2,1,'logMode','none'), +(3,1,'logLockout','0.0'), +(4,1,'showTimestamps','true'); /*!40000 ALTER TABLE `property_metadata_history` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_property_type.sql b/db/sql/test/populate_property_type.sql index b4b980dfb..463775d3a 100644 --- a/db/sql/test/populate_property_type.sql +++ b/db/sql/test/populate_property_type.sql @@ -4,9 +4,11 @@ -- LOCK TABLES `property_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `property_type` DISABLE KEYS */; INSERT INTO `property_type` VALUES (1,'Image',NULL,NULL,1,2,NULL,NULL,0,0,0,1,1), -(2,'Document (Upload)','',NULL,1,1,'','',0,0,0,1,1); +(2,'Document (Upload)','',NULL,1,1,'','',0,0,0,1,1), +(3,'Logbook Document Settings',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL,NULL); /*!40000 ALTER TABLE `property_type` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_property_type_category.sql b/db/sql/test/populate_property_type_category.sql index 52e98b7c5..04c9c774e 100644 --- a/db/sql/test/populate_property_type_category.sql +++ b/db/sql/test/populate_property_type_category.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `property_type_category` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `property_type_category` DISABLE KEYS */; INSERT INTO `property_type_category` VALUES (1,'Documentation',NULL), diff --git a/db/sql/test/populate_property_type_handler.sql b/db/sql/test/populate_property_type_handler.sql index c18017494..f2b107837 100644 --- a/db/sql/test/populate_property_type_handler.sql +++ b/db/sql/test/populate_property_type_handler.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `property_type_handler` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `property_type_handler` DISABLE KEYS */; INSERT INTO `property_type_handler` VALUES (1,'Document','Generic document handler.'), diff --git a/db/sql/test/populate_property_type_metadata.sql b/db/sql/test/populate_property_type_metadata.sql index 39ea1680e..7a995cf26 100644 --- a/db/sql/test/populate_property_type_metadata.sql +++ b/db/sql/test/populate_property_type_metadata.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `property_type_metadata` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `property_type_metadata` DISABLE KEYS */; /*!40000 ALTER TABLE `property_type_metadata` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_property_value.sql b/db/sql/test/populate_property_value.sql index 25b192001..f239ee29d 100644 --- a/db/sql/test/populate_property_value.sql +++ b/db/sql/test/populate_property_value.sql @@ -4,6 +4,11 @@ -- LOCK TABLES `property_value` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `property_value` DISABLE KEYS */; +INSERT INTO `property_value` VALUES +(1,3,NULL,'',NULL,NULL,'2024-08-23 09:19:58',1,NULL,NULL,0,0,NULL,NULL), +(2,3,NULL,'',NULL,NULL,'2024-08-23 09:20:29',1,NULL,NULL,0,0,NULL,NULL), +(3,3,NULL,'',NULL,NULL,'2024-08-29 14:48:30',1,NULL,NULL,0,0,NULL,NULL); /*!40000 ALTER TABLE `property_value` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_property_value_history.sql b/db/sql/test/populate_property_value_history.sql index 642bb9445..11f550297 100644 --- a/db/sql/test/populate_property_value_history.sql +++ b/db/sql/test/populate_property_value_history.sql @@ -4,6 +4,9 @@ -- LOCK TABLES `property_value_history` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `property_value_history` DISABLE KEYS */; +INSERT INTO `property_value_history` VALUES +(1,3,NULL,'',NULL,NULL,'2024-08-29 14:47:33',1,'2024-08-29 14:47:33',NULL,NULL,NULL); /*!40000 ALTER TABLE `property_value_history` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_reaction.sql b/db/sql/test/populate_reaction.sql index b06c752d8..fae58e99a 100644 --- a/db/sql/test/populate_reaction.sql +++ b/db/sql/test/populate_reaction.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `reaction` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `reaction` DISABLE KEYS */; INSERT INTO `reaction` VALUES (1,'Like',128077,NULL,1.00), diff --git a/db/sql/test/populate_relationship_type.sql b/db/sql/test/populate_relationship_type.sql index 7cca9f84b..0251ae1b4 100644 --- a/db/sql/test/populate_relationship_type.sql +++ b/db/sql/test/populate_relationship_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `relationship_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `relationship_type` DISABLE KEYS */; INSERT INTO `relationship_type` VALUES (1,'Created From Template','',NULL); diff --git a/db/sql/test/populate_relationship_type_handler.sql b/db/sql/test/populate_relationship_type_handler.sql index 7434ac817..5bf0f6a4a 100644 --- a/db/sql/test/populate_relationship_type_handler.sql +++ b/db/sql/test/populate_relationship_type_handler.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `relationship_type_handler` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `relationship_type_handler` DISABLE KEYS */; /*!40000 ALTER TABLE `relationship_type_handler` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_resource_type.sql b/db/sql/test/populate_resource_type.sql index afb2e0856..929999b15 100644 --- a/db/sql/test/populate_resource_type.sql +++ b/db/sql/test/populate_resource_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `resource_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `resource_type` DISABLE KEYS */; /*!40000 ALTER TABLE `resource_type` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_resource_type_category.sql b/db/sql/test/populate_resource_type_category.sql index 87547c060..e1b5e26ac 100644 --- a/db/sql/test/populate_resource_type_category.sql +++ b/db/sql/test/populate_resource_type_category.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `resource_type_category` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `resource_type_category` DISABLE KEYS */; /*!40000 ALTER TABLE `resource_type_category` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_role_type.sql b/db/sql/test/populate_role_type.sql index 6d09a0088..4dc648d12 100644 --- a/db/sql/test/populate_role_type.sql +++ b/db/sql/test/populate_role_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `role_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `role_type` DISABLE KEYS */; INSERT INTO `role_type` VALUES (1,'group_settings_admin','Ability to edit view settings for a particular group.'); diff --git a/db/sql/test/populate_setting_type.sql b/db/sql/test/populate_setting_type.sql index d382d7f4d..e73d429ef 100644 --- a/db/sql/test/populate_setting_type.sql +++ b/db/sql/test/populate_setting_type.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `setting_type` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `setting_type` DISABLE KEYS */; INSERT INTO `setting_type` VALUES (1,'ItemDomainLogbook.List.Display.NumberOfItemsPerPage','Display specified number of items per page.','25'), diff --git a/db/sql/test/populate_source.sql b/db/sql/test/populate_source.sql index e08143d57..6ff3b64c8 100644 --- a/db/sql/test/populate_source.sql +++ b/db/sql/test/populate_source.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `source` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `source` DISABLE KEYS */; /*!40000 ALTER TABLE `source` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_system_log.sql b/db/sql/test/populate_system_log.sql index 5188687c4..d416765a7 100644 --- a/db/sql/test/populate_system_log.sql +++ b/db/sql/test/populate_system_log.sql @@ -4,6 +4,16 @@ -- LOCK TABLES `system_log` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `system_log` DISABLE KEYS */; +INSERT INTO `system_log` VALUES +(17,4), +(18,4), +(20,4), +(21,4), +(23,4), +(24,4), +(25,4), +(26,4); /*!40000 ALTER TABLE `system_log` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_group.sql b/db/sql/test/populate_user_group.sql index a81ec37a1..d668441fe 100644 --- a/db/sql/test/populate_user_group.sql +++ b/db/sql/test/populate_user_group.sql @@ -4,8 +4,10 @@ -- LOCK TABLES `user_group` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_group` DISABLE KEYS */; INSERT INTO `user_group` VALUES -(1,'LOGR_ADMIN','System Admin Group'); +(1,'LOGR_ADMIN','System Admin Group'), +(2,'REG',''); /*!40000 ALTER TABLE `user_group` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_group_list.sql b/db/sql/test/populate_user_group_list.sql index e0cb0e721..9a66d593d 100644 --- a/db/sql/test/populate_user_group_list.sql +++ b/db/sql/test/populate_user_group_list.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `user_group_list` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_group_list` DISABLE KEYS */; /*!40000 ALTER TABLE `user_group_list` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_group_setting.sql b/db/sql/test/populate_user_group_setting.sql index 70b13f65d..e081587f8 100644 --- a/db/sql/test/populate_user_group_setting.sql +++ b/db/sql/test/populate_user_group_setting.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `user_group_setting` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_group_setting` DISABLE KEYS */; /*!40000 ALTER TABLE `user_group_setting` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_info.sql b/db/sql/test/populate_user_info.sql index d4cf45949..19b64754c 100644 --- a/db/sql/test/populate_user_info.sql +++ b/db/sql/test/populate_user_info.sql @@ -4,8 +4,10 @@ -- LOCK TABLES `user_info` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_info` DISABLE KEYS */; INSERT INTO `user_info` VALUES -(1,'logr','LOGR','System Account',NULL,'logr@aps.anl.gov',NULL,NULL); +(1,'logr','LOGR','System Account','','logr@aps.anl.gov','aNX5$whZeG05Yq7xgrO8lah3oZilG5mAQAVaJ',''), +(2,'user','User','Standard','','','nQs4$9GXkrvqFf8+eFmRfK3uskEfun51bycyx',''); /*!40000 ALTER TABLE `user_info` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_list.sql b/db/sql/test/populate_user_list.sql index 8929359f9..2fb8d17df 100644 --- a/db/sql/test/populate_user_list.sql +++ b/db/sql/test/populate_user_list.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `user_list` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_list` DISABLE KEYS */; /*!40000 ALTER TABLE `user_list` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_role.sql b/db/sql/test/populate_user_role.sql index 69239390f..33e2bd779 100644 --- a/db/sql/test/populate_user_role.sql +++ b/db/sql/test/populate_user_role.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `user_role` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_role` DISABLE KEYS */; /*!40000 ALTER TABLE `user_role` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_session.sql b/db/sql/test/populate_user_session.sql index 1c194924f..e6b0ce0d0 100644 --- a/db/sql/test/populate_user_session.sql +++ b/db/sql/test/populate_user_session.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `user_session` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_session` DISABLE KEYS */; /*!40000 ALTER TABLE `user_session` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_setting.sql b/db/sql/test/populate_user_setting.sql index 25e9ab225..a2b1edeb4 100644 --- a/db/sql/test/populate_user_setting.sql +++ b/db/sql/test/populate_user_setting.sql @@ -4,6 +4,7 @@ -- LOCK TABLES `user_setting` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_setting` DISABLE KEYS */; /*!40000 ALTER TABLE `user_setting` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/sql/test/populate_user_user_group.sql b/db/sql/test/populate_user_user_group.sql index c619bd791..1ecef4468 100644 --- a/db/sql/test/populate_user_user_group.sql +++ b/db/sql/test/populate_user_user_group.sql @@ -4,8 +4,10 @@ -- LOCK TABLES `user_user_group` WRITE; +SET SESSION FOREIGN_KEY_CHECKS=0; /*!40000 ALTER TABLE `user_user_group` DISABLE KEYS */; INSERT INTO `user_user_group` VALUES -(1,1); +(1,1), +(2,2); /*!40000 ALTER TABLE `user_user_group` ENABLE KEYS */; UNLOCK TABLES; From 0aaa1eb23b566936755c7edac1e18e56a7e20ac7 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Mon, 21 Sep 2026 14:48:38 -0500 Subject: [PATCH 02/17] The get logbook types no loger returns the logbook that are groupings of logbooks. --- tools/developer_tools/python-client/test/log_document_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/developer_tools/python-client/test/log_document_test.py b/tools/developer_tools/python-client/test/log_document_test.py index 775799c53..675fc52a7 100644 --- a/tools/developer_tools/python-client/test/log_document_test.py +++ b/tools/developer_tools/python-client/test/log_document_test.py @@ -9,8 +9,7 @@ class LogDocumentFetchTests(BelyTestBase): def test_fetch_logbooks(self): logbooks = self.logbook_api.get_logbook_types() - - self.assertEqual(len(logbooks), 13) + self.assertEqual(len(logbooks), 11) def test_fetch_lobook_systems(self): systems = self.logbook_api.get_logbook_systems() From 65ad1b7b4904734e53d2e93a0de83027dbf36ceb Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Mon, 21 Sep 2026 15:11:51 -0500 Subject: [PATCH 03/17] Add a delete route for log entries --- .../aps/logr/rest/routes/LogbookRoute.java | 24 +++++++ .../python-client/test/log_entry_test.py | 69 ++++++++++++++++++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java index 36acd50fc..336a684f2 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java @@ -46,6 +46,7 @@ import java.util.List; import java.util.Objects; import javax.ejb.EJB; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.Consumes; import javax.ws.rs.PUT; @@ -54,6 +55,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -258,6 +260,28 @@ public LogEntry addUpdateLogEntry(@RequestBody(required = true) LogEntry logEntr return new LogEntry(itemId, logEntity, false, false); } + @DELETE + @Path("/DeleteLogEntry/{logDocumentId}/{logId}") + @Operation(summary = "Delete a log entry or reply from a log document or section.", responses = { + @ApiResponse(responseCode = "204", description = "Deleted")}) + @SecurityRequirement(name = "belyAuth") + @Secured + public Response deleteLogEntry( + @PathParam("logDocumentId") int logDocumentId, + @PathParam("logId") int logId) throws CdbException { + ItemDomainLogbook logDocument = getLogDocumentById(logDocumentId); + verifyCurrentUserPermissionForItem(logDocument); + + Log logEntity = findLogInDocument(logDocument, logId); + UserInfo user = getCurrentRequestUserInfo(); + ItemDomainLogbookControllerUtility utility = new ItemDomainLogbookControllerUtility(); + utility.verifySaveLogLockoutsForItem(logDocument, logEntity, user); + utility.destroyLogEntry(logEntity, user); + + updateModifiedDateForLogDocument(logDocument, user); + return Response.noContent().build(); + } + @PUT @Path("/CreateLogDocument") @Consumes(MediaType.APPLICATION_JSON) diff --git a/tools/developer_tools/python-client/test/log_entry_test.py b/tools/developer_tools/python-client/test/log_entry_test.py index 127bc51a5..2e8bff3be 100644 --- a/tools/developer_tools/python-client/test/log_entry_test.py +++ b/tools/developer_tools/python-client/test/log_entry_test.py @@ -1,5 +1,5 @@ import unittest -from belyApi import OpenApiException +from belyApi import LogDocumentOptions, OpenApiException from test.bely_test_base import BelyTestBase @@ -138,6 +138,73 @@ def test_update_log_reply(self): log_reply = log_entry.log_replies[0] self.assertEqual(log_entry_text, log_reply.log_entry) + def _create_document_and_entry(self): + self.login_as_user() + options = LogDocumentOptions( + name=f"Delete entry {self._gen_unique_name()}", + logbook_type_id=self.CTL_LOGBOOK_ID, + ) + document = self.logbook_api.create_logbook_document(options) + entry = self.logbook_api.get_log_entry_template(document.id) + entry.log_entry = "entry to delete" + return document, self.logbook_api.add_update_log_entry(entry) + + def test_delete_log_entry(self): + document, entry = self._create_document_and_entry() + + result = self.logbook_api.delete_log_entry(document.id, entry.log_id) + + self.assertIsNone(result) + self.assertEqual([], self.logbook_api.get_log_entries(document.id)) + + def test_delete_log_entry_requires_authentication(self): + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_entry(self.DOC_WITH_ENTRIES, 1) + + def test_delete_log_entry_rejects_mismatched_document(self): + document, entry = self._create_document_and_entry() + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_entry(self.DOC_WITH_ENTRIES, entry.log_id) + + entries = self.logbook_api.get_log_entries(document.id) + self.assertEqual([entry.log_id], [item.log_id for item in entries]) + + def test_delete_log_entry_requires_document_permission(self): + self.login_as_admin() + entry = self.logbook_api.get_log_entry_template(self.DOC_SAMPLE_ID) + entry.log_entry = "permission test entry" + entry = self.logbook_api.add_update_log_entry(entry) + + self.login_as_user() + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_entry(self.DOC_SAMPLE_ID, entry.log_id) + + self.login_as_admin() + entry_ids = [ + item.log_id + for item in self.logbook_api.get_log_entries(self.DOC_SAMPLE_ID) + ] + self.assertIn(entry.log_id, entry_ids) + self.logbook_api.delete_log_entry(self.DOC_SAMPLE_ID, entry.log_id) + + def test_delete_log_reply(self): + self.login_as_user() + entries = self.logbook_api.get_log_entries( + self.DOC_WITH_ENTRIES, load_replies=True + ) + entry = entries[0] + reply_id = entry.log_replies[0].log_id + + result = self.logbook_api.delete_log_entry(self.DOC_WITH_ENTRIES, reply_id) + + self.assertIsNone(result) + updated_entries = self.logbook_api.get_log_entries( + self.DOC_WITH_ENTRIES, load_replies=True + ) + updated_reply_ids = [reply.log_id for reply in updated_entries[0].log_replies] + self.assertNotIn(reply_id, updated_reply_ids) + if __name__ == "__main__": unittest.main() From 84e4ef7463af0085c84dea27b3fd2e6035f02b1e Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 08:01:41 -0500 Subject: [PATCH 04/17] Standardize removal of log document in the controller utility for destroy function in API. --- .../ItemDomainLogbookController.java | 30 +------------------ .../ItemDomainLogbookControllerUtility.java | 19 ++++++++++++ 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/ItemDomainLogbookController.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/ItemDomainLogbookController.java index 37edfe4c4..ede7ad1a6 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/ItemDomainLogbookController.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/ItemDomainLogbookController.java @@ -961,37 +961,9 @@ protected void appendTemplateEntityType(ItemDomainLogbook item) throws CdbExcept @Override protected void performDestroyOperation(ItemDomainLogbook entity) throws CdbException { - // Remove placeholder settings or other property value - // No need to perform destroy operation on non-existing entities, causes exception. - List propertyValueList = entity.getPropertyValueList(); - for (int i = 0; i < propertyValueList.size(); i++) { - PropertyValue pv = propertyValueList.get(i); - - if (pv.getId() == null) { - propertyValueList.remove(i); - } - } - - if (entity.getIsItemTemplate()) { - List itemsCreatedFromThisTemplateItem = entity.getItemsCreatedFromThisTemplateItem(); - - if (itemsCreatedFromThisTemplateItem.size() > 0) { - throw new CdbException("The item has template instances."); - } - } - ItemDomainLogbookControllerUtility controllerUtility = getControllerUtility(); UserInfo user = SessionUtility.getUser(); - - List itemsToDestroy = new ArrayList<>(); - - for (ItemElement child : entity.getItemElementDisplayList()) { - ItemDomainLogbook containedItem = (ItemDomainLogbook) child.getContainedItem(); - itemsToDestroy.add(containedItem); - } - - controllerUtility.destroy(entity, user); - controllerUtility.destroyList(itemsToDestroy, null, user); + controllerUtility.destroyLogDocument(entity, user); } @Override diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/utilities/ItemDomainLogbookControllerUtility.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/utilities/ItemDomainLogbookControllerUtility.java index da4235646..d7814d077 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/utilities/ItemDomainLogbookControllerUtility.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/utilities/ItemDomainLogbookControllerUtility.java @@ -60,6 +60,25 @@ protected ItemDomainLogbook instenciateNewItemDomainEntity() { return new ItemDomainLogbook(); } + public void destroyLogDocument(ItemDomainLogbook entity, UserInfo user) throws CdbException { + // Remove placeholder settings or empty property values. + // No need to remove non-existing entities, causes execptions. + List propertyValueList = entity.getPropertyValueList(); + propertyValueList.removeIf(propertyValue -> propertyValue.getId() == null); + + if (entity.getIsItemTemplate() && !entity.getItemsCreatedFromThisTemplateItem().isEmpty()) { + throw new CdbException("The item has template instances."); + } + + List sections = new ArrayList<>(); + for (ItemElement child : entity.getItemElementDisplayList()) { + sections.add((ItemDomainLogbook) child.getContainedItem()); + } + + destroy(entity, user); + destroyList(sections, null, user); + } + @Override public boolean isEntityHasQrId() { return false; From 129866c0a7e70e5aeb4f2c27e5cae1f6b8aa0383 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 08:03:12 -0500 Subject: [PATCH 05/17] Add a delete operation for removing log documents from REST API. --- .../aps/logr/rest/routes/LogbookRoute.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java index 336a684f2..f3820c68f 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java @@ -282,6 +282,28 @@ public Response deleteLogEntry( return Response.noContent().build(); } + @DELETE + @Path("/DeleteLogDocument/{logDocumentId}") + @Operation(summary = "Delete a top-level log document and its sections.", responses = { + @ApiResponse(responseCode = "204", description = "Deleted")}) + @SecurityRequirement(name = "belyAuth") + @Secured + public Response deleteLogDocument(@PathParam("logDocumentId") int logDocumentId) throws CdbException { + ItemDomainLogbook logDocument = getLogDocumentById(logDocumentId); + if (!Objects.equals(logDocument.getTopLevelLogDocument().getId(), logDocument.getId())) { + throw new InvalidArgument("Log document id identifies a section."); + } + if (logDocument.getIsItemTemplate()) { + throw new InvalidArgument("Log document id identifies a template."); + } + verifyCurrentUserPermissionForItem(logDocument); + + UserInfo user = getCurrentRequestUserInfo(); + ItemDomainLogbookControllerUtility utility = new ItemDomainLogbookControllerUtility(); + utility.destroyLogDocument(logDocument, user); + return Response.noContent().build(); + } + @PUT @Path("/CreateLogDocument") @Consumes(MediaType.APPLICATION_JSON) From 3129f8c0c518fada303073911b40487fa5223fe9 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 08:55:55 -0500 Subject: [PATCH 06/17] Add ability to remove a log document --- .../python-client/test/log_document_test.py | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tools/developer_tools/python-client/test/log_document_test.py b/tools/developer_tools/python-client/test/log_document_test.py index 675fc52a7..01e8c6b34 100644 --- a/tools/developer_tools/python-client/test/log_document_test.py +++ b/tools/developer_tools/python-client/test/log_document_test.py @@ -231,6 +231,73 @@ def test_create_log_document_with_sections(self): for i, section in enumerate(added_sections): self.assertEqual(sample_sections[i], section.name) + def _create_document_for_delete(self, with_section=False, as_admin=False): + if as_admin: + self.login_as_admin() + else: + self.login_as_user() + options = LogDocumentOptions( + name=f"Delete document {self._gen_unique_name()}", + logbook_type_id=self.CTL_LOGBOOK_ID, + ) + document = self.logbook_api.create_logbook_document(options) + section = None + if with_section: + section = self.logbook_api.create_log_document_section( + document.id, "section to delete" + ) + return document, section + + def test_delete_log_document(self): + document, section = self._create_document_for_delete(with_section=True) + + result = self.logbook_api.delete_log_document(document.id) + + self.assertIsNone(result) + with self.assertRaises(OpenApiException): + self.logbook_api.get_log_document_by_name(document.name) + with self.assertRaises(OpenApiException): + self.logbook_api.get_log_entries(section.id) + + def test_delete_log_document_requires_authentication(self): + document, _ = self._create_document_for_delete() + self.factory.logout_user() + self.loggedIn = False + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_document(document.id) + + self.login_as_user() + self.logbook_api.delete_log_document(document.id) + + def test_delete_log_document_requires_permission(self): + document, _ = self._create_document_for_delete(as_admin=True) + + self.login_as_user() + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_document(document.id) + + self.login_as_admin() + result = self.logbook_api.get_log_document_by_name(document.name) + self.assertEqual(document.id, result.id) + self.logbook_api.delete_log_document(document.id) + + def test_delete_log_document_rejects_section(self): + document, section = self._create_document_for_delete(with_section=True) + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_document(section.id) + + result = self.logbook_api.get_log_document_by_name(document.name) + self.assertEqual(document.id, result.id) + self.logbook_api.delete_log_document(document.id) + + def test_delete_log_document_rejects_template(self): + self.login_as_admin() + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_document(self.DOC_TEMPLATE_COPY_ID) + if __name__ == "__main__": unittest.main() From 9b81cc2b594195e0b8acc3109321cb6fb80a55ac Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 11:17:52 -0500 Subject: [PATCH 07/17] Include log entry id that can be later used to reference it for removal. --- .../aps/logr/rest/entities/LogEntryAttachment.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/entities/LogEntryAttachment.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/entities/LogEntryAttachment.java index 31290d8e2..5d1a94b52 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/entities/LogEntryAttachment.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/entities/LogEntryAttachment.java @@ -11,6 +11,7 @@ */ public class LogEntryAttachment { + private Integer id; private String markdownReference; private String downloadPath; private String originalFilename; @@ -19,13 +20,22 @@ public class LogEntryAttachment { public LogEntryAttachment() { } - public LogEntryAttachment(String markdownReference, String downloadPath, String originalFilename, String storedFilename) { + public LogEntryAttachment(Integer id, String markdownReference, String downloadPath, String originalFilename, String storedFilename) { + this.id = id; this.markdownReference = markdownReference; this.downloadPath = downloadPath; this.originalFilename = originalFilename; this.storedFilename = storedFilename; } + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + public String getMarkdownReference() { return markdownReference; } From c55be972742a66a9ab08b0a7f266970a6057f7a8 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 11:22:51 -0500 Subject: [PATCH 08/17] Add utility to allow file system removal of an attachment --- .../logr/portal/utilities/LogAttachmentUtility.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java index c7467fbf1..da0a17f55 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java @@ -4,6 +4,7 @@ */ package gov.anl.aps.logr.portal.utilities; +import gov.anl.aps.logr.common.constants.CdbPropertyValue; import gov.anl.aps.logr.common.utilities.FileUtility; import gov.anl.aps.logr.portal.model.db.entities.Attachment; import gov.anl.aps.logr.portal.model.db.entities.Log; @@ -73,6 +74,15 @@ public static Attachment uploadAttachment(InputStream inputStream, String fileNa return attachment; } + public static void deleteAttachmentFiles(Attachment attachment) throws IOException { + String name = attachment.getName(); + Files.deleteIfExists(Paths.get(StorageUtility.getFileSystemLogAttachmentPath(name))); + Files.deleteIfExists(Paths.get(StorageUtility.getFileSystemLogAttachmentPath( + name + CdbPropertyValue.SCALED_IMAGE_EXTENSION))); + Files.deleteIfExists(Paths.get(StorageUtility.getFileSystemLogAttachmentPath( + name + CdbPropertyValue.THUMBNAIL_IMAGE_EXTENSION))); + } + /** * Build a markdown reference string for an attachment. Returns * "![filename](path)" for viewable files, "[filename](path)" for others. From e1b57209cf2eb72d1efceabdec3720873caffd97 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 11:23:34 -0500 Subject: [PATCH 09/17] Add a API call to delete an attachment --- .../aps/logr/rest/routes/LogbookRoute.java | 59 ++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java index f3820c68f..db3296636 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java @@ -12,6 +12,7 @@ import gov.anl.aps.logr.portal.constants.ItemDomainName; import gov.anl.aps.logr.portal.controllers.utilities.EntityInfoControllerUtility; import gov.anl.aps.logr.portal.controllers.utilities.ItemDomainLogbookControllerUtility; +import gov.anl.aps.logr.portal.model.db.beans.AttachmentFacade; import gov.anl.aps.logr.portal.model.db.beans.DomainFacade; import gov.anl.aps.logr.portal.model.db.beans.ItemDomainLogbookFacade; import gov.anl.aps.logr.portal.model.db.beans.LogFacade; @@ -79,6 +80,9 @@ public class LogbookRoute extends ItemBaseRoute { @EJB LogFacade logFacade; + @EJB + AttachmentFacade attachmentFacade; + // Delegates to the shared helper, which copies before removing the template type instead of filtering the domain's managed list in place. @GET @Path("/LogbookTypes") @@ -421,17 +425,53 @@ public LogEntryAttachment uploadAttachment( ItemDomainLogbookControllerUtility utility = new ItemDomainLogbookControllerUtility(); Log originalLogEntry = logFacade.find(logId); utility.saveLog(logEntity, user, originalLogEntry); + attachment = attachmentFacade.findByName(attachment.getName()); updateModifiedDateForLogDocument(logDocument, user); String downloadPath = "/api/Downloads/Attachments/" + attachment.getName(); - return new LogEntryAttachment(markdownReference, downloadPath, fileName, attachment.getName()); + return new LogEntryAttachment(attachment.getId(), markdownReference, downloadPath, fileName, attachment.getName()); } catch (IOException ex) { LOGGER.error(ex); throw new CdbException("Failed to upload attachment: " + ex.getMessage()); } } + @DELETE + @Path("/DeleteAttachment/{logDocumentId}/{logId}/{attachmentId}") + @Operation(summary = "Delete an attachment from a log entry.", responses = { + @ApiResponse(responseCode = "204", description = "Deleted")}) + @SecurityRequirement(name = "belyAuth") + @Secured + public Response deleteAttachment( + @PathParam("logDocumentId") int logDocumentId, + @PathParam("logId") int logId, + @PathParam("attachmentId") int attachmentId) throws CdbException { + ItemDomainLogbook logDocument = getLogDocumentById(logDocumentId); + verifyCurrentUserPermissionForItem(logDocument); + + Log logEntity = findLogInDocument(logDocument, logId); + Attachment attachment = findAttachmentInLog(logEntity, attachmentId); + UserInfo user = getCurrentRequestUserInfo(); + ItemDomainLogbookControllerUtility utility = new ItemDomainLogbookControllerUtility(); + utility.verifySaveLogLockoutsForItem(logDocument, logEntity, user); + + Log originalLogEntry = logFacade.find(logId); + logEntity.getAttachmentList().remove(attachment); + utility.saveLog(logEntity, user, originalLogEntry); + attachmentFacade.remove(attachment); + + try { + LogAttachmentUtility.deleteAttachmentFiles(attachment); + } catch (IOException ex) { + LOGGER.error(ex); + throw new CdbException("Failed to delete attachment files: " + ex.getMessage()); + } + + updateModifiedDateForLogDocument(logDocument, user); + return Response.noContent().build(); + } + @GET @Path("/LogEntryAttachments/{logDocumentId}/{logId}") @Produces(MediaType.APPLICATION_JSON) @@ -454,13 +494,28 @@ public List getLogEntryAttachments( } String markdownReference = LogAttachmentUtility.buildMarkdownReference(originalFilename, attachment); String downloadPath = "/api/Downloads/Attachments/" + attachment.getName(); - result.add(new LogEntryAttachment(markdownReference, downloadPath, originalFilename, attachment.getName())); + result.add(new LogEntryAttachment(attachment.getId(), markdownReference, downloadPath, originalFilename, attachment.getName())); } } return result; } + private Attachment findAttachmentInLog(Log logEntity, int attachmentId) throws ObjectNotFound { + List attachments = logEntity.getAttachmentList(); + if (attachments != null) { + for (Attachment attachment : attachments) { + if (Objects.equals(attachment.getId(), attachmentId)) { + return attachment; + } + } + } + + throw new ObjectNotFound( + String.format("Attachment id %d does not exist for log entry %d.", + attachmentId, logEntity.getId())); + } + private Log findLogInDocument(ItemDomainLogbook logDocument, int logId) throws ObjectNotFound { List logList = logDocument.getLogList(); From 88364e16a0c9c17f5f370967c8b297cb421ee4c7 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 13:15:02 -0500 Subject: [PATCH 10/17] Ensure all possible extenstions removed --- .../gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java index da0a17f55..8de54c1a0 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/utilities/LogAttachmentUtility.java @@ -77,6 +77,8 @@ public static Attachment uploadAttachment(InputStream inputStream, String fileNa public static void deleteAttachmentFiles(Attachment attachment) throws IOException { String name = attachment.getName(); Files.deleteIfExists(Paths.get(StorageUtility.getFileSystemLogAttachmentPath(name))); + Files.deleteIfExists(Paths.get(StorageUtility.getFileSystemLogAttachmentPath( + name + CdbPropertyValue.ORIGINAL_IMAGE_EXTENSION))); Files.deleteIfExists(Paths.get(StorageUtility.getFileSystemLogAttachmentPath( name + CdbPropertyValue.SCALED_IMAGE_EXTENSION))); Files.deleteIfExists(Paths.get(StorageUtility.getFileSystemLogAttachmentPath( From b5e02a4f9e8fbfbd8a735a6bb6a0c8bea9bb19c8 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 13:15:13 -0500 Subject: [PATCH 11/17] Add acceptnace tests for removal of attachments --- .../python-client/test/attachment_test.py | 104 +++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/tools/developer_tools/python-client/test/attachment_test.py b/tools/developer_tools/python-client/test/attachment_test.py index 4bfb16ee2..0c97bca43 100644 --- a/tools/developer_tools/python-client/test/attachment_test.py +++ b/tools/developer_tools/python-client/test/attachment_test.py @@ -1,7 +1,7 @@ import os import unittest -from belyApi import OpenApiException +from belyApi import LogDocumentOptions, OpenApiException from test.bely_test_base import BelyTestBase TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "..", "data") @@ -28,6 +28,7 @@ def test_upload_attachment_with_file_path(self): file_name="AnlLogo.png", ) + self.assertIsNotNone(result.id) self.assertIsNotNone(result.markdown_reference) self.assertIsNotNone(result.download_path) self.assertIsNotNone(result.original_filename) @@ -47,6 +48,7 @@ def test_upload_attachment_with_bytes(self): file_name="AnlLogo.png", ) + self.assertIsNotNone(result.id) self.assertIsNotNone(result.markdown_reference) self.assertIsNotNone(result.download_path) self.assertIsNotNone(result.original_filename) @@ -89,6 +91,7 @@ def test_get_log_entry_attachments(self): filenames = [a.original_filename for a in attachments] self.assertIn("AnlLogo.png", filenames) + self.assertTrue(all(attachment.id is not None for attachment in attachments)) def test_download_attachment(self): doc_id, log_id = self._create_log_entry() @@ -128,5 +131,104 @@ def test_upload_attachment_append_reference(self): self.assertIn(result.markdown_reference, entry.log_entry) +class AttachmentDeleteTests(BelyTestBase): + + def _create_document_entry_and_attachment(self, as_admin=False, append_reference=False): + if as_admin: + self.login_as_admin() + else: + self.login_as_user() + options = LogDocumentOptions( + name=f"Delete attachment {self._gen_unique_name()}", + logbook_type_id=self.CTL_LOGBOOK_ID, + ) + document = self.logbook_api.create_logbook_document(options) + entry = self.logbook_api.get_log_entry_template(document.id) + entry.log_entry = "attachment delete test" + entry = self.logbook_api.add_update_log_entry(entry) + attachment = self.logbook_api.upload_attachment( + log_document_id=document.id, + log_id=entry.log_id, + body=TEST_IMAGE, + file_name="AnlLogo.png", + append_reference=append_reference, + ) + return document, entry, attachment + + def test_delete_attachment(self): + document, entry, attachment = self._create_document_entry_and_attachment( + append_reference=True + ) + + result = self.logbook_api.delete_attachment( + document.id, entry.log_id, attachment.id + ) + + self.assertIsNone(result) + self.assertEqual( + [], self.logbook_api.get_log_entry_attachments(document.id, entry.log_id) + ) + updated_entry = self.logbook_api.get_log_entries(document.id)[0] + self.assertIn(attachment.markdown_reference, updated_entry.log_entry) + download_api = self.factory.get_download_api() + with self.assertRaises(OpenApiException): + download_api.get_attachment(attachment.stored_filename) + for scaling in ("original", "scaled", "thumbnail"): + with self.assertRaises(OpenApiException): + download_api.get_attachment1(attachment.stored_filename, scaling) + self.logbook_api.delete_log_document(document.id) + + def test_delete_attachment_requires_authentication(self): + document, entry, attachment = self._create_document_entry_and_attachment() + self.factory.logout_user() + self.loggedIn = False + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_attachment( + document.id, entry.log_id, attachment.id + ) + + self.login_as_user() + self.logbook_api.delete_attachment(document.id, entry.log_id, attachment.id) + self.logbook_api.delete_log_document(document.id) + + def test_delete_attachment_requires_permission(self): + document, entry, attachment = self._create_document_entry_and_attachment( + as_admin=True + ) + + self.login_as_user() + with self.assertRaises(OpenApiException): + self.logbook_api.delete_attachment( + document.id, entry.log_id, attachment.id + ) + + self.login_as_admin() + attachments = self.logbook_api.get_log_entry_attachments( + document.id, entry.log_id + ) + self.assertIn(attachment.id, [item.id for item in attachments]) + self.logbook_api.delete_attachment(document.id, entry.log_id, attachment.id) + self.logbook_api.delete_log_document(document.id) + + def test_delete_attachment_rejects_mismatched_entry(self): + document, entry, attachment = self._create_document_entry_and_attachment() + other_entry = self.logbook_api.get_log_entry_template(document.id) + other_entry.log_entry = "other entry" + other_entry = self.logbook_api.add_update_log_entry(other_entry) + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_attachment( + document.id, other_entry.log_id, attachment.id + ) + + attachments = self.logbook_api.get_log_entry_attachments( + document.id, entry.log_id + ) + self.assertIn(attachment.id, [item.id for item in attachments]) + self.logbook_api.delete_attachment(document.id, entry.log_id, attachment.id) + self.logbook_api.delete_log_document(document.id) + + if __name__ == "__main__": unittest.main() From cb88781e3340d36b5794dbcd1ccffe4162c0ff4b Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 14:19:14 -0500 Subject: [PATCH 12/17] Add API call to delete log document section. --- .../aps/logr/rest/routes/LogbookRoute.java | 38 ++++++++++++ .../python-client/test/log_document_test.py | 62 +++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java index db3296636..dc2db7e3f 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java @@ -308,6 +308,31 @@ public Response deleteLogDocument(@PathParam("logDocumentId") int logDocumentId) return Response.noContent().build(); } + @DELETE + @Path("/DeleteLogDocumentSection/{logDocumentId}/{sectionId}") + @Operation(summary = "Delete a section from a top-level log document.", responses = { + @ApiResponse(responseCode = "204", description = "Deleted")}) + @SecurityRequirement(name = "belyAuth") + @Secured + public Response deleteLogDocumentSection( + @PathParam("logDocumentId") int logDocumentId, + @PathParam("sectionId") int sectionId) throws CdbException { + ItemDomainLogbook logDocument = getLogDocumentById(logDocumentId); + if (!Objects.equals(logDocument.getTopLevelLogDocument().getId(), logDocument.getId())) { + throw new InvalidArgument("Log document id identifies a section."); + } + verifyCurrentUserPermissionForItem(logDocument); + + ItemElement sectionElement = findSectionElement(logDocument, sectionId); + ItemDomainLogbook section = (ItemDomainLogbook) sectionElement.getContainedItem(); + sectionElement.setMarkedForDeletion(true); + + UserInfo user = getCurrentRequestUserInfo(); + ItemDomainLogbookControllerUtility utility = new ItemDomainLogbookControllerUtility(); + utility.destroy(section, user); + return Response.noContent().build(); + } + @PUT @Path("/CreateLogDocument") @Consumes(MediaType.APPLICATION_JSON) @@ -501,6 +526,19 @@ public List getLogEntryAttachments( return result; } + private ItemElement findSectionElement(ItemDomainLogbook logDocument, int sectionId) throws ObjectNotFound { + for (ItemElement itemElement : logDocument.getItemElementDisplayList()) { + Item containedItem = itemElement.getContainedItem(); + if (containedItem != null && Objects.equals(containedItem.getId(), sectionId)) { + return itemElement; + } + } + + throw new ObjectNotFound( + String.format("Section id %d does not exist for log document %d.", + sectionId, logDocument.getId())); + } + private Attachment findAttachmentInLog(Log logEntity, int attachmentId) throws ObjectNotFound { List attachments = logEntity.getAttachmentList(); if (attachments != null) { diff --git a/tools/developer_tools/python-client/test/log_document_test.py b/tools/developer_tools/python-client/test/log_document_test.py index 01e8c6b34..19b6cc009 100644 --- a/tools/developer_tools/python-client/test/log_document_test.py +++ b/tools/developer_tools/python-client/test/log_document_test.py @@ -298,6 +298,68 @@ def test_delete_log_document_rejects_template(self): with self.assertRaises(OpenApiException): self.logbook_api.delete_log_document(self.DOC_TEMPLATE_COPY_ID) + def test_delete_log_document_section(self): + document, section = self._create_document_for_delete(with_section=True) + + result = self.logbook_api.delete_log_document_section(document.id, section.id) + + self.assertIsNone(result) + self.assertEqual([], self.logbook_api.get_logbook_sections(document.id)) + with self.assertRaises(OpenApiException): + self.logbook_api.get_log_entries(section.id) + self.logbook_api.delete_log_document(document.id) + + def test_delete_log_document_section_requires_authentication(self): + document, section = self._create_document_for_delete(with_section=True) + self.factory.logout_user() + self.loggedIn = False + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_document_section(document.id, section.id) + + self.login_as_user() + self.logbook_api.delete_log_document_section(document.id, section.id) + self.logbook_api.delete_log_document(document.id) + + def test_delete_log_document_section_requires_permission(self): + document, section = self._create_document_for_delete( + with_section=True, as_admin=True + ) + + self.login_as_user() + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_document_section(document.id, section.id) + + self.login_as_admin() + section_ids = [ + item.id for item in self.logbook_api.get_logbook_sections(document.id) + ] + self.assertIn(section.id, section_ids) + self.logbook_api.delete_log_document_section(document.id, section.id) + self.logbook_api.delete_log_document(document.id) + + def test_delete_log_document_section_rejects_mismatched_parent(self): + document, section = self._create_document_for_delete(with_section=True) + other_document, _ = self._create_document_for_delete() + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_document_section(other_document.id, section.id) + + section_ids = [ + item.id for item in self.logbook_api.get_logbook_sections(document.id) + ] + self.assertIn(section.id, section_ids) + self.logbook_api.delete_log_document(document.id) + self.logbook_api.delete_log_document(other_document.id) + + def test_delete_log_document_section_rejects_section_parent(self): + document, section = self._create_document_for_delete(with_section=True) + + with self.assertRaises(OpenApiException): + self.logbook_api.delete_log_document_section(section.id, section.id) + + self.logbook_api.delete_log_document(document.id) + if __name__ == "__main__": unittest.main() From 8de524e8d0507514fe99185259a024718d15f5b6 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 14:28:40 -0500 Subject: [PATCH 13/17] Standardize creation of a reply for reuse between API and Portal --- .../portal/controllers/ItemDomainLogbookController.java | 7 +------ .../utilities/ItemDomainLogbookControllerUtility.java | 7 +++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/ItemDomainLogbookController.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/ItemDomainLogbookController.java index ede7ad1a6..d30b72a85 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/ItemDomainLogbookController.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/ItemDomainLogbookController.java @@ -42,7 +42,6 @@ import gov.anl.aps.logr.portal.model.db.entities.SettingType; import gov.anl.aps.logr.portal.model.db.entities.UserInfo; import gov.anl.aps.logr.portal.model.db.utilities.EntityInfoUtility; -import gov.anl.aps.logr.portal.model.db.utilities.LogUtility; import gov.anl.aps.logr.portal.utilities.MarkdownParser; import gov.anl.aps.logr.portal.utilities.SearchResult; import gov.anl.aps.logr.portal.utilities.SessionUtility; @@ -512,12 +511,8 @@ private boolean isSaveLogLockoutsForCurrent(Log log) { public Log prepareAddLogReply(Log parentLog) { UserInfo user = SessionUtility.getUser(); - - Log logEntry = LogUtility.createLogEntry(user); - logEntry.setParentLog(parentLog); - + Log logEntry = getControllerUtility().prepareAddLogReply(parentLog, user); setNewLogEdit(logEntry); - return logEntry; } diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/utilities/ItemDomainLogbookControllerUtility.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/utilities/ItemDomainLogbookControllerUtility.java index d7814d077..4df2bc61b 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/utilities/ItemDomainLogbookControllerUtility.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/portal/controllers/utilities/ItemDomainLogbookControllerUtility.java @@ -23,6 +23,7 @@ import gov.anl.aps.logr.portal.model.db.entities.PropertyValue; import gov.anl.aps.logr.portal.model.db.entities.UserGroup; import gov.anl.aps.logr.portal.model.db.entities.UserInfo; +import gov.anl.aps.logr.portal.model.db.utilities.LogUtility; import gov.anl.aps.logr.portal.utilities.AuthorizationUtility; import gov.anl.aps.logr.portal.utilities.SearchResult; import java.util.ArrayList; @@ -230,6 +231,12 @@ protected void additionalSelectionOfTemplateSteps(ItemDomainLogbook item, ItemDo } } + public Log prepareAddLogReply(Log parentLog, UserInfo user) { + Log reply = LogUtility.createLogEntry(user); + reply.setParentLog(parentLog); + return reply; + } + public ItemDomainLogbook createLogbookSectionItem(UserInfo user) throws CdbException { ItemDomainLogbook newSectionItem = createEntityInstance(user); From f509fbb7826d86bb6f2f86e983813afa27342064 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 14:32:31 -0500 Subject: [PATCH 14/17] Add ability to add log replies from the API --- .../aps/logr/rest/routes/LogbookRoute.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java index dc2db7e3f..8f9981f81 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java @@ -264,6 +264,34 @@ public LogEntry addUpdateLogEntry(@RequestBody(required = true) LogEntry logEntr return new LogEntry(itemId, logEntity, false, false); } + @PUT + @Path("/CreateLogReply/{logDocumentId}/{parentLogId}") + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + @Operation(summary = "Create a reply to a top-level log entry.", responses = { + @ApiResponse(responseCode = "200", description = "OK", useReturnTypeSchema = true)}) + @SecurityRequirement(name = "belyAuth") + @Secured + public LogEntry createLogReply( + @PathParam("logDocumentId") int logDocumentId, + @PathParam("parentLogId") int parentLogId, + @RequestBody(required = true) String replyText) throws CdbException { + ItemDomainLogbook logDocument = getLogDocumentById(logDocumentId); + verifyCurrentUserPermissionForItem(logDocument); + + Log parentLog = findTopLevelLogInDocument(logDocument, parentLogId); + UserInfo user = getCurrentRequestUserInfo(); + ItemDomainLogbookControllerUtility utility = new ItemDomainLogbookControllerUtility(); + utility.verifySaveLogLockoutsForItem(logDocument, parentLog, user); + + Log reply = utility.prepareAddLogReply(parentLog, user); + reply.setText(replyText); + reply = utility.saveLog(reply, user, null); + + updateModifiedDateForLogDocument(logDocument, user); + return new LogEntry(logDocumentId, reply, false, false); + } + @DELETE @Path("/DeleteLogEntry/{logDocumentId}/{logId}") @Operation(summary = "Delete a log entry or reply from a log document or section.", responses = { @@ -554,6 +582,18 @@ private Attachment findAttachmentInLog(Log logEntity, int attachmentId) throws O attachmentId, logEntity.getId())); } + private Log findTopLevelLogInDocument(ItemDomainLogbook logDocument, int logId) throws ObjectNotFound { + for (Log log : logDocument.getLogList()) { + if (Objects.equals(log.getId(), logId)) { + return log; + } + } + + throw new ObjectNotFound( + String.format("Top-level log id %d does not exist for log document %d.", + logId, logDocument.getId())); + } + private Log findLogInDocument(ItemDomainLogbook logDocument, int logId) throws ObjectNotFound { List logList = logDocument.getLogList(); From e5e96ea2d27f93ae27ccc3865f34aba10add98ee Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 14:37:23 -0500 Subject: [PATCH 15/17] Refactor to use the existing add_update_log_entry for adding a reply. --- .../java/gov/anl/aps/logr/rest/entities/LogEntry.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/entities/LogEntry.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/entities/LogEntry.java index 9a1ee12d5..7cede896c 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/entities/LogEntry.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/entities/LogEntry.java @@ -23,6 +23,7 @@ public class LogEntry { private int itemId; private Integer logId; + private Integer parentLogId; private String logEntry; private Date enteredOnDateTime; @@ -40,6 +41,8 @@ public LogEntry() { public LogEntry(int itemId, Log log, boolean loadReplies, boolean loadReactions) { this.itemId = itemId; logId = log.getId(); + Log parentLog = log.getParentLog(); + parentLogId = parentLog == null ? null : parentLog.getId(); logEntry = log.getText(); enteredOnDateTime = log.getEnteredOnDateTime(); @@ -75,6 +78,14 @@ public Integer getLogId() { return logId; } + public Integer getParentLogId() { + return parentLogId; + } + + public void setParentLogId(Integer parentLogId) { + this.parentLogId = parentLogId; + } + @JsonFormat(shape = JsonFormat.Shape.STRING) public Date getEnteredOnDateTime() { return enteredOnDateTime; From 3a97bab887cf7ebf297d5e6af80ff30165a03e96 Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 14:37:57 -0500 Subject: [PATCH 16/17] Refactor to use the existing add_update_log_entry for adding a reply. --- .../aps/logr/rest/routes/LogbookRoute.java | 39 +++++-------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java index 8f9981f81..685e06d4d 100644 --- a/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java +++ b/src/java/LogrPortal/src/java/gov/anl/aps/logr/rest/routes/LogbookRoute.java @@ -228,7 +228,7 @@ public LogEntry getLogEntryTemplate(@PathParam("logDocumentId") int logDocumentI @Path("/AddUpdateLogEntry") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Operation(summary = "Add/Update a log entry to a log document or section. Will only update the core log entry not related reply/reaction.", responses = { + @Operation(summary = "Add a log entry or reply, or update an existing log entry or reply. Set parentLogId when creating a reply. Does not modify related replies or reactions.", responses = { @ApiResponse(responseCode = "200", description = "OK", useReturnTypeSchema = true)}) @SecurityRequirement(name = "belyAuth") @Secured @@ -244,7 +244,14 @@ public LogEntry addUpdateLogEntry(@RequestBody(required = true) LogEntry logEntr ItemDomainLogbookControllerUtility utility = new ItemDomainLogbookControllerUtility(); if (logId == null) { - logEntity = utility.prepareAddLog(logDocument, user); + Integer parentLogId = logEntry.getParentLogId(); + if (parentLogId == null) { + logEntity = utility.prepareAddLog(logDocument, user); + } else { + Log parentLog = findTopLevelLogInDocument(logDocument, parentLogId); + utility.verifySaveLogLockoutsForItem(logDocument, parentLog, user); + logEntity = utility.prepareAddLogReply(parentLog, user); + } } else { logEntity = findLogInDocument(logDocument, logId); utility.verifySaveLogLockoutsForItem(logDocument, logEntity, user); @@ -264,34 +271,6 @@ public LogEntry addUpdateLogEntry(@RequestBody(required = true) LogEntry logEntr return new LogEntry(itemId, logEntity, false, false); } - @PUT - @Path("/CreateLogReply/{logDocumentId}/{parentLogId}") - @Consumes(MediaType.TEXT_PLAIN) - @Produces(MediaType.APPLICATION_JSON) - @Operation(summary = "Create a reply to a top-level log entry.", responses = { - @ApiResponse(responseCode = "200", description = "OK", useReturnTypeSchema = true)}) - @SecurityRequirement(name = "belyAuth") - @Secured - public LogEntry createLogReply( - @PathParam("logDocumentId") int logDocumentId, - @PathParam("parentLogId") int parentLogId, - @RequestBody(required = true) String replyText) throws CdbException { - ItemDomainLogbook logDocument = getLogDocumentById(logDocumentId); - verifyCurrentUserPermissionForItem(logDocument); - - Log parentLog = findTopLevelLogInDocument(logDocument, parentLogId); - UserInfo user = getCurrentRequestUserInfo(); - ItemDomainLogbookControllerUtility utility = new ItemDomainLogbookControllerUtility(); - utility.verifySaveLogLockoutsForItem(logDocument, parentLog, user); - - Log reply = utility.prepareAddLogReply(parentLog, user); - reply.setText(replyText); - reply = utility.saveLog(reply, user, null); - - updateModifiedDateForLogDocument(logDocument, user); - return new LogEntry(logDocumentId, reply, false, false); - } - @DELETE @Path("/DeleteLogEntry/{logDocumentId}/{logId}") @Operation(summary = "Delete a log entry or reply from a log document or section.", responses = { From 4afe1f2092d1a98894ede6d9f034ebf5cd6115ce Mon Sep 17 00:00:00 2001 From: Dariusz Jarosz Date: Tue, 22 Sep 2026 14:39:57 -0500 Subject: [PATCH 17/17] Add tests for the new add log reply api endpoint --- .../python-client/test/log_entry_test.py | 82 ++++++++++++++++--- 1 file changed, 71 insertions(+), 11 deletions(-) diff --git a/tools/developer_tools/python-client/test/log_entry_test.py b/tools/developer_tools/python-client/test/log_entry_test.py index 2e8bff3be..526d64f0f 100644 --- a/tools/developer_tools/python-client/test/log_entry_test.py +++ b/tools/developer_tools/python-client/test/log_entry_test.py @@ -1,5 +1,5 @@ import unittest -from belyApi import LogDocumentOptions, OpenApiException +from belyApi import LogDocumentOptions, LogEntry, OpenApiException from test.bely_test_base import BelyTestBase @@ -188,22 +188,82 @@ def test_delete_log_entry_requires_document_permission(self): self.assertIn(entry.log_id, entry_ids) self.logbook_api.delete_log_entry(self.DOC_SAMPLE_ID, entry.log_id) - def test_delete_log_reply(self): - self.login_as_user() - entries = self.logbook_api.get_log_entries( - self.DOC_WITH_ENTRIES, load_replies=True + def test_create_and_delete_log_reply(self): + document, entry = self._create_document_and_entry() + reply_text = f"Reply-{self._gen_unique_name()}" + + reply_template = LogEntry( + item_id=document.id, + parent_log_id=entry.log_id, + log_entry=reply_text, ) - entry = entries[0] - reply_id = entry.log_replies[0].log_id + reply = self.logbook_api.add_update_log_entry(reply_template) + + self.assertIsNotNone(reply.log_id) + self.assertEqual(entry.log_id, reply.parent_log_id) + self.assertEqual(reply_text, reply.log_entry) + entries = self.logbook_api.get_log_entries(document.id, load_replies=True) + self.assertEqual([reply.log_id], [item.log_id for item in entries[0].log_replies]) + + updated_reply_text = f"Updated-{reply_text}" + reply.log_entry = updated_reply_text + updated_reply = self.logbook_api.add_update_log_entry(reply) + self.assertEqual(reply.log_id, updated_reply.log_id) + self.assertEqual(updated_reply_text, updated_reply.log_entry) + + entries = self.logbook_api.get_log_entries(document.id, load_replies=True) + self.assertEqual(updated_reply_text, entries[0].log_replies[0].log_entry) - result = self.logbook_api.delete_log_entry(self.DOC_WITH_ENTRIES, reply_id) + result = self.logbook_api.delete_log_entry(document.id, reply.log_id) self.assertIsNone(result) updated_entries = self.logbook_api.get_log_entries( - self.DOC_WITH_ENTRIES, load_replies=True + document.id, load_replies=True ) - updated_reply_ids = [reply.log_id for reply in updated_entries[0].log_replies] - self.assertNotIn(reply_id, updated_reply_ids) + self.assertEqual([], updated_entries[0].log_replies) + self.logbook_api.delete_log_document(document.id) + + def test_create_log_reply_requires_authentication(self): + reply = LogEntry( + item_id=self.DOC_WITH_ENTRIES, + parent_log_id=1, + log_entry="reply", + ) + with self.assertRaises(OpenApiException): + self.logbook_api.add_update_log_entry(reply) + + def test_create_log_reply_rejects_mismatched_document(self): + document, entry = self._create_document_and_entry() + + reply = LogEntry( + item_id=self.DOC_WITH_ENTRIES, + parent_log_id=entry.log_id, + log_entry="reply", + ) + with self.assertRaises(OpenApiException): + self.logbook_api.add_update_log_entry(reply) + + self.logbook_api.delete_log_document(document.id) + + def test_create_log_reply_rejects_reply_parent(self): + document, entry = self._create_document_and_entry() + reply = self.logbook_api.add_update_log_entry( + LogEntry( + item_id=document.id, + parent_log_id=entry.log_id, + log_entry="reply", + ) + ) + nested_reply = LogEntry( + item_id=document.id, + parent_log_id=reply.log_id, + log_entry="nested reply", + ) + + with self.assertRaises(OpenApiException): + self.logbook_api.add_update_log_entry(nested_reply) + + self.logbook_api.delete_log_document(document.id) if __name__ == "__main__":