// --- std::string VSWContentPrjSaver::saveSchedulings (VSWContentProjectPt cntPrj, const std::string& bPath, QBOOLEAN saveAll) { #ifdef __DEBUGSYSTEM __KEEPENTRYSIMPLETRACE #endif // Creates the header... std::string result = std::string ("\t\t<") + std::string (__SCHEDULINGS_TAGNAME__) + std::string (">\n"); // Iterates over all the schedulings... VSWContentProject::CursorForSchedulingsPt cursor = cntPrj -> listOfSchedulings (); for (cursor -> first (); cursor -> areThereMoreElements (); cursor -> next ()) { // First, get the name of the original scheduling description xml file... std::string oFName (__NULL_STRING__); // The original name... if (cursor -> actualElement () -> _aditionalData.exists (std::string (__GENVALUE_DESCRIPTORPATH__))) oFName = cursor -> actualElement () -> _aditionalData.getStr (std::string (__GENVALUE_DESCRIPTORPATH__)) -> value ().asString (); else throw VSWContentSaverError (__DATAEXCEP (_IMPOSIBLEOPENAFILE_TXTERROR_)); // If not exists an exception must be thrown. The system will never know // wher to keep the new file... // ...then, extract the relpath of that file, // taking the location of the reproduction definition file as the basic path // what it has been received as a parameter... std::string oldBasicPath = _theData -> valueForVariable (std::string (__VARBASICPATH__)); size_t oldBasicPathPos = oFName.find (oldBasicPath); if (oldBasicPathPos == -1) throw VSWContentSaverError (__DATAEXCEP (_IMPOSIBLEOPENAFILE_TXTERROR_)); // It is not possible that the original basic path was not included into // the name of the file. If it occurrs, then an excepction will be thrown. std::string newPathForDescriptor = std::string (".") + std::string (__PATH_SEPARATOR__) + oFName.substr (oldBasicPathPos + oldBasicPath.length () + 1); // The fullName of the descriptor file, is the unión between the path where the // the new description file is located, and the related path of the orginal // file... std::string fullFileName = bPath + std::string (__PATH_SEPARATOR__) + newPathForDescriptor; _temporalPathsForSchedulings.push_back (fullFileName); // Save the scheduling, // and add a reference to it, into the reproduction project xml description file. result += std::string ("\t\t\t") + _theSchdSaver -> saveScheduling (cursor -> actualElement (), fullFileName, saveAll); } // Add the footer... result += std::string ("\t\t</") + std::string (__SCHEDULINGS_TAGNAME__) + std::string (">\n"); #ifdef __DEBUGSYSTEM __KEEPEXITSIMPLETRACE #endif // Return the result... return (result); }
void ExportSingleDatasetSelect(wxWindow* pWnd, IGxDataset* const pGxDataset) { wxCHECK_RET(pGxDataset, wxT("The input pointer (IGxDataset*) is NULL")); wxGxObject* pGxSrcObj = dynamic_cast<wxGxObject*>(pGxDataset); wxString sName = pGxSrcObj->GetName(); sName = ClearExt(sName); wxGxObjectDialog dlg(pWnd, wxID_ANY, _("Select output")); dlg.SetName(sName); dlg.SetAllowMultiSelect(false); dlg.SetAllFilters(false); wxGISEnumDatasetType eType = pGxDataset->GetType(); int eSubType = pGxDataset->GetSubType(); bool bDefaultSet = false; int eDefaulSubType = 0; if (eType == enumGISFeatureDataset) { for (size_t i = enumVecUnknown + 1; i < enumVecMAX; ++i) { wxGISEnumVectorDatasetType eCurrentSubType = (wxGISEnumVectorDatasetType)i; if (eCurrentSubType != eSubType && IsFileDataset(enumGISFeatureDataset, eCurrentSubType)) { if (bDefaultSet) { dlg.AddFilter(new wxGxFeatureDatasetFilter(eCurrentSubType), false); } else { dlg.AddFilter(new wxGxFeatureDatasetFilter(eCurrentSubType), true); bDefaultSet = true; eDefaulSubType = eCurrentSubType; } } } if (eSubType != enumVecPostGIS) { dlg.AddFilter(new wxGxFeatureDatasetFilter(enumVecPostGIS), false); } } else if (eType == enumGISRasterDataset) { //for (size_t i = enumRasterUnknown + 1; i < enumRasterMAX; ++i) //{ // wxGISEnumRasterDatasetType eCurrentSubType = (wxGISEnumRasterDatasetType)i; // if (eCurrentSubType != eSubType && IsFileDataset(enumGISRasterDataset, eCurrentSubType)) // { // if (bDefaultSet) // { // dlg.AddFilter(new wxGxRasterDatasetFilter(eCurrentSubType), false); // } // else // { // dlg.AddFilter(new wxGxRasterDatasetFilter(eCurrentSubType), true); // bDefaultSet = true; // eDefaulSubType = eCurrentSubType; // } // } //} //if (eSubType != enumRasterPostGIS) //{ // dlg.AddFilter(new wxGxRasterDatasetFilter(enumRasterPostGIS), false); //} } else if (eType == enumGISTableDataset) { for (size_t i = enumTableUnknown + 1; i < enumTableMAX; ++i) { wxGISEnumTableDatasetType eCurrentSubType = (wxGISEnumTableDatasetType)i; if (eCurrentSubType != eSubType && IsFileDataset(enumGISTableDataset, eCurrentSubType)) { if (bDefaultSet) { dlg.AddFilter(new wxGxTableDatasetFilter(eCurrentSubType), false); } else { dlg.AddFilter(new wxGxTableDatasetFilter(eCurrentSubType), true); bDefaultSet = true; eDefaulSubType = eCurrentSubType; } } } if (eSubType != enumTablePostgres) { dlg.AddFilter(new wxGxTableDatasetFilter(enumTablePostgres), false); } } dlg.SetButtonCaption(_("Export")); dlg.SetOverwritePrompt(true); wxGxObject* pGxParentObj = pGxSrcObj->GetParent(); wxString sStartLoc; if (pGxParentObj) { while (NULL != pGxParentObj) { wxGxObjectContainer* pGxCont = wxDynamicCast(pGxParentObj, wxGxObjectContainer); if (NULL != pGxCont && pGxCont->CanCreate(enumGISFeatureDataset, eDefaulSubType)) { break; } else { pGxParentObj = pGxParentObj->GetParent(); } } if (pGxParentObj) { sStartLoc = pGxParentObj->GetFullName(); } } wxGISAppConfig oConfig = GetConfig(); if (oConfig.IsOk()) { if (eType == enumGISFeatureDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_vector_ds/path"), sStartLoc); } else if (eType == enumGISRasterDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_raster_ds/path"), sStartLoc); } else if (eType == enumGISTableDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_table_ds/path"), sStartLoc); } } if (!sStartLoc.IsEmpty()) dlg.SetStartingLocation(sStartLoc); if (dlg.ShowModalSave() == wxID_OK) { wxGxObjectFilter* pFilter = dlg.GetCurrentFilter(); if (NULL == pFilter) { wxMessageBox(_("Unexpected error"), _("Error"), wxCENTRE | wxOK | wxICON_ERROR, pWnd); wxLogError(_("Null wxGxObjectFilter returned")); return; } CPLString sPath = dlg.GetPath(); wxString sCatalogPath = dlg.GetLocation()->GetFullName(); wxFileName oFName(dlg.GetName()); wxString sName = oFName.GetName(); if (oConfig.IsOk()) { if (eType == enumGISFeatureDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_vector_ds/path"), sCatalogPath); } else if (eType == enumGISRasterDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_raster_ds/path"), sCatalogPath); } else if (eType == enumGISTableDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_table_ds/path"), sCatalogPath); } } if (eType == enumGISFeatureDataset) { ExportSingleVectorDataset(pWnd, sPath, sName, pFilter, pGxDataset); } else if (eType == enumGISRasterDataset) { ExportSingleRasterDataset(pWnd, sPath, sName, pFilter, pGxDataset); } else if (eType == enumGISTableDataset) { ExportSingleTableDataset(pWnd, sPath, sName, pFilter, pGxDataset); } } }