#region Disclaimer / License // Copyright (C) 2009, Kenneth Skovhede // http://www.hexad.dk, opensource@hexad.dk // // 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.Net; using System.Xml; using System.Collections.Specialized; using System.Collections; namespace OSGeo.MapGuide.MaestroAPI { /// /// Primary connection to the MapGuide Server /// public interface ServerConnectionI : IDisposable { string SessionID { get; } ResourceList RepositoryResources { get; } ResourceList GetRepositoryResources(); ResourceList GetRepositoryResources(int depth); ResourceList GetRepositoryResources(string startingpoint, int depth); ResourceList GetRepositoryResources(string startingpoint); ResourceList GetRepositoryResources(string startingpoint, string type); ResourceList GetRepositoryResources(string startingpoint, string type, int depth); ResourceList GetRepositoryResources(string startingpoint, string type, int depth, bool computeChildren); FeatureProviderRegistryFeatureProviderCollection FeatureProviders { get; } string TestConnection(string providername, NameValueCollection parameters); string TestConnection(string featuresource); string TestConnection(FeatureSource feature); /// /// Gets or sets a value indicating if the session should automatically be restarted if it expires /// bool AutoRestartSession { get; set; } /// /// Placeholder for actual method call /// void DescribeSchema(); OSGeo.MapGuide.MaestroAPI.WebLayout GetWebLayout(string resourceID); OSGeo.MapGuide.MaestroAPI.MapDefinition GetMapDefinition(string resourceID); OSGeo.MapGuide.MaestroAPI.LayerDefinition GetLayerDefinition(string resourceID); OSGeo.MapGuide.MaestroAPI.ApplicationDefinition.ApplicationDefinitionType GetApplicationDefinition(string resourceID); OSGeo.MapGuide.MaestroAPI.FdoProviderCapabilities GetProviderCapabilities(string provider); System.IO.MemoryStream GetResourceData(string resourceID, string dataname); OSGeo.MapGuide.MaestroAPI.ResourceDocumentHeaderType GetResourceHeader(string resourceID); OSGeo.MapGuide.MaestroAPI.ResourceFolderHeaderType GetFolderHeader(string resourceID); OSGeo.MapGuide.MaestroAPI.FeatureSource GetFeatureSource(string resourceID); byte[] GetResourceXmlData(string resourceID); object GetResource(string resourceID); /// /// Removes the version numbers from a providername /// /// The name of the provider, with or without version numbers /// The provider name without version numbers string RemoveVersionFromProviderName(string providername); /// /// Gets the possible values for a given connection property /// /// The FDO provider name /// The property name /// A partial connection string if certain providers require such information /// A list of possible values for the given property string[] GetConnectionPropertyValues(string providerName, string propertyName, string partialConnectionString); /// /// Returns an installed provider, given the name of the provider /// /// The name of the provider /// The first matching provider or null FeatureProviderRegistryFeatureProvider GetFeatureProvider(string providername); System.IO.Stream GetMapDWF(string resourceID); object DeserializeObject(Type type, System.IO.Stream data); T DeserializeObject(System.IO.Stream data); System.IO.MemoryStream SerializeObject(object o); void SerializeObject(object o, System.IO.Stream stream); Version MaxTestedVersion { get; } void SetResourceData(string resourceid, string dataname, ResourceDataType datatype, System.IO.Stream stream); void SetResourceData(string resourceid, string dataname, ResourceDataType datatype, System.IO.Stream stream, Utility.StreamCopyProgressDelegate callback); void SetResourceXmlData(string resourceid, System.IO.Stream stream); /// /// Executes a SQL query /// /// /// /// FeatureSetReader ExecuteSqlQuery(string featureSourceID, string sql); FeatureSetReader QueryFeatureSource(string resourceID, string schema, string query); FeatureSetReader QueryFeatureSource(string resourceID, string schema); FeatureSetReader QueryFeatureSource(string resourceID, string schema, string query, string[] columns); FeatureSetReader QueryFeatureSource(string resourceID, string schema, string query, string[] columns, NameValueCollection computedProperties); FeatureSetReader AggregateQueryFeatureSource(string resourceID, string schema, string filter); FeatureSetReader AggregateQueryFeatureSource(string resourceID, string schema, string filter, string[] columns); FeatureSetReader AggregateQueryFeatureSource(string resourceID, string schema, string filter, NameValueCollection aggregateFunctions); Topology.Geometries.IEnvelope GetSpatialExtent(string resourceID, string schema, string geometry); Topology.Geometries.IEnvelope GetSpatialExtent(string resourceID, string schema, string geometry, string filter); Topology.Geometries.IEnvelope GetSpatialExtent(string resourceID, string schema, string geometry, bool allowFallbackToContextInformation); FeatureSourceDescription DescribeFeatureSource(string resourceID); FeatureSourceDescription DescribeFeatureSource(string resourceID, string schema); FeatureSourceDescription.FeatureSourceSchema GetFeatureSourceSchema(string resourceID, string schema); FeatureSourceDescription GetFeatureSourceDescription(string resourceID); void ResetFeatureSourceSchemaCache(); FdoSpatialContextList GetSpatialContextInfo(string resourceID, bool activeOnly); void SetFolderHeader(string resourceID, ResourceFolderHeaderType header); void SetResourceHeader(string resourceID, ResourceDocumentHeaderType header); void UpdateRepository(string resourceId, ResourceFolderHeaderType header); /// /// Creates a runtime map on the server. /// The map name will be the name of the resource, without path information. /// This is equivalent to the way the AJAX viewer creates the runtime map. /// /// The mapDefinition resource id void CreateRuntimeMap(string resourceID); /// /// Creates a runtime map on the server /// /// The target resource id for the runtime map /// The mapdefinition to base the map on void CreateRuntimeMap(string resourceID, string mapdefinition); /// /// Creates a runtime map on the server /// /// The target resource id for the runtime map /// The mapdefinition to base the map on void CreateRuntimeMap(string resourceID, MapDefinition map); /// /// Creates a runtime map on the server /// /// The target resource id for the runtime map /// The mapdefinition to base the map on void CreateRuntimeMap(string resourceID, RuntimeClasses.RuntimeMap map); /// /// Updates an existing runtime map /// /// The target resource id for the runtime map /// The runtime map to update with void SaveRuntimeMap(string resourceID, RuntimeClasses.RuntimeMap map); void DeleteResourceData(string resourceID, string dataname); ResourceDataList EnumerateResourceData(string resourceID); void DeleteResource(string resourceID); void DeleteFolder(string folderPath); RuntimeClasses.RuntimeMap GetRuntimeMap(string resourceID); Version SiteVersion { get; } bool DisableValidation { get; set; } ICoordinateSystemCatalog CoordinateSystemCatalog { get; } bool HasFolder(string folderpath); void CreateFolder(string folderpath); /// /// Gets a string that can be used to identify the server by a user /// string DisplayName { get; } ResourceReferenceList EnumerateResourceReferences(string resourceid); void CopyResource(string oldpath, string newpath, bool overwrite); void CopyFolder(string oldpath, string newpath, bool overwrite); void MoveResource(string oldpath, string newpath, bool overwrite); void MoveFolder(string oldpath, string newpath, bool overwrite); bool MoveResourceWithReferences(string oldpath, string newpath, LengthyOperationCallBack callback, LengthyOperationProgressCallBack progress); bool MoveFolderWithReferences(string oldpath, string newpath, LengthyOperationCallBack callback, LengthyOperationProgressCallBack progress); bool CopyFolderWithReferences(string oldpath, string newpath, LengthyOperationCallBack callback, LengthyOperationProgressCallBack progress); bool ResourceExists(string resourceid); System.IO.Stream RenderRuntimeMap(string resourceId, double x, double y, double scale, int width, int height, int dpi); System.IO.Stream RenderRuntimeMap(string resourceId, double x1, double y1, double x2, double y2, int width, int height, int dpi); System.IO.Stream RenderRuntimeMap(string resourceId, double x, double y, double scale, int width, int height, int dpi, string format); System.IO.Stream RenderRuntimeMap(string resourceId, double x1, double y1, double x2, double y2, int width, int height, int dpi, string format); System.IO.Stream RenderRuntimeMap(string resourceId, double x, double y, double scale, int width, int height, int dpi, string format, bool clip); System.IO.Stream RenderRuntimeMap(string resourceId, double x1, double y1, double x2, double y2, int width, int height, int dpi, string format, bool clip); /// /// Saves a WebLayout, using its originating resourceId /// /// The WebLayout to save void SaveResource(WebLayout resource); /// /// Saves a FeatureSource, using its originating resourceId /// /// The FeatureSource to save void SaveResource(FeatureSource resource); /// /// Saves a LayerDefinition, using its originating resourceId /// /// The LayerDefinition to save void SaveResource(LayerDefinition resource); /// /// Saves a MapDefinition, using its originating resourceId /// /// The MapDefintion to save void SaveResource(MapDefinition resource); /// /// Saves an object into the repository /// /// The object to save /// The resourceId to save the object as void SaveResourceAs(object resource, string resourceid); /// /// Saves a MapDefinition under a different resourceID /// /// The MapDefinition to save /// The new path of the MapDefinition void SaveResourceAs(MapDefinition resource, string resourceid); /// /// Saves a LayerDefinition under a different resourceID /// /// The LayerDefinition to save /// The new path of the LayerDefinition void SaveResourceAs(LayerDefinition resource, string resourceid); /// /// Saves a FeatureSource under a different resourceID /// /// The FeatureSource to save /// The new path of the FeatureSource void SaveResourceAs(FeatureSource resource, string resourceid); /// /// Saves a WebLayout under a different resourceID /// /// The WebLayout to save /// The new path of the WebLayout void SaveResourceAs(WebLayout resource, string resourceid); ApplicationDefinitionTemplateInfoSet GetApplicationTemplates(); /// /// Returns the avalible application widgets on the server /// /// The avalible application widgets on the server ApplicationDefinitionWidgetInfoSet GetApplicationWidgets(); /// /// Returns the avalible widget containers on the server /// /// The avalible widget containers on the server ApplicationDefinitionContainerInfoSet GetApplicationContainers(); /// /// Gets the resource type from a resourceID /// /// The resourceID for the resource /// The type of the given item, throws an exception if the type does not exist Type GetResourceType(string resourceID); /// /// Gets the resource type from a resourceID /// /// The resourceID for the resource /// The type of the given item, returns null if no such type exists Type TryGetResourceType(string resourceID); /// /// Gets the names of the identity properties from a feature /// /// The resourceID for the FeatureSource /// The classname of the feature, including schema /// A string array with the found identities string[] GetIdentityProperties(string resourceID, string classname); /// /// Restarts the server session, and creates a new session ID /// void RestartSession(); /// /// Restarts the server session, and creates a new session ID /// /// If set to true, the call throws an exception if the call failed /// True if the creation succeed, false otherwise bool RestartSession(bool throwException); /// /// Sets the selection of a map /// /// The resourceID of the runtime map /// The selection xml void SetSelectionXml(string runtimeMap, string selectionXml); /// /// Gets the selection from a map /// /// The resourceID of the runtime map /// The selection xml string GetSelectionXml(string runtimeMap); /// /// Enumerates all unmanaged folders, meaning alias'ed folders /// /// The type of data to return /// A filter applied to the items /// True if the list should contains recursive results /// The path to retrieve the data from /// A list of unmanaged data UnmanagedDataList EnumerateUnmanagedData(string startpath, string filter, bool recursive, UnmanagedDataTypes type); /// /// Selects features from a runtime map, returning a selection Xml. /// /// The map to query. NOT a resourceID, only the map name! /// The WKT of the geometry to query with (always uses intersection) /// True if the selection should be saved in the runtime map, false otherwise. /// The type of layer to include in the query /// True if the result should contain the tooltip and link info /// The selection Xml, or an empty string if there were no data. string QueryMapFeatures(string runtimemap, string wkt, bool persist, QueryMapFeaturesLayerAttributes attributes, bool raw); /// /// Selects features from a runtime map, returning a selection Xml. /// /// The map to query. NOT a resourceID, only the map name! /// The WKT of the geometry to query with (always uses intersection) /// True if the selection should be saved in the runtime map, false otherwise. /// The selection Xml, or an empty string if there were no data. string QueryMapFeatures(string runtimemap, string wkt, bool persist); /// /// Renders a minature bitmap of the layers style /// /// The scale for the bitmap to match /// The layer the image should represent /// If the layer is themed, this gives the theme index, otherwise set to 0 /// The geometry type, 1 for point, 2 for line, 3 for area, 4 for composite /// The minature bitmap System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type); /// /// Upload a MapGuide Package file to the server /// /// Name of the file to upload /// A callback argument used to display progress. May be null. void UploadPackage(string filename, Utility.StreamCopyProgressDelegate callback); /// /// Gets a list of all users on the server /// /// The list of users UserList EnumerateUsers(); /// /// Gets a list of users in a group /// /// The group to retrieve the users from /// The list of users UserList EnumerateUsers(string group); /// /// Gets a list of all groups on the server /// /// The list of groups GroupList EnumerateGroups(); /// /// Reads a tile from MapGuide /// /// A map with baselayergroups /// The name of a baselayergroup /// The column index of the tile /// The row index of the tile /// The scale index for the tile set /// The format to return the tile in, either JPG, GIF, PNG or PNG8 /// An image stream System.IO.Stream GetTile(string mapdefinition, string baselayergroup, int col, int row, int scaleindex, string format); /// /// Creates a new object of the given type, with standard values inserted /// /// The type of the object to create /// A new instance of the object T CreateResourceObject(); /// /// Executes the specified load procedure. If this load procedure has not been executed before, /// it will update the load procedure resource with the list of resource ids created. On subsequent /// executions, it will only create or update resources from this list. /// /// /// /// /// A list of resource IDs that were created or updated from the execution of this load procedure string[] ExecuteLoadProcedure(string resourceID, bool ignoreUnsupportedFeatures, LengthyOperationProgressCallBack callback); /// /// Indicates whether previewing capabilities are possible with this connection /// bool SupportsResourcePreviews { get; } } }