#region Disclaimer / License // Copyright (C) 2010, Jackie Ng // http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@gmail.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #endregion using System; using System.Collections.Generic; using System.Text; using System.Xml; using OSGeo.MapGuide.ObjectModels.Common; namespace OSGeo.MapGuide.MaestroAPI.Schema { /// /// Defines the types of properties in a FDO class definition /// public enum PropertyDefinitionType : int { /// /// Data Properties /// Data = 100, /// /// Geometric Properties /// Geometry = 102, /// /// Raster Properties /// Raster = 104, /// /// Association Properties /// Association = 103, /// /// Object Properties /// Object = 101 } /// /// Defines the valid types of property values /// public enum PropertyValueType : int { /// /// BLOB /// Blob = 10, /// /// Boolean /// Boolean = 1, /// /// Byte /// Byte = 2, /// /// CLOB /// Clob = 11, /// /// DateTime /// DateTime = 3, /// /// Double /// Double = 5, /// /// Feature /// Feature = 12, /// /// Geometry /// Geometry = 13, /// /// Int16 /// Int16 = 6, /// /// Int32 /// Int32 = 7, /// /// Int64 /// Int64 = 8, /// /// Invalid or Unknown /// Null = 0, /// /// Raster /// Raster = 14, /// /// Single /// Single = 4, /// /// String /// String = 9 } /// /// Defines the valid data types of data properties /// public enum DataPropertyType : int { /// /// BLOB /// Blob = PropertyValueType.Blob, /// /// Boolean /// Boolean = PropertyValueType.Boolean, /// /// Byte /// Byte = PropertyValueType.Byte, /// /// CLOB /// Clob = PropertyValueType.Clob, /// /// DateTime /// DateTime = PropertyValueType.DateTime, /// /// Double /// Double = PropertyValueType.Double, /// /// Int16 /// Int16 = PropertyValueType.Int16, /// /// Int32 /// Int32 = PropertyValueType.Int32, /// /// Int64 /// Int64 = PropertyValueType.Int64, /// /// Single /// Single = PropertyValueType.Single, /// /// String /// String = PropertyValueType.String } /// /// Base class of all property definitions /// public abstract class PropertyDefinition : SchemaElement, IFdoSerializable, IExpressionPropertySource { /// /// Gets the parent class definition /// public ClassDefinition Parent { get; internal set; } /// /// Gets the type of property /// public abstract PropertyDefinitionType Type { get; } /// /// Writes the current element's content /// /// /// public abstract void WriteXml(System.Xml.XmlDocument doc, System.Xml.XmlNode currentNode); /// /// Set the current element's content from the current XML node /// /// /// public abstract void ReadXml(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr); /// /// Parses the specified XML node into a Property Definition /// /// /// /// public static PropertyDefinition Parse(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr) { PropertyDefinition prop = null; var nn = node.Attributes["name"]; var nulln = node.Attributes["minOccurs"]; string name = Utility.DecodeFDOName(nn.Value); string desc = string.Empty; //Description var docNode = node.SelectSingleNode("xs:annotation/xs:documentation", mgr); //NOXLATE if (docNode != null) desc = docNode.InnerText; if (node.Attributes["type"] != null && node.Attributes["type"].Value == "gml:AbstractGeometryType") //NOXLATE { prop = new GeometricPropertyDefinition(name, desc); } else if (node["xs:simpleType"] == null) { prop = new RasterPropertyDefinition(name, desc); } else { if (node["xs:simpleType"] != null) prop = new DataPropertyDefinition(name, desc); } if (prop != null) prop.ReadXml(node, mgr); else throw new NotSupportedException("Unrecognized element. Only a subset of the FDO logical schema is supported here"); //LOCALIZEME return prop; } /// /// Gets the expression data type /// public abstract ExpressionDataType ExpressionType { get; } } }