[mapguide-commits] r9122 - in trunk/Tools/Maestro: Maestro OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Resource/Validation OSGeo.MapGuide.MaestroAPI/Schema OSGeo.MapGuide.MaestroAPI.Tests OSGeo.MapGuide.ObjectModel.Tests OSGeo.MapGuide.ObjectModels OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_0_0 OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_1_0 OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_2_0 OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_3_0 OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_3_0 OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_4_0
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Jan 24 07:26:36 PST 2017
Author: jng
Date: 2017-01-24 07:26:36 -0800 (Tue, 24 Jan 2017)
New Revision: 9122
Modified:
trunk/Tools/Maestro/Maestro/
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Tests/ValidationTests.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Schema/GeometricPropertyDefinition.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModel.Tests/ObjectFactoryTests.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_0_0/VectorLayerDefinitionImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_1_0/VectorLayerDefinitionImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_2_0/VectorLayerDefinitionImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_3_0/VectorLayerDefinitionImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_3_0/VectorLayerDefinitionImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_4_0/VectorLayerDefinitionImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/Strings.Designer.cs
Log:
Add unit tests to cover Maestro validation for Feature Sources and Layer Definitions
Property changes on: trunk/Tools/Maestro/Maestro
___________________________________________________________________
Modified: svn:ignore
- Maestro.suo
obj
*.user
*.cache
*.suo
.vs
+ Maestro.suo
obj
*.user
*.cache
*.suo
.vs
TestResults
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseLayerDefinitionValidator.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -138,7 +138,7 @@
}
}
if (!found)
- issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_ClassNotFound, string.Format(Strings.LDF_SchemaMissingError, qualClassName, fs.ResourceID)));
+ issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_InvalidPropertyMapping, string.Format(Strings.LDF_InvalidPropertyMapping, s.Name, qualClassName)));
}
}
}
@@ -163,7 +163,7 @@
if (vldef != null)
{
if (string.IsNullOrEmpty(vldef.FeatureName))
- issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_MissingFeatureSource, Strings.LDF_MissingFeatureSourceError));
+ issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_MissingFeatureName, Strings.LDF_MissingFeatureSourceError));
if (string.IsNullOrEmpty(vldef.Geometry))
issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_MissingGeometry, Strings.LDF_MissingGeometryError));
@@ -296,6 +296,10 @@
}
else if (gldef != null)
{
+ if (string.IsNullOrEmpty(gldef.FeatureName))
+ issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_MissingFeatureName, Strings.LDF_MissingFeatureSourceError));
+ if (string.IsNullOrEmpty(gldef.Geometry))
+ issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_MissingGeometry, Strings.LDF_MissingGeometryError));
if (gldef.GridScaleRange == null || gldef.GridScaleRangeCount == 0)
issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_LayerDefinition_NoGridScaleRanges, Strings.LDF_MissingScaleRangesError));
else if (gldef.GridScaleRangeCount != 1)
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -140,6 +140,7 @@
if (providerNameUpper == "OSGEO.SQLSERVERSPATIAL" || //NOXLATE
providerNameUpper == "OSGEO.MYSQL" || //NOXLATE
providerNameUpper == "OSGEO.POSTGRESQL" || //NOXLATE
+ providerNameUpper == "OSGEO.ODBC" || //NOXLATE
providerNameUpper == "OSGEO.ARCSDE" || //NOXLATE
providerNameUpper == "OSGEO.WFS" || //NOXLATE
providerNameUpper == "OSGEO.WMS" || //NOXLATE
@@ -186,13 +187,19 @@
System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.InvariantCulture;
FdoSpatialContextList lst = context.GetSpatialContexts(feature.ResourceID);
if (lst == null || lst.SpatialContext == null || lst.SpatialContext.Count == 0)
+ {
issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_NoSpatialContext, Strings.FS_NoSpatialContextWarning));
+ }
else
+ {
foreach (FdoSpatialContextListSpatialContext c in lst.SpatialContext)
+ {
if (c.Extent == null || c.Extent.LowerLeftCoordinate == null || c.Extent.UpperRightCoordinate == null)
issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_EmptySpatialContext, Strings.FS_EmptySpatialContextWarning));
else if (double.Parse(c.Extent.LowerLeftCoordinate.X, ci) <= -1000000 && double.Parse(c.Extent.LowerLeftCoordinate.Y, ci) <= -1000000 && double.Parse(c.Extent.UpperRightCoordinate.X, ci) >= 1000000 && double.Parse(c.Extent.UpperRightCoordinate.Y, ci) >= 1000000)
issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_DefaultSpatialContext, Strings.FS_DefaultSpatialContextWarning));
+ }
+ }
}
catch (Exception ex)
{
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -418,6 +418,16 @@
Error_LayerDefinition_SymbolDefintionReferenceNotFound,
/// <summary>
+ /// The Layer Definition contains a property mapping for a non-existent property
+ /// </summary>
+ Error_LayerDefinition_InvalidPropertyMapping,
+
+ /// <summary>
+ /// The Layer Definition does not specify a class name
+ /// </summary>
+ Error_LayerDefinition_MissingFeatureName,
+
+ /// <summary>
/// Unclassified validation error
/// </summary>
Error_WebLayout_Generic = 5501,
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Schema/GeometricPropertyDefinition.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Schema/GeometricPropertyDefinition.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Schema/GeometricPropertyDefinition.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -296,8 +296,8 @@
geom.SetAttribute("hasMeasure", XmlNamespaces.FDO, this.HasMeasure.ToString().ToLower()); //NOXLATE
geom.SetAttribute("hasElevation", XmlNamespaces.FDO, this.HasElevation.ToString().ToLower()); //NOXLATE
geom.SetAttribute("srsName", XmlNamespaces.FDO, this.SpatialContextAssociation); //NOXLATE
- geom.SetAttribute("geometricTypes", XmlNamespaces.FDO, GeometricTypesToString()); //NOXLATE
- geom.SetAttribute("geometryTypes", XmlNamespaces.FDO, GeometryTypesToString()); //NOXLATE
+ geom.SetAttribute("geometricTypes", XmlNamespaces.FDO, GeometryTypesToString()); //NOXLATE
+ geom.SetAttribute("geometryTypes", XmlNamespaces.FDO, GeometricTypesToString()); //NOXLATE
geom.SetAttribute("geometryReadOnly", XmlNamespaces.FDO, this.IsReadOnly.ToString().ToLower()); //NOXLATE
//Write description node
@@ -324,7 +324,7 @@
var hev = Utility.GetFdoAttribute(node, "hasElevation"); //NOXLATE
var srs = Utility.GetFdoAttribute(node, "srsName"); //NOXLATE
- this.GeometricTypes = ProcessGeometricTypes(gt2.Value);
+ this.GeometricTypes = ProcessGeometricTypes(gt.Value);
if (gt2 != null)
this.SpecificGeometryTypes = ProcessSpecificGeometryTypes(gt2.Value);
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -1573,6 +1573,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to Layer has property mapping for non-existent property ({0}) in class ({1}).
+ /// </summary>
+ public static string LDF_InvalidPropertyMapping {
+ get {
+ return ResourceManager.GetString("LDF_InvalidPropertyMapping", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Referenced Symbol Definition {0} has an irrelevant usage context for this layer because this layer does not have features of type: {1}.
/// </summary>
public static string LDF_IrrelevantUsageContext {
@@ -1600,6 +1609,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to Layer Definition does not specify a class name.
+ /// </summary>
+ public static string LDF_MissingFeatureName {
+ get {
+ return ResourceManager.GetString("LDF_MissingFeatureName", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to No FeatureSource is assigned to the layer.
/// </summary>
public static string LDF_MissingFeatureSourceError {
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx 2017-01-24 15:26:36 UTC (rev 9122)
@@ -903,4 +903,10 @@
<data name="ODBC_IncompleteXYZColumnMapping" xml:space="preserve">
<value>Table mapping for Feature class ({0}) has an incomplete column mapping. Either the X or Y or both columns are not specified</value>
</data>
+ <data name="LDF_InvalidPropertyMapping" xml:space="preserve">
+ <value>Layer has property mapping for non-existent property ({0}) in class ({1})</value>
+ </data>
+ <data name="LDF_MissingFeatureName" xml:space="preserve">
+ <value>Layer Definition does not specify a class name</value>
+ </data>
</root>
\ No newline at end of file
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Tests/ValidationTests.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Tests/ValidationTests.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Tests/ValidationTests.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -274,40 +274,12 @@
public void TestCase_FsValidator_ValidatesOdbcConfigurationIssues()
{
var conf = new OdbcConfigurationDocument();
+ var sc = CreateTestSpatialContext();
- var sc = new FdoSpatialContextListSpatialContext();
- sc.CoordinateSystemName = "LL84";
- sc.CoordinateSystemWkt = "";
- sc.Description = "Default Spatial Context";
- sc.Extent = new FdoSpatialContextListSpatialContextExtent()
- {
- LowerLeftCoordinate = new FdoSpatialContextListSpatialContextExtentLowerLeftCoordinate()
- {
- X = "-180.0",
- Y = "-180.0"
- },
- UpperRightCoordinate = new FdoSpatialContextListSpatialContextExtentUpperRightCoordinate()
- {
- X = "180.0",
- Y = "180.0"
- }
- };
- sc.ExtentType = FdoSpatialContextListSpatialContextExtentType.Static;
- sc.Name = "Default";
- sc.XYTolerance = 0.0001;
- sc.ZTolerance = 0.0001;
-
var schema = new FeatureSchema("Default", "Default Schema");
- var klass = new ClassDefinition("Test", "Test Class");
- var id = new DataPropertyDefinition("ID", "Identity");
- var geom = new GeometricPropertyDefinition("Geometry", "geometry")
- {
- GeometricTypes = FeatureGeometricType.Point
- };
- geom.SpatialContextAssociation = sc.Name;
- klass.AddProperty(id, true);
- klass.AddProperty(geom);
- klass.DefaultGeometryPropertyName = geom.Name;
+ ClassDefinition klass = CreateTestClass(sc.Name);
+ GeometricPropertyDefinition geom = klass.Properties.OfType<GeometricPropertyDefinition>().FirstOrDefault(p => p.Name == klass.DefaultGeometryPropertyName);
+
schema.AddClass(klass);
conf.AddSchema(schema);
@@ -352,7 +324,7 @@
mockFs.Setup(fs => fs.ResourceID).Returns(resId);
mockFs.Setup(fs => fs.Extension).Returns(Enumerable.Empty<IFeatureSourceExtension>());
mockFs.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
- mockFs.Setup(fs => fs.Provider).Returns("OSGeo.ODBC");
+ mockFs.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
mockFs.Setup(fs => fs.Serialize()).Returns(string.Empty);
//XYZ column misconfigurations
@@ -363,7 +335,7 @@
var issues = validator.Validate(context, mockFs.Object, false);
Assert.AreEqual(1, issues.Count());
Assert.AreEqual(ValidationStatusCode.Error_OdbcConfig_IncompleteXYZColumnMapping, issues.First().StatusCode);
-
+
odbcTable.XColumn = null;
odbcTable.YColumn = "Y";
@@ -434,5 +406,845 @@
issues = validator.Validate(context, mockFs.Object, false);
Assert.AreEqual(0, issues.Count());
}
+
+ private ClassDefinition CreateTestClass(string scName, string className = "Test", string idName = "ID", string geomName = "Geometry")
+ {
+ var klass = new ClassDefinition(className, "Test Class");
+
+ var id = new DataPropertyDefinition(idName, "Identity");
+ var geom = new GeometricPropertyDefinition(geomName, "geometry")
+ {
+ GeometricTypes = FeatureGeometricType.Point
+ };
+ geom.SpatialContextAssociation = scName;
+ klass.AddProperty(id, true);
+ klass.AddProperty(geom);
+ klass.DefaultGeometryPropertyName = geom.Name;
+
+ return klass;
+ }
+
+ private static FdoSpatialContextListSpatialContext CreateTestSpatialContext()
+ {
+ var sc = new FdoSpatialContextListSpatialContext();
+ sc.CoordinateSystemName = "LL84";
+ sc.CoordinateSystemWkt = "";
+ sc.Description = "Default Spatial Context";
+ sc.Extent = new FdoSpatialContextListSpatialContextExtent()
+ {
+ LowerLeftCoordinate = new FdoSpatialContextListSpatialContextExtentLowerLeftCoordinate()
+ {
+ X = "-180.0",
+ Y = "-180.0"
+ },
+ UpperRightCoordinate = new FdoSpatialContextListSpatialContextExtentUpperRightCoordinate()
+ {
+ X = "180.0",
+ Y = "180.0"
+ }
+ };
+ sc.ExtentType = FdoSpatialContextListSpatialContextExtentType.Static;
+ sc.Name = "Default";
+ sc.XYTolerance = 0.0001;
+ sc.ZTolerance = 0.0001;
+ return sc;
+ }
+
+ [Test]
+ public void TestCase_FsValidator_FailedTestConnection()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var dataName = "config.xml";
+ var schemaName = "Default";
+
+ var sc = CreateTestSpatialContext();
+ var scList = new FdoSpatialContextList
+ {
+ SpatialContext = new System.ComponentModel.BindingList<FdoSpatialContextListSpatialContext>() { sc }
+ };
+
+ var mockExt = new Mock<IFeatureSourceExtension>();
+ var mockRelate = new Mock<IAttributeRelation>();
+ mockRelate.Setup(r => r.Name).Returns("abcd");
+
+ mockExt.Setup(ext => ext.AttributeRelate).Returns(new[] { mockRelate.Object });
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rs => rs.GetResourceData(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == dataName))).Returns((Stream)null);
+ mockFeatSvc.Setup(fs => fs.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fs => fs.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId), It.IsAny<bool>())).Returns(scList);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var mockFs = new Mock<IFeatureSource>();
+ mockFs.Setup(fs => fs.ConfigurationDocument).Returns(dataName);
+ mockFs.Setup(fs => fs.ResourceID).Returns(resId);
+ mockFs.Setup(fs => fs.Extension).Returns(new[] { mockExt.Object });
+ mockFs.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
+ mockFs.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
+ mockFs.Setup(fs => fs.Serialize()).Returns(string.Empty);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, mockFs.Object, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_FeatureSource_ConnectionTestFailed, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_FsValidator_Credentials()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var dataName = "config.xml";
+ var schemaName = "Default";
+
+ var sc = CreateTestSpatialContext();
+ var scList = new FdoSpatialContextList
+ {
+ SpatialContext = new System.ComponentModel.BindingList<FdoSpatialContextListSpatialContext>() { sc }
+ };
+
+ var mockExt = new Mock<IFeatureSourceExtension>();
+ var mockRelate = new Mock<IAttributeRelation>();
+ mockRelate.Setup(r => r.Name).Returns("abcd");
+
+ mockExt.Setup(ext => ext.AttributeRelate).Returns(new[] { mockRelate.Object });
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rs => rs.GetResourceData(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == dataName))).Returns((Stream)null);
+ mockResSvc.Setup(rs => rs.EnumerateResourceData(It.IsAny<string>())).Returns(new ResourceDataList { ResourceData = new System.ComponentModel.BindingList<ResourceDataListResourceData>() });
+ mockFeatSvc.Setup(fs => fs.TestConnection(It.Is<string>(arg => arg == resId))).Returns("true");
+ mockFeatSvc.Setup(fs => fs.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId), It.IsAny<bool>())).Returns(scList);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var mockFs = ObjectFactory.CreateFeatureSource("OSGeo.ODBC");
+ mockFs.ResourceID = resId;
+ mockFs.SetConnectionProperty("Username", "admin");
+ mockFs.SetConnectionProperty("Password", "password");
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, mockFs, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Warning_FeatureSource_Plaintext_Credentials, issues.First().StatusCode);
+
+ mockFs.SetConnectionProperty("Username", StringConstants.MgUsernamePlaceholder);
+ mockFs.SetConnectionProperty("Password", StringConstants.MgPasswordPlaceholder);
+
+ context = new ResourceValidationContext(mockConn.Object);
+ validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ issues = validator.Validate(context, mockFs, false);
+ Assert.AreEqual(2, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Warning_FeatureSource_Cannot_Package_Secured_Credentials, issues.First().StatusCode);
+ Assert.AreEqual(ValidationStatusCode.Error_FeatureSource_SecuredCredentialTokensWithoutSecuredCredentialData, issues.Last().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_FsValidator_SchemaRead()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var dataName = "config.xml";
+
+ var sc = CreateTestSpatialContext();
+ var scList = new FdoSpatialContextList
+ {
+ SpatialContext = new System.ComponentModel.BindingList<FdoSpatialContextListSpatialContext>() { sc }
+ };
+
+ var mockExt = new Mock<IFeatureSourceExtension>();
+ var mockRelate = new Mock<IAttributeRelation>();
+ mockRelate.Setup(r => r.Name).Returns("abcd");
+
+ mockExt.Setup(ext => ext.AttributeRelate).Returns(new[] { mockRelate.Object });
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rs => rs.GetResourceData(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == dataName))).Returns((Stream)null);
+ mockFeatSvc.Setup(fs => fs.TestConnection(It.Is<string>(arg => arg == resId))).Returns("true");
+ mockFeatSvc.Setup(fs => fs.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new string[0]);
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId), It.IsAny<bool>())).Returns(scList);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var mockFs = new Mock<IFeatureSource>();
+ mockFs.Setup(fs => fs.ConfigurationDocument).Returns(dataName);
+ mockFs.Setup(fs => fs.ResourceID).Returns(resId);
+ mockFs.Setup(fs => fs.Extension).Returns(new[] { mockExt.Object });
+ mockFs.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
+ mockFs.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
+ mockFs.Setup(fs => fs.Serialize()).Returns(string.Empty);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, mockFs.Object, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Warning_FeatureSource_NoSchemasFound, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_FsValidator_SpatialContexts()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var resId2 = "Library://Test2.FeatureSource";
+ var resId3 = "Library://Test3.FeatureSource";
+ var resId4 = "Library://Test4.FeatureSource";
+ var resId5 = "Library://Test5.FeatureSource";
+ var dataName = "config.xml";
+ var schemaName = "Default";
+
+ var sc = CreateTestSpatialContext();
+ var scBogus = CreateTestSpatialContext();
+ scBogus.Extent = null;
+ var scOOB = CreateTestSpatialContext();
+ scOOB.Extent = new FdoSpatialContextListSpatialContextExtent()
+ {
+ LowerLeftCoordinate = new FdoSpatialContextListSpatialContextExtentLowerLeftCoordinate()
+ {
+ X = "-1000001",
+ Y = "-1000001"
+ },
+ UpperRightCoordinate = new FdoSpatialContextListSpatialContextExtentUpperRightCoordinate()
+ {
+ X = "1000001",
+ Y = "1000001"
+ }
+ };
+ var badScList = new FdoSpatialContextList();
+ var scList = new FdoSpatialContextList
+ {
+ SpatialContext = new System.ComponentModel.BindingList<FdoSpatialContextListSpatialContext>() { sc }
+ };
+ var scListBogus = new FdoSpatialContextList
+ {
+ SpatialContext = new System.ComponentModel.BindingList<FdoSpatialContextListSpatialContext>() { scBogus }
+ };
+ var scListOOB = new FdoSpatialContextList
+ {
+ SpatialContext = new System.ComponentModel.BindingList<FdoSpatialContextListSpatialContext>() { scOOB }
+ };
+
+ var mockExt = new Mock<IFeatureSourceExtension>();
+ var mockRelate = new Mock<IAttributeRelation>();
+ mockRelate.Setup(r => r.Name).Returns("abcd");
+
+ mockExt.Setup(ext => ext.AttributeRelate).Returns(new[] { mockRelate.Object });
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rs => rs.GetResourceData(It.IsAny<string>(), It.IsAny<string>())).Returns((Stream)null);
+ mockFeatSvc.Setup(fs => fs.TestConnection(It.IsAny<string>())).Returns("true");
+ mockFeatSvc.Setup(fs => fs.GetSchemas(It.IsAny<string>())).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId), It.IsAny<bool>())).Returns((FdoSpatialContextList)null);
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId2), It.IsAny<bool>())).Returns(badScList);
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId3), It.IsAny<bool>())).Returns(scListBogus);
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId4), It.IsAny<bool>())).Returns(scListOOB);
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId5), It.IsAny<bool>())).Returns(scList);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var mockFs = new Mock<IFeatureSource>();
+ mockFs.Setup(fs => fs.ConfigurationDocument).Returns(dataName);
+ mockFs.Setup(fs => fs.ResourceID).Returns(resId);
+ mockFs.Setup(fs => fs.Extension).Returns(new[] { mockExt.Object });
+ mockFs.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
+ mockFs.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
+ mockFs.Setup(fs => fs.Serialize()).Returns(string.Empty);
+
+ var mockFs2 = new Mock<IFeatureSource>();
+ mockFs2.Setup(fs => fs.ConfigurationDocument).Returns(dataName);
+ mockFs2.Setup(fs => fs.ResourceID).Returns(resId2);
+ mockFs2.Setup(fs => fs.Extension).Returns(new[] { mockExt.Object });
+ mockFs2.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
+ mockFs2.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
+ mockFs2.Setup(fs => fs.Serialize()).Returns(string.Empty);
+
+ var mockFs3 = new Mock<IFeatureSource>();
+ mockFs3.Setup(fs => fs.ConfigurationDocument).Returns(dataName);
+ mockFs3.Setup(fs => fs.ResourceID).Returns(resId3);
+ mockFs3.Setup(fs => fs.Extension).Returns(new[] { mockExt.Object });
+ mockFs3.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
+ mockFs3.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
+ mockFs3.Setup(fs => fs.Serialize()).Returns(string.Empty);
+
+ var mockFs4 = new Mock<IFeatureSource>();
+ mockFs4.Setup(fs => fs.ConfigurationDocument).Returns(dataName);
+ mockFs4.Setup(fs => fs.ResourceID).Returns(resId4);
+ mockFs4.Setup(fs => fs.Extension).Returns(new[] { mockExt.Object });
+ mockFs4.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
+ mockFs4.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
+ mockFs4.Setup(fs => fs.Serialize()).Returns(string.Empty);
+
+ var mockFs5 = new Mock<IFeatureSource>();
+ mockFs5.Setup(fs => fs.ConfigurationDocument).Returns(dataName);
+ mockFs5.Setup(fs => fs.ResourceID).Returns(resId5);
+ mockFs5.Setup(fs => fs.Extension).Returns(new[] { mockExt.Object });
+ mockFs5.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
+ mockFs5.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
+ mockFs5.Setup(fs => fs.Serialize()).Returns(string.Empty);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, mockFs2.Object, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Warning_FeatureSource_NoSpatialContext, issues.First().StatusCode);
+
+ context = new ResourceValidationContext(mockConn.Object);
+ validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ issues = validator.Validate(context, mockFs3.Object, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Warning_FeatureSource_EmptySpatialContext, issues.First().StatusCode);
+
+ context = new ResourceValidationContext(mockConn.Object);
+ validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ issues = validator.Validate(context, mockFs4.Object, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Warning_FeatureSource_DefaultSpatialContext, issues.First().StatusCode);
+
+ context = new ResourceValidationContext(mockConn.Object);
+ validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ issues = validator.Validate(context, mockFs5.Object, false);
+ Assert.AreEqual(0, issues.Count());
+ }
+
+ [Test]
+ public void TestCase_FsValidator_EmptyJoinPrefix()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var dataName = "config.xml";
+ var schemaName = "Default";
+
+ var sc = CreateTestSpatialContext();
+ var scList = new FdoSpatialContextList
+ {
+ SpatialContext = new System.ComponentModel.BindingList<FdoSpatialContextListSpatialContext>() { sc }
+ };
+
+ var mockExt = new Mock<IFeatureSourceExtension>();
+ var mockRelate = new Mock<IAttributeRelation>();
+ mockRelate.Setup(r => r.Name).Returns(string.Empty);
+
+ mockExt.Setup(ext => ext.AttributeRelate).Returns(new[] { mockRelate.Object });
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rs => rs.GetResourceData(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == dataName))).Returns((Stream)null);
+ mockFeatSvc.Setup(fs => fs.TestConnection(It.Is<string>(arg => arg == resId))).Returns("true");
+ mockFeatSvc.Setup(fs => fs.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fs => fs.GetSpatialContextInfo(It.Is<string>(arg => arg == resId), It.IsAny<bool>())).Returns(scList);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var mockFs = new Mock<IFeatureSource>();
+ mockFs.Setup(fs => fs.ConfigurationDocument).Returns(dataName);
+ mockFs.Setup(fs => fs.ResourceID).Returns(resId);
+ mockFs.Setup(fs => fs.Extension).Returns(new[] { mockExt.Object });
+ mockFs.Setup(fs => fs.ResourceType).Returns(ResourceTypes.FeatureSource.ToString());
+ mockFs.Setup(fs => fs.Provider).Returns("OSGeo.SDF");
+ mockFs.Setup(fs => fs.Serialize()).Returns(string.Empty);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new FeatureSourceValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, mockFs.Object, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Warning_FeatureSource_EmptyJoinPrefix, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_ClassNotFound()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, geomName);
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = resId;
+ ldf.ResourceID = ldfId;
+ var vl = (IVectorLayerDefinition)ldf.SubLayer;
+ vl.FeatureName = $"{schemaName}:{klass.Name}";
+ vl.Geometry = geomName;
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns((ClassDefinition)null);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_ClassNotFound, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_GeometryNotFound()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, "Geom");
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+ fs.ResourceID = resId;
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = resId;
+ ldf.ResourceID = ldfId;
+ var vl = (IVectorLayerDefinition)ldf.SubLayer;
+ vl.FeatureName = $"{schemaName}:{klass.Name}";
+ vl.Geometry = geomName;
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_GeometryNotFound, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_BadPropertyMapping()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, geomName);
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+ fs.ResourceID = resId;
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = resId;
+ ldf.ResourceID = ldfId;
+ var vl = (IVectorLayerDefinition)ldf.SubLayer;
+ vl.FeatureName = $"{schemaName}:{klass.Name}";
+ vl.Geometry = geomName;
+
+ vl.AddPropertyMapping(ldf.CreatePair("Foo", "Bar"));
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_InvalidPropertyMapping, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_MissingFeatureName()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var resId2 = "Library://TestRaster.FeatureSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, geomName);
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+ fs.ResourceID = resId;
+
+ var gfs = ObjectFactory.CreateFeatureSource("OSGeo.GDAL");
+ gfs.ResourceID = resId2;
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = resId;
+ ldf.ResourceID = ldfId;
+ var vl = (IVectorLayerDefinition)ldf.SubLayer;
+ vl.Geometry = geomName;
+
+ var gldf = ObjectFactory.CreateDefaultLayer(LayerType.Raster, new Version(1, 0, 0));
+ gldf.SubLayer.ResourceId = resId2;
+ gldf.ResourceID = ldfId;
+ var gl = (IRasterLayerDefinition)gldf.SubLayer;
+ gl.Geometry = geomName;
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId2))).Returns(gfs);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("true");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("true");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(2, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_ClassNotFound, issues.First().StatusCode);
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_MissingFeatureName, issues.Last().StatusCode);
+
+ context = new ResourceValidationContext(mockConn.Object);
+ validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ issues = validator.Validate(context, gldf, false);
+ Assert.AreEqual(2, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_ClassNotFound, issues.First().StatusCode);
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_MissingFeatureName, issues.Last().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_MissingGeometry()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var resId2 = "Library://TestRaster.FeatureSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, geomName);
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+ fs.ResourceID = resId;
+
+ var gfs = ObjectFactory.CreateFeatureSource("OSGeo.GDAL");
+ gfs.ResourceID = resId;
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = resId;
+ ldf.ResourceID = ldfId;
+ var vl = (IVectorLayerDefinition)ldf.SubLayer;
+ vl.FeatureName = $"{schemaName}:{klass.Name}";
+
+ var gldf = ObjectFactory.CreateDefaultLayer(LayerType.Raster, new Version(1, 0, 0));
+ gldf.SubLayer.ResourceId = resId2;
+ gldf.ResourceID = ldfId;
+ var gl = (IRasterLayerDefinition)gldf.SubLayer;
+ gl.FeatureName = $"{schemaName}:{klass.Name}";
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId2))).Returns(gfs);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(2, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_GeometryNotFound, issues.First().StatusCode);
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_MissingGeometry, issues.Last().StatusCode);
+
+ context = new ResourceValidationContext(mockConn.Object);
+ validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ issues = validator.Validate(context, gldf, false);
+ Assert.AreEqual(2, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_GeometryNotFound, issues.First().StatusCode);
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_MissingGeometry, issues.Last().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_ScaleRangeMinMaxSwapped()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, geomName);
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+ fs.ResourceID = resId;
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = resId;
+ ldf.ResourceID = ldfId;
+ var vl = (IVectorLayerDefinition)ldf.SubLayer;
+ vl.FeatureName = $"{schemaName}:{klass.Name}";
+ vl.Geometry = geomName;
+
+ vl.GetScaleRangeAt(0).MinScale = 1000;
+ vl.GetScaleRangeAt(0).MaxScale = 999;
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_MinMaxScaleSwapped, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_OverlappingScaleRanges()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, geomName);
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+ fs.ResourceID = resId;
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = resId;
+ ldf.ResourceID = ldfId;
+ var vl = (IVectorLayerDefinition)ldf.SubLayer;
+ vl.FeatureName = $"{schemaName}:{klass.Name}";
+ vl.Geometry = geomName;
+
+ vl.GetScaleRangeAt(0).MinScale = 100;
+ vl.GetScaleRangeAt(0).MaxScale = 200;
+
+ var vsr = ldf.CreateVectorScaleRange();
+ vsr.MinScale = 199;
+ vsr.MaxScale = 300;
+ vl.AddVectorScaleRange(vsr);
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Info_LayerDefinition_ScaleRangeOverlap, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_MissingDrawingSheet()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var dsId = "Library://Test.DrawingSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, geomName);
+
+ var ds = ObjectFactory.CreateDrawingSource();
+ ds.ResourceID = dsId;
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+ fs.ResourceID = resId;
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Drawing, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = dsId;
+ ldf.ResourceID = ldfId;
+ var dl = (IDrawingLayerDefinition)ldf.SubLayer;
+ dl.Sheet = "Foo";
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+ var mockDrawSvc = new Mock<IDrawingService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == dsId))).Returns(ds);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ var sheetList = new DrawingSectionList
+ {
+ Section = new System.ComponentModel.BindingList<DrawingSectionListSection>()
+ };
+ mockDrawSvc.Setup(dsvc => dsvc.EnumerateDrawingSections(It.IsAny<string>())).Returns(sheetList);
+
+ var mockCaps = new Mock<IConnectionCapabilities>();
+ mockCaps.Setup(c => c.SupportedServices).Returns(new[] { (int)ServiceType.Drawing });
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+ mockConn.Setup(c => c.Capabilities).Returns(mockCaps.Object);
+ mockConn.Setup(c => c.GetService(It.Is<int>(arg => arg == (int)ServiceType.Drawing))).Returns(mockDrawSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_DrawingSourceSheetNotFound, issues.First().StatusCode);
+ }
+
+ [Test]
+ public void TestCase_LayerValidator_MissingDrawingSheetLayer()
+ {
+ var resId = "Library://Test.FeatureSource";
+ var dsId = "Library://Test.DrawingSource";
+ var ldfId = "Library://Test.LayerDefinition";
+ var schemaName = "Default";
+ var className = "Test";
+ var idName = "ID";
+ var geomName = "Geometry";
+ var klass = CreateTestClass("Default", className, idName, geomName);
+
+ var ds = ObjectFactory.CreateDrawingSource();
+ ds.ResourceID = dsId;
+
+ var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
+ fs.ResourceID = resId;
+
+ var ldf = ObjectFactory.CreateDefaultLayer(LayerType.Drawing, new Version(1, 0, 0));
+ ldf.SubLayer.ResourceId = dsId;
+ ldf.ResourceID = ldfId;
+ var dl = (IDrawingLayerDefinition)ldf.SubLayer;
+ dl.Sheet = "Foo";
+ dl.LayerFilter = "Baz";
+
+ var mockConn = new Mock<IServerConnection>();
+ var mockFeatSvc = new Mock<IFeatureService>();
+ var mockResSvc = new Mock<IResourceService>();
+ var mockDrawSvc = new Mock<IDrawingService>();
+
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == resId))).Returns(fs);
+ mockResSvc.Setup(rsvc => rsvc.GetResource(It.Is<string>(arg => arg == dsId))).Returns(ds);
+
+ mockFeatSvc.Setup(fsvc => fsvc.TestConnection(It.Is<string>(arg => arg == resId))).Returns("false");
+ mockFeatSvc.Setup(fsvc => fsvc.GetSchemas(It.Is<string>(arg => arg == resId))).Returns(new[] { schemaName });
+ mockFeatSvc.Setup(fsvc => fsvc.GetClassDefinition(It.Is<string>(arg => arg == resId), It.Is<string>(arg => arg == $"{schemaName}:{className}"))).Returns(klass);
+
+ var sheetList = new DrawingSectionList
+ {
+ Section = new System.ComponentModel.BindingList<DrawingSectionListSection>()
+ {
+ new DrawingSectionListSection { Name = "Foo" }
+ }
+ };
+ mockDrawSvc.Setup(dsvc => dsvc.EnumerateDrawingSections(It.Is<string>(arg => arg == dsId))).Returns(sheetList);
+ mockDrawSvc.Setup(dsvc => dsvc.EnumerateDrawingLayers(It.Is<string>(arg => arg == dsId), It.Is<string>(arg => arg == "Foo"))).Returns(new[] { "Bar" });
+
+ var mockCaps = new Mock<IConnectionCapabilities>();
+ mockCaps.Setup(c => c.SupportedServices).Returns(new[] { (int)ServiceType.Drawing });
+
+ mockConn.Setup(c => c.FeatureService).Returns(mockFeatSvc.Object);
+ mockConn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);
+ mockConn.Setup(c => c.Capabilities).Returns(mockCaps.Object);
+ mockConn.Setup(c => c.GetService(It.Is<int>(arg => arg == (int)ServiceType.Drawing))).Returns(mockDrawSvc.Object);
+
+ var context = new ResourceValidationContext(mockConn.Object);
+ var validator = new LayerDefinitionValidator();
+ validator.Connection = mockConn.Object;
+ var issues = validator.Validate(context, ldf, false);
+ Assert.AreEqual(1, issues.Count());
+ Assert.AreEqual(ValidationStatusCode.Error_LayerDefinition_DrawingSourceSheetLayerNotFound, issues.First().StatusCode);
+ }
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModel.Tests/ObjectFactoryTests.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModel.Tests/ObjectFactoryTests.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModel.Tests/ObjectFactoryTests.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -293,6 +293,38 @@
}
[Test]
+ public void CreateVectorLayerDefinitionTest()
+ {
+ var ldf100 = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));
+ var ldf110 = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 1, 0));
+ var ldf120 = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 2, 0));
+ var ldf130 = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 3, 0));
+ var ldf230 = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(2, 3, 0));
+ var ldf240 = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(2, 4, 0));
+
+ var vl100 = (IVectorLayerDefinition)ldf100.SubLayer;
+ var vl110 = (IVectorLayerDefinition)ldf110.SubLayer;
+ var vl120 = (IVectorLayerDefinition)ldf120.SubLayer;
+ var vl130 = (IVectorLayerDefinition)ldf130.SubLayer;
+ var vl230 = (IVectorLayerDefinition)ldf230.SubLayer;
+ var vl240 = (IVectorLayerDefinition)ldf240.SubLayer;
+
+ Assert.AreEqual(0, vl100.PropertyMapping.Count());
+ Assert.AreEqual(0, vl110.PropertyMapping.Count());
+ Assert.AreEqual(0, vl120.PropertyMapping.Count());
+ Assert.AreEqual(0, vl130.PropertyMapping.Count());
+ Assert.AreEqual(0, vl230.PropertyMapping.Count());
+ Assert.AreEqual(0, vl240.PropertyMapping.Count());
+
+ Assert.AreEqual(1, vl100.VectorScaleRange.Count());
+ Assert.AreEqual(1, vl110.VectorScaleRange.Count());
+ Assert.AreEqual(1, vl120.VectorScaleRange.Count());
+ Assert.AreEqual(1, vl130.VectorScaleRange.Count());
+ Assert.AreEqual(1, vl230.VectorScaleRange.Count());
+ Assert.AreEqual(1, vl240.VectorScaleRange.Count());
+ }
+
+ [Test]
public void CreateFeatureSourceTest()
{
var fs = ObjectFactory.CreateFeatureSource("OSGeo.SDF");
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_0_0/VectorLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_0_0/VectorLayerDefinitionImpl.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_0_0/VectorLayerDefinitionImpl.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -1613,26 +1613,32 @@
{
get
{
- foreach (var pair in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- yield return pair;
+ foreach (var pair in this.PropertyMapping)
+ {
+ yield return pair;
+ }
}
}
}
INameStringPair IVectorLayerDefinition.GetPropertyMapping(string name)
{
- foreach (var p in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- if (p.Name == name)
- return p;
+ foreach (var p in this.PropertyMapping)
+ {
+ if (p.Name == name)
+ return p;
+ }
}
return null;
}
INameStringPair IVectorLayerDefinition.GetPropertyMappingAt(int index)
{
- if (index < 0 || index >= this.PropertyMapping.Count)
+ if (this.PropertyMapping == null || index < 0 || index >= this.PropertyMapping.Count)
throw new ArgumentOutOfRangeException();
var item = this.PropertyMapping[index];
@@ -1657,57 +1663,78 @@
{
var p = pair as NameStringPairType;
if (p != null)
+ {
+ if (this.PropertyMapping == null)
+ {
+ this.PropertyMapping = new BindingList<NameStringPairType>();
+ }
+
this.PropertyMapping.Add(p);
+ }
}
void IVectorLayerDefinition.RemovePropertyMapping(INameStringPair pair)
{
var p = pair as NameStringPairType;
- if (p != null)
- this.PropertyMapping.Remove(p);
+ var pmaps = this.PropertyMapping;
+ if (p != null && pmaps != null)
+ {
+ pmaps.Remove(p);
+ if (pmaps.Count == 0)
+ this.PropertyMapping = null;
+ }
}
int IVectorLayerDefinition.GetPosition(INameStringPair pair)
{
- var p = pair as NameStringPairType;
- if (p != null)
- return this.PropertyMapping.IndexOf(p);
+ if (this.PropertyMapping != null)
+ {
+ var p = pair as NameStringPairType;
+ if (p != null)
+ return this.PropertyMapping.IndexOf(p);
+ }
return -1;
}
int IVectorLayerDefinition.MoveUp(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos > 0)
+ if (this.PropertyMapping != null)
{
- int dest = pos - 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos > 0)
+ {
+ int dest = pos - 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
int IVectorLayerDefinition.MoveDown(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos < this.PropertyMapping.Count - 1)
+ if (this.PropertyMapping != null)
{
- int dest = pos + 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos < this.PropertyMapping.Count - 1)
+ {
+ int dest = pos + 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_1_0/VectorLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_1_0/VectorLayerDefinitionImpl.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_1_0/VectorLayerDefinitionImpl.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -1693,26 +1693,32 @@
{
get
{
- foreach (var pair in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- yield return pair;
+ foreach (var pair in this.PropertyMapping)
+ {
+ yield return pair;
+ }
}
}
}
INameStringPair IVectorLayerDefinition.GetPropertyMapping(string name)
{
- foreach (var p in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- if (p.Name == name)
- return p;
+ foreach (var p in this.PropertyMapping)
+ {
+ if (p.Name == name)
+ return p;
+ }
}
return null;
}
INameStringPair IVectorLayerDefinition.GetPropertyMappingAt(int index)
{
- if (index < 0 || index >= this.PropertyMapping.Count)
+ if (this.PropertyMapping == null || index < 0 || index >= this.PropertyMapping.Count)
throw new ArgumentOutOfRangeException();
var item = this.PropertyMapping[index];
@@ -1737,57 +1743,76 @@
{
var p = pair as NameStringPairType;
if (p != null)
+ {
+ if (this.PropertyMapping == null)
+ {
+ this.PropertyMapping = new BindingList<NameStringPairType>();
+ }
this.PropertyMapping.Add(p);
+ }
}
void IVectorLayerDefinition.RemovePropertyMapping(INameStringPair pair)
{
var p = pair as NameStringPairType;
- if (p != null)
- this.PropertyMapping.Remove(p);
+ var pmaps = this.PropertyMapping;
+ if (p != null && pmaps != null)
+ {
+ pmaps.Remove(p);
+ if (pmaps.Count == 0)
+ this.PropertyMapping = null;
+ }
}
int IVectorLayerDefinition.GetPosition(INameStringPair pair)
{
- var p = pair as NameStringPairType;
- if (p != null)
- return this.PropertyMapping.IndexOf(p);
-
+ if (this.PropertyMapping != null)
+ {
+ var p = pair as NameStringPairType;
+ if (p != null)
+ return this.PropertyMapping.IndexOf(p);
+ }
return -1;
}
int IVectorLayerDefinition.MoveUp(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos > 0)
+ if (this.PropertyMapping != null)
{
- int dest = pos - 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos > 0)
+ {
+ int dest = pos - 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
int IVectorLayerDefinition.MoveDown(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos < this.PropertyMapping.Count - 1)
+ if (this.PropertyMapping != null)
{
- int dest = pos + 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos < this.PropertyMapping.Count - 1)
+ {
+ int dest = pos + 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_2_0/VectorLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_2_0/VectorLayerDefinitionImpl.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_2_0/VectorLayerDefinitionImpl.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -1878,26 +1878,32 @@
{
get
{
- foreach (var pair in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- yield return pair;
+ foreach (var pair in this.PropertyMapping)
+ {
+ yield return pair;
+ }
}
}
}
INameStringPair IVectorLayerDefinition.GetPropertyMapping(string name)
{
- foreach (var p in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- if (p.Name == name)
- return p;
+ foreach (var p in this.PropertyMapping)
+ {
+ if (p.Name == name)
+ return p;
+ }
}
return null;
}
INameStringPair IVectorLayerDefinition.GetPropertyMappingAt(int index)
{
- if (index < 0 || index >= this.PropertyMapping.Count)
+ if (this.PropertyMapping == null || index < 0 || index >= this.PropertyMapping.Count)
throw new ArgumentOutOfRangeException();
var item = this.PropertyMapping[index];
@@ -1922,57 +1928,78 @@
{
var p = pair as NameStringPairType;
if (p != null)
+ {
+ if (this.PropertyMapping == null)
+ {
+ this.PropertyMapping = new BindingList<NameStringPairType>();
+ }
+
this.PropertyMapping.Add(p);
+ }
}
void IVectorLayerDefinition.RemovePropertyMapping(INameStringPair pair)
{
var p = pair as NameStringPairType;
- if (p != null)
- this.PropertyMapping.Remove(p);
+ var pmaps = this.PropertyMapping;
+ if (p != null && pmaps != null)
+ {
+ pmaps.Remove(p);
+ if (pmaps.Count == 0)
+ this.PropertyMapping = null;
+ }
}
int IVectorLayerDefinition.GetPosition(INameStringPair pair)
{
- var p = pair as NameStringPairType;
- if (p != null)
- return this.PropertyMapping.IndexOf(p);
+ if (this.PropertyMapping != null)
+ {
+ var p = pair as NameStringPairType;
+ if (p != null)
+ return this.PropertyMapping.IndexOf(p);
+ }
return -1;
}
int IVectorLayerDefinition.MoveUp(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos > 0)
+ if (this.PropertyMapping != null)
{
- int dest = pos - 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos > 0)
+ {
+ int dest = pos - 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
int IVectorLayerDefinition.MoveDown(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos < this.PropertyMapping.Count - 1)
+ if (this.PropertyMapping != null)
{
- int dest = pos + 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos < this.PropertyMapping.Count - 1)
+ {
+ int dest = pos + 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_3_0/VectorLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_3_0/VectorLayerDefinitionImpl.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v1_3_0/VectorLayerDefinitionImpl.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -1879,26 +1879,32 @@
{
get
{
- foreach (var pair in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- yield return pair;
+ foreach (var pair in this.PropertyMapping)
+ {
+ yield return pair;
+ }
}
}
}
INameStringPair IVectorLayerDefinition.GetPropertyMapping(string name)
{
- foreach (var p in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- if (p.Name == name)
- return p;
+ foreach (var p in this.PropertyMapping)
+ {
+ if (p.Name == name)
+ return p;
+ }
}
return null;
}
INameStringPair IVectorLayerDefinition.GetPropertyMappingAt(int index)
{
- if (index < 0 || index >= this.PropertyMapping.Count)
+ if (this.PropertyMapping == null || index < 0 || index >= this.PropertyMapping.Count)
throw new ArgumentOutOfRangeException();
var item = this.PropertyMapping[index];
@@ -1923,57 +1929,78 @@
{
var p = pair as NameStringPairType;
if (p != null)
+ {
+ if (this.PropertyMapping == null)
+ {
+ this.PropertyMapping = new BindingList<NameStringPairType>();
+ }
+
this.PropertyMapping.Add(p);
+ }
}
void IVectorLayerDefinition.RemovePropertyMapping(INameStringPair pair)
{
var p = pair as NameStringPairType;
- if (p != null)
- this.PropertyMapping.Remove(p);
+ var pmaps = this.PropertyMapping;
+ if (p != null && pmaps != null)
+ {
+ pmaps.Remove(p);
+ if (pmaps.Count == 0)
+ this.PropertyMapping = null;
+ }
}
int IVectorLayerDefinition.GetPosition(INameStringPair pair)
{
- var p = pair as NameStringPairType;
- if (p != null)
- return this.PropertyMapping.IndexOf(p);
+ if (this.PropertyMapping != null)
+ {
+ var p = pair as NameStringPairType;
+ if (p != null)
+ return this.PropertyMapping.IndexOf(p);
+ }
return -1;
}
int IVectorLayerDefinition.MoveUp(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos > 0)
+ if (this.PropertyMapping != null)
{
- int dest = pos - 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos > 0)
+ {
+ int dest = pos - 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
int IVectorLayerDefinition.MoveDown(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos < this.PropertyMapping.Count - 1)
+ if (this.PropertyMapping != null)
{
- int dest = pos + 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos < this.PropertyMapping.Count - 1)
+ {
+ int dest = pos + 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_3_0/VectorLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_3_0/VectorLayerDefinitionImpl.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_3_0/VectorLayerDefinitionImpl.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -1881,26 +1881,32 @@
{
get
{
- foreach (var pair in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- yield return pair;
+ foreach (var pair in this.PropertyMapping)
+ {
+ yield return pair;
+ }
}
}
}
INameStringPair IVectorLayerDefinition.GetPropertyMapping(string name)
{
- foreach (var p in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- if (p.Name == name)
- return p;
+ foreach (var p in this.PropertyMapping)
+ {
+ if (p.Name == name)
+ return p;
+ }
}
return null;
}
INameStringPair IVectorLayerDefinition.GetPropertyMappingAt(int index)
{
- if (index < 0 || index >= this.PropertyMapping.Count)
+ if (this.PropertyMapping == null || index < 0 || index >= this.PropertyMapping.Count)
throw new ArgumentOutOfRangeException();
var item = this.PropertyMapping[index];
@@ -1925,57 +1931,78 @@
{
var p = pair as NameStringPairType;
if (p != null)
+ {
+ if (this.PropertyMapping == null)
+ {
+ this.PropertyMapping = new BindingList<NameStringPairType>();
+ }
+
this.PropertyMapping.Add(p);
+ }
}
void IVectorLayerDefinition.RemovePropertyMapping(INameStringPair pair)
{
var p = pair as NameStringPairType;
- if (p != null)
- this.PropertyMapping.Remove(p);
+ var pmaps = this.PropertyMapping;
+ if (p != null && pmaps != null)
+ {
+ pmaps.Remove(p);
+ if (pmaps.Count == 0)
+ this.PropertyMapping = null;
+ }
}
int IVectorLayerDefinition.GetPosition(INameStringPair pair)
{
- var p = pair as NameStringPairType;
- if (p != null)
- return this.PropertyMapping.IndexOf(p);
+ if (this.PropertyMapping != null)
+ {
+ var p = pair as NameStringPairType;
+ if (p != null)
+ return this.PropertyMapping.IndexOf(p);
+ }
return -1;
}
int IVectorLayerDefinition.MoveUp(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos > 0)
+ if (this.PropertyMapping != null)
{
- int dest = pos - 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos > 0)
+ {
+ int dest = pos - 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
int IVectorLayerDefinition.MoveDown(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos < this.PropertyMapping.Count - 1)
+ if (this.PropertyMapping != null)
{
- int dest = pos + 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos < this.PropertyMapping.Count - 1)
+ {
+ int dest = pos + 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_4_0/VectorLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_4_0/VectorLayerDefinitionImpl.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/LayerDefinition/v2_4_0/VectorLayerDefinitionImpl.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -1881,26 +1881,32 @@
{
get
{
- foreach (var pair in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- yield return pair;
+ foreach (var pair in this.PropertyMapping)
+ {
+ yield return pair;
+ }
}
}
}
INameStringPair IVectorLayerDefinition.GetPropertyMapping(string name)
{
- foreach (var p in this.PropertyMapping)
+ if (this.PropertyMapping != null)
{
- if (p.Name == name)
- return p;
+ foreach (var p in this.PropertyMapping)
+ {
+ if (p.Name == name)
+ return p;
+ }
}
return null;
}
INameStringPair IVectorLayerDefinition.GetPropertyMappingAt(int index)
{
- if (index < 0 || index >= this.PropertyMapping.Count)
+ if (this.PropertyMapping == null || index < 0 || index >= this.PropertyMapping.Count)
throw new ArgumentOutOfRangeException();
var item = this.PropertyMapping[index];
@@ -1925,57 +1931,77 @@
{
var p = pair as NameStringPairType;
if (p != null)
+ {
+ if (this.PropertyMapping == null)
+ {
+ this.PropertyMapping = new BindingList<NameStringPairType>();
+ }
+
this.PropertyMapping.Add(p);
+ }
}
void IVectorLayerDefinition.RemovePropertyMapping(INameStringPair pair)
{
var p = pair as NameStringPairType;
- if (p != null)
- this.PropertyMapping.Remove(p);
+ var pmaps = this.PropertyMapping;
+ if (p != null && pmaps != null)
+ {
+ pmaps.Remove(p);
+ if (pmaps.Count == 0)
+ this.PropertyMapping = null;
+ }
}
int IVectorLayerDefinition.GetPosition(INameStringPair pair)
{
- var p = pair as NameStringPairType;
- if (p != null)
- return this.PropertyMapping.IndexOf(p);
-
+ if (this.PropertyMapping != null)
+ {
+ var p = pair as NameStringPairType;
+ if (p != null)
+ return this.PropertyMapping.IndexOf(p);
+ }
return -1;
}
int IVectorLayerDefinition.MoveUp(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos > 0)
+ if (this.PropertyMapping != null)
{
- int dest = pos - 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos > 0)
+ {
+ int dest = pos - 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
int IVectorLayerDefinition.MoveDown(INameStringPair pair)
{
- int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
- if (pos < this.PropertyMapping.Count - 1)
+ if (this.PropertyMapping != null)
{
- int dest = pos + 1;
- var p = this.PropertyMapping[dest];
- var p2 = (NameStringPairType)pair;
+ int pos = ((IVectorLayerDefinition)this).GetPosition(pair);
+ if (pos < this.PropertyMapping.Count - 1)
+ {
+ int dest = pos + 1;
+ var p = this.PropertyMapping[dest];
+ var p2 = (NameStringPairType)pair;
- //Swap
- this.PropertyMapping[dest] = p2;
- this.PropertyMapping[pos] = p;
+ //Swap
+ this.PropertyMapping[dest] = p2;
+ this.PropertyMapping[pos] = p;
- return dest;
+ return dest;
+ }
}
return -1;
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/Strings.Designer.cs 2017-01-24 12:41:11 UTC (rev 9121)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/Strings.Designer.cs 2017-01-24 15:26:36 UTC (rev 9122)
@@ -1,17 +1,17 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30319.34209
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
-namespace OSGeo.MapGuide.ObjectModels
-{
-
-
+namespace OSGeo.MapGuide.ObjectModels {
+ using System;
+
+
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
More information about the mapguide-commits
mailing list