Commit b1090574 by Celine Mercier

View import: associated column informations are now correctly updated

with the new versions
parent 8faabd3e
......@@ -1526,7 +1526,9 @@ int obi_import_view(const char* dms_path_1, const char* dms_path_2, const char*
Obiview_p view_1;
Obiview_p view_2;
obiversion_t new_version;
int i;
int i, j;
OBIDMS_column_header_p header = NULL;
OBIDMS_column_header_p header_2 = NULL;
dms_1 = obi_open_dms(dms_path_1);
if (dms_1 == NULL)
......@@ -1606,6 +1608,48 @@ int obi_import_view(const char* dms_path_1, const char* dms_path_2, const char*
}
}
// Go through columns again to update associated columns
for (i=0; i < (view_1->infos->column_count); i++)
{
header = obi_column_get_header_from_name(dms_1, ((((view_1->infos)->column_references)[i]).column_refs).column_name, ((((view_1->infos)->column_references)[i]).column_refs).version);
if (header == NULL)
{
obidebug(1, "\nError opening a column header while importing a view");
return -1;
}
if (header->returned_data_type == OBI_QUAL) // TODO maybe there should be a bool in column headers
{
// Look for the index of the associated column in the list
for (j=0; j < (view_1->infos->column_count); j++)
{
if ((strcmp((header->associated_column).column_name, ((((view_1->infos)->column_references)[j]).column_refs).column_name) == 0) &&
((header->associated_column).version == ((((view_1->infos)->column_references)[j]).column_refs).version))
break;
}
header_2 = obi_column_get_header_from_name(dms_2, ((((view_2->infos)->column_references)[i]).column_refs).column_name, ((((view_2->infos)->column_references)[i]).column_refs).version);
if (header_2 == NULL)
{
obidebug(1, "\nError opening a column header while importing a view");
return -1;
}
// Update version of associated column
(header_2->associated_column).version = ((((view_2->infos)->column_references)[j]).column_refs).version;
if (obi_close_header(header_2) < 0)
{
obidebug(1, "\nError closing a column header while importing a view");
return -1;
}
}
if (obi_close_header(header) < 0)
{
obidebug(1, "\nError closing a column header while importing a view");
return -1;
}
}
// Close the views
if (obi_save_and_close_view(view_1) < 0)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment