Ajouter la suppression globale des positions du graphe

This commit is contained in:
grayTerminal-sh 2026-07-22 07:09:03 +02:00
parent c46039a2aa
commit 0465209d06
4 changed files with 1353 additions and 2 deletions

View file

@ -1,3 +1,4 @@
CC = gcc CC = gcc
PKG_CONFIG = pkg-config PKG_CONFIG = pkg-config
@ -27,6 +28,7 @@ EVIDENCE_RECORD_TEST_CFLAGS := $(TEST_CFLAGS) -Wpedantic
EVIDENCE_TYPE_TEST_CFLAGS := $(TEST_CFLAGS) -Wpedantic EVIDENCE_TYPE_TEST_CFLAGS := $(TEST_CFLAGS) -Wpedantic
ENTITY_TYPE_TEST_CFLAGS := $(TEST_CFLAGS) -Wpedantic ENTITY_TYPE_TEST_CFLAGS := $(TEST_CFLAGS) -Wpedantic
EVIDENCE_TYPE_DAO_TEST_CFLAGS := $(TEST_CFLAGS) -Wpedantic EVIDENCE_TYPE_DAO_TEST_CFLAGS := $(TEST_CFLAGS) -Wpedantic
GRAPH_NODE_POSITION_DAO_TEST_CFLAGS := $(TEST_CFLAGS) -Wpedantic
EVIDENCE_IMPORT_DIALOG_TEST_CFLAGS := \ EVIDENCE_IMPORT_DIALOG_TEST_CFLAGS := \
-std=c17 \ -std=c17 \
-Wall \ -Wall \
@ -107,6 +109,7 @@ TEST_RELATION_SERVICE := tests/test_relation_service
TEST_INVESTIGATION_GRAPH_MODEL := tests/test_investigation_graph_model TEST_INVESTIGATION_GRAPH_MODEL := tests/test_investigation_graph_model
TEST_INVESTIGATION_GRAPH_LOADER := tests/test_investigation_graph_loader TEST_INVESTIGATION_GRAPH_LOADER := tests/test_investigation_graph_loader
TEST_INVESTIGATION_GRAPH_LOAD_TASK := tests/test_investigation_graph_load_task TEST_INVESTIGATION_GRAPH_LOAD_TASK := tests/test_investigation_graph_load_task
TEST_GRAPH_NODE_POSITION_DAO := tests/test_graph_node_position_dao
all: $(TARGET) all: $(TARGET)
@ -510,6 +513,18 @@ $(TEST_INVESTIGATION_GRAPH_LOADER): \
$(CC) $(INVESTIGATION_GRAPH_LOADER_TEST_CFLAGS) $^ -o $@ \ $(CC) $(INVESTIGATION_GRAPH_LOADER_TEST_CFLAGS) $^ -o $@ \
$(TEST_LDFLAGS) -lsqlite3 $(TEST_LDFLAGS) -lsqlite3
$(TEST_GRAPH_NODE_POSITION_DAO): \
tests/test_graph_node_position_dao.c \
src/dao/graph_node_position_dao.c \
src/models/graph_node_position.c \
src/database/database.c \
src/database/schema.c \
src/database/statement.c \
src/database/transaction.c \
src/database/error.c
$(CC) $(GRAPH_NODE_POSITION_DAO_TEST_CFLAGS) $^ -o $@ \
$(TEST_LDFLAGS) -lsqlite3
$(TEST_INVESTIGATION_GRAPH_LOAD_TASK): \ $(TEST_INVESTIGATION_GRAPH_LOAD_TASK): \
tests/test_investigation_graph_load_task.c \ tests/test_investigation_graph_load_task.c \
src/core/investigation_graph_load_task.c \ src/core/investigation_graph_load_task.c \
@ -576,7 +591,8 @@ test: \
$(TEST_RELATION_SERVICE) \ $(TEST_RELATION_SERVICE) \
$(TEST_INVESTIGATION_GRAPH_MODEL) \ $(TEST_INVESTIGATION_GRAPH_MODEL) \
$(TEST_INVESTIGATION_GRAPH_LOADER) \ $(TEST_INVESTIGATION_GRAPH_LOADER) \
$(TEST_INVESTIGATION_GRAPH_LOAD_TASK) $(TEST_INVESTIGATION_GRAPH_LOAD_TASK) \
$(TEST_GRAPH_NODE_POSITION_DAO)
@echo "Exécution des tests..." @echo "Exécution des tests..."
@./$(TEST_NODE) @./$(TEST_NODE)
@./$(TEST_TREE_MODEL) @./$(TEST_TREE_MODEL)
@ -623,6 +639,7 @@ test: \
@$(TEST_INVESTIGATION_GRAPH_MODEL) @$(TEST_INVESTIGATION_GRAPH_MODEL)
@$(TEST_INVESTIGATION_GRAPH_LOADER) @$(TEST_INVESTIGATION_GRAPH_LOADER)
@$(TEST_INVESTIGATION_GRAPH_LOAD_TASK) @$(TEST_INVESTIGATION_GRAPH_LOAD_TASK)
@$(TEST_GRAPH_NODE_POSITION_DAO)
@echo "Tous les tests sont valides." @echo "Tous les tests sont valides."
%.o: %.c %.o: %.c
@ -675,6 +692,7 @@ clean:
$(TEST_RELATION_SERVICE) \ $(TEST_RELATION_SERVICE) \
$(TEST_INVESTIGATION_GRAPH_MODEL) \ $(TEST_INVESTIGATION_GRAPH_MODEL) \
$(TEST_INVESTIGATION_GRAPH_LOADER) \ $(TEST_INVESTIGATION_GRAPH_LOADER) \
$(TEST_INVESTIGATION_GRAPH_LOAD_TASK) $(TEST_INVESTIGATION_GRAPH_LOAD_TASK) \
$(TEST_GRAPH_NODE_POSITION_DAO)
.PHONY: clean run test .PHONY: clean run test

View file

@ -128,6 +128,21 @@ gboolean graph_node_position_dao_delete(
GError **error GError **error
); );
/**
* @brief Supprime toutes les positions persistées du graphe.
*
* Une table déjà vide n'est pas une erreur.
*
* @param position_dao DAO valide.
* @param error Adresse recevant une éventuelle erreur.
*
* @return TRUE si la requête réussit, sinon FALSE.
*/
gboolean graph_node_position_dao_delete_all(
GraphNodePositionDao *position_dao,
GError **error
);
G_END_DECLS G_END_DECLS
#endif #endif

View file

@ -65,6 +65,12 @@ static const char *const graph_node_position_dao_delete_sql =
"DELETE FROM graph_node_positions " "DELETE FROM graph_node_positions "
"WHERE entity_id = ?;"; "WHERE entity_id = ?;";
/**
* @brief Requête de suppression de toutes les positions.
*/
static const char *const graph_node_position_dao_delete_all_sql =
"DELETE FROM graph_node_positions;";
/** /**
* @brief Enregistre une erreur littérale. * @brief Enregistre une erreur littérale.
*/ */
@ -791,3 +797,75 @@ cleanup:
return success; return success;
} }
gboolean graph_node_position_dao_delete_all(
GraphNodePositionDao *position_dao,
GError **error
)
{
DatabaseStatement *statement =
NULL;
gboolean success =
FALSE;
g_return_val_if_fail(
error == NULL || *error == NULL,
FALSE
);
if (position_dao == NULL ||
position_dao->database == NULL)
{
graph_node_position_dao_set_error_literal(
error,
GRAPH_NODE_POSITION_DAO_ERROR_INVALID_ARGUMENT,
"Le DAO des positions de nœuds est invalide."
);
return FALSE;
}
statement =
database_statement_prepare(
position_dao->database,
graph_node_position_dao_delete_all_sql
);
if (statement == NULL)
{
graph_node_position_dao_set_database_error(
position_dao,
error,
GRAPH_NODE_POSITION_DAO_ERROR_PREPARE,
"Impossible de préparer la suppression des positions"
);
goto cleanup;
}
if (database_statement_step(
statement
) != DATABASE_STATEMENT_STEP_DONE)
{
graph_node_position_dao_set_database_error(
position_dao,
error,
GRAPH_NODE_POSITION_DAO_ERROR_EXECUTE,
"Impossible de supprimer les positions du graphe"
);
goto cleanup;
}
success =
TRUE;
cleanup:
database_statement_finalize(
statement
);
return success;
}

File diff suppressed because it is too large Load diff