[mapguide-commits] r5473 - in sandbox/maestro-3.0: Maestro.Base/Commands/SiteExplorer Maestro.Base/Editor Maestro.Editors/Fusion OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/ObjectModels OSGeo.MapGuide.MaestroAPI/Resource OSGeo.MapGuide.MaestroAPI/Resource/Validation

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Dec 13 06:38:21 EST 2010


Author: jng
Date: 2010-12-13 03:38:21 -0800 (Mon, 13 Dec 2010)
New Revision: 5473

Modified:
   sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/ValidateCommand.cs
   sandbox/maestro-3.0/Maestro.Base/Editor/EditorContentBase.cs
   sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetReferenceCtrl.cs
   sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.Designer.cs
   sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.cs
   sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.resx
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinitionInterfaces.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/IResourceValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ApplicationDefinitionValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLoadProcedureValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseWebLayoutValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/DrawingSourceValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/MapDefinitionValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/PrintLayoutValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ResourceValidatorSet.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/SymbolDefinitionValidator.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/SymbolLibraryValidator.cs
Log:
3.0 sandbox changes:
 - #1566: Implement a ResourceValidationContext class which helps skip validation of already validated resources. It also provides caching of common items (schema, spatial context, resources) to avoid redundant lookups. Should considerably improve validation performance for large sets of resources.
 - More implementation of the Fusion Editor. The only remaining items to implement are:
    - Adding new containers
    - Editing containers
    - Removing containers
    - Adding new widgets to the widget set
    - Configuring widgets in the widget set

Modified: sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/ValidateCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/ValidateCommand.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/ValidateCommand.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -122,6 +122,7 @@
             }
 
             worker.ReportProgress(0);
+            var context = new ResourceValidationContext(_conn.ResourceService, _conn.FeatureService);
 
             var set = new ValidationResultSet();
             int i = 0;
@@ -134,7 +135,7 @@
                     //TODO: This will validate resources multiple times, if they are referenced by
                     //resources inside the folder
                     item = _conn.ResourceService.GetResource(s);
-                    set.AddIssues(ResourceValidatorSet.Validate(item, true));
+                    set.AddIssues(ResourceValidatorSet.Validate(context, item, true));
                 }
                 catch (Exception ex)
                 {

Modified: sandbox/maestro-3.0/Maestro.Base/Editor/EditorContentBase.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Editor/EditorContentBase.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/Maestro.Base/Editor/EditorContentBase.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -132,8 +132,9 @@
         /// </summary>
         protected virtual ICollection<ValidationIssue> ValidateEditedResource() 
         {
+            var context = new ResourceValidationContext(_svc.ResourceService, _svc.FeatureService);
             //Don't recurse as we only want to validate the current resource
-            var issues = ResourceValidatorSet.Validate(this.Resource, false);
+            var issues = ResourceValidatorSet.Validate(context, this.Resource, false);
             var set = new ValidationResultSet(issues);
 
             var errors = set.GetIssuesForResource(this.Resource.ResourceID, ValidationStatus.Error);

Modified: sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetReferenceCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetReferenceCtrl.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetReferenceCtrl.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -37,6 +37,7 @@
 
         private IWidgetItem _widgetRef;
         private IApplicationDefinition _flexLayout;
+        private bool _init = true;
 
         public WidgetReferenceCtrl(IWidgetItem item, IEditorService edsvc)
             : this()
@@ -46,10 +47,14 @@
             cmbWidgetRefs.DataSource = _flexLayout.GetAllReferenceableWidgetNames();
 
             cmbWidgetRefs.SelectedItem = item.Widget;
+            _init = false;
         }
 
         private void cmbWidgetRefs_SelectedIndexChanged(object sender, EventArgs e)
         {
+            if (_init)
+                return;
+
             if (cmbWidgetRefs.SelectedItem != null)
             {
                 _widgetRef.Widget = cmbWidgetRefs.SelectedItem.ToString();

Modified: sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.Designer.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.Designer.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -70,6 +70,7 @@
             resources.ApplyResources(this.trvWidgets, "trvWidgets");
             this.trvWidgets.ImageList = this.widgetImageList;
             this.trvWidgets.Name = "trvWidgets";
+            this.trvWidgets.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.trvWidgets_AfterSelect);
             // 
             // widgetImageList
             // 
@@ -132,6 +133,7 @@
             this.btnAddContainer.Image = global::Maestro.Editors.Properties.Resources.application__plus;
             resources.ApplyResources(this.btnAddContainer, "btnAddContainer");
             this.btnAddContainer.Name = "btnAddContainer";
+            this.btnAddContainer.Click += new System.EventHandler(this.btnAddContainer_Click);
             // 
             // btnRemoveWidget
             // 
@@ -182,10 +184,10 @@
             // 
             // WidgetSettingsCtrl
             // 
-            resources.ApplyResources(this, "$this");
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
             this.HeaderText = "Widgets";
             this.Name = "WidgetSettingsCtrl";
+            resources.ApplyResources(this, "$this");
             this.contentPanel.ResumeLayout(false);
             this.groupBox1.ResumeLayout(false);
             this.groupBox1.PerformLayout();

Modified: sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -47,12 +47,14 @@
         private IFusionService _fsvc;
         private IApplicationDefinition _flexLayout;
         private string _baseUrl;
+        private IEditorService _edsvc;
 
         public override void Bind(IEditorService service)
         {
             try
             {
-                _fsvc = (IFusionService)service.GetService((int)ServiceType.Fusion);
+                _edsvc = service;
+                _fsvc = (IFusionService)_edsvc.GetService((int)ServiceType.Fusion);
                 _baseUrl = service.GetCustomProperty("BaseUrl").ToString();
 
                 if (!_baseUrl.EndsWith("/"))
@@ -162,7 +164,7 @@
             }
         }
 
-        private static TreeNode CreateNode(IUIItem item)
+        private TreeNode CreateNode(IUIItem item)
         {
             Check.NotNull(item, "item");
             var node = new TreeNode();
@@ -173,6 +175,15 @@
                         node.ImageIndex = node.SelectedImageIndex = IDX_MENU;
                         node.Text = ((IFlyoutItem)item).Label;
                         node.Tag = item;
+
+                        item.PropertyChanged += (s, evt) =>
+                        {
+                            if (evt.PropertyName == "Label")
+                            {
+                                node.Text = ((IFlyoutItem)item).Label;
+                                OnResourceChanged();
+                            }
+                        };
                     }
                     break;
                 case UiItemFunctionType.Separator:
@@ -187,6 +198,15 @@
                         node.ImageIndex = node.SelectedImageIndex = IDX_WIDGET;
                         node.Text = ((IWidgetItem)item).Widget;
                         node.Tag = item;
+
+                        item.PropertyChanged += (s, evt) =>
+                        {
+                            if (evt.PropertyName == "Widget")
+                            {
+                                node.Text = ((IWidgetItem)item).Widget;
+                                OnResourceChanged();
+                            }
+                        };
                     }
                     break;
             }
@@ -216,22 +236,102 @@
 
         private void btnRemoveWidget_Click(object sender, EventArgs e)
         {
-
+            var node = trvWidgets.SelectedNode;
+            var parent = node.Parent;
+            if (parent != null)
+            {
+                var item = node.Tag as IUIItem;
+                var cnt = parent.Tag as IUIItemContainer;
+                if (cnt != null && item != null)
+                {
+                    cnt.RemoveItem(item);
+                    parent.Nodes.Remove(node);
+                    OnResourceChanged();
+                }
+            }
         }
 
         private void btnMoveUp_Click(object sender, EventArgs e)
         {
-
+            var node = trvWidgets.SelectedNode;
+            var parent = node.Parent;
+            if (parent != null)
+            {
+                var item = node.Tag as IUIItem;
+                var cnt = parent.Tag as IUIItemContainer;
+                if (cnt != null && item != null)
+                {
+                    int index = node.Index;
+                    if (index >= 0)
+                    {
+                        index--;
+                        cnt.MoveUp(item);
+                        parent.Nodes.Remove(node);
+                        parent.Nodes.Insert(index, node);
+                        trvWidgets.SelectedNode = node;
+                        OnResourceChanged();
+                    }
+                }
+            }
         }
 
         private void btnMoveDown_Click(object sender, EventArgs e)
         {
-
+            var node = trvWidgets.SelectedNode;
+            var parent = node.Parent;
+            if (parent != null)
+            {
+                var item = node.Tag as IUIItem;
+                var cnt = parent.Tag as IUIItemContainer;
+                if (cnt != null && item != null)
+                {
+                    int index = node.Index;
+                    if (index < parent.Nodes.Count - 1)
+                    {
+                        index++;
+                        cnt.MoveDown(item);
+                        parent.Nodes.Remove(node);
+                        parent.Nodes.Insert(index, node);
+                        trvWidgets.SelectedNode = node;
+                        OnResourceChanged();
+                    }
+                }
+            }
         }
 
         private void btnConfigureWidgets_Click(object sender, EventArgs e)
         {
 
         }
+
+        private void trvWidgets_AfterSelect(object sender, TreeViewEventArgs e)
+        {
+            var menu = trvWidgets.SelectedNode.Tag as IMenu;
+            var item = trvWidgets.SelectedNode.Tag as IWidgetItem;
+            propertiesPanel.Controls.Clear();
+            btnAddWidget.Enabled = false;
+            btnMoveUp.Enabled = btnMoveDown.Enabled = false;
+            btnRemoveWidget.Enabled = false;
+            if (menu != null)
+            {
+                btnAddWidget.Enabled = true;
+            }
+            else
+            {
+                btnMoveDown.Enabled = btnMoveUp.Enabled = true;
+                btnRemoveWidget.Enabled = true;
+                if (item != null)
+                {
+                    var ctrl = new WidgetReferenceCtrl(item, _edsvc);
+                    ctrl.Dock = DockStyle.Fill;
+                    propertiesPanel.Controls.Add(ctrl);
+                }
+            }
+        }
+
+        private void btnAddContainer_Click(object sender, EventArgs e)
+        {
+
+        }
     }
 }

Modified: sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.resx	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/Maestro.Editors/Fusion/WidgetSettingsCtrl.resx	2010-12-13 11:38:21 UTC (rev 5473)
@@ -164,7 +164,7 @@
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
         LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
         ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACU
-        CQAAAk1TRnQBSQFMAgEBBAEAAUABAAFAAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+        CQAAAk1TRnQBSQFMAgEBBAEAAVgBAAFYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
         AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
         AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
         AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@@ -232,26 +232,8 @@
     <value>0</value>
   </data>
   <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 17</value>
+    <value>3, 16</value>
   </metadata>
-  <data name="widgetToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
-    <value>141, 22</value>
-  </data>
-  <data name="widgetToolStripMenuItem.Text" xml:space="preserve">
-    <value>Widget</value>
-  </data>
-  <data name="separatorToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
-    <value>141, 22</value>
-  </data>
-  <data name="separatorToolStripMenuItem.Text" xml:space="preserve">
-    <value>Separator</value>
-  </data>
-  <data name="flyoutMenuToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
-    <value>141, 22</value>
-  </data>
-  <data name="flyoutMenuToolStripMenuItem.Text" xml:space="preserve">
-    <value>Flyout Menu</value>
-  </data>
   <data name="btnAddWidget.ImageTransparentColor" type="System.Drawing.Color, System.Drawing">
     <value>Magenta</value>
   </data>
@@ -280,7 +262,7 @@
     <value>23, 22</value>
   </data>
   <data name="btnRemoveWidget.Text" xml:space="preserve">
-    <value>toolStripButton2</value>
+    <value>Remove</value>
   </data>
   <data name="toolStripSeparator1.Size" type="System.Drawing.Size, System.Drawing">
     <value>6, 25</value>
@@ -295,7 +277,7 @@
     <value>23, 22</value>
   </data>
   <data name="btnMoveUp.Text" xml:space="preserve">
-    <value>toolStripButton3</value>
+    <value>Move Up</value>
   </data>
   <data name="btnMoveDown.Enabled" type="System.Boolean, mscorlib">
     <value>False</value>
@@ -307,7 +289,7 @@
     <value>23, 22</value>
   </data>
   <data name="btnMoveDown.Text" xml:space="preserve">
-    <value>toolStripButton4</value>
+    <value>Move Down</value>
   </data>
   <data name="toolStripSeparator2.Size" type="System.Drawing.Size, System.Drawing">
     <value>6, 25</value>
@@ -384,12 +366,27 @@
   <data name="&gt;&gt;contentPanel.ZOrder" xml:space="preserve">
     <value>0</value>
   </data>
+  <data name="widgetToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
+    <value>141, 22</value>
+  </data>
+  <data name="widgetToolStripMenuItem.Text" xml:space="preserve">
+    <value>Widget</value>
+  </data>
+  <data name="separatorToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
+    <value>141, 22</value>
+  </data>
+  <data name="separatorToolStripMenuItem.Text" xml:space="preserve">
+    <value>Separator</value>
+  </data>
+  <data name="flyoutMenuToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
+    <value>141, 22</value>
+  </data>
+  <data name="flyoutMenuToolStripMenuItem.Text" xml:space="preserve">
+    <value>Flyout Menu</value>
+  </data>
   <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
-    <value>6, 13</value>
-  </data>
   <data name="$this.Size" type="System.Drawing.Size, System.Drawing">
     <value>648, 319</value>
   </data>

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-12-13 11:38:21 UTC (rev 5473)
@@ -271,6 +271,7 @@
     <Compile Include="Resource\Validation\LoadProcedureValidator.cs" />
     <Compile Include="Resource\Validation\MapDefinitionValidator.cs" />
     <Compile Include="Resource\Validation\PrintLayoutValidator.cs" />
+    <Compile Include="Resource\Validation\ResourceValidationContext.cs" />
     <Compile Include="Resource\Validation\ResourceValidatorLoader.cs" />
     <Compile Include="Resource\Validation\ResourceValidatorSet.cs" />
     <Compile Include="Resource\Validation\SymbolDefinitionValidator.cs" />

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -61,9 +61,9 @@
 
             foreach (var ws in this.WidgetSets)
             {
-                foreach (var cnt in ws.Containers)
-                { 
-                    
+                foreach (var wgt in ws.Widgets)
+                {
+                    names.Add(wgt.Name);
                 }
             }
 

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinitionInterfaces.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinitionInterfaces.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinitionInterfaces.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -1164,7 +1164,7 @@
         Flyout,
     }
 
-    public interface IUIItem
+    public interface IUIItem : INotifyPropertyChanged
     {
         IMenu Parent { get; }
 

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/IResourceValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/IResourceValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/IResourceValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -23,6 +23,8 @@
 
 namespace OSGeo.MapGuide.MaestroAPI.Resource
 {
+    using Validation;
+
     /// <summary>
     /// Interface for validating specific resource types
     /// </summary>
@@ -37,10 +39,11 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        ValidationIssue[] Validate(IResource resource, bool recurse);
+        ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse);
     }
 
     /// <summary>

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ApplicationDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ApplicationDefinitionValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ApplicationDefinitionValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -38,10 +38,11 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
+        public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
             if (resource.ResourceType != OSGeo.MapGuide.MaestroAPI.ResourceTypes.ApplicationDefinition)
                 return null;
@@ -76,9 +77,9 @@
                                 }
                                 else
                                 {
-                                    IMapDefinition mdef = (IMapDefinition)fusionApp.CurrentConnection.ResourceService.GetResource(map.GetMapDefinition());
+                                    IMapDefinition mdef = (IMapDefinition)context.GetResource(map.GetMapDefinition());
 
-                                    issues.AddRange(ResourceValidatorSet.Validate(mdef, true));
+                                    issues.AddRange(ResourceValidatorSet.Validate(context, mdef, true));
 
                                     IEnvelope mapEnv = ObjectFactory.CreateEnvelope(mdef.Extents.MinX, mdef.Extents.MaxX, mdef.Extents.MinY, mdef.Extents.MaxY);
 
@@ -99,6 +100,8 @@
                 }
             }
 
+            context.MarkValidated(resource.ResourceID);
+
             return issues.ToArray();
         }
 

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -39,25 +39,32 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public virtual ValidationIssue[] Validate(IResource resource, bool recurse)
+        public virtual ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
             if (!resource.GetResourceTypeDescriptor().Equals(this.SupportedResourceAndVersion))
                 return null;
 
-            return ValidateBase(resource, recurse);
+            return ValidateBase(context, resource, recurse);
         }
 
         /// <summary>
         /// Perform base validation logic
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        protected static ValidationIssue[] ValidateBase(IResource resource, bool recurse)
+        protected static ValidationIssue[] ValidateBase(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             var ldef = resource as ILayerDefinition;
             var vldef = ldef.SubLayer as IVectorLayerDefinition;
             var gldef = ldef.SubLayer as IRasterLayerDefinition;
@@ -118,7 +125,7 @@
                 IDrawingSource dws = null;
                 try
                 {
-                    dws = (IDrawingSource)ldef.CurrentConnection.ResourceService.GetResource(dldef.ResourceId);
+                    dws = (IDrawingSource)context.GetResource(dldef.ResourceId);
                 }
                 catch (Exception)
                 {
@@ -186,8 +193,8 @@
 
                     try
                     {
-                        fs = (IFeatureSource)ldef.CurrentConnection.ResourceService.GetResource(ldef.SubLayer.ResourceId);
-                        issues.AddRange(ResourceValidatorSet.Validate(fs, recurse));
+                        fs = (IFeatureSource)context.GetResource(ldef.SubLayer.ResourceId);
+                        issues.AddRange(ResourceValidatorSet.Validate(context, fs, recurse));
                     }
                     catch (Exception)
                     {
@@ -205,7 +212,7 @@
                             bool foundSchema = false;
                             bool foundGeometry = false;
 
-                            FeatureSourceDescription desc = fs.Describe();
+                            FeatureSourceDescription desc = context.DescribeFeatureSource(ldef.SubLayer.ResourceId);
                             foreach (ClassDefinition scm in desc.Classes)
                             {
                                 if (scm.QualifiedNameDecoded == schema)
@@ -256,6 +263,8 @@
                 }
             }
 
+            context.MarkValidated(resource.ResourceID);
+
             return issues.ToArray();
         }
 

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLoadProcedureValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLoadProcedureValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLoadProcedureValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -21,25 +21,32 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public virtual ValidationIssue[] Validate(IResource resource, bool recurse)
+        public virtual ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
             if (!resource.GetResourceTypeDescriptor().Equals(this.SupportedResourceAndVersion))
                 return null;
 
-            return ValidateBase(resource, recurse);
+            return ValidateBase(context, resource, recurse);
         }
 
         /// <summary>
         /// Performs base validation logic
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        protected static ValidationIssue[] ValidateBase(IResource resource, bool recurse)
+        protected static ValidationIssue[] ValidateBase(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             if (resource.ResourceType != OSGeo.MapGuide.MaestroAPI.ResourceTypes.LoadProcedure)
                 return null;
 
@@ -91,6 +98,8 @@
                 }
             }
 
+            context.MarkValidated(resource.ResourceID);
+
             return set.GetAllIssues();
         }
     }

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseWebLayoutValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseWebLayoutValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseWebLayoutValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -28,25 +28,32 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public virtual ValidationIssue[] Validate(IResource resource, bool recurse)
+        public virtual ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
             if (!resource.GetResourceTypeDescriptor().Equals(this.SupportedResourceAndVersion))
                 return null;
 
-            return ValidateBase(resource, recurse);
+            return ValidateBase(context, resource, recurse);
         }
 
         /// <summary>
         /// Performs base validation logic
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        protected static ValidationIssue[] ValidateBase(IResource resource, bool recurse)
+        protected static ValidationIssue[] ValidateBase(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             if (resource.ResourceType != OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout)
                 return null;
 
@@ -122,9 +129,9 @@
                 {
                     try
                     {
-                        IMapDefinition mdef = (IMapDefinition)layout.CurrentConnection.ResourceService.GetResource(layout.Map.ResourceId);
+                        IMapDefinition mdef = (IMapDefinition)context.GetResource(layout.Map.ResourceId);
 
-                        issues.AddRange(ResourceValidatorSet.Validate(mdef, true));
+                        issues.AddRange(ResourceValidatorSet.Validate(context, mdef, true));
 
                         if (layout.Map.InitialView != null)
                         {
@@ -142,6 +149,8 @@
                 }
             }
 
+            context.MarkValidated(resource.ResourceID);
+
             return issues.ToArray();
         }
     }

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/DrawingSourceValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/DrawingSourceValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/DrawingSourceValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -35,11 +35,17 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
+        public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             if (resource.ResourceType != ResourceTypes.DrawingSource)
                 return null;
 
@@ -52,6 +58,8 @@
             if (string.IsNullOrEmpty(dws.CoordinateSpace))
                 issues.Add(new ValidationIssue(resource, ValidationStatus.Information, Properties.Resources.DS_NoCoordinateSpace));
 
+            context.MarkValidated(resource.ResourceID);
+
             return issues.ToArray();
         }
 

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -37,11 +37,17 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
+        public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             if (resource.ResourceType != ResourceTypes.FeatureSource)
                 return null;
 
@@ -56,7 +62,7 @@
             try
             {
                 System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.InvariantCulture;
-                FdoSpatialContextList lst = feature.GetSpatialInfo(false);
+                FdoSpatialContextList lst = context.GetSpatialContexts(feature.ResourceID);
                 if (lst == null || lst.SpatialContext == null || lst.SpatialContext.Count == 0)
                     issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, Properties.Resources.FS_NoSpatialContextWarning));
                 else
@@ -76,7 +82,7 @@
             FeatureSourceDescription fsd = null;
             try
             {
-                fsd = feature.Describe();
+                fsd = context.DescribeFeatureSource(feature.ResourceID);
                 if (fsd == null || fsd.Classes == null || fsd.Classes.Length == 0)
                     issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, Properties.Resources.FS_SchemasMissingWarning));
             }
@@ -94,6 +100,8 @@
                     issues.Add(new ValidationIssue(feature, ValidationStatus.Information, string.Format(Properties.Resources.FS_PrimaryKeyMissingInformation, cl)));
             }
 
+            context.MarkValidated(resource.ResourceID);
+
             return issues.ToArray();
         }
 

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/MapDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/MapDefinitionValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/MapDefinitionValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -40,11 +40,17 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
+        public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             if (resource.ResourceType != ResourceTypes.MapDefinition)
                 return null;
 
@@ -68,7 +74,7 @@
                         layers.Add(l);
 
             Dictionary<string, IBaseMapLayer> nameCounter = new Dictionary<string, IBaseMapLayer>();
-
+            
             foreach (IBaseMapLayer l in layers)
             {
                 if (nameCounter.ContainsKey(l.Name))
@@ -86,16 +92,16 @@
                     try
                     {
                         ILayerDefinition layer = null;
-                        IResource res = mdef.CurrentConnection.ResourceService.GetResource(l.ResourceId);
+                        IResource res = context.GetResource(l.ResourceId);
                         if (!ResourceValidatorSet.HasValidator(res.ResourceType, res.ResourceVersion))
                         {
                             //Need to trap the no registered validator message
-                            issues.AddRange(ResourceValidatorSet.Validate(res, true));
+                            issues.AddRange(ResourceValidatorSet.Validate(context, res, true));
                             continue;
                         }
 
                         layer = (ILayerDefinition)res;
-                        issues.AddRange(ResourceValidatorSet.Validate(layer, true));
+                        issues.AddRange(ResourceValidatorSet.Validate(context, layer, true));
 
                         IVectorLayerDefinition vl = null;
                         if (layer.SubLayer.LayerType == LayerType.Vector)
@@ -105,25 +111,26 @@
                         {
                             try
                             {
-                                IFeatureSource fs = (IFeatureSource)layer.CurrentConnection.ResourceService.GetResource(vl.ResourceId);
+                                IFeatureSource fs = (IFeatureSource)context.GetResource(vl.ResourceId);
                                 //The layer recurses on the FeatureSource
                                 //issues.AddRange(Validation.Validate(fs, true));
 
                                 try
                                 {
-                                    FdoSpatialContextList context = fs.GetSpatialInfo(false);
-                                    if (context.SpatialContext == null || context.SpatialContext.Count == 0)
+                                    FdoSpatialContextList scList = context.GetSpatialContexts(fs.ResourceID);
+
+                                    if (scList.SpatialContext == null || scList.SpatialContext.Count == 0)
                                         issues.Add(new ValidationIssue(fs, ValidationStatus.Warning, string.Format(Properties.Resources.MDF_MissingSpatialContextWarning, fs.ResourceID)));
                                     else
                                     {
-                                        if (context.SpatialContext.Count > 1)
+                                        if (scList.SpatialContext.Count > 1)
                                             issues.Add(new ValidationIssue(fs, ValidationStatus.Information, string.Format(Properties.Resources.MDF_MultipleSpatialContextsInformation, fs.ResourceID)));
 
 
                                         bool skipGeomCheck = false;
 
                                         //TODO: Switch to the correct version (2.1), once released
-                                        if (context.SpatialContext[0].CoordinateSystemWkt != mdef.CoordinateSystem)
+                                        if (scList.SpatialContext[0].CoordinateSystemWkt != mdef.CoordinateSystem)
                                         {
                                             if (layer.SubLayer.LayerType == LayerType.Raster && mdef.CurrentConnection.SiteVersion <= SiteVersions.GetVersion(OSGeo.MapGuide.MaestroAPI.KnownSiteVersions.MapGuideOS2_0_2))
                                                 issues.Add(new ValidationIssue(fs, ValidationStatus.Error, string.Format(Properties.Resources.MDF_RasterReprojectionError, fs.ResourceID)));
@@ -163,6 +170,8 @@
                 }
             }
 
+            context.MarkValidated(resource.ResourceID);
+
             return issues.ToArray();
         }
 

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/PrintLayoutValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/PrintLayoutValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/PrintLayoutValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -44,16 +44,24 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
+        public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             if (resource.ResourceType != ResourceTypes.PrintLayout)
                 return null;
 
             //TODO: What problems could there possibly be?
 
+            context.MarkValidated(resource.ResourceID);
+
             return new ValidationIssue[0];
         }
     }

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ResourceValidatorSet.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ResourceValidatorSet.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ResourceValidatorSet.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -49,28 +49,28 @@
         /// <param name="items">The items.</param>
         /// <param name="recurse">if set to <c>true</c> [recurse].</param>
         /// <returns></returns>
-        public static ValidationIssue[] Validate(IEnumerable<IResource> items, bool recurse)
+        public static ValidationIssue[] Validate(ResourceValidationContext context, IEnumerable<IResource> items, bool recurse)
         {
             Check.NotNull(items, "items");
-
             var issues = new List<ValidationIssue>();
             foreach (var item in items)
             {
-                issues.AddRange(Validate(item, true));
+                issues.AddRange(Validate(context, item, true));
             }
             return issues.ToArray();
         }
 
         /// <summary>
-        /// Validates the specified item.
+        /// Validates the specified item using an existing validation context to skip over
+        /// items already validated
         /// </summary>
-        /// <param name="item">The item.</param>
-        /// <param name="recurse">if set to <c>true</c> [recurse].</param>
+        /// <param name="context"></param>
+        /// <param name="item"></param>
+        /// <param name="recurse"></param>
         /// <returns></returns>
-        public static ValidationIssue[] Validate(IResource item, bool recurse)
+        public static ValidationIssue[] Validate(ResourceValidationContext context, IResource item, bool recurse)
         {
             Check.NotNull(item, "item");
-
             var issueSet = new ValidationResultSet();
             if (!HasValidator(item.ResourceType, item.ResourceVersion))
             {
@@ -80,9 +80,12 @@
             {
                 foreach (IResourceValidator v in m_validators)
                 {
+                    if (!v.SupportedResourceAndVersion.Equals(item.GetResourceTypeDescriptor()))
+                        continue;
+
                     try
                     {
-                        ValidationIssue[] tmp = v.Validate(item, recurse);
+                        ValidationIssue[] tmp = v.Validate(context, item, recurse);
                         if (tmp != null)
                             issueSet.AddIssues(tmp);
                     }

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/SymbolDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/SymbolDefinitionValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/SymbolDefinitionValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -43,16 +43,24 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
+        public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             if (resource.ResourceType != ResourceTypes.SymbolDefinition)
                 return null;
 
             //TODO: What problems could there possibly be?
 
+            context.MarkValidated(resource.ResourceID);
+
             return new ValidationIssue[0];
         }
     }

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/SymbolLibraryValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/SymbolLibraryValidator.cs	2010-12-11 09:39:24 UTC (rev 5472)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/Validation/SymbolLibraryValidator.cs	2010-12-13 11:38:21 UTC (rev 5473)
@@ -43,16 +43,24 @@
         /// Validats the specified resources for common issues associated with this
         /// resource type
         /// </summary>
+        /// <param name="context"></param>
         /// <param name="resource"></param>
         /// <param name="recurse"></param>
         /// <returns></returns>
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
+        public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
         {
+            Check.NotNull(context, "context");
+
+            if (context.IsAlreadyValidated(resource.ResourceID))
+                return null;
+
             if (resource.ResourceType != ResourceTypes.SymbolLibrary)
                 return null;
 
             //TODO: What problems could there possibly be?
 
+            context.MarkValidated(resource.ResourceID);
+
             return new ValidationIssue[0];
         }
     }



More information about the mapguide-commits mailing list