/// <summary> /// Write this document's schema mappings from the given XML document /// </summary> /// <param name="node">The node.</param> /// <param name="mgr">The namespace manager.</param> protected override void ReadSchemaMappings(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr) { //var mappings = node.SelectNodes("SchemaMapping", mgr); foreach (XmlNode map in node.ChildNodes) { if (map.Name != "SchemaMapping") //NOXLATE { continue; } var sn = map.Attributes["name"]; //NOXLATE if (sn == null) { throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedAttribute, "name")); } foreach (XmlNode clsMap in map.ChildNodes) { if (clsMap.Name != "complexType") //NOXLATE { continue; } var item = new OdbcTableItem(); item.Parent = this; item.SchemaName = sn.Value; item.ReadXml(clsMap, mgr); AddOverride(item); } } }
/// <summary> /// Adds the specified table override /// </summary> /// <param name="item"></param> public void AddOverride(OdbcTableItem item) { _tables.Add(item); item.Parent = this; }
/// <summary> /// Write this document's schema mappings from the given XML document /// </summary> /// <param name="node">The node.</param> /// <param name="mgr">The namespace manager.</param> protected override void ReadSchemaMappings(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr) { //var mappings = node.SelectNodes("SchemaMapping", mgr); foreach (XmlNode map in node.ChildNodes) { if (map.Name != "SchemaMapping") //NOXLATE continue; var sn = map.Attributes["name"]; //NOXLATE if (sn == null) throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedAttribute, "name")); foreach (XmlNode clsMap in map.ChildNodes) { if (clsMap.Name != "complexType") //NOXLATE continue; var item = new OdbcTableItem(); item.Parent = this; item.SchemaName = sn.Value; item.ReadXml(clsMap, mgr); AddOverride(item); } } }
public void TestOdbcSaveLoad() { var schema = new FeatureSchema("Default", "Test schema"); var cls = new ClassDefinition("Cities", "Cities class"); cls.AddProperty(new DataPropertyDefinition("ID", "Primary Key") { DataType = DataPropertyType.Int64, IsNullable = false, IsAutoGenerated = true }, true); cls.AddProperty(new DataPropertyDefinition("Name", "City Name") { DataType = DataPropertyType.String, IsNullable = true, IsAutoGenerated = false, Length = 255 }); cls.AddProperty(new GeometricPropertyDefinition("Geometry", "Geometry property") { GeometricTypes = FeatureGeometricType.Point, SpecificGeometryTypes = new SpecificGeometryType[] { SpecificGeometryType.Point }, HasElevation = false, HasMeasure = false, SpatialContextAssociation = "Default" }); cls.AddProperty(new DataPropertyDefinition("Population", "Population") { DataType = DataPropertyType.Int32, IsNullable = true, IsAutoGenerated = false }); cls.DefaultGeometryPropertyName = "Geometry"; schema.AddClass(cls); 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 conf = new OdbcConfigurationDocument(); conf.AddSchema(schema); conf.AddSpatialContext(sc); var ov = new OdbcTableItem(); ov.SchemaName = schema.Name; ov.ClassName = cls.Name; ov.SpatialContextName = sc.Name; ov.XColumn = "Lon"; ov.YColumn = "Lat"; conf.AddOverride(ov); string path = "OdbcConfigTest.xml"; File.WriteAllText(path, conf.ToXml()); conf = null; string xml = File.ReadAllText(path); conf = ConfigurationDocument.LoadXml(xml) as OdbcConfigurationDocument; Assert.NotNull(conf); ov = conf.GetOverride("Default", "Cities"); Assert.NotNull(ov); Assert.AreEqual("Default", ov.SchemaName); Assert.AreEqual("Cities", ov.ClassName); Assert.AreEqual(sc.Name, ov.SpatialContextName); Assert.AreEqual("Lon", ov.XColumn); Assert.AreEqual("Lat", ov.YColumn); }