From 7c57bd33e5c78737973cf541165d7bb3fe05b0d6 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Fri, 15 Sep 2017 14:54:55 +0200 Subject: [PATCH] Added check to prevent views from having the name 'taxonomy' (used for URIs) --- src/obiview.c | 10 +++++++++- src/obiview.h | 12 ++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/obiview.c b/src/obiview.c index acc7312..04153c8 100644 --- a/src/obiview.c +++ b/src/obiview.c @@ -1558,6 +1558,14 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl return NULL; } + // Check that the view name is not 'taxonomy' (used for URIs) + if (strcmp(view_name, "taxonomy") == 0) + { + obi_set_errno(OBIVIEW_ERROR); + obidebug(1, "\nView name can not be 'taxonomy'"); + return NULL; + } + // Allocate memory for view structure view = (Obiview_p) malloc(sizeof(Obiview_t)); if (view == NULL) @@ -1838,7 +1846,7 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v if (view_to_clone == NULL) { // Adding sequence column - if (obi_view_add_column(view, NUC_SEQUENCE_COLUMN, -1, NULL, OBI_SEQ, 0, 1, NULL, NULL, NULL, -1, "Nucleotide sequences", true) < 0) + if (obi_view_add_column(view, NUC_SEQUENCE_COLUMN, -1, NULL, OBI_SEQ, 0, 1, NULL, NULL, NULL, -1, "Nucleotide sequences", true) < 0) // discuss using same indexer "NUC_SEQ_INDEXER" { obidebug(1, "Error adding an obligatory column in a nucleotide sequences view"); return NULL; diff --git a/src/obiview.h b/src/obiview.h index 641178c..93297a4 100644 --- a/src/obiview.h +++ b/src/obiview.h @@ -140,7 +140,7 @@ typedef struct Obiview { * Fails if a view with the same name already exists. * * @param dms A pointer on the OBIDMS. - * @param view_name The unique name of the view. + * @param view_name The unique name of the view. Can not be 'taxonomy' (used for URIs). * @param view_to_clone Eventually a pointer on the opened view to clone to create the new one, if there is one. NULL if not. * @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone * if there is one. NULL if there is no line selection or no view to clone. @@ -165,7 +165,7 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl * Fails if a view with the same name already exists. * * @param dms A pointer on the OBIDMS. - * @param view_name The unique name of the new view. + * @param view_name The unique name of the new view. Can not be 'taxonomy' (used for URIs). * @param view_to_clone_name The name of the view to clone stored in the view file of the OBIDMS. * @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone * if there is one. NULL if there is no line selection or no view to clone. @@ -193,7 +193,7 @@ Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const char* view_name, con * - QUALITY_COLUMN where sequence qualities are stored * * @param dms A pointer on the OBIDMS. - * @param view_name The unique name of the view. + * @param view_name The unique name of the view. Can not be 'taxonomy' (used for URIs). * @param view_to_clone Eventually a pointer on the opened view to clone to create the new one, if there is one. NULL if not. * @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone * if there is one. NULL if there is no line selection or no view to clone. @@ -227,7 +227,7 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v * - QUALITY_COLUMN where sequence qualities are stored * * @param dms A pointer on the OBIDMS. - * @param view_name The unique name of the new view. + * @param view_name The unique name of the new view. Can not be 'taxonomy' (used for URIs). * @param view_to_clone_name The name of the view to clone stored in the view file of the OBIDMS. * @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone * if there is one. NULL if there is no line selection or no view to clone. @@ -250,7 +250,7 @@ Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const char* view_ * * @param dms A pointer on the OBIDMS. * @param view_to_clone A pointer on the opened view to clone to create the new one. - * @param view_name The unique name of the new view. + * @param view_name The unique name of the new view. Can not be 'taxonomy' (used for URIs). * @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone * if there is one. NULL if there is no line selection or no view to clone. * @param comments Eventually, comments to associate with the view. NULL if not. @@ -272,7 +272,7 @@ Obiview_p obi_clone_view(OBIDMS_p dms, Obiview_p view_to_clone, const char* view * * @param dms A pointer on the OBIDMS. * @param view_to_clone_name The name of the view to clone. - * @param view_name The unique name of the new view. + * @param view_name The unique name of the new view. Can not be 'taxonomy' (used for URIs). * @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone * if there is one. NULL if there is no line selection or no view to clone. * @param comments Eventually, comments to associate with the view. NULL if not.