MCPcopy Create free account
hub / github.com/GeoDaCenter/geoda / SaveDataSourceData

Method SaveDataSourceData

Project.cpp:772–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

770}
771
772void 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
828void Project::UpdateProjectConf()
829{

Callers 2

OnCloseProjectMethod · 0.80
OnSaveProjectMethod · 0.80

Calls 10

GdaExceptionClass · 0.85
ChangedSinceLastSaveMethod · 0.80
SetDbSaveNeededMethod · 0.80
AddGeometriesMethod · 0.80
GetTypeMethod · 0.45
SaveMethod · 0.45
whatMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected