[mapguide-commits] r6905 - in branches/2.4/MgDev/Desktop/MgDesktop: . Services Services/Feature Services/Feature/Commands

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Jul 15 19:14:39 PDT 2012


Author: jng
Date: 2012-07-15 19:14:39 -0700 (Sun, 15 Jul 2012)
New Revision: 6905

Added:
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.h
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/EnumerateDataStores.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/EnumerateDataStores.h
Removed:
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/CreateFeatureSource.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/CreateFeatureSource.h
Modified:
   branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.vcproj
   branches/2.4/MgDev/Desktop/MgDesktop/MgDesktopBuild.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp
Log:
mg-desktop: More integration of existing server code and some re-organization

Modified: branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.vcproj
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.vcproj	2012-07-15 21:07:04 UTC (rev 6904)
+++ branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.vcproj	2012-07-16 02:14:39 UTC (rev 6905)
@@ -580,7 +580,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath=".\Services\Feature\CreateFeatureSource.cpp"
+				RelativePath=".\Services\Feature\Commands\CreateFeatureSource.cpp"
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
@@ -1048,6 +1048,42 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath=".\Services\Feature\Commands\EnumerateDataStores.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath=".\Services\Feature\Commands\ExtendedSelectCommand.cpp"
 				>
 				<FileConfiguration
@@ -4838,7 +4874,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\Services\Feature\CreateFeatureSource.h"
+				RelativePath=".\Services\Feature\Commands\CreateFeatureSource.h"
 				>
 			</File>
 			<File
@@ -4910,6 +4946,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\Services\Feature\Commands\EnumerateDataStores.h"
+				>
+			</File>
+			<File
 				RelativePath=".\Services\Feature\Commands\ExtendedSelectCommand.h"
 				>
 			</File>

Modified: branches/2.4/MgDev/Desktop/MgDesktop/MgDesktopBuild.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/MgDesktopBuild.cpp	2012-07-15 21:07:04 UTC (rev 6904)
+++ branches/2.4/MgDev/Desktop/MgDesktop/MgDesktopBuild.cpp	2012-07-16 02:14:39 UTC (rev 6905)
@@ -46,7 +46,6 @@
 
 #include "Services/Drawing/DrawingServiceUtil.cpp"
 
-#include "Services/Feature/CreateFeatureSource.cpp"
 #include "Services/Feature/FdoConnectionPool.cpp"
 #include "Services/Feature/FdoConnectionUtil.cpp"
 #include "Services/Feature/FdoFeatureReader.cpp"
@@ -76,8 +75,10 @@
 #include "Services/Feature/SpatialContextCacheItem.cpp"
 #include "Services/Feature/TransformCache.cpp"
 #include "Services/Feature/Commands/ApplySchema.cpp"
+#include "Services/Feature/Commands/CreateFeatureSource.cpp"
 #include "Services/Feature/Commands/DeleteCommand.cpp"
 #include "Services/Feature/Commands/DescribeSchema.cpp"
+#include "Services/Feature/Commands/EnumerateDataStores.cpp"
 #include "Services/Feature/Commands/ExtendedSelectCommand.cpp"
 #include "Services/Feature/Commands/FeatureManipulationCommand.cpp"
 #include "Services/Feature/Commands/FeatureServiceCommand.cpp"

Added: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.cpp	                        (rev 0)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.cpp	2012-07-16 02:14:39 UTC (rev 6905)
@@ -0,0 +1,534 @@
+#include "MgDesktop.h"
+#include "CreateFeatureSource.h"
+#include "Services/Feature/FdoConnectionUtil.h"
+#include "Services/Feature/FeatureUtil.h"
+
+MgCreateFeatureSource::MgCreateFeatureSource()
+{
+}
+
+MgCreateFeatureSource::~MgCreateFeatureSource()
+{
+}
+
+void MgCreateFeatureSource::CreateFeatureSource(MgResourceIdentifier* resource, MgFeatureSourceParams* sourceParams)
+{
+    MG_FEATURE_SERVICE_TRY()
+
+    MgFileFeatureSourceParams* params = dynamic_cast<MgFileFeatureSourceParams*>(sourceParams);
+    MgRdbmsFeatureSourceParams* rdbParams = dynamic_cast<MgRdbmsFeatureSourceParams*>(sourceParams);
+    if (NULL != params)
+    {
+        STRING providerName = params->GetProviderName();
+        Ptr<MgCreateFileFeatureSource> creator = NULL;    
+        if (providerName == L"OSGeo.SDF") // NOXLATE
+        {
+            creator = new MgCreateSdfFeatureSource(resource, params);
+            creator->CreateFeatureSource(false, false);
+        }
+        else if (providerName == L"OSGeo.SHP") // NOXLATE
+        {
+            creator = new MgCreateShpFeatureSource(resource, params);
+            creator->CreateFeatureSource(true, false);
+        }
+        else if (providerName == L"OSGeo.SQLite") // NOXLATE
+        {
+            creator = new MgCreateSqliteFeatureSource(resource, params);
+            creator->CreateFeatureSource(false, false);
+        }
+        else
+            throw new MgInvalidArgumentException(L"MgCreateFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+    else if (NULL != rdbParams)
+    {
+        STRING providerName = rdbParams->GetProviderName();
+        Ptr<MgCreateRdbmsFeatureSource> creator = NULL;
+        if (providerName == L"OSGeo.MySQL" ||
+            providerName == L"OSGeo.SQLServerSpatial" ||
+            providerName == L"OSGeo.PostgreSQL")
+        {
+            creator = new MgCreateRdbmsFeatureSource(resource, rdbParams);
+            creator->CreateFeatureSource();
+        }
+        else
+            throw new MgInvalidArgumentException(L"MgCreateFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    MG_FEATURE_SERVICE_CHECK_CONNECTION_CATCH_AND_THROW(resource, L"MgCreateFeatureSource.CreateFeatureSource")
+}
+
+MgCreateFileFeatureSource::MgCreateFileFeatureSource(
+    MgResourceIdentifier* resource,
+    MgFileFeatureSourceParams* params)
+{
+    m_resource = resource;
+    SAFE_ADDREF(resource);
+
+    m_params = params;
+    SAFE_ADDREF(params);
+}
+
+MgCreateFileFeatureSource::~MgCreateFileFeatureSource()
+{
+    SAFE_RELEASE(m_resource);
+    SAFE_RELEASE(m_params);
+}
+
+void MgCreateFileFeatureSource::CreateFeatureSource(bool bCheckFeatureClass, bool bCheckSpatialContext)
+{
+    MG_FEATURE_SERVICE_TRY()
+
+    //Some basic schema validation:
+    //  A schema must be supplied
+    //  The schema must define at least one class
+    //  Each class must have an identity property
+    //  A coordinate system must be defined
+    //
+    Ptr<MgFeatureSchema> schema = m_params->GetFeatureSchema();
+    if(schema == NULL)
+        throw new MgInvalidArgumentException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingSchema", NULL);
+
+    if (bCheckFeatureClass)
+    {
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        if(classes == NULL || classes->GetCount() == 0)
+            throw new MgInvalidArgumentException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingClassDef", NULL);
+
+        for(INT32 ci = 0; ci < classes->GetCount(); ci++)
+        {
+            Ptr<MgClassDefinition> classDef = classes->GetItem(ci);
+            Ptr<MgPropertyDefinitionCollection> idProps = classDef->GetIdentityProperties();
+            if(idProps == NULL || idProps->GetCount() == 0)
+                throw new MgInvalidArgumentException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgClassWOIdentity", NULL);
+        }
+    }
+
+    if (bCheckSpatialContext)
+    {
+        // A coordinate system must be defined
+        if(m_params->GetCoordinateSystemWkt().empty())
+            throw new MgInvalidArgumentException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingSrs", NULL);
+    }
+
+    // Connect to provider
+    STRING connString = GetFirstConnectionString();
+    STRING providerName = m_params->GetProviderName();
+    
+    
+    Ptr<MgFeatureConnection> connWrap = new MgFeatureConnection(providerName, connString);
+    {
+        if(NULL == connWrap.p)
+        {
+            throw new MgConnectionFailedException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        FdoPtr<FdoIConnection> conn = connWrap->GetConnection();
+        if (conn == NULL)
+        {
+            throw new MgConnectionFailedException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        CreateDataStore(conn);
+        ApplySchemaAndCreateSpatialContext(conn);
+
+        conn->Close();
+
+        Ptr<MgResourceService> resourceService = GetResourceService();
+        if (NULL != (MgResourceService*)resourceService)
+        {
+            SetFeatureSourceDefinition(resourceService);
+            SetResourceData(resourceService);
+        }
+    }
+
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::CreateFeatureSource")
+}
+
+void MgCreateFileFeatureSource::CreateDataStore(
+    FdoIConnection* conn)
+{
+    MG_FEATURE_SERVICE_TRY()
+    m_tempFileName = MgFileUtil::GenerateTempFileName(true, STRING(L"tmp"), m_fileExtension); // NOXLATE
+
+    // Create the datastore
+    FdoPtr<FdoICreateDataStore> createDsCmd = static_cast<FdoICreateDataStore*>(conn->CreateCommand(FdoCommandType_CreateDataStore));
+    FdoPtr<FdoIDataStorePropertyDictionary> dsProp = createDsCmd->GetDataStoreProperties();
+    dsProp->SetProperty (m_connectParamName.c_str(), m_tempFileName.c_str());
+    createDsCmd->Execute();
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::CreateDataStore")
+}
+
+void MgCreateFileFeatureSource::ApplySchemaAndCreateSpatialContextInternal(FdoIConnection* conn)
+{
+    MG_FEATURE_SERVICE_TRY()
+    // Create the spatialcontext
+    if (!m_params->GetCoordinateSystemWkt().empty())
+    {
+        FdoPtr<FdoICreateSpatialContext> spatialContext = (FdoICreateSpatialContext*)conn->CreateCommand(FdoCommandType_CreateSpatialContext);
+        spatialContext->SetCoordinateSystemWkt(m_params->GetCoordinateSystemWkt().c_str());
+        spatialContext->SetDescription(m_params->GetSpatialContextDescription().c_str());
+        spatialContext->SetName(m_params->GetSpatialContextName().c_str());
+        spatialContext->SetXYTolerance(m_params->GetXYTolerance());
+        spatialContext->SetZTolerance(m_params->GetZTolerance());
+        spatialContext->Execute();
+    }
+
+    // Create and set the schema
+    Ptr<MgFeatureSchema> featureSchema = m_params->GetFeatureSchema();
+    FdoPtr<FdoFeatureSchema> fdoSchema = MgFeatureUtil::GetFdoFeatureSchema(featureSchema);
+    FdoPtr<FdoIApplySchema> applyschema = (FdoIApplySchema*)conn->CreateCommand(FdoCommandType_ApplySchema);
+    applyschema->SetFeatureSchema(fdoSchema);
+    applyschema->Execute();
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::ApplySchemaAndCreateSpatialContextInternal")
+}
+
+void MgCreateFileFeatureSource::ApplySchemaAndCreateSpatialContext(FdoIConnection* conn)
+{
+    MG_FEATURE_SERVICE_TRY()
+    // Open the connection to the newly created file
+    STRING connstr = GetSecondConnectionString();
+    conn->SetConnectionString(connstr.c_str());
+    conn->Open();
+
+    ApplySchemaAndCreateSpatialContextInternal(conn);
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::ApplySchemaAndCreateSpatialContext")
+}
+
+STRING MgCreateFileFeatureSource::GetFileName() const
+{
+    STRING fileName = m_params->GetFileName();
+    if (fileName.empty())
+        fileName = m_resource->GetName() + L"." + m_fileExtension;
+
+    return fileName;
+}
+
+
+void MgCreateFileFeatureSource::SetFeatureSourceDefinition(MgResourceService* resourceService)
+{
+    MG_FEATURE_SERVICE_TRY()
+    STRING fileName = GetFileName();
+
+    STRING featureSource = L"<FeatureSource xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FeatureSource-1.0.0.xsd\" version=\"1.0.0\">\n"; // NOXLATE
+    featureSource += L"  <Provider>" + m_params->GetProviderName() + L"</Provider>\n"; // NOXLATE
+    featureSource += GetFeatureSourceParameterString();
+    featureSource += L"</FeatureSource>"; // NOXLATE
+
+    string utf8Text = MgUtil::WideCharToMultiByte(featureSource);
+
+    Ptr<MgByteSource> xmlSource = new MgByteSource((BYTE_ARRAY_IN) utf8Text.c_str(), (INT32)utf8Text.length());
+    Ptr<MgByteReader> xmlReader = xmlSource->GetReader();
+    resourceService->SetResource(m_resource, xmlReader, NULL);
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::SetFeatureSourceDefinition")
+}
+
+void MgCreateFileFeatureSource::SetResourceDataInternal(MgResourceService* resourceService,
+                                                        STRING source,
+                                                        STRING target)
+{
+    MG_FEATURE_SERVICE_TRY()
+    Ptr<MgByteSource> byteSource = new MgByteSource(source, true);
+    Ptr<MgByteReader> reader = byteSource->GetReader();
+    resourceService->SetResourceData(m_resource, target, MgResourceDataType::File, reader);
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::SetResourceDataInternal")
+}
+
+void MgCreateFileFeatureSource::SetResourceData(MgResourceService* resourceService)
+{
+    MG_FEATURE_SERVICE_TRY()
+    STRING target = GetFileName();
+    SetResourceDataInternal(resourceService, m_tempFileName, target);
+    MgFileUtil::DeleteFile(m_tempFileName);
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::SetResourceData")
+}
+
+MgResourceService* MgCreateFileFeatureSource::GetResourceService()
+{
+    Ptr<MgServiceFactory> fact = new MgServiceFactory();
+    return static_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
+}
+
+STRING MgCreateFileFeatureSource::GetFirstConnectionString()
+{
+    return L"";
+}
+
+STRING MgCreateFileFeatureSource::GetSecondConnectionString()
+{
+    STRING connstr = m_connectParamName + L"=" + m_tempFileName;  // NOXLATE
+    return connstr;
+}
+
+STRING MgCreateFileFeatureSource::GetFeatureSourceParameterString() const
+{
+    STRING fileName = GetFileName();
+    STRING featureSource = L"  <Parameter>\n    <Name>" + m_connectParamName + L"</Name>\n"; // NOXLATE
+    featureSource += L"     <Value>%MG_DATA_FILE_PATH%" + fileName + L"</Value>\n"; // NOXLATE
+    featureSource += L"  </Parameter>\n"; // NOXLATE
+    return featureSource;
+}
+
+void MgCreateFileFeatureSource::Dispose()
+{
+    delete this;
+}
+
+MgCreateSdfFeatureSource::MgCreateSdfFeatureSource(
+    MgResourceIdentifier* resource,
+    MgFileFeatureSourceParams* params):
+    MgCreateFileFeatureSource(resource, params)
+{
+    m_fileExtension = L"sdf";  // NOXLATE
+    m_connectParamName = L"File";  // NOXLATE
+}
+
+MgCreateSdfFeatureSource::~MgCreateSdfFeatureSource()
+{
+}
+
+STRING MgCreateSdfFeatureSource::GetFeatureSourceParameterString() const
+{
+    STRING fileName = GetFileName();
+    STRING featureSource = L"  <Parameter>\n    <Name>" + m_connectParamName + L"</Name>\n"; // NOXLATE
+    featureSource += L"     <Value>%MG_DATA_FILE_PATH%" + fileName + L"</Value>\n"; // NOXLATE
+    featureSource += L"  </Parameter>\n\
+  <Parameter>\n\
+    <Name>ReadOnly</Name>\n\
+    <Value>FALSE</Value>\n\
+  </Parameter>\n"; // NOXLATE
+    return featureSource;
+}
+
+MgCreateShpFeatureSource::MgCreateShpFeatureSource(
+    MgResourceIdentifier* resource,
+    MgFileFeatureSourceParams* params):
+    MgCreateFileFeatureSource(resource, params)
+{
+    m_fileExtension = L"shp";  // NOXLATE
+    m_connectParamName = L"DefaultFileLocation";  // NOXLATE
+}
+
+MgCreateShpFeatureSource::~MgCreateShpFeatureSource()
+{
+}
+
+void MgCreateShpFeatureSource::CreateDataStore(
+    FdoIConnection* conn)
+{
+    // Do nothing because SHP files are created by FdoIApplySchema command.
+}
+
+
+void MgCreateShpFeatureSource::ApplySchemaAndCreateSpatialContext(FdoIConnection* conn)
+{
+    MG_FEATURE_SERVICE_TRY()
+    ApplySchemaAndCreateSpatialContextInternal(conn);
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateShpFeatureSource::ApplySchemaAndCreateSpatialContext")
+}
+
+void MgCreateShpFeatureSource::SetResourceData(MgResourceService* resourceService)
+{
+    MG_FEATURE_SERVICE_TRY()
+    Ptr<MgStringCollection> sourceFiles = new MgStringCollection();
+    Ptr<MgStringCollection> targetFiles = new MgStringCollection();
+    MgFileUtil::GetFilesInDirectory(sourceFiles, m_tempFileName, false, false);
+    MgFileUtil::GetFilesInDirectory(targetFiles, m_tempFileName, false, true);
+
+    int i = 0;
+    for ( i = 0; i < sourceFiles->GetCount(); ++i)
+    {
+        SetResourceDataInternal(resourceService, sourceFiles->GetItem(i), targetFiles->GetItem(i));
+    }
+    MgFileUtil::DeleteDirectory(m_tempFileName);
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateShpFeatureSource::SetResourceData")
+}
+
+STRING MgCreateShpFeatureSource::GetFirstConnectionString()
+{
+    // For SHP feature source, m_tempFileName saves a temporary path
+    // instead of a temporary file name.
+    m_tempFileName = MgFileUtil::GenerateTempPath();
+    STRING connstr = m_connectParamName + L"=" + m_tempFileName;  // NOXLATE
+    return connstr;
+}
+
+STRING MgCreateShpFeatureSource::GetSecondConnectionString()
+{
+    if (m_tempFileName.empty())
+        m_tempFileName = MgFileUtil::GenerateTempPath();
+    STRING connstr = m_connectParamName + L"=" + m_tempFileName;  // NOXLATE
+    return connstr;
+}
+
+STRING MgCreateShpFeatureSource::GetFeatureSourceParameterString() const
+{
+    STRING featureSource = L"  <Parameter>\n    <Name>" + m_connectParamName + L"</Name>\n"; // NOXLATE
+    featureSource += L"     <Value>%MG_DATA_FILE_PATH%</Value>\n"; // NOXLATE
+    featureSource += L"  </Parameter>\n"; // NOXLATE
+    return featureSource;
+}
+
+MgCreateSqliteFeatureSource::MgCreateSqliteFeatureSource(
+    MgResourceIdentifier* resource,
+    MgFileFeatureSourceParams* params):
+    MgCreateFileFeatureSource(resource, params)
+{
+    m_fileExtension = L"sqlite";  // NOXLATE
+    m_connectParamName = L"File";  // NOXLATE
+}
+
+MgCreateSqliteFeatureSource::~MgCreateSqliteFeatureSource()
+{
+}
+
+STRING MgCreateSqliteFeatureSource::GetSecondConnectionString()
+{
+    STRING connstr = m_connectParamName + L"=" + m_tempFileName + L";UseFdoMetadata=true";  // NOXLATE
+    return connstr;
+}
+
+STRING MgCreateSqliteFeatureSource::GetFeatureSourceParameterString() const
+{
+    STRING fileName = GetFileName();
+    STRING featureSource = L"  <Parameter>\n"; // NOXLATE
+    featureSource += L"     <Name>" + m_connectParamName + L"</Name>\n"; // NOXLATE
+    featureSource += L"     <Value>%MG_DATA_FILE_PATH%" + fileName + L"</Value>\n"; // NOXLATE
+    featureSource += L"  </Parameter>\n"; // NOXLATE
+    featureSource += L"  <Parameter>\n";  // NOXLATE
+    featureSource += L"     <Name>UseFdoMetadata</Name>\n"; // NOXLATE
+    featureSource += L"     <Value>true</Value>\n"; // NOXLATE
+    featureSource += L"  </Parameter>\n"; // NOXLATE
+    return featureSource;
+}
+
+MgCreateRdbmsFeatureSource::MgCreateRdbmsFeatureSource(MgResourceIdentifier* resource, MgRdbmsFeatureSourceParams* params)
+{
+    m_resource = resource;
+    SAFE_ADDREF(resource);
+
+    m_params = params;
+    SAFE_ADDREF(params);
+}
+
+MgCreateRdbmsFeatureSource::~MgCreateRdbmsFeatureSource()
+{
+    SAFE_RELEASE(m_resource);
+    SAFE_RELEASE(m_params);
+}
+
+void MgCreateRdbmsFeatureSource::CreateFeatureSource() 
+{
+    MG_FEATURE_SERVICE_TRY()
+    STRING provider = m_params->GetProviderName();
+    STRING service = m_params->GetService();
+    STRING username = m_params->GetUsername();
+    STRING password = m_params->GetPassword();
+    STRING dataStore = m_params->GetDataStore();
+    Ptr<MgFeatureSchema> mgSchema = m_params->GetFeatureSchema();
+
+    STRING connStr = L"";
+    connStr += L"Service=" + service;
+    if (!username.empty())
+        connStr += L";Username=" + username;
+    if (!password.empty())
+        connStr += L";Password=" + password;
+
+    Ptr<MgFeatureConnection> conn = new MgFeatureConnection(provider, connStr);
+    {
+        FdoPtr<FdoIConnection> fdoConn = conn->GetConnection();
+
+        //Create the data store
+        FdoPtr<FdoICreateDataStore> create = (FdoICreateDataStore*)fdoConn->CreateCommand(FdoCommandType_CreateDataStore);
+        FdoPtr<FdoIDataStorePropertyDictionary> dataProps = create->GetDataStoreProperties();
+
+        dataProps->SetProperty(L"DataStore", dataStore.c_str());
+        dataProps->SetProperty(L"IsFdoEnabled", (m_params->GetIsFdoEnabled() ? L"true" : L"false")); 
+
+        create->Execute();
+        fdoConn = NULL;
+        conn = NULL;
+
+        connStr += L";DataStore=" + dataStore;
+        //Amend connection string to incorporate the created data store
+        conn = new MgFeatureConnection(provider, connStr);
+        if (!conn->IsConnectionOpen())
+            throw new MgConnectionFailedException(L"MgCreateRdbmsFeatureSource::CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
+
+        fdoConn = conn->GetConnection();
+
+        //Create spatial context
+        FdoPtr<FdoFgfGeometryFactory> geomFactory = FdoFgfGeometryFactory::GetInstance();
+        FdoPtr<FdoIConnectionCapabilities> connCaps = fdoConn->GetConnectionCapabilities();
+        FdoPtr<FdoICreateSpatialContext> createSc = (FdoICreateSpatialContext*)fdoConn->CreateCommand(FdoCommandType_CreateSpatialContext);
+        
+        //Extents is required for RDBMS data stores
+        Ptr<MgEnvelope> extents = m_params->GetSpatialContextExtents();
+        CHECKNULL((MgEnvelope*)extents, L"MgCreateRdbmsFeatureSource::CreateFeatureSource");
+
+        Ptr<MgCoordinate> extentsLL = extents->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> extentsUR = extents->GetUpperRightCoordinate();
+
+        createSc->SetName(m_params->GetSpatialContextName().c_str());
+        createSc->SetDescription(m_params->GetSpatialContextDescription().c_str());
+        createSc->SetCoordinateSystem(m_params->GetCoordinateSystemName().c_str());
+
+        //This is true for SQL Server
+        if (!connCaps->SupportsCSysWKTFromCSysName())
+            createSc->SetCoordinateSystemWkt(m_params->GetCoordinateSystemWkt().c_str());
+
+        FdoPtr<FdoIEnvelope> env = geomFactory->CreateEnvelopeXY(
+            extentsLL->GetX(),
+            extentsLL->GetY(),
+            extentsUR->GetX(),
+            extentsUR->GetY());
+            
+        FdoPtr<FdoIGeometry> geom = geomFactory->CreateGeometry(env);
+        FdoPtr<FdoByteArray> fgf = geomFactory->GetFgf(geom);
+        createSc->SetExtent(fgf);
+        createSc->SetExtentType(FdoSpatialContextExtentType_Static);
+        createSc->Execute();
+
+        //Now apply the specified schema
+        FdoPtr<FdoIApplySchema> apply = (FdoIApplySchema*)fdoConn->CreateCommand(FdoCommandType_ApplySchema);
+
+        FdoPtr<FdoFeatureSchema> fdoSchema = FdoFeatureSchema::Create(
+            mgSchema->GetName().c_str(),
+            mgSchema->GetDescription().c_str());
+
+        //TODO: Should we be smart here or put the onus on the invoker to
+        //ensure that geometry properties of the schema we are going to apply
+        //are correctly pointing to the name of the spatial context we just 
+        //created?
+
+        MgFeatureUtil::UpdateFdoFeatureSchema(mgSchema, fdoSchema);
+        apply->SetFeatureSchema(fdoSchema);
+        apply->Execute();
+
+        WriteFeatureSourceContent();
+    }
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateRdbmsFeatureSource::CreateFeatureSource")
+}
+
+void MgCreateRdbmsFeatureSource::WriteFeatureSourceContent()
+{
+    MG_FEATURE_SERVICE_TRY()
+    Ptr<MgServiceFactory> fact = new MgServiceFactory();
+    Ptr<MgdResourceService> resSvc = static_cast<MgdResourceService*>(fact->CreateService(MgServiceType::ResourceService));
+
+    STRING xml = L"<FeatureSource xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FeatureSource-1.0.0.xsd\" version=\"1.0.0\">\n"; // NOXLATE
+    xml += L"  <Provider>" + m_params->GetProviderName() + L"</Provider>\n"; // NOXLATE
+    xml += L"  <Parameter>\n    <Name>Service</Name>\n    <Value>" + m_params->GetService() + L"</Value>\n  </Parameter>\n"; // NOXLATE
+    xml += L"  <Parameter>\n    <Name>Username</Name>\n    <Value>" + m_params->GetUsername() + L"</Value>\n  </Parameter>\n"; // NOXLATE
+    xml += L"  <Parameter>\n    <Name>Password</Name>\n    <Value>" + m_params->GetPassword() + L"</Value>\n  </Parameter>\n"; // NOXLATE
+    xml += L"  <Parameter>\n    <Name>DataStore</Name>\n    <Value>" + m_params->GetDataStore() + L"</Value>\n  </Parameter>\n"; // NOXLATE
+    xml += L"</FeatureSource>"; // NOXLATE
+
+    string utf8Text = MgUtil::WideCharToMultiByte(xml);
+
+    Ptr<MgByteSource> xmlSource = new MgByteSource((BYTE_ARRAY_IN) utf8Text.c_str(), (INT32)utf8Text.length());
+    Ptr<MgByteReader> xmlReader = xmlSource->GetReader();
+    resSvc->SetResource(m_resource, xmlReader, NULL);
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateRdbmsFeatureSource::WriteFeatureSourceContent")
+}
+
+void MgCreateRdbmsFeatureSource::Dispose() { delete this; }
\ No newline at end of file

Added: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.h	                        (rev 0)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.h	2012-07-16 02:14:39 UTC (rev 6905)
@@ -0,0 +1,101 @@
+#ifndef DESKTOP_CREATE_FEATURE_SOURCE_H
+#define DESKTOP_CREATE_FEATURE_SOURCE_H
+
+class FdoIConnection;
+class MgResourceIdentifier;
+class MgResourceService;
+class MgFeatureSourceParams;
+class MgFileFeatureSourceParams;
+template class FdoPtr<FdoIConnection>;
+
+class MgCreateFeatureSource : public MgGuardDisposable
+{
+public:
+    MgCreateFeatureSource();
+    virtual ~MgCreateFeatureSource();
+    void CreateFeatureSource(MgResourceIdentifier* resource, MgFeatureSourceParams* sourceParams);
+
+    virtual void Dispose() { delete this; }
+};
+
+class MgCreateRdbmsFeatureSource : public MgGuardDisposable
+{
+public:
+    MgCreateRdbmsFeatureSource(MgResourceIdentifier* resource, MgRdbmsFeatureSourceParams* params);
+    virtual ~MgCreateRdbmsFeatureSource();
+
+    void CreateFeatureSource();
+    virtual void Dispose();
+
+private:
+    void WriteFeatureSourceContent();
+
+    MgResourceIdentifier* m_resource;
+    MgRdbmsFeatureSourceParams* m_params;
+};
+
+class MgCreateFileFeatureSource : public MgGuardDisposable
+{
+public:
+    MgCreateFileFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
+    virtual ~MgCreateFileFeatureSource();
+    void CreateFeatureSource(bool bCheckFeatureClass = false, bool bCheckSpatialContext = false);
+    virtual void Dispose();
+
+protected:
+    virtual void CreateDataStore(FdoIConnection* conn);
+    virtual void ApplySchemaAndCreateSpatialContext(FdoIConnection* conn);
+    virtual void SetFeatureSourceDefinition(MgResourceService* resourceService);
+    virtual void SetResourceData(MgResourceService* resourceService);
+    virtual STRING GetFirstConnectionString();
+    virtual STRING GetSecondConnectionString();
+    virtual STRING GetFeatureSourceParameterString() const;
+
+protected:
+    STRING GetFileName() const;
+    MgResourceService* GetResourceService();
+    void ApplySchemaAndCreateSpatialContextInternal(FdoIConnection* conn);
+    void SetResourceDataInternal(MgResourceService* resourceService, STRING source, STRING target);
+
+protected:
+    STRING m_fileExtension;
+    STRING m_connectParamName;
+    STRING m_tempFileName;
+    MgResourceIdentifier* m_resource;
+    MgFileFeatureSourceParams* m_params;
+};
+
+class MgCreateSdfFeatureSource: public MgCreateFileFeatureSource
+{
+public:
+    MgCreateSdfFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
+    virtual ~MgCreateSdfFeatureSource();
+protected:
+    virtual STRING GetFeatureSourceParameterString() const;
+};
+
+class MgCreateShpFeatureSource: public MgCreateFileFeatureSource
+{
+public:
+    MgCreateShpFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
+    virtual ~MgCreateShpFeatureSource();
+protected:
+    virtual void CreateDataStore(FdoIConnection* conn);
+    virtual void ApplySchemaAndCreateSpatialContext(FdoIConnection* conn);
+    virtual void SetResourceData(MgResourceService* resourceService);
+    virtual STRING GetFirstConnectionString();
+    virtual STRING GetSecondConnectionString();
+    virtual STRING GetFeatureSourceParameterString() const;
+};
+
+class MgCreateSqliteFeatureSource: public MgCreateFileFeatureSource
+{
+public:
+    MgCreateSqliteFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
+    virtual ~MgCreateSqliteFeatureSource();
+protected:
+    virtual STRING GetSecondConnectionString();
+    virtual STRING GetFeatureSourceParameterString() const;
+};
+
+#endif
\ No newline at end of file

Added: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/EnumerateDataStores.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/EnumerateDataStores.cpp	                        (rev 0)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/EnumerateDataStores.cpp	2012-07-16 02:14:39 UTC (rev 6905)
@@ -0,0 +1,95 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "Services/Feature/FeatureDefs.h"
+#include "EnumerateDataStores.h"
+
+MgEnumerateDataStores::MgEnumerateDataStores()
+{
+    // This XML follows the DataStoreList-1.0.0.xsd schema
+    m_xmlUtil = new MgXmlUtil("DataStoreList" /* NOXLATE */);
+    CHECKNULL(m_xmlUtil, L"MgEnumerateDataStores.EnumerateDataStores()");
+}
+
+MgEnumerateDataStores::~MgEnumerateDataStores()
+{
+    delete m_xmlUtil;
+    m_xmlUtil = NULL;
+}
+
+
+MgByteReader* MgEnumerateDataStores::EnumerateDataStores(CREFSTRING providerName, CREFSTRING partialConnString)
+{
+    Ptr<MgByteReader> byteReader;
+
+    MG_FEATURE_SERVICE_TRY()
+
+    // Connect to the provider
+    FdoPtr<FdoIDataStoreReader> fdoDataStoreReader;
+
+    Ptr<MgFeatureConnection> msfc = new MgFeatureConnection(providerName, partialConnString);
+    if ((NULL != msfc.p) && (( msfc->IsConnectionOpen() ) || ( msfc->IsConnectionPending() )))
+    {
+        // The reference to the FDO connection from the MgFeatureConnection object must be cleaned up before the parent object
+        // otherwise it leaves the FDO connection marked as still in use.
+        FdoPtr<FdoIConnection> fdoConnection;
+        fdoConnection = msfc->GetConnection();
+
+        FdoPtr<FdoIListDataStores> fdoCommand = (FdoIListDataStores*)fdoConnection->CreateCommand(FdoCommandType_ListDataStores);
+        CHECKNULL((FdoIListDataStores*)fdoCommand, L"MgEnumerateDataStores.EnumerateDataStores");
+
+        fdoCommand->SetIncludeNonFdoEnabledDatastores(true);
+
+        // Execute the command
+        fdoDataStoreReader = fdoCommand->Execute();
+        CHECKNULL((FdoIDataStoreReader*)fdoDataStoreReader, L"MgEnumerateDataStores.EnumerateDataStores");
+
+        // Add Feature Provider element
+        DOMElement* rootElem = m_xmlUtil->GetRootNode();
+
+        while(fdoDataStoreReader->ReadNext())
+        {
+            FdoString* dataStoreName = fdoDataStoreReader->GetName();
+            const char *name = MgUtil::WideCharToMultiByte(dataStoreName);
+
+            DOMElement* featureProviderElem = m_xmlUtil->AddChildNode(rootElem, "DataStore" /* NOXLATE */);
+
+            // Add DataStore Name
+            m_xmlUtil->AddTextNode(featureProviderElem, "Name" /* NOXLATE */, name);
+
+            // Add FDO Enabled
+            m_xmlUtil->AddTextNode(featureProviderElem, "FdoEnabled" /* NOXLATE */, fdoDataStoreReader->GetIsFdoEnabled());
+
+            delete[] name;
+            name = NULL;
+        }
+
+        // Close the reader
+        fdoDataStoreReader->Close();
+
+        // Convert the XML to a byte reader
+        byteReader = m_xmlUtil->ToReader();
+    }
+    else
+    {
+        throw new MgConnectionFailedException(L"MgEnumerateDataStores::EnumerateDataStores()", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgEnumerateDataStores.EnumerateDataStores")
+
+    return byteReader.Detach();
+}

Added: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/EnumerateDataStores.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/EnumerateDataStores.h	                        (rev 0)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/EnumerateDataStores.h	2012-07-16 02:14:39 UTC (rev 6905)
@@ -0,0 +1,39 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _MG_SERVER_ENUMERATE_DATASTORES_H_
+#define _MG_SERVER_ENUMERATE_DATASTORES_H_
+
+#include "MgDesktop.h"
+#include "System/XmlDefs.h"
+#include "System/XmlUtil.h"
+#include "Fdo.h"
+
+class MgEnumerateDataStores
+{
+public:
+    MgEnumerateDataStores();
+    ~MgEnumerateDataStores();
+
+
+    MgByteReader* EnumerateDataStores(CREFSTRING providerName, CREFSTRING partialConnString);
+
+private:
+    MgXmlUtil* m_xmlUtil;
+};
+
+#endif

Deleted: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/CreateFeatureSource.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/CreateFeatureSource.cpp	2012-07-15 21:07:04 UTC (rev 6904)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/CreateFeatureSource.cpp	2012-07-16 02:14:39 UTC (rev 6905)
@@ -1,534 +0,0 @@
-#include "MgDesktop.h"
-#include "CreateFeatureSource.h"
-#include "FdoConnectionUtil.h"
-#include "FeatureUtil.h"
-
-MgCreateFeatureSource::MgCreateFeatureSource()
-{
-}
-
-MgCreateFeatureSource::~MgCreateFeatureSource()
-{
-}
-
-void MgCreateFeatureSource::CreateFeatureSource(MgResourceIdentifier* resource, MgFeatureSourceParams* sourceParams)
-{
-    MG_FEATURE_SERVICE_TRY()
-
-    MgFileFeatureSourceParams* params = dynamic_cast<MgFileFeatureSourceParams*>(sourceParams);
-    MgRdbmsFeatureSourceParams* rdbParams = dynamic_cast<MgRdbmsFeatureSourceParams*>(sourceParams);
-    if (NULL != params)
-    {
-        STRING providerName = params->GetProviderName();
-        Ptr<MgCreateFileFeatureSource> creator = NULL;    
-        if (providerName == L"OSGeo.SDF") // NOXLATE
-        {
-            creator = new MgCreateSdfFeatureSource(resource, params);
-            creator->CreateFeatureSource(false, false);
-        }
-        else if (providerName == L"OSGeo.SHP") // NOXLATE
-        {
-            creator = new MgCreateShpFeatureSource(resource, params);
-            creator->CreateFeatureSource(true, false);
-        }
-        else if (providerName == L"OSGeo.SQLite") // NOXLATE
-        {
-            creator = new MgCreateSqliteFeatureSource(resource, params);
-            creator->CreateFeatureSource(false, false);
-        }
-        else
-            throw new MgInvalidArgumentException(L"MgCreateFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-    else if (NULL != rdbParams)
-    {
-        STRING providerName = rdbParams->GetProviderName();
-        Ptr<MgCreateRdbmsFeatureSource> creator = NULL;
-        if (providerName == L"OSGeo.MySQL" ||
-            providerName == L"OSGeo.SQLServerSpatial" ||
-            providerName == L"OSGeo.PostgreSQL")
-        {
-            creator = new MgCreateRdbmsFeatureSource(resource, rdbParams);
-            creator->CreateFeatureSource();
-        }
-        else
-            throw new MgInvalidArgumentException(L"MgCreateFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-
-    MG_FEATURE_SERVICE_CHECK_CONNECTION_CATCH_AND_THROW(resource, L"MgCreateFeatureSource.CreateFeatureSource")
-}
-
-MgCreateFileFeatureSource::MgCreateFileFeatureSource(
-    MgResourceIdentifier* resource,
-    MgFileFeatureSourceParams* params)
-{
-    m_resource = resource;
-    SAFE_ADDREF(resource);
-
-    m_params = params;
-    SAFE_ADDREF(params);
-}
-
-MgCreateFileFeatureSource::~MgCreateFileFeatureSource()
-{
-    SAFE_RELEASE(m_resource);
-    SAFE_RELEASE(m_params);
-}
-
-void MgCreateFileFeatureSource::CreateFeatureSource(bool bCheckFeatureClass, bool bCheckSpatialContext)
-{
-    MG_FEATURE_SERVICE_TRY()
-
-    //Some basic schema validation:
-    //  A schema must be supplied
-    //  The schema must define at least one class
-    //  Each class must have an identity property
-    //  A coordinate system must be defined
-    //
-    Ptr<MgFeatureSchema> schema = m_params->GetFeatureSchema();
-    if(schema == NULL)
-        throw new MgInvalidArgumentException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingSchema", NULL);
-
-    if (bCheckFeatureClass)
-    {
-        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
-        if(classes == NULL || classes->GetCount() == 0)
-            throw new MgInvalidArgumentException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingClassDef", NULL);
-
-        for(INT32 ci = 0; ci < classes->GetCount(); ci++)
-        {
-            Ptr<MgClassDefinition> classDef = classes->GetItem(ci);
-            Ptr<MgPropertyDefinitionCollection> idProps = classDef->GetIdentityProperties();
-            if(idProps == NULL || idProps->GetCount() == 0)
-                throw new MgInvalidArgumentException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgClassWOIdentity", NULL);
-        }
-    }
-
-    if (bCheckSpatialContext)
-    {
-        // A coordinate system must be defined
-        if(m_params->GetCoordinateSystemWkt().empty())
-            throw new MgInvalidArgumentException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingSrs", NULL);
-    }
-
-    // Connect to provider
-    STRING connString = GetFirstConnectionString();
-    STRING providerName = m_params->GetProviderName();
-    
-    
-    Ptr<MgFeatureConnection> connWrap = new MgFeatureConnection(providerName, connString);
-    {
-        if(NULL == connWrap.p)
-        {
-            throw new MgConnectionFailedException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        FdoPtr<FdoIConnection> conn = connWrap->GetConnection();
-        if (conn == NULL)
-        {
-            throw new MgConnectionFailedException(L"MgCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        CreateDataStore(conn);
-        ApplySchemaAndCreateSpatialContext(conn);
-
-        conn->Close();
-
-        Ptr<MgResourceService> resourceService = GetResourceService();
-        if (NULL != (MgResourceService*)resourceService)
-        {
-            SetFeatureSourceDefinition(resourceService);
-            SetResourceData(resourceService);
-        }
-    }
-
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::CreateFeatureSource")
-}
-
-void MgCreateFileFeatureSource::CreateDataStore(
-    FdoIConnection* conn)
-{
-    MG_FEATURE_SERVICE_TRY()
-    m_tempFileName = MgFileUtil::GenerateTempFileName(true, STRING(L"tmp"), m_fileExtension); // NOXLATE
-
-    // Create the datastore
-    FdoPtr<FdoICreateDataStore> createDsCmd = static_cast<FdoICreateDataStore*>(conn->CreateCommand(FdoCommandType_CreateDataStore));
-    FdoPtr<FdoIDataStorePropertyDictionary> dsProp = createDsCmd->GetDataStoreProperties();
-    dsProp->SetProperty (m_connectParamName.c_str(), m_tempFileName.c_str());
-    createDsCmd->Execute();
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::CreateDataStore")
-}
-
-void MgCreateFileFeatureSource::ApplySchemaAndCreateSpatialContextInternal(FdoIConnection* conn)
-{
-    MG_FEATURE_SERVICE_TRY()
-    // Create the spatialcontext
-    if (!m_params->GetCoordinateSystemWkt().empty())
-    {
-        FdoPtr<FdoICreateSpatialContext> spatialContext = (FdoICreateSpatialContext*)conn->CreateCommand(FdoCommandType_CreateSpatialContext);
-        spatialContext->SetCoordinateSystemWkt(m_params->GetCoordinateSystemWkt().c_str());
-        spatialContext->SetDescription(m_params->GetSpatialContextDescription().c_str());
-        spatialContext->SetName(m_params->GetSpatialContextName().c_str());
-        spatialContext->SetXYTolerance(m_params->GetXYTolerance());
-        spatialContext->SetZTolerance(m_params->GetZTolerance());
-        spatialContext->Execute();
-    }
-
-    // Create and set the schema
-    Ptr<MgFeatureSchema> featureSchema = m_params->GetFeatureSchema();
-    FdoPtr<FdoFeatureSchema> fdoSchema = MgFeatureUtil::GetFdoFeatureSchema(featureSchema);
-    FdoPtr<FdoIApplySchema> applyschema = (FdoIApplySchema*)conn->CreateCommand(FdoCommandType_ApplySchema);
-    applyschema->SetFeatureSchema(fdoSchema);
-    applyschema->Execute();
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::ApplySchemaAndCreateSpatialContextInternal")
-}
-
-void MgCreateFileFeatureSource::ApplySchemaAndCreateSpatialContext(FdoIConnection* conn)
-{
-    MG_FEATURE_SERVICE_TRY()
-    // Open the connection to the newly created file
-    STRING connstr = GetSecondConnectionString();
-    conn->SetConnectionString(connstr.c_str());
-    conn->Open();
-
-    ApplySchemaAndCreateSpatialContextInternal(conn);
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::ApplySchemaAndCreateSpatialContext")
-}
-
-STRING MgCreateFileFeatureSource::GetFileName() const
-{
-    STRING fileName = m_params->GetFileName();
-    if (fileName.empty())
-        fileName = m_resource->GetName() + L"." + m_fileExtension;
-
-    return fileName;
-}
-
-
-void MgCreateFileFeatureSource::SetFeatureSourceDefinition(MgResourceService* resourceService)
-{
-    MG_FEATURE_SERVICE_TRY()
-    STRING fileName = GetFileName();
-
-    STRING featureSource = L"<FeatureSource xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FeatureSource-1.0.0.xsd\" version=\"1.0.0\">\n"; // NOXLATE
-    featureSource += L"  <Provider>" + m_params->GetProviderName() + L"</Provider>\n"; // NOXLATE
-    featureSource += GetFeatureSourceParameterString();
-    featureSource += L"</FeatureSource>"; // NOXLATE
-
-    string utf8Text = MgUtil::WideCharToMultiByte(featureSource);
-
-    Ptr<MgByteSource> xmlSource = new MgByteSource((BYTE_ARRAY_IN) utf8Text.c_str(), (INT32)utf8Text.length());
-    Ptr<MgByteReader> xmlReader = xmlSource->GetReader();
-    resourceService->SetResource(m_resource, xmlReader, NULL);
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::SetFeatureSourceDefinition")
-}
-
-void MgCreateFileFeatureSource::SetResourceDataInternal(MgResourceService* resourceService,
-                                                        STRING source,
-                                                        STRING target)
-{
-    MG_FEATURE_SERVICE_TRY()
-    Ptr<MgByteSource> byteSource = new MgByteSource(source, true);
-    Ptr<MgByteReader> reader = byteSource->GetReader();
-    resourceService->SetResourceData(m_resource, target, MgResourceDataType::File, reader);
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::SetResourceDataInternal")
-}
-
-void MgCreateFileFeatureSource::SetResourceData(MgResourceService* resourceService)
-{
-    MG_FEATURE_SERVICE_TRY()
-    STRING target = GetFileName();
-    SetResourceDataInternal(resourceService, m_tempFileName, target);
-    MgFileUtil::DeleteFile(m_tempFileName);
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateFileFeatureSource::SetResourceData")
-}
-
-MgResourceService* MgCreateFileFeatureSource::GetResourceService()
-{
-    Ptr<MgServiceFactory> fact = new MgServiceFactory();
-    return static_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
-}
-
-STRING MgCreateFileFeatureSource::GetFirstConnectionString()
-{
-    return L"";
-}
-
-STRING MgCreateFileFeatureSource::GetSecondConnectionString()
-{
-    STRING connstr = m_connectParamName + L"=" + m_tempFileName;  // NOXLATE
-    return connstr;
-}
-
-STRING MgCreateFileFeatureSource::GetFeatureSourceParameterString() const
-{
-    STRING fileName = GetFileName();
-    STRING featureSource = L"  <Parameter>\n    <Name>" + m_connectParamName + L"</Name>\n"; // NOXLATE
-    featureSource += L"     <Value>%MG_DATA_FILE_PATH%" + fileName + L"</Value>\n"; // NOXLATE
-    featureSource += L"  </Parameter>\n"; // NOXLATE
-    return featureSource;
-}
-
-void MgCreateFileFeatureSource::Dispose()
-{
-    delete this;
-}
-
-MgCreateSdfFeatureSource::MgCreateSdfFeatureSource(
-    MgResourceIdentifier* resource,
-    MgFileFeatureSourceParams* params):
-    MgCreateFileFeatureSource(resource, params)
-{
-    m_fileExtension = L"sdf";  // NOXLATE
-    m_connectParamName = L"File";  // NOXLATE
-}
-
-MgCreateSdfFeatureSource::~MgCreateSdfFeatureSource()
-{
-}
-
-STRING MgCreateSdfFeatureSource::GetFeatureSourceParameterString() const
-{
-    STRING fileName = GetFileName();
-    STRING featureSource = L"  <Parameter>\n    <Name>" + m_connectParamName + L"</Name>\n"; // NOXLATE
-    featureSource += L"     <Value>%MG_DATA_FILE_PATH%" + fileName + L"</Value>\n"; // NOXLATE
-    featureSource += L"  </Parameter>\n\
-  <Parameter>\n\
-    <Name>ReadOnly</Name>\n\
-    <Value>FALSE</Value>\n\
-  </Parameter>\n"; // NOXLATE
-    return featureSource;
-}
-
-MgCreateShpFeatureSource::MgCreateShpFeatureSource(
-    MgResourceIdentifier* resource,
-    MgFileFeatureSourceParams* params):
-    MgCreateFileFeatureSource(resource, params)
-{
-    m_fileExtension = L"shp";  // NOXLATE
-    m_connectParamName = L"DefaultFileLocation";  // NOXLATE
-}
-
-MgCreateShpFeatureSource::~MgCreateShpFeatureSource()
-{
-}
-
-void MgCreateShpFeatureSource::CreateDataStore(
-    FdoIConnection* conn)
-{
-    // Do nothing because SHP files are created by FdoIApplySchema command.
-}
-
-
-void MgCreateShpFeatureSource::ApplySchemaAndCreateSpatialContext(FdoIConnection* conn)
-{
-    MG_FEATURE_SERVICE_TRY()
-    ApplySchemaAndCreateSpatialContextInternal(conn);
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateShpFeatureSource::ApplySchemaAndCreateSpatialContext")
-}
-
-void MgCreateShpFeatureSource::SetResourceData(MgResourceService* resourceService)
-{
-    MG_FEATURE_SERVICE_TRY()
-    Ptr<MgStringCollection> sourceFiles = new MgStringCollection();
-    Ptr<MgStringCollection> targetFiles = new MgStringCollection();
-    MgFileUtil::GetFilesInDirectory(sourceFiles, m_tempFileName, false, false);
-    MgFileUtil::GetFilesInDirectory(targetFiles, m_tempFileName, false, true);
-
-    int i = 0;
-    for ( i = 0; i < sourceFiles->GetCount(); ++i)
-    {
-        SetResourceDataInternal(resourceService, sourceFiles->GetItem(i), targetFiles->GetItem(i));
-    }
-    MgFileUtil::DeleteDirectory(m_tempFileName);
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateShpFeatureSource::SetResourceData")
-}
-
-STRING MgCreateShpFeatureSource::GetFirstConnectionString()
-{
-    // For SHP feature source, m_tempFileName saves a temporary path
-    // instead of a temporary file name.
-    m_tempFileName = MgFileUtil::GenerateTempPath();
-    STRING connstr = m_connectParamName + L"=" + m_tempFileName;  // NOXLATE
-    return connstr;
-}
-
-STRING MgCreateShpFeatureSource::GetSecondConnectionString()
-{
-    if (m_tempFileName.empty())
-        m_tempFileName = MgFileUtil::GenerateTempPath();
-    STRING connstr = m_connectParamName + L"=" + m_tempFileName;  // NOXLATE
-    return connstr;
-}
-
-STRING MgCreateShpFeatureSource::GetFeatureSourceParameterString() const
-{
-    STRING featureSource = L"  <Parameter>\n    <Name>" + m_connectParamName + L"</Name>\n"; // NOXLATE
-    featureSource += L"     <Value>%MG_DATA_FILE_PATH%</Value>\n"; // NOXLATE
-    featureSource += L"  </Parameter>\n"; // NOXLATE
-    return featureSource;
-}
-
-MgCreateSqliteFeatureSource::MgCreateSqliteFeatureSource(
-    MgResourceIdentifier* resource,
-    MgFileFeatureSourceParams* params):
-    MgCreateFileFeatureSource(resource, params)
-{
-    m_fileExtension = L"sqlite";  // NOXLATE
-    m_connectParamName = L"File";  // NOXLATE
-}
-
-MgCreateSqliteFeatureSource::~MgCreateSqliteFeatureSource()
-{
-}
-
-STRING MgCreateSqliteFeatureSource::GetSecondConnectionString()
-{
-    STRING connstr = m_connectParamName + L"=" + m_tempFileName + L";UseFdoMetadata=true";  // NOXLATE
-    return connstr;
-}
-
-STRING MgCreateSqliteFeatureSource::GetFeatureSourceParameterString() const
-{
-    STRING fileName = GetFileName();
-    STRING featureSource = L"  <Parameter>\n"; // NOXLATE
-    featureSource += L"     <Name>" + m_connectParamName + L"</Name>\n"; // NOXLATE
-    featureSource += L"     <Value>%MG_DATA_FILE_PATH%" + fileName + L"</Value>\n"; // NOXLATE
-    featureSource += L"  </Parameter>\n"; // NOXLATE
-    featureSource += L"  <Parameter>\n";  // NOXLATE
-    featureSource += L"     <Name>UseFdoMetadata</Name>\n"; // NOXLATE
-    featureSource += L"     <Value>true</Value>\n"; // NOXLATE
-    featureSource += L"  </Parameter>\n"; // NOXLATE
-    return featureSource;
-}
-
-MgCreateRdbmsFeatureSource::MgCreateRdbmsFeatureSource(MgResourceIdentifier* resource, MgRdbmsFeatureSourceParams* params)
-{
-    m_resource = resource;
-    SAFE_ADDREF(resource);
-
-    m_params = params;
-    SAFE_ADDREF(params);
-}
-
-MgCreateRdbmsFeatureSource::~MgCreateRdbmsFeatureSource()
-{
-    SAFE_RELEASE(m_resource);
-    SAFE_RELEASE(m_params);
-}
-
-void MgCreateRdbmsFeatureSource::CreateFeatureSource() 
-{
-    MG_FEATURE_SERVICE_TRY()
-    STRING provider = m_params->GetProviderName();
-    STRING service = m_params->GetService();
-    STRING username = m_params->GetUsername();
-    STRING password = m_params->GetPassword();
-    STRING dataStore = m_params->GetDataStore();
-    Ptr<MgFeatureSchema> mgSchema = m_params->GetFeatureSchema();
-
-    STRING connStr = L"";
-    connStr += L"Service=" + service;
-    if (!username.empty())
-        connStr += L";Username=" + username;
-    if (!password.empty())
-        connStr += L";Password=" + password;
-
-    Ptr<MgFeatureConnection> conn = new MgFeatureConnection(provider, connStr);
-    {
-        FdoPtr<FdoIConnection> fdoConn = conn->GetConnection();
-
-        //Create the data store
-        FdoPtr<FdoICreateDataStore> create = (FdoICreateDataStore*)fdoConn->CreateCommand(FdoCommandType_CreateDataStore);
-        FdoPtr<FdoIDataStorePropertyDictionary> dataProps = create->GetDataStoreProperties();
-
-        dataProps->SetProperty(L"DataStore", dataStore.c_str());
-        dataProps->SetProperty(L"IsFdoEnabled", (m_params->GetIsFdoEnabled() ? L"true" : L"false")); 
-
-        create->Execute();
-        fdoConn = NULL;
-        conn = NULL;
-
-        connStr += L";DataStore=" + dataStore;
-        //Amend connection string to incorporate the created data store
-        conn = new MgFeatureConnection(provider, connStr);
-        if (!conn->IsConnectionOpen())
-            throw new MgConnectionFailedException(L"MgCreateRdbmsFeatureSource::CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
-
-        fdoConn = conn->GetConnection();
-
-        //Create spatial context
-        FdoPtr<FdoFgfGeometryFactory> geomFactory = FdoFgfGeometryFactory::GetInstance();
-        FdoPtr<FdoIConnectionCapabilities> connCaps = fdoConn->GetConnectionCapabilities();
-        FdoPtr<FdoICreateSpatialContext> createSc = (FdoICreateSpatialContext*)fdoConn->CreateCommand(FdoCommandType_CreateSpatialContext);
-        
-        //Extents is required for RDBMS data stores
-        Ptr<MgEnvelope> extents = m_params->GetSpatialContextExtents();
-        CHECKNULL((MgEnvelope*)extents, L"MgCreateRdbmsFeatureSource::CreateFeatureSource");
-
-        Ptr<MgCoordinate> extentsLL = extents->GetLowerLeftCoordinate();
-        Ptr<MgCoordinate> extentsUR = extents->GetUpperRightCoordinate();
-
-        createSc->SetName(m_params->GetSpatialContextName().c_str());
-        createSc->SetDescription(m_params->GetSpatialContextDescription().c_str());
-        createSc->SetCoordinateSystem(m_params->GetCoordinateSystemName().c_str());
-
-        //This is true for SQL Server
-        if (!connCaps->SupportsCSysWKTFromCSysName())
-            createSc->SetCoordinateSystemWkt(m_params->GetCoordinateSystemWkt().c_str());
-
-        FdoPtr<FdoIEnvelope> env = geomFactory->CreateEnvelopeXY(
-            extentsLL->GetX(),
-            extentsLL->GetY(),
-            extentsUR->GetX(),
-            extentsUR->GetY());
-            
-        FdoPtr<FdoIGeometry> geom = geomFactory->CreateGeometry(env);
-        FdoPtr<FdoByteArray> fgf = geomFactory->GetFgf(geom);
-        createSc->SetExtent(fgf);
-        createSc->SetExtentType(FdoSpatialContextExtentType_Static);
-        createSc->Execute();
-
-        //Now apply the specified schema
-        FdoPtr<FdoIApplySchema> apply = (FdoIApplySchema*)fdoConn->CreateCommand(FdoCommandType_ApplySchema);
-
-        FdoPtr<FdoFeatureSchema> fdoSchema = FdoFeatureSchema::Create(
-            mgSchema->GetName().c_str(),
-            mgSchema->GetDescription().c_str());
-
-        //TODO: Should we be smart here or put the onus on the invoker to
-        //ensure that geometry properties of the schema we are going to apply
-        //are correctly pointing to the name of the spatial context we just 
-        //created?
-
-        MgFeatureUtil::UpdateFdoFeatureSchema(mgSchema, fdoSchema);
-        apply->SetFeatureSchema(fdoSchema);
-        apply->Execute();
-
-        WriteFeatureSourceContent();
-    }
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateRdbmsFeatureSource::CreateFeatureSource")
-}
-
-void MgCreateRdbmsFeatureSource::WriteFeatureSourceContent()
-{
-    MG_FEATURE_SERVICE_TRY()
-    Ptr<MgServiceFactory> fact = new MgServiceFactory();
-    Ptr<MgdResourceService> resSvc = static_cast<MgdResourceService*>(fact->CreateService(MgServiceType::ResourceService));
-
-    STRING xml = L"<FeatureSource xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FeatureSource-1.0.0.xsd\" version=\"1.0.0\">\n"; // NOXLATE
-    xml += L"  <Provider>" + m_params->GetProviderName() + L"</Provider>\n"; // NOXLATE
-    xml += L"  <Parameter>\n    <Name>Service</Name>\n    <Value>" + m_params->GetService() + L"</Value>\n  </Parameter>\n"; // NOXLATE
-    xml += L"  <Parameter>\n    <Name>Username</Name>\n    <Value>" + m_params->GetUsername() + L"</Value>\n  </Parameter>\n"; // NOXLATE
-    xml += L"  <Parameter>\n    <Name>Password</Name>\n    <Value>" + m_params->GetPassword() + L"</Value>\n  </Parameter>\n"; // NOXLATE
-    xml += L"  <Parameter>\n    <Name>DataStore</Name>\n    <Value>" + m_params->GetDataStore() + L"</Value>\n  </Parameter>\n"; // NOXLATE
-    xml += L"</FeatureSource>"; // NOXLATE
-
-    string utf8Text = MgUtil::WideCharToMultiByte(xml);
-
-    Ptr<MgByteSource> xmlSource = new MgByteSource((BYTE_ARRAY_IN) utf8Text.c_str(), (INT32)utf8Text.length());
-    Ptr<MgByteReader> xmlReader = xmlSource->GetReader();
-    resSvc->SetResource(m_resource, xmlReader, NULL);
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgCreateRdbmsFeatureSource::WriteFeatureSourceContent")
-}
-
-void MgCreateRdbmsFeatureSource::Dispose() { delete this; }
\ No newline at end of file

Deleted: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/CreateFeatureSource.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/CreateFeatureSource.h	2012-07-15 21:07:04 UTC (rev 6904)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/CreateFeatureSource.h	2012-07-16 02:14:39 UTC (rev 6905)
@@ -1,101 +0,0 @@
-#ifndef DESKTOP_CREATE_FEATURE_SOURCE_H
-#define DESKTOP_CREATE_FEATURE_SOURCE_H
-
-class FdoIConnection;
-class MgResourceIdentifier;
-class MgResourceService;
-class MgFeatureSourceParams;
-class MgFileFeatureSourceParams;
-template class FdoPtr<FdoIConnection>;
-
-class MgCreateFeatureSource : public MgGuardDisposable
-{
-public:
-    MgCreateFeatureSource();
-    virtual ~MgCreateFeatureSource();
-    void CreateFeatureSource(MgResourceIdentifier* resource, MgFeatureSourceParams* sourceParams);
-
-    virtual void Dispose() { delete this; }
-};
-
-class MgCreateRdbmsFeatureSource : public MgGuardDisposable
-{
-public:
-    MgCreateRdbmsFeatureSource(MgResourceIdentifier* resource, MgRdbmsFeatureSourceParams* params);
-    virtual ~MgCreateRdbmsFeatureSource();
-
-    void CreateFeatureSource();
-    virtual void Dispose();
-
-private:
-    void WriteFeatureSourceContent();
-
-    MgResourceIdentifier* m_resource;
-    MgRdbmsFeatureSourceParams* m_params;
-};
-
-class MgCreateFileFeatureSource : public MgGuardDisposable
-{
-public:
-    MgCreateFileFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
-    virtual ~MgCreateFileFeatureSource();
-    void CreateFeatureSource(bool bCheckFeatureClass = false, bool bCheckSpatialContext = false);
-    virtual void Dispose();
-
-protected:
-    virtual void CreateDataStore(FdoIConnection* conn);
-    virtual void ApplySchemaAndCreateSpatialContext(FdoIConnection* conn);
-    virtual void SetFeatureSourceDefinition(MgResourceService* resourceService);
-    virtual void SetResourceData(MgResourceService* resourceService);
-    virtual STRING GetFirstConnectionString();
-    virtual STRING GetSecondConnectionString();
-    virtual STRING GetFeatureSourceParameterString() const;
-
-protected:
-    STRING GetFileName() const;
-    MgResourceService* GetResourceService();
-    void ApplySchemaAndCreateSpatialContextInternal(FdoIConnection* conn);
-    void SetResourceDataInternal(MgResourceService* resourceService, STRING source, STRING target);
-
-protected:
-    STRING m_fileExtension;
-    STRING m_connectParamName;
-    STRING m_tempFileName;
-    MgResourceIdentifier* m_resource;
-    MgFileFeatureSourceParams* m_params;
-};
-
-class MgCreateSdfFeatureSource: public MgCreateFileFeatureSource
-{
-public:
-    MgCreateSdfFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
-    virtual ~MgCreateSdfFeatureSource();
-protected:
-    virtual STRING GetFeatureSourceParameterString() const;
-};
-
-class MgCreateShpFeatureSource: public MgCreateFileFeatureSource
-{
-public:
-    MgCreateShpFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
-    virtual ~MgCreateShpFeatureSource();
-protected:
-    virtual void CreateDataStore(FdoIConnection* conn);
-    virtual void ApplySchemaAndCreateSpatialContext(FdoIConnection* conn);
-    virtual void SetResourceData(MgResourceService* resourceService);
-    virtual STRING GetFirstConnectionString();
-    virtual STRING GetSecondConnectionString();
-    virtual STRING GetFeatureSourceParameterString() const;
-};
-
-class MgCreateSqliteFeatureSource: public MgCreateFileFeatureSource
-{
-public:
-    MgCreateSqliteFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
-    virtual ~MgCreateSqliteFeatureSource();
-protected:
-    virtual STRING GetSecondConnectionString();
-    virtual STRING GetFeatureSourceParameterString() const;
-};
-
-#endif
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp	2012-07-15 21:07:04 UTC (rev 6904)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp	2012-07-16 02:14:39 UTC (rev 6905)
@@ -1,7 +1,6 @@
 #include "FSDSAX2Parser.h"
 #include "FeatureService.h"
 #include "ResourceService.h"
-#include "Services/Feature/CreateFeatureSource.h"
 #include "Services/Feature/FeatureConnection.h"
 #include "Services/Feature/FeatureDefs.h"
 #include "Services/Feature/FeatureServiceCache.h"
@@ -25,7 +24,9 @@
 #include "GwsQueryEngineImp.h"
 
 #include "Services/Feature/Commands/ApplySchema.h"
+#include "Services/Feature/Commands/CreateFeatureSource.h"
 #include "Services/Feature/Commands/DescribeSchema.h"
+#include "Services/Feature/Commands/EnumerateDataStores.h"
 #include "Services/Feature/Commands/GetConnectionPropertyValues.h"
 #include "Services/Feature/Commands/GetFeatureProviders.h"
 #include "Services/Feature/Commands/GetLongTransactions.h"
@@ -1995,39 +1996,9 @@
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(partialConnString.c_str());
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
-    if (providerName.empty())
-        throw new MgInvalidArgumentException(L"MgdFeatureService::EnumerateDataStores", __LINE__, __WFILE__, NULL, L"", NULL);
-    
-    Ptr<MgFeatureConnection> connWrap = new MgFeatureConnection(providerName, partialConnString);
-	FdoPtr<FdoIConnection> conn = connWrap->GetConnection();
+    MgEnumerateDataStores cmd;
 
-	FdoPtr<FdoIListDataStores> list = (FdoIListDataStores*)conn->CreateCommand(FdoCommandType_ListDataStores);
-	list->SetIncludeNonFdoEnabledDatastores(true);
-	
-	FdoPtr<FdoIDataStoreReader> dsReader = list->Execute();
 
-	STRING xml = L"<DataStoreList>\n";
-
-	while (dsReader->ReadNext())
-	{
-		xml += L"\t<DataStore>\n";
-		xml += L"\t\t<Name>";
-		xml += dsReader->GetName();
-		xml += L"</Name>\n";
-		xml += L"\t\t<FdoEnabled>\n";
-		xml += dsReader->GetIsFdoEnabled() ? L"true" : L"false";
-		xml += L"</FdoEnabled>\n";
-		xml += L"\t</DataStore>\n";
-	}
-	dsReader->Close();
-
-	xml += L"</DataStoreList>";
-
-	string utf8Text = MgUtil::WideCharToMultiByte(xml);
-    Ptr<MgByteSource> byteSource = new MgByteSource((BYTE_ARRAY_IN) utf8Text.c_str(), (INT32)utf8Text.length());
-    byteSource->SetMimeType(MgMimeType::Xml);
-	reader = byteSource->GetReader();
-
     // Successful operation
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
 



More information about the mapguide-commits mailing list