#region Disclaimer / License // Copyright (C) 2012, Jackie Ng // http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@gmail.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // 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 Street, Fifth Floor, Boston, MA 02110-1301 USA // #endregion using System; using System.Collections.Generic; using System.Text; using OSGeo.MapGuide.MaestroAPI.Schema; using OSGeo.MapGuide.MaestroAPI.Feature; using OSGeo.MapGuide.ObjectModels.Common; namespace OSGeo.MapGuide.MaestroAPI.Commands { /// /// Defines a command that works against a Feature Class of a Feature Source /// public interface IFeatureCommand : ICommand { /// /// Gets or sets the Feature Source ID /// string FeatureSourceId { get; set; } /// /// Gets or sets the Feature Class name /// string ClassName { get; set; } } /// /// Defines a command that creates a file-based data store on a given feature source /// /// /// This command is only supported on certain implementations of /// You can find out if the connection supports this command through the /// /// /// How to create a data store with a given schema /// /// /// IServerConnection conn = ...; /// /// FeatureSchema schema = new FeatureSchema("Default", ""); /// ClassDefinition cls = new ClassDefinition("MyClass", ""); /// /// cls.DefaultGeometryProperty = "GEOM"; /// //Add identity property KEY /// cls.AddProperty(new DataPropertyDefinition("KEY", "") /// { /// DataType = DataPropertyType.Int32, /// IsAutoGenerated = true, /// IsReadOnly = true, /// IsNullable = false /// }, true); /// //Add string property NAME /// cls.AddProperty(new DataPropertyDefinition("NAME", "") /// { /// DataType = DataPropertyType.String, /// Length = 255, /// IsNullable = true, /// IsReadOnly = false /// }); /// //Add geometry property GEOM /// cls.AddProperty(new GeometricPropertyDefinition("GEOM", "") /// { /// GeometricTypes = FeatureGeometricType.Point, /// SpatialContextAssociation = "Default" /// }); /// /// schema.AddClass(cls); /// /// ICreateDataStore create = (ICreateDataStore)conn.CreateCommand((int)CommandType.CreateDataStore); /// CoordinateSystemDefinitionBase coordSys = conn.CoordinateSystemCatalog.FindCoordSys("LL84"); /// create.FeatureSourceId = fsId; /// create.CoordinateSystemWkt = coordSys.WKT; /// create.Name = "Default"; /// create.ExtentType = OSGeo.MapGuide.ObjectModels.Common.FdoSpatialContextListSpatialContextExtentType.Dynamic; /// create.FileName = "Test.sdf"; /// create.Provider = "OSGeo.SDF"; /// create.Schema = schema; /// create.XYTolerance = 0.001; /// create.ZTolerance = 0.001; /// create.Execute(); /// /// /// public interface ICreateDataStore : ICommand, IFdoSpatialContext { /// /// Gets or sets the Feature Schema that models the structure of the data store /// FeatureSchema Schema { get; set; } /// /// Gets or sets the FDO provider name /// string Provider { get; set; } /// /// Gets or sets the file name for the data store /// string FileName { get; set; } /// /// Gets or sets the Feature Source ID /// string FeatureSourceId { get; set; } /// /// Executes the command /// void Execute(); } /// /// Defines a command that inserts a feature into a Feature Source /// /// /// This command is only supported on certain implementations of /// You can find out if the connection supports this command through the /// /// /// How to insert a feature that contains a string and geometry value /// /// /// IServerConnection conn = ...; /// IInsertFeatures insertCmd = (IInsertFeatures)conn.CreateCommand((int)CommandType.InsertFeatures); /// insertCmd.FeatureSourceId = "Library://My.FeatureSource"; /// insertCmd.ClassName = "MyFeatureClass"; /// MutableRecord insertRec = new MutableRecord(); /// FixedWKTReader wktReader = new FixedWKTReader(); /// insertRec.PutValue("Geometry", new GeometryValue(wktReader.Read("POINT (10 10)"))); /// insertRec.PutValue("Name", new StringValue("Foo")); /// insertCmd.RecordToInsert = insertRec; /// InsertResult res = insertCmd.Execute(); /// /// /// public interface IInsertFeatures : IFeatureCommand { /// /// The feature to insert /// IMutableRecord RecordToInsert { get; set; } /// /// Executes the command. Any error during execution will be caught and stored in the property /// /// The feature insert result InsertResult Execute(); } /// /// The result of a operation /// public class InsertResult { /// /// Gets the object. If there is no exception, the insert operation succeeded. /// public Exception Error { get; set; } } /// /// Defines a command that inserts a series of features into a Feature Source /// /// /// /// This command is only supported on certain implementations of /// You can find out if the connection supports this command through the /// /// /// Nothing implements this interface at the moment /// /// public interface IBatchInsertFeatures : IFeatureCommand { /// /// Gets or sets the list of features to insert /// ICollection RecordsToInsert { get; set; } /// /// Executes the command. /// /// /// A collection of instances. /// Inspect the individual properties to /// determine which features failed to be inserted. /// ICollection Execute(); } /// /// Defines a command that updates one or more features in a Feature Source based on some filtering criteria /// /// /// This command is only supported on certain implementations of /// You can find out if the connection supports this command through the /// /// /// How to update all features matching a given filter to the given value /// /// /// IServerConnection conn = ...; /// IUpdateFeatures updateCmd = (IUpdateFeatures)conn.CreateCommand((int)CommandType.UpdateFeatures); /// updateCmd.FeatureSourceId = "Library://My.FeatureSource"; /// updateCmd.ClassName = "MyFeatureClass"; /// updateCmd.Filter = "Name = 'Bar'"; /// updateCmd.ValuesToUpdate = new MutableRecord(); /// updateCmd.ValuesToUpdate.PutValue("Name", new StringValue("Foo")); /// int updated = updateCmd.Execute(); /// /// /// public interface IUpdateFeatures : IFeatureCommand { /// /// Gets or sets the filter that determines which features will be updated. If empty, will cause all /// features to be updated /// string Filter { get; set; } /// /// Gets or sets the collection of values to apply /// IMutableRecord ValuesToUpdate { get; set; } /// /// Executes the command /// /// The number of features updated by this command int Execute(); } /// /// Defines a command that deletes one or more features in a Feature Source based on some filtering criteria /// /// /// This command is only supported on certain implementations of /// You can find out if the connection supports this command through the /// /// /// How to update all features matching a given filter to the given value /// /// /// IServerConnection conn = ...; /// IDeleteFeatures deleteCmd = (IDeleteFeatures)conn.CreateCommand((int)CommandType.DeleteFeatures); /// deleteCmd.FeatureSourceId = "Library://My.FeatureSource"; /// deleteCmd.ClassName = "MyFeatureClass"; /// deleteCmd.Filter = "Name = 'Bar'"; /// int deleted = deleteCmd.Execute(); /// /// /// public interface IDeleteFeatures : IFeatureCommand { /// /// Gets or sets the filter that determines what features will be deleted. If empty, this will delete all features /// string Filter { get; set; } /// /// Executes the command. /// /// The number of features deleted int Execute(); } /// /// Defines a command that applies the given Feature Schema to a Feature Source /// /// /// This command is only supported on certain implementations of /// You can find out if the connection supports this command through the /// public interface IApplySchema : ICommand { /// /// Gets or sets the Feature Source ID /// string FeatureSourceId { get; set; } /// /// Gets or sets the Feature Schema /// FeatureSchema Schema { get; set; } /// /// Executes the command /// void Execute(); } }