[mapguide-commits] r9155 - in sandbox/jng/clean_json/Common: PlatformBase/Services Schema

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Apr 19 08:26:54 PDT 2017


Author: jng
Date: 2017-04-19 08:26:54 -0700 (Wed, 19 Apr 2017)
New Revision: 9155

Added:
   sandbox/jng/clean_json/Common/Schema/ClassDefinition-3.3.0.xsd
   sandbox/jng/clean_json/Common/Schema/FeatureSchemaCollection-3.3.0.xsd
Modified:
   sandbox/jng/clean_json/Common/PlatformBase/Services/ClassDefinition.cpp
   sandbox/jng/clean_json/Common/PlatformBase/Services/ClassDefinition.h
   sandbox/jng/clean_json/Common/PlatformBase/Services/FeatureSchemaCollection.cpp
   sandbox/jng/clean_json/Common/PlatformBase/Services/FeatureSchemaCollection.h
Log:
Initial implementation of simplified XML schemas/responses for Feature Schemas and Class Definitions

Modified: sandbox/jng/clean_json/Common/PlatformBase/Services/ClassDefinition.cpp
===================================================================
--- sandbox/jng/clean_json/Common/PlatformBase/Services/ClassDefinition.cpp	2017-04-19 13:37:35 UTC (rev 9154)
+++ sandbox/jng/clean_json/Common/PlatformBase/Services/ClassDefinition.cpp	2017-04-19 15:26:54 UTC (rev 9155)
@@ -243,6 +243,188 @@
 }
 
 //////////////////////////////////////////////////////////////
+void MgClassDefinition::ToSimpleXml(string & str, bool includeProlog)
+{
+    STRING xml;
+    if (includeProlog) 
+    {
+        xml = L"<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+        xml.append(L"<ClassDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"ClassDefinition-3.3.0.xsd\">");
+    }
+    else 
+    {
+        xml.append(L"<ClassDefinition>");
+    }
+
+    xml.append(L"<Name>");
+    xml.append(GetName());
+    xml.append(L"</Name>");
+
+    xml.append(L"<Description>");
+    xml.append(GetDescription());
+    xml.append(L"</Description>");
+
+    xml.append(L"<IsAbstract>");
+    xml.append(IsAbstract() ? L"true" : L"false");
+    xml.append(L"</IsAbstract>");
+
+    xml.append(L"<IsComputed>");
+    xml.append(IsComputed() ? L"true" : L"false");
+    xml.append(L"</IsComputed>");
+
+    xml.append(L"<DefaultGeometryPropertyName>");
+    xml.append(GetDefaultGeometryPropertyName());
+    xml.append(L"</DefaultGeometryPropertyName>");
+
+    xml.append(L"<Properties>");
+    Ptr<MgPropertyDefinitionCollection> props = GetProperties();
+    INT32 pcount = props->GetCount();
+    for (INT32 i = 0; i < pcount; i++) 
+    {
+        Ptr<MgPropertyDefinition> pdef = props->GetItem(i);
+        INT32 ptype = pdef->GetPropertyType();
+        if (ptype == MgFeaturePropertyType::DataProperty ||
+            ptype == MgFeaturePropertyType::RasterProperty ||
+            ptype == MgFeaturePropertyType::GeometricProperty)
+        {
+            xml.append(L"<Property>");
+
+            xml.append(L"<Name>");
+            xml.append(pdef->GetName());
+            xml.append(L"</Name>");
+
+            xml.append(L"<Description>");
+            xml.append(pdef->GetDescription());
+            xml.append(L"</Description>");
+            
+            xml.append(L"<PropertyType>");
+            STRING wpType;
+            MgUtil::Int32ToString(ptype, wpType);
+            xml.append(wpType);
+            xml.append(L"</PropertyType>");
+
+            MgDataPropertyDefinition* dpd = dynamic_cast<MgDataPropertyDefinition*>(pdef.p);
+            MgGeometricPropertyDefinition* gpd = dynamic_cast<MgGeometricPropertyDefinition*>(pdef.p);
+            MgRasterPropertyDefinition* rpd = dynamic_cast<MgRasterPropertyDefinition*>(pdef.p);
+
+            if (NULL != dpd)
+            {
+                xml.append(L"<DataType>");
+                STRING wDataType;
+                MgUtil::Int32ToString(dpd->GetDataType(), wDataType);
+                xml.append(wDataType);
+                xml.append(L"</DataType>");
+
+                xml.append(L"<DefaultValue>");
+                xml.append(dpd->GetDefaultValue());
+                xml.append(L"</DefaultValue>");
+
+                xml.append(L"<Length>");
+                STRING wLength;
+                MgUtil::Int32ToString(dpd->GetLength(), wLength);
+                xml.append(wLength);
+                xml.append(L"</Length>");
+
+                xml.append(L"<Nullable>");
+                xml.append(dpd->GetNullable() ? L"true" : L"false");
+                xml.append(L"</Nullable>");
+
+                xml.append(L"<ReadOnly>");
+                xml.append(dpd->GetReadOnly() ? L"true" : L"false");
+                xml.append(L"</ReadOnly>");
+
+                xml.append(L"<IsAutoGenerated>");
+                xml.append(dpd->IsAutoGenerated() ? L"true" : L"false");
+                xml.append(L"</IsAutoGenerated>");
+
+                xml.append(L"<Precision>");
+                STRING wPrecision;
+                MgUtil::Int32ToString(dpd->GetPrecision(), wPrecision);
+                xml.append(wPrecision);
+                xml.append(L"</Precision>");
+
+                xml.append(L"<Scale>");
+                STRING wScale;
+                MgUtil::Int32ToString(dpd->GetScale(), wScale);
+                xml.append(wScale);
+                xml.append(L"</Scale>");
+            }
+            else if (NULL != gpd)
+            {
+                xml.append(L"<ReadOnly>");
+                xml.append(gpd->GetReadOnly() ? L"true" : L"false");
+                xml.append(L"</ReadOnly>");
+
+                xml.append(L"<SpatialContextAssocation>");
+                xml.append(gpd->GetSpatialContextAssociation());
+                xml.append(L"</SpatialContextAssociation>");
+
+                xml.append(L"<GeometryTypes>");
+                STRING wGeomTypes;
+                MgUtil::Int32ToString(gpd->GetGeometryTypes(), wGeomTypes);
+                xml.append(wGeomTypes);
+                xml.append(L"</GeometryTypes>");
+
+                xml.append(L"<SpecificGeometryTypes>");
+                Ptr<MgGeometryTypeInfo> sgt = gpd->GetSpecificGeometryTypes();
+                INT32 scount = sgt->GetCount();
+                for (INT32 g = 0; g < scount; g++)
+                {
+                    INT32 gt = sgt->GetType(g);
+                    STRING wSpecGeomType;
+                    MgUtil::Int32ToString(gt, wSpecGeomType);
+                    xml.append(L"<Type>");
+                    xml.append(wSpecGeomType);
+                    xml.append(L"</Type>");
+                }
+                xml.append(L"</SpecificGeometryTypes>");
+
+                xml.append(L"<HasElevation>");
+                xml.append(gpd->GetHasElevation() ? L"true" : L"false");
+                xml.append(L"</HasElevation>");
+
+                xml.append(L"<HasMeasure>");
+                xml.append(gpd->GetHasMeasure() ? L"true" : L"false");
+                xml.append(L"</HasMeasure>");
+            }
+            else if (NULL != rpd)
+            {
+                xml.append(L"<Nullable>");
+                xml.append(rpd->GetNullable() ? L"true" : L"false");
+                xml.append(L"</Nullable>");
+
+                xml.append(L"<ReadOnly>");
+                xml.append(rpd->GetReadOnly() ? L"true" : L"false");
+                xml.append(L"</ReadOnly>");
+
+                xml.append(L"<SpatialContextAssocation>");
+                xml.append(rpd->GetSpatialContextAssociation());
+                xml.append(L"</SpatialContextAssociation>");
+
+                xml.append(L"<DefaultImageXSize>");
+                STRING wImageXSize;
+                MgUtil::Int32ToString(rpd->GetDefaultImageXSize(), wImageXSize);
+                xml.append(wImageXSize);
+                xml.append(L"</DefaultImageXSize>");
+
+                xml.append(L"<DefaultImageYSize>");
+                STRING wImageYSize;
+                MgUtil::Int32ToString(rpd->GetDefaultImageYSize(), wImageYSize);
+                xml.append(wImageYSize);
+                xml.append(L"</DefaultImageYSize>");
+            }
+
+            xml.append(L"</Property>");
+        }
+    }
+    xml.append(L"</Properties>");
+
+    xml.append(L"</ClassDefinition>");
+
+    MgUtil::WideCharToMultiByte(xml, str);
+}
+
+//////////////////////////////////////////////////////////////
 void MgClassDefinition::ToXml(string &str)
 {
     assert(!m_serializedXml.empty());

Modified: sandbox/jng/clean_json/Common/PlatformBase/Services/ClassDefinition.h
===================================================================
--- sandbox/jng/clean_json/Common/PlatformBase/Services/ClassDefinition.h	2017-04-19 13:37:35 UTC (rev 9154)
+++ sandbox/jng/clean_json/Common/PlatformBase/Services/ClassDefinition.h	2017-04-19 15:26:54 UTC (rev 9155)
@@ -334,6 +334,7 @@
     bool CanSetName();
     INT32 GetClassId();
     void Dispose();
+    void ToSimpleXml(string &str, bool includeProlog);
     void ToXml(string &str);
     void SetSerializedXml(CREFSTRING strXml);
     bool HasRasterProperty();

Modified: sandbox/jng/clean_json/Common/PlatformBase/Services/FeatureSchemaCollection.cpp
===================================================================
--- sandbox/jng/clean_json/Common/PlatformBase/Services/FeatureSchemaCollection.cpp	2017-04-19 13:37:35 UTC (rev 9154)
+++ sandbox/jng/clean_json/Common/PlatformBase/Services/FeatureSchemaCollection.cpp	2017-04-19 15:26:54 UTC (rev 9155)
@@ -200,6 +200,50 @@
     }
 }
 
+void MgFeatureSchemaCollection::ToSimpleXml(std::string & str)
+{
+    str = "<FeatureSchemaCollection xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FeatureSchemaCollection-3.3.0.xsd\">";
+
+    INT32 fcount = GetCount();
+    for (INT32 i = 0; i < fcount; i++)
+    {
+        Ptr<MgFeatureSchema> fs = GetItem(i);
+        str.append("<FeatureSchema>");
+        
+        str.append("<Name>");
+        std::string mbName;
+        MgUtil::WideCharToMultiByte(fs->GetName(), mbName);
+        str.append(mbName);
+        str.append("</Name>");
+
+        str.append("<Description>");
+        std::string mbDesc;
+        MgUtil::WideCharToMultiByte(fs->GetDescription(), mbDesc);
+        str.append(mbDesc);
+        str.append("</Description>");
+
+        str.append("<Classes>");
+
+        Ptr<MgClassDefinitionCollection> classes = fs->GetClasses();
+        INT32 ccount = classes->GetCount();
+
+        for (INT32 j = 0; j < ccount; j++) 
+        {
+            Ptr<MgClassDefinition> clsDef = classes->GetItem(j);
+            std::string mbCls;
+            clsDef->ToSimpleXml(mbCls, false);
+
+            str.append(mbCls);
+        }
+
+        str.append("</Classes>");
+
+        str.append("</FeatureSchema>");
+    }
+
+    str.append("</FeatureSchemaCollection>");
+}
+
 /////////////////////////////////////////////////////////////////
 /// <summary>
 /// Returns the classId.

Modified: sandbox/jng/clean_json/Common/PlatformBase/Services/FeatureSchemaCollection.h
===================================================================
--- sandbox/jng/clean_json/Common/PlatformBase/Services/FeatureSchemaCollection.h	2017-04-19 13:37:35 UTC (rev 9154)
+++ sandbox/jng/clean_json/Common/PlatformBase/Services/FeatureSchemaCollection.h	2017-04-19 15:26:54 UTC (rev 9155)
@@ -331,6 +331,8 @@
     ///
     void Deserialize(MgStream* stream);
 
+    void ToSimpleXml(std::string& str);
+
 protected:
 
     /////////////////////////////////////////////////////////////////

Added: sandbox/jng/clean_json/Common/Schema/ClassDefinition-3.3.0.xsd
===================================================================
--- sandbox/jng/clean_json/Common/Schema/ClassDefinition-3.3.0.xsd	                        (rev 0)
+++ sandbox/jng/clean_json/Common/Schema/ClassDefinition-3.3.0.xsd	2017-04-19 15:26:54 UTC (rev 9155)
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
+  <xs:element name="ClassDefinition" type="ClassDefinition">
+    <xs:annotation>
+      <xs:documentation>A FDO Class Definition.</xs:documentation>
+    </xs:annotation>
+  </xs:element>
+  <xs:complexType name="ClassDefinition">
+    <xs:annotation>
+      <xs:documentation>A FDO Class Definition.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of this class definition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Description" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The description of this class definition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="IsAbstract" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Indicates if this class definition is abstract</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="IsComputed" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Indicates if this class definition is computed</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="DefaultGeometryPropertyName" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of the designated geometry property of this class definition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Properties" type="PropertyDefinitionCollection">
+        <xs:annotation>
+          <xs:documentation>The collection of properties in this class definition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="PropertyDefinitionCollection">
+    <xs:annotation>
+      <xs:documentation>A collection of property definitions</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Property" type="PropertyDefinition" minOccurs="0" maxOccurs="unbounded" />
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="PropertyDefinition">
+    <xs:annotation>
+      <xs:documentation>A FDO property definition</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of this property definition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Description" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The description of this property definition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="PropertyType" type="xs:integer">
+        <xs:annotation>
+          <xs:documentation>The type of this property definition. The value here is within the same set of values from MgFeaturePropertyType</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="IsIdentity" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Indicates if this property is an identity property</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="DataType" type="xs:integer" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The data type of this data property. The value here is within the same set of values from MgPropertyType. Only applicable if this is a data property</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="DefaultValue" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The default value for this data property. Only applicable if this is a data property and the data type is string</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Length" type="xs:integer" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The maximum length for this data property. Only applicable if this is a data property and the data type is string</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Nullable" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Indicates if this property is nullable. Only applicable if this is a raster or data property.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ReadOnly" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Indicates if this property is read-only. Only applicable if this is a raster, geometry or data property.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="IsAutoGenerated" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Indicates if this property is auto-generated. Only applicable if this is a data property and the data type is int.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Precision" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The precision (total number of digits) of this property. Only applicable if this is a data property and the data type is decimal.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Scale" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The scale (number of digits to the right of the decimal point) of this property. Only applicable if this is a data property and the data type is decimal.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SpatialContextAssociation" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The spatial context name associated with this geometric property. Only applicable if this is a raster or geometry property.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="GeometryTypes" type="xs:integer" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A bitmask that indicates the types which specify the categories of the geometries (point, line, surface, solid) that can be stored in this geometric property. Values here come from MgFeatureGeometricType.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SpecificGeometryTypes" type="GeometryTypeInfo" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Indicates the specific geometry types that can be stored in this geometric property. Values here come from MgGeometryType.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="HasElevation" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Indicates if this property has elevation. Only applicable if this is a geometry property.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="HasMeasure" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Indicates if this property has measure. Only applicable if this is a geometry property.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="DefaultImageXSize" type="xs:integer" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The default size of the image file in the horizontal direction, in pixels (number of columns)</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="DefaultImageYSize" type="xs:integer" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The default size of the image file in the vertical direction, in pixels (number of rows).</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="GeometryTypeInfo">
+    <xs:annotation>
+      <xs:documentation>Defines a list of geometric types</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Type" type="xs:integer" minOccurs="0" maxOccurs="unbounded" />
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
\ No newline at end of file

Added: sandbox/jng/clean_json/Common/Schema/FeatureSchemaCollection-3.3.0.xsd
===================================================================
--- sandbox/jng/clean_json/Common/Schema/FeatureSchemaCollection-3.3.0.xsd	                        (rev 0)
+++ sandbox/jng/clean_json/Common/Schema/FeatureSchemaCollection-3.3.0.xsd	2017-04-19 15:26:54 UTC (rev 9155)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
+  <xs:include schemaLocation="ClassDefinition-3.3.0.xsd"/>
+  <xs:element name="FeatureSchemaCollection" type="FeatureSchemaCollection">
+    <xs:annotation>
+      <xs:documentation>A FDO Feature Schema Definition.</xs:documentation>
+    </xs:annotation>
+  </xs:element>
+  <xs:complexType name="FeatureSchemaCollection">
+    <xs:sequence>
+      <xs:element name="FeatureSchema" type="FeatureSchema" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>The feature schemas in this collection</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="FeatureSchema">
+    <xs:annotation>
+      <xs:documentation>A FDO Feature Schema.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of this feature schema</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Description" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The description of this feature schema</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Classes" type="ClassDefinitionCollection">
+        <xs:annotation>
+          <xs:documentation>The collection of classes in this schema</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="ClassDefinitionCollection">
+    <xs:annotation>
+      <xs:documentation>A collection of FDO class definitions</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="ClassDefinition" type="ClassDefinition" />
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
\ No newline at end of file



More information about the mapguide-commits mailing list