Changes between Version 2 and Version 3 of MapGuideRfc143


Ignore:
Timestamp:
Jul 4, 2014, 3:28:05 AM (10 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc143

    v2 v3  
    9494As you can see, this type of code is a lot of boilerplate for just inserting features.
    9595
    96 For this RFC, we will add convenience APIs to MgFeatureService and MgLayerBase to do individual insert/update/delete operations instead of a one-size-fits-all API that we currently have:
     96For this RFC, we will add convenience APIs to MgFeatureService to allow individual insert/update/delete operations instead of a one-size-fits-all API that we currently have
    9797
    9898{{{
     
    437437};
    438438}}}
    439 {{{
    440 class MG_PLATFORMBASE_API MgLayerBase : public MgNamedSerializable
    441 {
    442 PUBLISHED_API:
    443     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    444     /// \brief
    445     /// Inserts a new feature into the specified feature class of the specified Feature Source
    446     ///
    447     /// <!-- Syntax in .Net, Java, and PHP -->
    448     /// \htmlinclude DotNetSyntaxTop.html
    449     /// virtual MgFeatureReader InsertFeatures(MgPropertyCollection properties);
    450     /// \htmlinclude SyntaxBottom.html
    451     /// \htmlinclude JavaSyntaxTop.html
    452     /// virtual MgFeatureReader InsertFeatures(MgPropertyCollection properties);
    453     /// \htmlinclude SyntaxBottom.html
    454     /// \htmlinclude PHPSyntaxTop.html
    455     /// virtual MgFeatureReader InsertFeatures(MgPropertyCollection properties);
    456     /// \htmlinclude SyntaxBottom.html
    457     ///
    458     /// \param properties (MgPropertyCollection)
    459     /// The collection of property values to insert
    460     ///
    461     /// \return
    462     /// Returns a feature reader object that contains the set of properties
    463     /// inserted into the datastore by the insert command.
    464     ///
    465     /// \remarks
    466     /// Transactions will be used internally if the provider supports them.
    467     /// Remember to close any feature readers returned by this method, even if you don't intend
    468     /// to do anything with them
    469     ///
    470     /// \exception MgFeatureServiceException
    471     /// \exception MgInvalidArgumentException
    472     /// \exception MgInvalidOperationException
    473     /// \exception MgFdoException
    474     ///
    475     /// \since 3.0
    476     virtual MgFeatureReader* InsertFeatures(MgPropertyCollection* properties);
    477 
    478     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    479     /// \brief
    480     /// Inserts a set of new features into the specified feature class of the specified Feature Source
    481     ///
    482     /// <!-- Syntax in .Net, Java, and PHP -->
    483     /// \htmlinclude DotNetSyntaxTop.html
    484     /// virtual MgFeatureReader InsertFeatures(MgBatchPropertyCollection properties);
    485     /// \htmlinclude SyntaxBottom.html
    486     /// \htmlinclude JavaSyntaxTop.html
    487     /// virtual MgFeatureReader InsertFeatures(MgBatchPropertyCollection properties);
    488     /// \htmlinclude SyntaxBottom.html
    489     /// \htmlinclude PHPSyntaxTop.html
    490     /// virtual MgFeatureReader InsertFeatures(MgBatchPropertyCollection properties);
    491     /// \htmlinclude SyntaxBottom.html
    492     ///
    493     /// \param properties (MgBatchPropertyCollection)
    494     /// The collection of property values to insert. Each MgPropertyCollection within
    495     /// this collection represents property values for a single feature to insert
    496     ///
    497     /// \return
    498     /// Returns a feature reader object that contains the set of properties
    499     /// inserted into the datastore by the insert command.
    500     ///
    501     /// \remarks
    502     /// Transactions will be used internally if the provider supports them.
    503     /// Remember to close any feature readers returned by this method, even if you don't intend
    504     /// to do anything with them
    505     ///
    506     /// \exception MgFeatureServiceException
    507     /// \exception MgInvalidArgumentException
    508     /// \exception MgInvalidOperationException
    509     /// \exception MgFdoException
    510     ///
    511     /// \since 3.0
    512     virtual MgFeatureReader* InsertFeatures(MgBatchPropertyCollection* properties);
    513 
    514     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    515     /// \brief
    516     /// Updates all features that match the given filter with the specified property values
    517     ///
    518     /// \remarks
    519     /// Transactions will be used internally if the provider supports them
    520     ///
    521     /// <!-- Syntax in .Net, Java, and PHP -->
    522     /// \htmlinclude DotNetSyntaxTop.html
    523     /// virtual int UpdateMatchingFeatures(MgPropertyCollection properties, string filter);
    524     /// \htmlinclude SyntaxBottom.html
    525     /// \htmlinclude JavaSyntaxTop.html
    526     /// virtual int UpdateMatchingFeatures(MgPropertyCollection properties, String filter);
    527     /// \htmlinclude SyntaxBottom.html
    528     /// \htmlinclude PHPSyntaxTop.html
    529     /// virtual int UpdateMatchingFeatures(MgPropertyCollection properties, String filter);
    530     /// \htmlinclude SyntaxBottom.html
    531     ///
    532     /// \param properties (MgBatchPropertyCollection)
    533     /// The property values to update matching features with
    534     /// \param filter (String/string)
    535     /// The FDO filter string that detemines what features will be updated
    536     ///
    537     /// \return
    538     /// Returns the number of features updated by this operation
    539     ///
    540     /// \exception MgFeatureServiceException
    541     /// \exception MgInvalidArgumentException
    542     /// \exception MgInvalidOperationException
    543     /// \exception MgFdoException
    544     ///
    545     /// \since 3.0
    546     virtual INT32 UpdateMatchingFeatures(MgPropertyCollection* properties, CREFSTRING filter);
    547 
    548     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    549     /// \brief
    550     /// Deletes all features that match the given filter
    551     ///
    552     /// \remarks
    553     /// Transactions will be used internally if the provider supports them
    554     ///
    555     /// <!-- Syntax in .Net, Java, and PHP -->
    556     /// \htmlinclude DotNetSyntaxTop.html
    557     /// virtual int DeleteFeatures(string filter);
    558     /// \htmlinclude SyntaxBottom.html
    559     /// \htmlinclude JavaSyntaxTop.html
    560     /// virtual int DeleteFeatures(String filter);
    561     /// \htmlinclude SyntaxBottom.html
    562     /// \htmlinclude PHPSyntaxTop.html
    563     /// virtual int DeleteFeatures(String filter);
    564     /// \htmlinclude SyntaxBottom.html
    565     ///
    566     /// \param filter (String/string)
    567     /// The FDO filter string that detemines what features will be deleted
    568     ///
    569     /// \return
    570     /// Returns the number of features deleted by this operation
    571     ///
    572     /// \exception MgFeatureServiceException
    573     /// \exception MgInvalidArgumentException
    574     /// \exception MgInvalidOperationException
    575     /// \exception MgFdoException
    576     ///
    577     /// \since 3.0
    578     virtual INT32 DeleteFeatures(CREFSTRING filter);
    579 };
    580 }}}
    581439
    582440With these convenience APIs, the above example for inserting features now becomes:
     
    608466}}}
    609467
    610 For updating/deleting features, you will see similar reductions in code using these convenience APIs
     468For updating/deleting features you will see similar reductions in code using these convenience APIs
     469
     470For MgLayerBase, we'll add convenience APIs to shortcut boilerplate that would normally require MgFeatureService and extracting additional information from the layer:
     471
     472 - Individual insert/update/delete operations instead of a one-size-fits-all API that we currently have
     473 - The ability to start transactions on the layer's feature source
     474 - The ability to interrogate spatial contexts for the layer's feature source
     475 - The ability to call UpdateFeatures() transactionally or non-transactionally instead of having the method internally decide (ie. UpdateFeatures() that can take a MgTransaction parameter)
     476
     477{{{
     478class MG_PLATFORMBASE_API MgLayerBase : public MgNamedSerializable
     479{
     480PUBLISHED_API:
     481    ////////////////////////////////////////////////////////////////////////////////////////////////
     482    /// \brief
     483    /// Starts a transaction on the this layer. The FDO provider indicated by the layer's
     484    /// Feature Source must support transactions.
     485    ///
     486    /// \remarks
     487    /// The XML returned by MgFeatureService::GetCapabilities says
     488    /// whether a provider supports transactions. See \link ProviderCapabilities Provider Capabilities \endlink.
     489    ///
     490    /// <!-- Syntax in .Net, Java, and PHP -->
     491    /// \htmlinclude DotNetSyntaxTop.html
     492    /// virtual MgTransaction BeginTransaction();
     493    /// \htmlinclude SyntaxBottom.html
     494    /// \htmlinclude JavaSyntaxTop.html
     495    /// virtual MgTransaction BeginTransaction();
     496    /// \htmlinclude SyntaxBottom.html
     497    /// \htmlinclude PHPSyntaxTop.html
     498    /// virtual MgTransaction BeginTransaction();
     499    /// \htmlinclude SyntaxBottom.html
     500    ///
     501    /// \return
     502    /// Returns an MgTransaction instance (or NULL).
     503    ///
     504    /// \exception MgFeatureServiceException
     505    /// \exception MgInvalidArgumentException
     506    /// \exception MgInvalidOperationException
     507    /// \exception MgFdoException
     508    ///
     509    /// \since 3.0
     510    virtual MgTransaction* BeginTransaction();
     511
     512    //////////////////////////////////////////////////////////////////
     513    /// \brief
     514    /// Executes the MgDeleteFeatures, MgInsertFeatures,
     515    /// MgUpdateFeatures, MgLockFeatures or MgUnlockFeatures commands
     516    /// contained in the given MgFeatureCommandCollection object.
     517    ///
     518    /// \remarks
     519    /// The XML returned by MgFeatureService::GetCapabilities says
     520    /// whether a provider supports SQL commands. See \link ProviderCapabilities Provider Capabilities \endlink.
     521    ///
     522    /// <!-- Syntax in .Net, Java, and PHP -->
     523    /// \htmlinclude DotNetSyntaxTop.html
     524    /// virtual MgPropertyCollection UpdateFeatures(MgFeatureCommandCollection commands);
     525    /// \htmlinclude SyntaxBottom.html
     526    /// \htmlinclude JavaSyntaxTop.html
     527    /// virtual MgPropertyCollection UpdateFeatures(MgFeatureCommandCollection commands);
     528    /// \htmlinclude SyntaxBottom.html
     529    /// \htmlinclude PHPSyntaxTop.html
     530    /// virtual MgPropertyCollection UpdateFeatures(MgFeatureCommandCollection commands);
     531    /// \htmlinclude SyntaxBottom.html
     532    ///
     533    /// \param commands (MgFeatureCommandCollection)
     534    /// A collection of feature commands to be
     535    /// executed.
     536    /// \param transaction (MgTransaction)
     537    /// An optional transaction to execute this operation under
     538    ///
     539    /// \return
     540    /// Returns an MgPropertyCollection object. Each property in the
     541    /// collection corresponds to a command in the
     542    /// MgFeatureCommandCollection argument. The property name is the
     543    /// index of the command in the feature command collection.
     544    /// <ul>
     545    ///   <li>If the command is of type MgDeleteFeatures, the property
     546    ///     type is an MgPropertyType::Int32, and its value is the number
     547    ///     of features deleted.</li>
     548    ///   <li>If the command is of type MgInsertFeatures, the property
     549    ///     type is an MgPropertyType::Feature, and its value is a
     550    ///     MgFeatureReader object. The feature reader object contains
     551    ///     the set of properties inserted into the datastore by the
     552    ///     insert command.</li>
     553    ///   <li>If the command is of type MgUpdateFeatures, the property
     554    ///     type is MgPropertyType::Int32, and its value is the number of
     555    ///     features updated.</li>
     556    ///   <li>If the command is of type MgLockFeatures, the property
     557    ///     type is MgPropertyType::Feature, and its value is the number
     558    ///     of features locked.</li>
     559    ///   <li>If the command is of type MgUnLockFeatures, the property
     560    ///     type is MgPropertyType::Int32, and its value is the number of
     561    ///     features unlocked.</li>
     562    /// </ul>
     563    ///
     564    /// \exception MgFeatureServiceException
     565    /// \exception MgInvalidArgumentException
     566    /// \exception MgInvalidOperationException
     567    /// \exception MgFdoException
     568    ///
     569    /// \since 3.0
     570    virtual MgPropertyCollection* UpdateFeatures(MgFeatureCommandCollection* commands, MgTransaction* transaction);
     571
     572    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     573    /// \brief
     574    /// Inserts a new feature into the specified feature class of the specified Feature Source
     575    ///
     576    /// <!-- Syntax in .Net, Java, and PHP -->
     577    /// \htmlinclude DotNetSyntaxTop.html
     578    /// virtual MgFeatureReader InsertFeatures(MgPropertyCollection properties);
     579    /// \htmlinclude SyntaxBottom.html
     580    /// \htmlinclude JavaSyntaxTop.html
     581    /// virtual MgFeatureReader InsertFeatures(MgPropertyCollection properties);
     582    /// \htmlinclude SyntaxBottom.html
     583    /// \htmlinclude PHPSyntaxTop.html
     584    /// virtual MgFeatureReader InsertFeatures(MgPropertyCollection properties);
     585    /// \htmlinclude SyntaxBottom.html
     586    ///
     587    /// \param properties (MgPropertyCollection)
     588    /// The collection of property values to insert
     589    /// \param transaction (MgTransaction)
     590    /// An optional transaction to execute this operation under
     591    ///
     592    /// \return
     593    /// Returns a feature reader object that contains the set of properties
     594    /// inserted into the datastore by the insert command.
     595    ///
     596    /// \remarks
     597    /// Transactions will be used internally if the provider supports them.
     598    /// Remember to close any feature readers returned by this method, even if you don't intend
     599    /// to do anything with them
     600    ///
     601    /// \exception MgFeatureServiceException
     602    /// \exception MgInvalidArgumentException
     603    /// \exception MgInvalidOperationException
     604    /// \exception MgFdoException
     605    ///
     606    /// \since 3.0
     607    virtual MgFeatureReader* InsertFeatures(MgPropertyCollection* properties, MgTransaction* transaction);
     608
     609    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     610    /// \brief
     611    /// Inserts a set of new features into the specified feature class of the specified Feature Source
     612    ///
     613    /// <!-- Syntax in .Net, Java, and PHP -->
     614    /// \htmlinclude DotNetSyntaxTop.html
     615    /// virtual MgFeatureReader InsertFeatures(MgBatchPropertyCollection properties);
     616    /// \htmlinclude SyntaxBottom.html
     617    /// \htmlinclude JavaSyntaxTop.html
     618    /// virtual MgFeatureReader InsertFeatures(MgBatchPropertyCollection properties);
     619    /// \htmlinclude SyntaxBottom.html
     620    /// \htmlinclude PHPSyntaxTop.html
     621    /// virtual MgFeatureReader InsertFeatures(MgBatchPropertyCollection properties);
     622    /// \htmlinclude SyntaxBottom.html
     623    ///
     624    /// \param properties (MgBatchPropertyCollection)
     625    /// The collection of property values to insert. Each MgPropertyCollection within
     626    /// this collection represents property values for a single feature to insert
     627    /// \param transaction (MgTransaction)
     628    /// An optional transaction to execute this operation under
     629    ///
     630    /// \return
     631    /// Returns a feature reader object that contains the set of properties
     632    /// inserted into the datastore by the insert command.
     633    ///
     634    /// \remarks
     635    /// Transactions will be used internally if the provider supports them.
     636    /// Remember to close any feature readers returned by this method, even if you don't intend
     637    /// to do anything with them
     638    ///
     639    /// \exception MgFeatureServiceException
     640    /// \exception MgInvalidArgumentException
     641    /// \exception MgInvalidOperationException
     642    /// \exception MgFdoException
     643    ///
     644    /// \since 3.0
     645    virtual MgFeatureReader* InsertFeatures(MgBatchPropertyCollection* properties, MgTransaction* transaction);
     646
     647    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     648    /// \brief
     649    /// Updates all features that match the given filter with the specified property values
     650    ///
     651    /// \remarks
     652    /// Transactions will be used internally if the provider supports them
     653    ///
     654    /// <!-- Syntax in .Net, Java, and PHP -->
     655    /// \htmlinclude DotNetSyntaxTop.html
     656    /// virtual int UpdateMatchingFeatures(MgPropertyCollection properties, string filter);
     657    /// \htmlinclude SyntaxBottom.html
     658    /// \htmlinclude JavaSyntaxTop.html
     659    /// virtual int UpdateMatchingFeatures(MgPropertyCollection properties, String filter);
     660    /// \htmlinclude SyntaxBottom.html
     661    /// \htmlinclude PHPSyntaxTop.html
     662    /// virtual int UpdateMatchingFeatures(MgPropertyCollection properties, String filter);
     663    /// \htmlinclude SyntaxBottom.html
     664    ///
     665    /// \param properties (MgBatchPropertyCollection)
     666    /// The property values to update matching features with
     667    /// \param filter (String/string)
     668    /// The FDO filter string that detemines what features will be updated
     669    /// \param transaction (MgTransaction)
     670    /// An optional transaction to execute this operation under
     671    ///
     672    /// \return
     673    /// Returns the number of features updated by this operation
     674    ///
     675    /// \exception MgFeatureServiceException
     676    /// \exception MgInvalidArgumentException
     677    /// \exception MgInvalidOperationException
     678    /// \exception MgFdoException
     679    ///
     680    /// \since 3.0
     681    virtual INT32 UpdateMatchingFeatures(MgPropertyCollection* properties, CREFSTRING filter, MgTransaction* transaction);
     682
     683    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     684    /// \brief
     685    /// Deletes all features that match the given filter
     686    ///
     687    /// \remarks
     688    /// Transactions will be used internally if the provider supports them
     689    ///
     690    /// <!-- Syntax in .Net, Java, and PHP -->
     691    /// \htmlinclude DotNetSyntaxTop.html
     692    /// virtual int DeleteFeatures(string filter);
     693    /// \htmlinclude SyntaxBottom.html
     694    /// \htmlinclude JavaSyntaxTop.html
     695    /// virtual int DeleteFeatures(String filter);
     696    /// \htmlinclude SyntaxBottom.html
     697    /// \htmlinclude PHPSyntaxTop.html
     698    /// virtual int DeleteFeatures(String filter);
     699    /// \htmlinclude SyntaxBottom.html
     700    ///
     701    /// \param filter (String/string)
     702    /// The FDO filter string that detemines what features will be deleted
     703    /// \param transaction (MgTransaction)
     704    /// An optional transaction to execute this operation under
     705    ///
     706    /// \return
     707    /// Returns the number of features deleted by this operation
     708    ///
     709    /// \exception MgFeatureServiceException
     710    /// \exception MgInvalidArgumentException
     711    /// \exception MgInvalidOperationException
     712    /// \exception MgFdoException
     713    ///
     714    /// \since 3.0
     715    virtual INT32 DeleteFeatures(CREFSTRING filter, MgTransaction* transaction);
     716
     717    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     718    /// \brief
     719    /// Gets all of the spatial contexts available in the layer or just the active one
     720    ///
     721    /// \remarks
     722    /// The \link FdoSpatialContextList_schema FdoSpatialContextList \endlink XML schema contains
     723    /// a specification of the content of the spatial context
     724    /// information returned in the MgSpatialContextReader object.
     725    ///
     726    /// <!-- Syntax in .Net, Java, and PHP -->
     727    /// \htmlinclude DotNetSyntaxTop.html
     728    /// virtual MgSpatialContextReader GetSpatialContexts(bool bActiveOnly);
     729    /// \htmlinclude SyntaxBottom.html
     730    /// \htmlinclude JavaSyntaxTop.html
     731    /// virtual MgSpatialContextReader GetSpatialContexts(boolean bActiveOnly);
     732    /// \htmlinclude SyntaxBottom.html
     733    /// \htmlinclude PHPSyntaxTop.html
     734    /// virtual MgSpatialContextReader GetSpatialContexts(bool bActiveOnly);
     735    /// \htmlinclude SyntaxBottom.html
     736    ///
     737    /// \param bActiveOnly (boolean/bool)
     738    /// This flag is obsolete and no longer used.
     739    ///
     740    /// \return
     741    /// Returns an MgSpatialContextReader object.
     742    ///
     743    /// \exception MgFeatureServiceException
     744    /// \exception MgInvalidArgumentException
     745    /// \exception MgInvalidOperationException
     746    /// \exception MgFdoException
     747    ///
     748    /// \since 3.0
     749    virtual MgSpatialContextReader* GetSpatialContexts(bool bActiveOnly);
     750};
     751}}}
    611752
    612753=== Rendering layer style icons ===
     
    10141155As with [wiki:MapGuideRfc9 MapGuide RFC 9], the new convenience APIs in MgLayer/MgLayerBase will only work if the parent MgMap was initialized with an MgSiteConnection instance. If [wiki:MapGuideRfc139 MapGuide RFC 139] is adopted, the deprecated MgMap() constructor will be removed, eliminating the possibility of these APIs not working under certain conditions.
    10151156
     1157It's up to Autodesk whether they choose to implement these convenience APIs for their AutoCAD Map implementation of MgLayerBase and MgFeatureService. These methods will throw MgNotImplementedException if not overridden.
     1158
    10161159== Test Plan ==
    10171160