| 770 | } |
| 771 | |
| 772 | void Project::SaveDataSourceData() |
| 773 | { |
| 774 | wxLogMessage("Entering Project::SaveDataSourceData"); |
| 775 | // for some read-only datasources, suggest Export dialog |
| 776 | GdaConst::DataSourceType ds_type = datasource->GetType(); |
| 777 | if (ds_type == GdaConst::ds_wfs || |
| 778 | ds_type == GdaConst::ds_kml || |
| 779 | ds_type == GdaConst::ds_xlsx || |
| 780 | ds_type == GdaConst::ds_xls || |
| 781 | ds_type == GdaConst::ds_esri_arc_sde ) |
| 782 | { |
| 783 | wxString msg = _("The data source is read only. Please try to save as other data source."); |
| 784 | throw GdaException(msg.mb_str()); |
| 785 | } |
| 786 | |
| 787 | if (table_int->ChangedSinceLastSave()) { |
| 788 | |
| 789 | wxString save_err_msg; |
| 790 | try { |
| 791 | // for saving changes in database, call OGRTableInterface::Save() |
| 792 | if ( |
| 793 | ds_type == GdaConst::ds_esri_file_geodb || |
| 794 | ds_type == GdaConst::ds_postgresql || |
| 795 | ds_type == GdaConst::ds_oci || |
| 796 | ds_type == GdaConst::ds_mysql || |
| 797 | ds_type == GdaConst::ds_cartodb) { |
| 798 | |
| 799 | table_int->Save(save_err_msg); |
| 800 | } |
| 801 | // for other datasources, call OGR interface to save. |
| 802 | else { |
| 803 | SaveOGRDataSource(); |
| 804 | } |
| 805 | } catch( GdaException& e) { |
| 806 | save_err_msg = e.what(); |
| 807 | } |
| 808 | if (!save_err_msg.empty()) { |
| 809 | table_int->SetChangedSinceLastSave(true); |
| 810 | throw GdaException(save_err_msg.mb_str()); |
| 811 | } else { |
| 812 | table_int->SetChangedSinceLastSave(false); |
| 813 | SaveButtonManager* sbm = GetSaveButtonManager(); |
| 814 | if (sbm) sbm->SetDbSaveNeeded(false); |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | if (isTableOnly && main_data.records.size()>0 |
| 819 | && layer_proxy != NULL) { |
| 820 | // case: create geometries for table-only datasource |
| 821 | // try to save the geometries (e.g. database table) |
| 822 | // NOTE: OGR/GDAL 2.0 is still implementing addGeomField feature. |
| 823 | layer_proxy->AddGeometries(main_data); |
| 824 | } |
| 825 | wxLogMessage("Exiting Project::SaveDataSourceData"); |
| 826 | } |
| 827 | |
| 828 | void Project::UpdateProjectConf() |
| 829 | { |
no test coverage detected