[mapguide-commits] r8275 - in sandbox/jng/convenience_apis/Desktop: . MgDesktop/MapLayer MgDesktop/Services MgDesktop/Services/Feature MgDesktop/Services/Feature/Commands UnitTest

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jul 4 00:12:17 PDT 2014


Author: jng
Date: 2014-07-04 00:12:17 -0700 (Fri, 04 Jul 2014)
New Revision: 8275

Modified:
   sandbox/jng/convenience_apis/Desktop/MgDesktop/MapLayer/Layer.cpp
   sandbox/jng/convenience_apis/Desktop/MgDesktop/MapLayer/Layer.h
   sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/Commands/UpdateFeatures.cpp
   sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/Commands/UpdateFeatures.h
   sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/RasterHelper.cpp
   sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/RasterHelper.h
   sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/FeatureService.cpp
   sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/FeatureService.h
   sandbox/jng/convenience_apis/Desktop/MgDesktopApi.sln
   sandbox/jng/convenience_apis/Desktop/UnitTest/TestFeatureService.cpp
Log:
mg-desktop updates:
 - Add missing Security project to VS2012 solution
 - Update MgdFeatureService and MgdLayer in light of the new convenience APIs introduced in PlatformBase

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktop/MapLayer/Layer.cpp
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktop/MapLayer/Layer.cpp	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktop/MapLayer/Layer.cpp	2014-07-04 07:12:17 UTC (rev 8275)
@@ -442,7 +442,7 @@
     return reader.Detach();
 }
 
-int MgdLayer::UpdateFeatures(MgPropertyCollection* propertyValues, CREFSTRING filter)
+INT32 MgdLayer::UpdateMatchingFeatures(MgPropertyCollection* propertyValues, CREFSTRING filter)
 {
     int updated = 0;
 
@@ -451,14 +451,14 @@
     Ptr<MgdFeatureService> featSvc = static_cast<MgdFeatureService*>(GetMap()->GetService(MgServiceType::FeatureService));
     Ptr<MgResourceIdentifier> fsId = new MgResourceIdentifier(GetFeatureSourceId());
 
-    updated = featSvc->UpdateFeatures(fsId, GetFeatureClassName(), propertyValues, filter);
+    updated = featSvc->UpdateMatchingFeatures(fsId, GetFeatureClassName(), propertyValues, filter);
 
-    MG_CATCH_AND_THROW(L"MgdLayer.UpdateFeatures")
+    MG_CATCH_AND_THROW(L"MgdLayer.UpdateMatchingFeatures")
 
     return updated;
 }
 
-int MgdLayer::DeleteFeatures(CREFSTRING filter)
+INT32 MgdLayer::DeleteFeatures(CREFSTRING filter)
 {
     int deleted = 0;
 
@@ -490,7 +490,7 @@
     return reader.Detach();
 }
 
-int MgdLayer::UpdateFeatures(MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans)
+INT32 MgdLayer::UpdateMatchingFeatures(MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans)
 {
     int updated = 0;
 
@@ -499,14 +499,14 @@
     Ptr<MgdFeatureService> featSvc = static_cast<MgdFeatureService*>(GetMap()->GetService(MgServiceType::FeatureService));
     Ptr<MgResourceIdentifier> fsId = new MgResourceIdentifier(GetFeatureSourceId());
 
-    updated = featSvc->UpdateFeatures(fsId, GetFeatureClassName(), propertyValues, filter, trans);
+    updated = featSvc->UpdateMatchingFeatures(fsId, GetFeatureClassName(), propertyValues, filter, trans);
 
-    MG_CATCH_AND_THROW(L"MgdLayer.UpdateFeatures")
+    MG_CATCH_AND_THROW(L"MgdLayer.UpdateMatchingFeatures")
 
     return updated;
 }
 
-int MgdLayer::DeleteFeatures(CREFSTRING filter, MgTransaction* trans)
+INT32 MgdLayer::DeleteFeatures(CREFSTRING filter, MgTransaction* trans)
 {
     int deleted = 0;
 

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktop/MapLayer/Layer.h
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktop/MapLayer/Layer.h	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktop/MapLayer/Layer.h	2014-07-04 07:12:17 UTC (rev 8275)
@@ -29,15 +29,15 @@
 
     virtual MgFeatureReader* InsertFeatures(MgPropertyCollection* propertyValues);
 
-	virtual int UpdateFeatures(MgPropertyCollection* propertyValues, CREFSTRING filter);
+    virtual INT32 UpdateMatchingFeatures(MgPropertyCollection* propertyValues, CREFSTRING filter);
 
-	virtual int DeleteFeatures(CREFSTRING filter);
+	virtual INT32 DeleteFeatures(CREFSTRING filter);
 
     virtual MgFeatureReader* InsertFeatures(MgPropertyCollection* propertyValues, MgTransaction* trans);
 
-	virtual int UpdateFeatures(MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans);
+	virtual INT32 UpdateMatchingFeatures(MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans);
 
-	virtual int DeleteFeatures(CREFSTRING filter, MgTransaction* trans);
+	virtual INT32 DeleteFeatures(CREFSTRING filter, MgTransaction* trans);
 
     virtual bool IsPotentiallyVisibleAtScale(double scale, bool bConsiderParentGroupVisibility);
 

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/Commands/UpdateFeatures.cpp
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/Commands/UpdateFeatures.cpp	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/Commands/UpdateFeatures.cpp	2014-07-04 07:12:17 UTC (rev 8275)
@@ -277,118 +277,8 @@
     return reader.Detach();
 }
 
-
-MgPropertyCollection* MgdUpdateFeaturesCommand::ExecuteInsert(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues, MgTransaction* trans)
+INT32 MgdUpdateFeaturesCommand::ExecuteUpdate(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans)
 {
-    Ptr<MgPropertyCollection> ret;
-
-    MG_FEATURE_SERVICE_TRY()
-
-    CHECK_FEATURE_SOURCE_ARGUMENT(resource, L"MgdUpdateFeaturesCommand::ExecuteInsert");
-	CHECKARGUMENTNULL(batchPropertyValues, L"MgdUpdateFeaturesCommand::ExecuteInsert");
-	if (className.empty())
-		throw new MgNullArgumentException(L"MgdUpdateFeaturesCommand::ExecuteInsert", __LINE__, __WFILE__, NULL, L"", NULL);
-	
-    ret = new MgPropertyCollection();
-
-    Ptr<MgdFeatureConnection> connWrap;
-	FdoPtr<FdoIConnection> conn;
-    FdoPtr<FdoITransaction> fdoTrans;
-    Ptr<MgdTransaction> mgTrans = dynamic_cast<MgdTransaction*>(trans);
-    if (NULL != mgTrans)
-    {
-        SAFE_ADDREF(mgTrans.p);
-        Ptr<MgResourceIdentifier> origFeatureSource = mgTrans->GetFeatureSource();
-        //Check that the transaction originates from the same feature source
-        if (origFeatureSource->ToString() != resource->ToString())
-            throw new MgInvalidArgumentException(L"MgdUpdateFeaturesCommand::ExecuteInsert", __LINE__, __WFILE__, NULL, L"", NULL);
-
-        connWrap = mgTrans->GetConnection(); //Connection is already open
-        fdoTrans = mgTrans->GetFdoTransaction();
-    }
-    else
-    {    
-        connWrap = new MgdFeatureConnection(resource);
-    }
-
-    conn = connWrap->GetConnection();
-	FdoPtr<FdoIInsert> insert = (FdoIInsert*)conn->CreateCommand(FdoCommandType_Insert);
-	
-	insert->SetFeatureClassName(className.c_str());
-
-	FdoPtr<FdoPropertyValueCollection> propVals = insert->GetPropertyValues();
-	
-    if (NULL != fdoTrans.p)
-        insert->SetTransaction(fdoTrans);
-
-    //TODO: Support batch parameters, the main beneficiary of this API. Even then,
-    //the value flipping approach employed here has performance benefits for certain
-    //providers, like SQLite
-
-    for (INT32 i = 0; i < batchPropertyValues->GetCount(); i++)
-    {
-        Ptr<MgPropertyCollection> propertyValues = batchPropertyValues->GetItem(i);
-
-        //First feature, set up the FDO property value collection
-        if (i == 0)
-        {
-            for (INT32 i = 0; i < propertyValues->GetCount(); i++)
-	        {
-		        Ptr<MgProperty> mgp = propertyValues->GetItem(i);
-		        FdoPtr<FdoPropertyValue> pv = MgdFeatureUtil::MgPropertyToFdoProperty(mgp);
-
-		        propVals->Add(pv);
-	        }
-        }
-        else //Feature after the first
-        {
-            //Set all to null
-            for (INT32 i = 0; i < propVals->GetCount(); i++)
-            {
-                FdoPtr<FdoPropertyValue> fp = propVals->GetItem(i);
-                FdoPtr<FdoValueExpression> expr = fp->GetValue();
-                FdoDataValue* fdv = dynamic_cast<FdoDataValue*>(expr.p);
-                FdoGeometryValue* fgv = dynamic_cast<FdoGeometryValue*>(expr.p);
-                if (fdv)
-                {
-                    fdv->SetNull();
-                }
-                else if (fgv)
-                {
-                    fgv->SetNullValue();
-                }
-            }
-
-            //Now set the appropriate values. MgdFeatureUtil does the work
-            for (INT32 i = 0; i < propertyValues->GetCount(); i++)
-	        {
-                Ptr<MgNullableProperty> mgp = (MgNullableProperty*)propertyValues->GetItem(i);
-                if (!mgp->IsNull())
-                {
-                    FdoPtr<FdoPropertyValue> fp = propVals->GetItem(mgp->GetName().c_str());
-                    MgdFeatureUtil::UpdateFdoPropertyValue(fp, mgp);
-                }
-            }
-        }
-
-        STRING sIndex;
-        MgUtil::Int32ToString(i, sIndex);
-
-        //Insert and stash the result in the property collection
-	    FdoPtr<FdoIFeatureReader> insertRes = insert->Execute();
-
-	    Ptr<MgFeatureReader> fr = new MgdFeatureReader(connWrap, insertRes);
-        Ptr<MgFeatureProperty> fp = new MgFeatureProperty(sIndex, fr);
-        ret->Add(fp);
-    }
-
-    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgdUpdateFeaturesCommand::ExecuteInsert", resource)
-
-    return ret.Detach();
-}
-
-int MgdUpdateFeaturesCommand::ExecuteUpdate(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans)
-{
     int updated = 0;
 
     MG_FEATURE_SERVICE_TRY()
@@ -444,7 +334,7 @@
     return updated;
 }
 
-int MgdUpdateFeaturesCommand::ExecuteDelete(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans)
+INT32 MgdUpdateFeaturesCommand::ExecuteDelete(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans)
 {
     int deleted = 0;
 

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/Commands/UpdateFeatures.h
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/Commands/UpdateFeatures.h	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/Commands/UpdateFeatures.h	2014-07-04 07:12:17 UTC (rev 8275)
@@ -40,22 +40,12 @@
                                   MgFeatureCommandCollection* commands,
                                   MgTransaction* transaction);
 
-    MgFeatureReader* ExecuteInsert(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues);
-
     MgFeatureReader* ExecuteInsert(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, MgTransaction* trans);
 
-    MgPropertyCollection* ExecuteInsert(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues);
+    INT32 ExecuteUpdate(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans);
 
-    MgPropertyCollection* ExecuteInsert(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues, MgTransaction* trans);
+	INT32 ExecuteDelete(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans);
 
-	int ExecuteUpdate(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter);
-
-    int ExecuteUpdate(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans);
-
-	int ExecuteDelete(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter);
-
-	int ExecuteDelete(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans);
-
 private:
     void Connect(MgResourceIdentifier* resource, MgTransaction* transaction);
 

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/RasterHelper.cpp
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/RasterHelper.cpp	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/RasterHelper.cpp	2014-07-04 07:12:17 UTC (rev 8275)
@@ -71,6 +71,46 @@
                                              MgFeatureCommandCollection* commands,
                                              MgTransaction* transaction) { NOT_IMPLEMENTED(L"MgdRasterHelper::UpdateFeatures"); }
 
+MgFeatureReader* MgdRasterHelper::InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues)   
+{
+    NOT_IMPLEMENTED(L"MgdRasterHelper::InsertFeatures");
+}
+
+MgFeatureReader* MgdRasterHelper::InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, MgTransaction* trans)
+{
+    NOT_IMPLEMENTED(L"MgdRasterHelper::InsertFeatures");
+}
+
+MgFeatureReader* MgdRasterHelper::InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues)
+{
+    NOT_IMPLEMENTED(L"MgdRasterHelper::InsertFeatures");
+}
+
+MgFeatureReader* MgdRasterHelper::InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues, MgTransaction* trans)
+{
+    NOT_IMPLEMENTED(L"MgdRasterHelper::InsertFeatures");
+}
+
+INT32 MgdRasterHelper::DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter)
+{
+    NOT_IMPLEMENTED(L"MgdRasterHelper::DeleteFeatures");
+}
+
+INT32 MgdRasterHelper::DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans)
+{
+    NOT_IMPLEMENTED(L"MgdRasterHelper::DeleteFeatures");
+}
+    
+INT32 MgdRasterHelper::UpdateMatchingFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter)
+{
+    NOT_IMPLEMENTED(L"MgdRasterHelper::UpdateMatchingFeatures");
+}
+
+INT32 MgdRasterHelper::UpdateMatchingFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans)
+{
+    NOT_IMPLEMENTED(L"MgdRasterHelper::UpdateMatchingFeatures");
+}
+
 MgFeatureReader* MgdRasterHelper::GetLockedFeatures(MgResourceIdentifier* resource,
                                            CREFSTRING className,
                                            MgFeatureQueryOptions* options) { NOT_IMPLEMENTED(L"MgdRasterHelper::GetLockedFeatures"); }

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/RasterHelper.h
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/RasterHelper.h	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/Feature/RasterHelper.h	2014-07-04 07:12:17 UTC (rev 8275)
@@ -133,7 +133,23 @@
     virtual MgByteReader* EnumerateDataStores(CREFSTRING providerName, CREFSTRING partialConnString);
 
     virtual MgByteReader* GetSchemaMapping(CREFSTRING providerName, CREFSTRING partialConnString);
+
+    virtual MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues);
+
+    virtual MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, MgTransaction* trans);
+
+    virtual MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues);
+
+    virtual MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues, MgTransaction* trans);
+
+    virtual INT32 DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter);
+
+	virtual INT32 DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans);
     
+    virtual INT32 UpdateMatchingFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter);
+
+    virtual INT32 UpdateMatchingFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans);
+    
 INTERNAL_API:
 
     MgdRasterHelper(MgdFeatureReader* reader);

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/FeatureService.cpp
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/FeatureService.cpp	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/FeatureService.cpp	2014-07-04 07:12:17 UTC (rev 8275)
@@ -1057,9 +1057,9 @@
 	return reader.Detach();
 }
 
-MgPropertyCollection* MgdFeatureService::InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues)
+MgFeatureReader* MgdFeatureService::InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues)
 {
-    Ptr<MgPropertyCollection> ret;
+    Ptr<MgFeatureReader> ret;
     MG_LOG_OPERATION_MESSAGE(L"InsertFeatures");
 
     MG_FEATURE_SERVICE_TRY()
@@ -1077,9 +1077,29 @@
 
     MG_LOG_TRACE_ENTRY(L"MgdFeatureService::InsertFeatures()");
 
-    MgdUpdateFeaturesCommand cmd;
-    ret = cmd.ExecuteInsert(resource, className, batchPropertyValues, NULL);
+    Ptr<MgFeatureCommandCollection> commands = new MgFeatureCommandCollection();
+    Ptr<MgInsertFeatures> insertCmd = new MgInsertFeatures(className, batchPropertyValues);
+    commands->Add(insertCmd);
     
+    Ptr<MgPropertyCollection> props = UpdateFeatures(resource, commands, (MgTransaction*)NULL);
+    if (props->GetCount() == 1)
+    {
+        INT32 i = 0;
+        Ptr<MgProperty> prop = props->GetItem(i);
+        if (prop->GetPropertyType() == MgPropertyType::String) //FDO error in non-transactional mode
+        {
+            MgStringProperty* sp = static_cast<MgStringProperty*>(prop.p);
+            MgStringCollection args;
+            args.Add(sp->GetValue());
+            throw new MgFdoException(L"MgdFeatureService::InsertFeatures", __LINE__, __WFILE__, &args, L"MgFormatInnerExceptionMessage", NULL);
+        }
+        else if (prop->GetPropertyType() == MgPropertyType::Feature) //Insert result
+        {
+            MgFeatureProperty* fp = static_cast<MgFeatureProperty*>(prop.p);
+            ret = fp->GetValue();
+        }
+    }
+    
     // Successful operation
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
 
@@ -1099,9 +1119,9 @@
     return ret.Detach();
 }
 
-MgPropertyCollection* MgdFeatureService::InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues, MgTransaction* trans)
+MgFeatureReader* MgdFeatureService::InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues, MgTransaction* trans)
 {
-    Ptr<MgPropertyCollection> ret;
+    Ptr<MgFeatureReader> ret;
     MG_LOG_OPERATION_MESSAGE(L"InsertFeatures");
 
     MG_FEATURE_SERVICE_TRY()
@@ -1121,8 +1141,28 @@
 
     MG_LOG_TRACE_ENTRY(L"MgdFeatureService::InsertFeatures()");
 
-    MgdUpdateFeaturesCommand cmd;
-    ret = cmd.ExecuteInsert(resource, className, batchPropertyValues, trans);
+    Ptr<MgFeatureCommandCollection> commands = new MgFeatureCommandCollection();
+    Ptr<MgInsertFeatures> insertCmd = new MgInsertFeatures(className, batchPropertyValues);
+    commands->Add(insertCmd);
+    
+    Ptr<MgPropertyCollection> props = UpdateFeatures(resource, commands, trans);
+    if (props->GetCount() == 1)
+    {
+        INT32 i = 0;
+        Ptr<MgProperty> prop = props->GetItem(i);
+        if (prop->GetPropertyType() == MgPropertyType::String) //FDO error in non-transactional mode
+        {
+            MgStringProperty* sp = static_cast<MgStringProperty*>(prop.p);
+            MgStringCollection args;
+            args.Add(sp->GetValue());
+            throw new MgFdoException(L"MgdFeatureService::InsertFeatures", __LINE__, __WFILE__, &args, L"MgFormatInnerExceptionMessage", NULL);
+        }
+        else if (prop->GetPropertyType() == MgPropertyType::Feature) //Insert result
+        {
+            MgFeatureProperty* fp = static_cast<MgFeatureProperty*>(prop.p);
+            ret = fp->GetValue();
+        }
+    }
 
     // Successful operation
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
@@ -1143,14 +1183,14 @@
     return ret.Detach();
 }
 
-int MgdFeatureService::UpdateFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter)
+INT32 MgdFeatureService::UpdateMatchingFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter)
 {
     int ret = 0;
-    MG_LOG_OPERATION_MESSAGE(L"UpdateFeatures");
+    MG_LOG_OPERATION_MESSAGE(L"UpdateMatchingFeatures");
 
     MG_FEATURE_SERVICE_TRY()
 
-    CHECK_FEATURE_SOURCE_ARGUMENT(resource, L"MgdFeatureService::UpdateFeatures");
+    CHECK_FEATURE_SOURCE_ARGUMENT(resource, L"MgdFeatureService::UpdateMatchingFeatures");
 
     MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 4);
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
@@ -1163,14 +1203,14 @@
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"STRING");
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
-    MG_LOG_TRACE_ENTRY(L"MgdFeatureService::UpdateFeatures()");
+    MG_LOG_TRACE_ENTRY(L"MgdFeatureService::UpdateMatchingFeatures()");
 
-	ret = UpdateFeatures(resource, className, propertyValues, filter, NULL);
+	ret = UpdateMatchingFeatures(resource, className, propertyValues, filter, NULL);
     
     // Successful operation
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
 
-    MG_FEATURE_SERVICE_CATCH_WITH_FEATURE_SOURCE(L"MgdFeatureService::UpdateFeatures", resource)
+    MG_FEATURE_SERVICE_CATCH_WITH_FEATURE_SOURCE(L"MgdFeatureService::UpdateMatchingFeatures", resource)
 
     if (mgException != NULL)
     {
@@ -1186,14 +1226,14 @@
     return ret;
 }
 
-int MgdFeatureService::UpdateFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* batchPropertyValues, CREFSTRING filter, MgTransaction* trans)
+INT32 MgdFeatureService::UpdateMatchingFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* batchPropertyValues, CREFSTRING filter, MgTransaction* trans)
 {
     int updated = 0;
-    MG_LOG_OPERATION_MESSAGE(L"UpdateFeatures");
+    MG_LOG_OPERATION_MESSAGE(L"UpdateMatchingFeatures");
 
     MG_FEATURE_SERVICE_TRY()
 
-    CHECK_FEATURE_SOURCE_ARGUMENT(resource, L"MgdFeatureService::UpdateFeatures");
+    CHECK_FEATURE_SOURCE_ARGUMENT(resource, L"MgdFeatureService::UpdateMatchingFeatures");
 
     MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 5);
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
@@ -1208,7 +1248,7 @@
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgTransaction");
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
-    MG_LOG_TRACE_ENTRY(L"MgdFeatureService::UpdateFeatures()");
+    MG_LOG_TRACE_ENTRY(L"MgdFeatureService::UpdateMatchingFeatures()");
 
     MgdUpdateFeaturesCommand cmd;
     updated = cmd.ExecuteUpdate(resource, className, batchPropertyValues, filter, trans);
@@ -1216,7 +1256,7 @@
     // Successful operation
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
 
-    MG_FEATURE_SERVICE_CHECK_CONNECTION_CATCH(resource, L"MgdFeatureService::UpdateFeatures")
+    MG_FEATURE_SERVICE_CHECK_CONNECTION_CATCH(resource, L"MgdFeatureService::UpdateMatchingFeatures")
 
     if (mgException != NULL)
     {
@@ -1233,7 +1273,7 @@
 	return updated;
 }
 
-int MgdFeatureService::DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter)
+INT32 MgdFeatureService::DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter)
 {
     int deleted = 0;
     MG_LOG_OPERATION_MESSAGE(L"DeleteFeatures");
@@ -1275,7 +1315,7 @@
     return deleted;
 }
 
-int MgdFeatureService::DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans)
+INT32 MgdFeatureService::DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans)
 {
     int deleted = 0;
     MG_LOG_OPERATION_MESSAGE(L"DeleteFeatures");

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/FeatureService.h
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/FeatureService.h	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktop/Services/FeatureService.h	2014-07-04 07:12:17 UTC (rev 8275)
@@ -171,32 +171,31 @@
 
     virtual MgByteReader* GetSchemaMapping(CREFSTRING providerName, CREFSTRING partialConnString);
 
-    //------- Desktop API additions --------//
+    virtual MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues);
 
-    MgdScrollableFeatureReader* SelectFeaturesExtended(MgResourceIdentifier* resource,
-                                                       CREFSTRING className,
-                                                       MgFeatureQueryOptions* options);
+    virtual MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, MgTransaction* trans);
 
-    void RegisterProvider(CREFSTRING providerLibraryPath);
+    virtual MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues);
 
-    void UnregisterProvider(CREFSTRING providerName);
+    virtual MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues, MgTransaction* trans);
 
-	MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues);
+    virtual INT32 DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter);
 
-    MgFeatureReader* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, MgTransaction* trans);
+	virtual INT32 DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans);
+    
+    virtual INT32 UpdateMatchingFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter);
 
-    MgPropertyCollection* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues);
+    virtual INT32 UpdateMatchingFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans);
 
-    MgPropertyCollection* InsertFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgBatchPropertyCollection* batchPropertyValues, MgTransaction* trans);
+    //------- Desktop API additions --------//
+    MgdScrollableFeatureReader* SelectFeaturesExtended(MgResourceIdentifier* resource,
+                                                       CREFSTRING className,
+                                                       MgFeatureQueryOptions* options);
 
-	int UpdateFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter);
+    void RegisterProvider(CREFSTRING providerLibraryPath);
 
-    int UpdateFeatures(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans);
+    void UnregisterProvider(CREFSTRING providerName);
 
-	int DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter);
-
-	int DeleteFeatures(MgResourceIdentifier* resource, CREFSTRING className, CREFSTRING filter, MgTransaction* trans);
-
 EXTERNAL_API:
     void PurgeCache(MgResourceIdentifier* resource);
 

Modified: sandbox/jng/convenience_apis/Desktop/MgDesktopApi.sln
===================================================================
--- sandbox/jng/convenience_apis/Desktop/MgDesktopApi.sln	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/MgDesktopApi.sln	2014-07-04 07:12:17 UTC (rev 8275)
@@ -1,6 +1,6 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
+# Visual Studio Express 2012 for Windows Desktop
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Foundation", "..\Common\Foundation\Foundation.vcxproj", "{A82ADC7D-4DA4-42F2-9BF6-DF5DCFB44425}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Geometry", "..\Common\Geometry\Geometry.vcxproj", "{D954DAAC-E305-40CE-B3F3-C229A0BEF4F0}"
@@ -74,6 +74,8 @@
 		{C50254F2-654A-48DE-AF5B-20605AEF8D10} = {C50254F2-654A-48DE-AF5B-20605AEF8D10}
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Security", "..\Common\Security\Security.vcxproj", "{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
@@ -257,6 +259,14 @@
 		{C02F44CB-D916-428D-A1A5-04E225A2A4EC}.Release|Win32.Build.0 = Release|Win32
 		{C02F44CB-D916-428D-A1A5-04E225A2A4EC}.Release|x64.ActiveCfg = Release|x64
 		{C02F44CB-D916-428D-A1A5-04E225A2A4EC}.Release|x64.Build.0 = Release|x64
+		{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}.Debug|Win32.Build.0 = Debug|Win32
+		{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}.Debug|x64.ActiveCfg = Debug|x64
+		{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}.Debug|x64.Build.0 = Debug|x64
+		{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}.Release|Win32.ActiveCfg = Release|Win32
+		{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}.Release|Win32.Build.0 = Release|Win32
+		{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}.Release|x64.ActiveCfg = Release|x64
+		{7C1C5695-C51C-4017-ABEF-BC3032CBAF3B}.Release|x64.Build.0 = Release|x64
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

Modified: sandbox/jng/convenience_apis/Desktop/UnitTest/TestFeatureService.cpp
===================================================================
--- sandbox/jng/convenience_apis/Desktop/UnitTest/TestFeatureService.cpp	2014-07-04 06:56:54 UTC (rev 8274)
+++ sandbox/jng/convenience_apis/Desktop/UnitTest/TestFeatureService.cpp	2014-07-04 07:12:17 UTC (rev 8275)
@@ -1719,20 +1719,15 @@
         batch->Add(propVals);
 
         //Call the API
-        Ptr<MgPropertyCollection> insertRes = pService->InsertFeatures(fsId, L"Default:Parcels", batch);
+        Ptr<MgFeatureReader> insertRes = pService->InsertFeatures(fsId, L"Default:Parcels", batch);
         
-        //We inserted 3 features
-        CPPUNIT_ASSERT(3 == insertRes->GetCount());
-
-        for (INT32 i = 0; i < insertRes->GetCount(); i++)
+        INT32 insertedCount = 0;
+        while (insertRes->ReadNext())
         {
-            Ptr<MgProperty> res = insertRes->GetItem(i);
-            CPPUNIT_ASSERT(MgPropertyType::Feature == res->GetPropertyType());
-
-            MgFeatureProperty* fp = static_cast<MgFeatureProperty*>(res.p);
-            Ptr<MgFeatureReader> fr = fp->GetValue();
-            fr->Close();
+            insertedCount++;
         }
+        //We inserted 3 features
+        CPPUNIT_ASSERT(3 == insertedCount);
 
         //Now query to verify all values are the same
         Ptr<MgFeatureReader> reader = pService->SelectFeatures(fsId, L"Default:Parcels", NULL);
@@ -1837,7 +1832,7 @@
         ACE_OS::itoa(smTestSdfId, sdfNum, 10);
         filter += sdfNum;
 
-        int updated = pService->UpdateFeatures(fsId, className, propVals, filter);
+        int updated = pService->UpdateMatchingFeatures(fsId, className, propVals, filter);
         CPPUNIT_ASSERT(updated == 1);
 
         Ptr<MgFeatureQueryOptions> query = new MgFeatureQueryOptions();
@@ -3436,7 +3431,7 @@
         ACE_OS::itoa(smTestSdfId, sdfNum, 10);
         filter += sdfNum;
 
-        int updated = parcels->UpdateFeatures(propVals, filter);
+        int updated = parcels->UpdateMatchingFeatures(propVals, filter);
         CPPUNIT_ASSERT(updated == 1);
 
         Ptr<MgFeatureQueryOptions> query = new MgFeatureQueryOptions();



More information about the mapguide-commits mailing list