[mapguide-commits] r6680 - in trunk/Tools/Maestro: Maestro.Editors/FeatureSource/Preview Maestro.Editors/LayerDefinition Maestro.Editors/LayerDefinition/Raster OSGeo.MapGuide.MaestroAPI/Commands OSGeo.MapGuide.MaestroAPI/ObjectModels OSGeo.MapGuide.MaestroAPI/Resource/Validation

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue May 22 10:56:41 EDT 2012


Author: jng
Date: 2012-05-22 07:56:41 -0700 (Tue, 22 May 2012)
New Revision: 6680

Modified:
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/LocalFeatureSourcePreviewCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerSettingsSectionCtrl.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSourceInterfaces.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs
Log:
#2004: Eliminate the need for a full schema walk in Feature Source and Layer Definition validation. Note that for large datstores, it's now spamming a series of small GetIdentityProperties requests instead of a single large DescribeSchema request (that could timeout)

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/LocalFeatureSourcePreviewCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/LocalFeatureSourcePreviewCtrl.cs	2012-05-22 14:20:34 UTC (rev 6679)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/LocalFeatureSourcePreviewCtrl.cs	2012-05-22 14:56:41 UTC (rev 6680)
@@ -88,6 +88,8 @@
             _caps = caps;
             ClearPreviewPanes();
             trvSchema.Nodes.Clear();
+            
+            //FIXME: Do this lazily ala. FDO Toolbox
             var schema = _fsvc.DescribeFeatureSource(currentFsId);
 
             Dictionary<string, List<ClassDefinition>> classes = new Dictionary<string, List<ClassDefinition>>();

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs	2012-05-22 14:20:34 UTC (rev 6679)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs	2012-05-22 14:56:41 UTC (rev 6680)
@@ -81,9 +81,7 @@
 
             if (_edsvc.ResourceService.ResourceExists(_vl.ResourceId))
             {
-                //TODO: Should just fetch the class definition
-                var desc = _edsvc.FeatureService.DescribeFeatureSource(_vl.ResourceId);
-                var cls = desc.GetClass(_vl.FeatureName);
+                var cls = _edsvc.FeatureService.GetClassDefinition(_vl.ResourceId, _vl.FeatureName);
                 if (cls != null)
                 {
                     grdProperties.Rows.Clear();

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerSettingsSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerSettingsSectionCtrl.cs	2012-05-22 14:20:34 UTC (rev 6679)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerSettingsSectionCtrl.cs	2012-05-22 14:56:41 UTC (rev 6680)
@@ -35,6 +35,10 @@
 
 namespace Maestro.Editors.LayerDefinition.Raster
 {
+    //NOTE: Unlike the Vector Layer editor, we have to do a full schema walk here because
+    //we need to filter out non-raster feature classes, something that the existing GetSchemas()
+    //and GetClassNames() cannot do for us.
+    
     [ToolboxItem(false)]
     internal partial class RasterLayerSettingsSectionCtrl : EditorBindableCollapsiblePanel
     {

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs	2012-05-22 14:20:34 UTC (rev 6679)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs	2012-05-22 14:56:41 UTC (rev 6680)
@@ -420,6 +420,10 @@
                             // 4. Infer the supported geometry types for this feature class. Toggle supported styles accordingly.
 
                             //Step 1: Describe the schema
+                            //
+                            //NOTE: I think we can get away with the full schema walk here. It's very unlikely we will be uploading a flat
+                            //file with hundreds of classes. Even then, flat-file schema walk performance blows RDBMS walking performance
+                            //out of the water anyway.
                             FeatureSourceDescription desc = this.Parent.FeatureService.DescribeFeatureSource(fsId);
 
                             //Step 2: Find the first feature class with a geometry property
@@ -735,6 +739,10 @@
                                 // 4. Infer the supported geometry types for this feature class. Toggle supported styles accordingly.
 
                                 //Step 1: Describe the schema
+                                //
+                                //NOTE: I think we can get away with the full schema walk here. It's very unlikely we will be uploading a flat
+                                //file with hundreds of classes. Even then, flat-file schema walk performance blows RDBMS walking performance
+                                //out of the water anyway.
                                 FeatureSourceDescription desc = this.Parent.FeatureService.DescribeFeatureSource(fsId);
 
                                 if (desc.HasClasses())

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSourceInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSourceInterfaces.cs	2012-05-22 14:20:34 UTC (rev 6679)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSourceInterfaces.cs	2012-05-22 14:56:41 UTC (rev 6680)
@@ -474,6 +474,11 @@
         /// <summary>
         /// Convenience method to return the description of this feature source
         /// </summary>
+        /// <remarks>
+        /// If you only need to list schemas and class names, use the respective <see cref="M:OSGeo.MapGuide.MaestroAPI.Services.IFeatureService.GetSchemas" /> and
+        /// <see cref="M:OSGeo.MapGuide.MaestroAPI.Services.IFeatureService.GetClassNames" /> methods. Using this API will have a noticeable performance impact on 
+        /// really large datastores (whose size is in the 100s of classes).
+        /// </remarks>
         /// <returns></returns>
         public static FeatureSourceDescription Describe(this IFeatureSource fs)
         {

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs	2012-05-22 14:20:34 UTC (rev 6679)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs	2012-05-22 14:56:41 UTC (rev 6680)
@@ -104,43 +104,34 @@
                         bool foundSchema = false;
                         bool foundGeometry = false;
 
-                        FeatureSourceDescription desc = context.DescribeFeatureSource(ldef.SubLayer.ResourceId);
-                        foreach (FeatureSchema fsc in desc.Schemas)
+                        cls = fs.GetClass(qualClassName);
+                        if (cls != null)
                         {
-                            foreach (ClassDefinition scm in fsc.Classes)
+                            foundSchema = true;
+                            foreach (PropertyDefinition col in cls.Properties)
                             {
-                                if (scm.QualifiedName == qualClassName)
+                                if (col.Name == geometry)
                                 {
-                                    foundSchema = true;
-                                    cls = scm;
-                                    foreach (PropertyDefinition col in scm.Properties)
+                                    foundGeometry = true;
+                                    break;
+                                }
+                            }
+
+                            if (vldef != null && vldef.PropertyMapping != null)
+                            {
+                                foreach (INameStringPair s in vldef.PropertyMapping)
+                                {
+                                    bool found = false;
+                                    foreach (PropertyDefinition col in cls.Properties)
                                     {
-                                        if (col.Name == geometry)
+                                        if (col.Name == s.Name)
                                         {
-                                            foundGeometry = true;
+                                            found = true;
                                             break;
                                         }
                                     }
-
-                                    if (vldef != null && vldef.PropertyMapping != null)
-                                    {
-                                        foreach (INameStringPair s in vldef.PropertyMapping)
-                                        {
-                                            bool found = false;
-                                            foreach (PropertyDefinition col in scm.Properties)
-                                            {
-                                                if (col.Name == s.Name)
-                                                {
-                                                    found = true;
-                                                    break;
-                                                }
-                                            }
-                                            if (!found)
-                                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_ClassNotFound, string.Format(Properties.Resources.LDF_SchemaMissingError, qualClassName, fs.ResourceID)));
-                                        }
-                                    }
-
-                                    break;
+                                    if (!found)
+                                        issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_ClassNotFound, string.Format(Properties.Resources.LDF_SchemaMissingError, qualClassName, fs.ResourceID)));
                                 }
                             }
                         }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs	2012-05-22 14:20:34 UTC (rev 6679)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs	2012-05-22 14:56:41 UTC (rev 6680)
@@ -20,12 +20,14 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Exceptions;
 using OSGeo.MapGuide.MaestroAPI.Resource;
-using OSGeo.MapGuide.MaestroAPI.Exceptions;
-using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Schema;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.ObjectModels.Common;
 using OSGeo.MapGuide.ObjectModels.FeatureSource;
-using OSGeo.MapGuide.ObjectModels.Common;
-using OSGeo.MapGuide.MaestroAPI.Schema;
 
 namespace OSGeo.MapGuide.MaestroAPI.Resource.Validation
 {
@@ -55,8 +57,9 @@
             List<ValidationIssue> issues = new List<ValidationIssue>();
 
             IFeatureSource feature = (IFeatureSource)resource;
+            IFeatureService featSvc = feature.CurrentConnection.FeatureService;
             //Note: Must be saved!
-            string s = feature.CurrentConnection.FeatureService.TestConnection(feature.ResourceID);
+            string s = featSvc.TestConnection(feature.ResourceID);
             if (s.Trim().ToUpper() != true.ToString().ToUpper())
                 return new ValidationIssue[] { new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_ConnectionTestFailed, string.Format(Properties.Resources.FS_ConnectionTestFailed, s)) };
 
@@ -80,12 +83,10 @@
             }
 
             List<string> classes = new List<string>();
-            FeatureSourceDescription fsd = null;
             try
             {
-                //FIXME: Can we do this without a full schema walk? Really large schemas will timeout
-                fsd = context.DescribeFeatureSource(feature.ResourceID);
-                if (fsd == null || fsd.Schemas.Length == 0)
+                var schemaNames = featSvc.GetSchemas(feature.ResourceID);
+                if (schemaNames.Length == 0)
                     issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_NoSchemasFound, Properties.Resources.FS_SchemasMissingWarning));
             }
             catch (Exception ex)
@@ -103,14 +104,23 @@
                 }
             }
 
-            if (fsd != null)
+            var classNames = featSvc.GetClassNames(feature.ResourceID, null);
+            foreach (var className in classNames)
             {
-                foreach (var cl in fsd.AllClasses)
+                try 
                 {
-                    var ids = cl.IdentityProperties;
-                    if (ids.Count == 0)
-                        issues.Add(new ValidationIssue(feature, ValidationStatus.Information, ValidationStatusCode.Info_FeatureSource_NoPrimaryKey, string.Format(Properties.Resources.FS_PrimaryKeyMissingInformation, cl.QualifiedName)));
+                    string[] idProps = featSvc.GetIdentityProperties(feature.ResourceID, className);
+                    if (idProps.Length == 0)
+                        issues.Add(new ValidationIssue(feature, ValidationStatus.Information, ValidationStatusCode.Info_FeatureSource_NoPrimaryKey, string.Format(Properties.Resources.FS_PrimaryKeyMissingInformation, className)));
                 }
+                catch (Exception ex)
+                {
+                    string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
+                    if (msg.Contains("MgClassNotFound")) //#1403 workaround
+                        issues.Add(new ValidationIssue(feature, ValidationStatus.Information, ValidationStatusCode.Info_FeatureSource_NoPrimaryKey, string.Format(Properties.Resources.FS_PrimaryKeyMissingInformation, className)));
+                    else
+                        issues.Add(new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_SchemaReadError, string.Format(Properties.Resources.FS_SchemaReadError, msg)));
+                }
             }
             context.MarkValidated(resource.ResourceID);
 



More information about the mapguide-commits mailing list