[mapguide-commits] r5252 - in sandbox/maestro-3.0:
Maestro.ResourceValidation Maestro.ResourceValidation/Properties
OSGeo.MapGuide.MaestroAPI/Feature
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Oct 6 23:35:11 EDT 2010
Author: jng
Date: 2010-10-07 03:35:11 +0000 (Thu, 07 Oct 2010)
New Revision: 5252
Modified:
sandbox/maestro-3.0/Maestro.ResourceValidation/FeatureSourceValidator.cs
sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.Designer.cs
sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.resx
sandbox/maestro-3.0/Maestro.ResourceValidation/WebLayoutValidator.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSetReader.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSourceDescription.cs
Log:
Forward-port r5251 changes to 3.0 sandbox
Modified: sandbox/maestro-3.0/Maestro.ResourceValidation/FeatureSourceValidator.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.ResourceValidation/FeatureSourceValidator.cs 2010-10-07 03:06:34 UTC (rev 5251)
+++ sandbox/maestro-3.0/Maestro.ResourceValidation/FeatureSourceValidator.cs 2010-10-07 03:35:11 UTC (rev 5252)
@@ -63,14 +63,12 @@
}
List<string> classes = new List<string>();
+ FeatureSourceDescription fsd = null;
try
{
- FeatureSourceDescription fsd = feature.Describe();
+ fsd = feature.Describe();
if (fsd == null || fsd.Schemas == null || fsd.Schemas.Length == 0)
issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, Properties.Resources.FS_SchemasMissingWarning));
- else
- foreach (FeatureSourceDescription.FeatureSourceSchema scm in fsd.Schemas)
- classes.Add(scm.FullnameDecoded);
}
catch (Exception ex)
{
@@ -79,23 +77,11 @@
}
- foreach (string cl in classes)
+ foreach (var cl in fsd.Schemas)
{
- try
- {
- string[] ids = feature.GetIdentityProperties(cl);
- //According to my tests, this code path never gets reached because the
- //MG server will incorrectly throw MgClassNotFoundException when querying
- //a class with no identity properties. Nevertheless we'll leave this in, if/when
- //this logic is fixed server-side.
- if (ids == null || ids.Length == 0)
- issues.Add(new ValidationIssue(feature, ValidationStatus.Information, string.Format(Properties.Resources.FS_PrimaryKeyMissingInformation, cl)));
- }
- catch (Exception ex)
- {
- string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
- issues.Add(new ValidationIssue(feature, ValidationStatus.Error, string.Format(Properties.Resources.FS_PrimaryKeyReadError, msg)));
- }
+ string[] ids = cl.GetIdentityProperties();
+ if (ids == null || ids.Length == 0)
+ issues.Add(new ValidationIssue(feature, ValidationStatus.Information, string.Format(Properties.Resources.FS_PrimaryKeyMissingInformation, cl)));
}
return issues.ToArray();
Modified: sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.Designer.cs 2010-10-07 03:06:34 UTC (rev 5251)
+++ sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.Designer.cs 2010-10-07 03:35:11 UTC (rev 5252)
@@ -511,6 +511,24 @@
}
/// <summary>
+ /// Looks up a localized string similar to There web layout has more than one command named: {0}.
+ /// </summary>
+ internal static string WL_DuplicateCommandName {
+ get {
+ return ResourceManager.GetString("WL_DuplicateCommandName", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The search command {0} references more than one property named {1}.
+ /// </summary>
+ internal static string WL_DuplicateSearchResultColumn {
+ get {
+ return ResourceManager.GetString("WL_DuplicateSearchResultColumn", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Error validating MapDefinition {0}, message: {1}.
/// </summary>
internal static string WL_MapValidationError {
Modified: sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.resx 2010-10-07 03:06:34 UTC (rev 5251)
+++ sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.resx 2010-10-07 03:35:11 UTC (rev 5252)
@@ -317,6 +317,12 @@
<value>Layer {0} is a type that is unsupported by Maestro</value>
<comment>A warning message that is displayed if a layer has a type that is not supported by Maestro</comment>
</data>
+ <data name="WL_DuplicateCommandName" xml:space="preserve">
+ <value>There web layout has more than one command named: {0}</value>
+ </data>
+ <data name="WL_DuplicateSearchResultColumn" xml:space="preserve">
+ <value>The search command {0} references more than one property named {1}</value>
+ </data>
<data name="WL_MapValidationError" xml:space="preserve">
<value>Error validating MapDefinition {0}, message: {1}</value>
<comment>An error message that is displayed if the map validation fails</comment>
Modified: sandbox/maestro-3.0/Maestro.ResourceValidation/WebLayoutValidator.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.ResourceValidation/WebLayoutValidator.cs 2010-10-07 03:06:34 UTC (rev 5251)
+++ sandbox/maestro-3.0/Maestro.ResourceValidation/WebLayoutValidator.cs 2010-10-07 03:35:11 UTC (rev 5252)
@@ -39,9 +39,39 @@
WebLayoutType layout = resource as WebLayoutType;
if (layout.Map == null || layout.Map.ResourceId == null)
+ {
issues.Add(new ValidationIssue(layout, ValidationStatus.Error, string.Format(Properties.Resources.WL_MissingMapError)));
+ }
else
{
+ //Check for duplicate command names
+ var cmdSet = layout.CommandSet;
+ Dictionary<string, CommandType> cmds = new Dictionary<string, CommandType>();
+ foreach (CommandType cmd in cmdSet)
+ {
+ if (cmds.ContainsKey(cmd.Name))
+ issues.Add(new ValidationIssue(layout, ValidationStatus.Error, string.Format(Properties.Resources.WL_DuplicateCommandName, cmd.Name)));
+ else
+ cmds[cmd.Name] = cmd;
+ }
+
+ //Check for duplicate property references in search commands
+ foreach (CommandType cmd in cmdSet)
+ {
+ if (cmd is SearchCommandType)
+ {
+ SearchCommandType search = (SearchCommandType)cmd;
+ Dictionary<string, string> resColProps = new Dictionary<string, string>();
+ foreach (ResultColumnType resCol in search.ResultColumns)
+ {
+ if (resColProps.ContainsKey(resCol.Property))
+ issues.Add(new ValidationIssue(layout, ValidationStatus.Error, string.Format(Properties.Resources.WL_DuplicateSearchResultColumn, search.Name, resCol.Property)));
+ else
+ resColProps.Add(resCol.Property, resCol.Property);
+ }
+ }
+ }
+
if (recurse)
{
try
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSetReader.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSetReader.cs 2010-10-07 03:06:34 UTC (rev 5251)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSetReader.cs 2010-10-07 03:35:11 UTC (rev 5252)
@@ -279,6 +279,7 @@
public string Name { get { return m_name; } }
public Type Type { get { return m_type; } }
+ public bool IsIdentity { get; internal set; }
public System.Collections.ICollection MetadataKeys { get { return m_metadata.Keys; } }
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSourceDescription.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSourceDescription.cs 2010-10-07 03:06:34 UTC (rev 5251)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSourceDescription.cs 2010-10-07 03:35:11 UTC (rev 5252)
@@ -19,6 +19,7 @@
#endregion
using System;
using System.Xml;
+using System.Collections.Generic;
namespace OSGeo.MapGuide.MaestroAPI
{
@@ -57,10 +58,41 @@
mgr.AddNamespace("gml", "http://www.opengis.net/gml");
mgr.AddNamespace("fdo", "http://fdo.osgeo.org/schemas");
- XmlNodeList lst = root.SelectNodes("xs:schema/xs:complexType[@abstract='false']", mgr);
- m_schemas = new FeatureSourceSchema[lst.Count];
+ var keys = new Dictionary<string, string[]>();
+ var classMap = new Dictionary<string, FeatureSourceSchema>();
+ XmlNodeList lst = root.SelectNodes("xs:schema/xs:complexType[@abstract='false']", mgr);
+ m_schemas = new FeatureSourceSchema[lst.Count];
for (int i = 0; i < m_schemas.Length; i++)
- m_schemas[i] = new FeatureSourceSchema(lst[i], mgr);
+ {
+ m_schemas[i] = new FeatureSourceSchema(lst[i], mgr);
+ classMap.Add(m_schemas[i].FullnameDecoded, m_schemas[i]);
+ }
+ XmlNodeList keyNodes = root.SelectNodes("xs:schema/xs:element[@abstract='false']", mgr);
+ foreach (XmlNode keyNode in keyNodes)
+ {
+ var typeAttr = keyNode.Attributes["type"];
+ if (typeAttr != null)
+ {
+ string clsName = typeAttr.Value.Substring(0, typeAttr.Value.Length - 4); //class name is suffixed with type
+ if (classMap.ContainsKey(clsName))
+ {
+ List<string> keyFieldNames = new List<string>();
+
+ var cls = classMap[clsName];
+ XmlNodeList keyFields = keyNode.SelectNodes("xs:key/xs:field", mgr);
+ foreach (XmlNode keyField in keyFields)
+ {
+ var xpathAttr = keyField.Attributes["xpath"];
+ if (xpathAttr != null)
+ {
+ keyFieldNames.Add(xpathAttr.Value);
+ }
+ }
+
+ cls.MarkIdentityProperties(keyFieldNames);
+ }
+ }
+ }
}
public FeatureSourceSchema[] Schemas { get { return m_schemas; } }
@@ -140,6 +172,31 @@
{
return this.FullnameDecoded;
}
+
+ internal void MarkIdentityProperties(IEnumerable<string> keyFieldNames)
+ {
+ foreach (var name in keyFieldNames)
+ {
+ foreach (var col in m_columns)
+ {
+ if (col.Name.Equals(name))
+ {
+ col.IsIdentity = true;
+ }
+ }
+ }
+ }
+
+ public string[] GetIdentityProperties()
+ {
+ List<string> keys = new List<string>();
+ foreach (var col in m_columns)
+ {
+ if (col.IsIdentity)
+ keys.Add(col.Name);
+ }
+ return keys.ToArray();
+ }
}
}
More information about the mapguide-commits
mailing list