#region Disclaimer / License // Copyright (C) 2014, 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 Disclaimer / License using OSGeo.MapGuide.ObjectModels.FeatureSource.v1_0_0; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; namespace OSGeo.MapGuide.ObjectModels.FeatureSource { /// /// Represents an FDO feature source /// public interface IFeatureSource : IResource { /// /// Removes all specified connection properties /// void ClearConnectionProperties(); /// /// Gets an array of names of the currently specified connection properties /// string[] ConnectionPropertyNames { get; } /// /// Gets or sets the FDO provider. /// /// The FDO provider. string Provider { get; set; } /// /// Gets the connection property. /// /// The name. /// string GetConnectionProperty(string name); /// /// Sets the connection property. /// /// The name. /// The value. If null, the matching parameter is removed from the feature source void SetConnectionProperty(string name, string value); /// /// Gets the connection string. /// /// The connection string. string ConnectionString { get; } /// /// Gets the name of the embedded data resource. Can only be called if returns true. /// /// /// If is false string GetEmbeddedDataName(); /// /// Gets the name of the alias. Can only be called if returns true /// /// /// If is false string GetAliasName(); /// /// Gets the name of the aliased file. Can only be called if returns true. An /// empty string is returned if it is a directory (ie. no file name was found) /// /// /// If is false string GetAliasedFileName(); /// /// Gets a value indicating whether [uses embedded data files]. /// /// /// true if [uses embedded data files]; otherwise, false. /// bool UsesEmbeddedDataFiles { get; } /// /// Gets a value indicating whether [uses aliased data files]. /// /// /// true if [uses aliased data files]; otherwise, false. /// bool UsesAliasedDataFiles { get; } /// /// Gets the supplemental spatial context info (coordinate system overrides). /// /// The supplemental spatial context info. IEnumerable SupplementalSpatialContextInfo { get; } /// /// Adds the spatial context override. /// /// The sc. void AddSpatialContextOverride(ISpatialContextInfo sc); /// /// Removes the spatial context override. /// /// The sc. void RemoveSpatialContextOverride(ISpatialContextInfo sc); /// /// Gets the extensions for this feature source. /// /// The extensions. IEnumerable Extension { get; } /// /// Adds the extension. /// /// The ext. void AddExtension(IFeatureSourceExtension ext); /// /// Removes the extension. /// /// The ext. void RemoveExtension(IFeatureSourceExtension ext); /// /// Gets or sets the name of the configuration document. /// /// The name of the configuration document. string ConfigurationDocument { get; set; } } /// /// Represents a spatial context override /// public interface ISpatialContextInfo { /// /// Gets or sets the name. /// /// The name. string Name { get; set; } /// /// Gets or sets the coordinate system. /// /// The coordinate system. string CoordinateSystem { get; set; } } /// /// Represents an extended feature class /// public interface IFeatureSourceExtension : INotifyPropertyChanged { /// /// Gets or sets the name. /// /// The name. string Name { get; set; } /// /// Gets or sets the feature class to extend /// /// The feature class. string FeatureClass { get; set; } /// /// Gets the calculated properties. /// /// The calculated properties. IEnumerable CalculatedProperty { get; } /// /// Adds the calculated property. /// /// The prop. void AddCalculatedProperty(ICalculatedProperty prop); /// /// Removes the calculated property. /// /// The prop. void RemoveCalculatedProperty(ICalculatedProperty prop); /// /// Gets the attribute joins /// /// The attribute joins. IEnumerable AttributeRelate { get; } /// /// Adds the relation. /// /// The relate. void AddRelation(IAttributeRelation relate); /// /// Removes the relation. /// /// The relate. void RemoveRelation(IAttributeRelation relate); } /// /// Represents a FDO calculated property /// public interface ICalculatedProperty : INotifyPropertyChanged { /// /// Gets or sets the name. /// /// The name. string Name { get; set; } /// /// Gets or sets the FDO expression. /// /// The FDO expression. string Expression { get; set; } } /// /// Defines the type of joins /// [System.SerializableAttribute] public enum RelateTypeEnum { /// LeftOuter, /// RightOuter, /// Inner, /// Association, } /// /// Represents an attribute join /// public interface IAttributeRelation : INotifyPropertyChanged { /// /// Gets or sets whether to force 1:1 cardinality /// bool ForceOneToOne { get; set; } /// /// Gets the type of join /// RelateTypeEnum RelateType { get; set; } /// /// Gets or sets the feature source id containing the feature class to extend /// string ResourceId { get; set; } /// /// Gets or sets the name of the feature class to extend /// string AttributeClass { get; set; } /// /// Gets or sets the name of the join /// string Name { get; set; } /// /// Gets or sets the prefix that prevents a naming collision on both sides of the join /// string AttributeNameDelimiter { get; set; } /// /// Gets the property pairs involved in this join /// /// The property pairs. IEnumerable RelateProperty { get; } /// /// Gets the number of properties being joined on /// int RelatePropertyCount { get; } /// /// Creates the property join. /// /// The primary property. /// The secondary property. /// IRelateProperty CreatePropertyJoin(string primaryProperty, string secondaryProperty); /// /// Adds the relate property. /// /// The prop. void AddRelateProperty(IRelateProperty prop); /// /// Removes the relate property. /// /// The prop. void RemoveRelateProperty(IRelateProperty prop); /// /// Removes all relate properties. /// void RemoveAllRelateProperties(); } /// /// Represents a property pair in an attribute join /// public interface IRelateProperty { /// /// Gets or sets the feature class property. /// /// The feature class property. string FeatureClassProperty { get; set; } /// /// Gets or sets the attribute class property. /// /// The attribute class property. string AttributeClassProperty { get; set; } } /// /// Extension method class /// public static class FeatureSourceExtensions { /// /// Gets a collection of connection properties /// /// /// public static NameValueCollection GetConnectionProperties(this IFeatureSource fs) { Check.ArgumentNotNull(fs, nameof(fs)); var values = new NameValueCollection(); foreach (string name in fs.ConnectionPropertyNames) { values[name] = fs.GetConnectionProperty(name); } return values; } /// /// Sets the connection properties of the feature source /// /// /// public static void ApplyConnectionProperties(this IFeatureSource fs, NameValueCollection values) { Check.ArgumentNotNull(fs, nameof(fs)); Check.ArgumentNotNull(values, nameof(values)); fs.ClearConnectionProperties(); foreach (string name in values.Keys) { string value = values[name]; fs.SetConnectionProperty(name, value); } } /// /// Adds a spatial context override /// /// /// /// public static void AddSpatialContextOverride(this IFeatureSource fs, string name, string coordSys) { Check.ArgumentNotNull(fs, nameof(fs)); fs.AddSpatialContextOverride(new SpatialContextType() { Name = name, CoordinateSystem = coordSys }); } /// /// Adds the specified property pair to this join /// /// /// /// public static void AddRelateProperty(this IAttributeRelation rel, string primary, string secondary) { Check.ArgumentNotNull(rel, nameof(rel)); rel.AddRelateProperty(new RelatePropertyType() { FeatureClassProperty = primary, AttributeClassProperty = secondary }); } } }