Good file for commit 6fa9a8bd
: When a view is cloned, a comment is added
to the new view specifying the name of the cloned view
This commit is contained in:
@ -1133,6 +1133,7 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
|||||||
Obiview_p view;
|
Obiview_p view;
|
||||||
int i;
|
int i;
|
||||||
index_t line_nb;
|
index_t line_nb;
|
||||||
|
char* clone_comment;
|
||||||
|
|
||||||
// Check that the DMS is a valid pointer
|
// Check that the DMS is a valid pointer
|
||||||
if (dms == NULL)
|
if (dms == NULL)
|
||||||
@ -1277,6 +1278,27 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
view->predicate_functions = NULL;
|
view->predicate_functions = NULL;
|
||||||
|
|
||||||
|
// Write comment specifying the name of the cloned view
|
||||||
|
clone_comment = (char*) malloc((strlen((view_to_clone->infos)->name) + 15)*sizeof(char));
|
||||||
|
if (clone_comment == NULL)
|
||||||
|
{
|
||||||
|
obi_set_errno(OBI_MALLOC_ERROR);
|
||||||
|
obidebug(1, "\nError allocating memory for a view comment");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (sprintf(clone_comment, "Cloned from %s.\n", (view_to_clone->infos)->name) < 0)
|
||||||
|
{
|
||||||
|
obi_set_errno(OBIVIEW_ERROR);
|
||||||
|
obidebug(1, "\nError building a view comment");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (write_comments_to_view_file(view, clone_comment) < 0)
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError writing comments when creating a view");
|
||||||
|
obi_close_view(view);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Else, fill empty view structure
|
// Else, fill empty view structure
|
||||||
@ -1297,7 +1319,7 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
|||||||
strcpy((view->infos)->name, view_name);
|
strcpy((view->infos)->name, view_name);
|
||||||
(view->infos)->creation_date = time(NULL);
|
(view->infos)->creation_date = time(NULL);
|
||||||
|
|
||||||
if (write_comments_to_view_file(view, comments) < 0) // TODO copy comments if cloning view?
|
if (write_comments_to_view_file(view, comments) < 0)
|
||||||
{
|
{
|
||||||
obidebug(1, "\nError writing comments when creating a view");
|
obidebug(1, "\nError writing comments when creating a view");
|
||||||
obi_close_view(view);
|
obi_close_view(view);
|
||||||
@ -1324,7 +1346,6 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Once the view has been created with all its elements and informations, add the columns if the view is cloned from another view
|
// Once the view has been created with all its elements and informations, add the columns if the view is cloned from another view
|
||||||
// Add the columns from the view to clone in the new view
|
|
||||||
if (view_to_clone != NULL)
|
if (view_to_clone != NULL)
|
||||||
{
|
{
|
||||||
(view->infos)->column_count = 0;
|
(view->infos)->column_count = 0;
|
||||||
|
Reference in New Issue
Block a user