Browse Source

Merge pull request #11514 from kenrowland/HPCC-20102

HPCC-20102 Look at refactoring componentName and itemType in XSD schema

Reviewed-By: Rodrigo Pastrana <rodrigo.pastrana@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 years ago
parent
commit
48a02600f1

+ 2 - 2
configuration/config2/EnvironmentNode.cpp

@@ -340,10 +340,10 @@ void EnvironmentNode::initialize()
 
     //
     // If we are a component and there is a buildSet attribute, set the value to the configItem's type
-    if (!(m_pSchemaItem->getProperty("componentName").empty())  && hasAttribute("buildSet"))
+    if (!(m_pSchemaItem->getProperty("itemType").empty()) && hasAttribute("buildSet"))
     {
         Status status;
-        setAttributeValue("buildSet", m_pSchemaItem->getProperty("componentName"), status);
+        setAttributeValue("buildSet", m_pSchemaItem->getProperty("itemType"), status);
     }
 
     //

+ 2 - 4
configuration/config2/SchemaItem.cpp

@@ -363,13 +363,13 @@ std::shared_ptr<SchemaItem> SchemaItem::getChild(const std::string &name)
 }
 
 
-std::shared_ptr<SchemaItem> SchemaItem::getChildByComponent(const std::string &name, std::string &componentName)
+std::shared_ptr<SchemaItem> SchemaItem::getChildByItemType(const std::string &name, std::string &itemType)
 {
     std::shared_ptr<SchemaItem> pItem = std::make_shared<SchemaItem>(name, "default", shared_from_this());
     auto childItRange = m_children.equal_range(name);
     for (auto childIt = childItRange.first; childIt != childItRange.second; ++childIt)
     {
-        if (childIt->second->getProperty("componentName") == componentName)
+        if (childIt->second->getProperty("itemType") == itemType)
         {
             pItem = childIt->second;
             break;
@@ -622,8 +622,6 @@ std::string SchemaItem::getItemType() const
     // Return itemType based on this set of rules
     if (!getProperty("itemType").empty())
         return getProperty("itemType");
-    else if (!getProperty("componentName").empty())
-        return getProperty("componentName");
 
     return getProperty("name");
 }

+ 1 - 1
configuration/config2/SchemaItem.hpp

@@ -53,7 +53,7 @@ class DECL_EXPORT SchemaItem : public std::enable_shared_from_this<SchemaItem>
         void addChild(const std::shared_ptr<SchemaItem> &pItem, const std::string &name) { m_children.insert({ name, pItem }); }
         void getChildren(std::vector<std::shared_ptr<SchemaItem>> &children, const std::string &name = std::string("")) const;
         std::shared_ptr<SchemaItem> getChild(const std::string &name);
-        std::shared_ptr<SchemaItem> getChildByComponent(const std::string &name, std::string &componentName);
+        std::shared_ptr<SchemaItem> getChildByItemType(const std::string &name, std::string &itemType);
         void setItemSchemaValue(const std::shared_ptr<SchemaValue> &pValue) { m_pItemValue = pValue; }
         std::shared_ptr<SchemaValue> getItemSchemaValue() const { return m_pItemValue; }
         bool isItemValueDefined() { return m_pItemValue != nullptr; }

+ 1 - 1
configuration/config2/XMLEnvironmentLoader.cpp

@@ -117,7 +117,7 @@ void XMLEnvironmentLoader::parse(const pt::ptree &envTree, const std::shared_ptr
             std::shared_ptr<SchemaItem> pSchemaItem;
             if (!typeName.empty())
             {
-                pSchemaItem = pConfigItem->getChildByComponent(elemName, typeName);
+                pSchemaItem = pConfigItem->getChildByItemType(elemName, typeName);
             }
             else
             {

+ 1 - 1
configuration/config2/XMLEnvironmentMgr.cpp

@@ -112,7 +112,7 @@ void XMLEnvironmentMgr::parse(const pt::ptree &envTree, const std::shared_ptr<Sc
             std::shared_ptr<SchemaItem> pSchemaItem;
             if (!typeName.empty())
             {
-                pSchemaItem = pConfigItem->getChildByComponent(elemName, typeName);
+                pSchemaItem = pConfigItem->getChildByItemType(elemName, typeName);
             }
             else
             {

+ 1 - 3
configuration/config2/XSDSchemaParser.cpp

@@ -294,7 +294,6 @@ void XSDSchemaParser::parseElement(const pt::ptree &elemTree)
         std::string displayName = elemTree.get("<xmlattr>.hpcc:displayName", elementName);
         std::string tooltip = elemTree.get("<xmlattr>.hpcc:tooltip", "");
         std::string typeName = elemTree.get("<xmlattr>.type", "");
-        std::string componentName = elemTree.get("<xmlattr>.hpcc:componentName", "");
         std::string itemType = elemTree.get("<xmlattr>.hpcc:itemType", "");
         std::string insertLimitType = elemTree.get("<xmlattr>.hpcc:insertLimitType", "");
         std::string insertLimitData = elemTree.get("<xmlattr>.hpcc:insertLimitData", "");
@@ -306,10 +305,9 @@ void XSDSchemaParser::parseElement(const pt::ptree &elemTree)
         if (!className.empty()) pNewSchemaItem->setProperty("className", className);
         if (!displayName.empty()) pNewSchemaItem->setProperty("displayName", displayName);
         if (!tooltip.empty()) pNewSchemaItem->setProperty("tooltip", tooltip);
-        if (!componentName.empty()) pNewSchemaItem->setProperty("componentName", componentName);
-        if (!itemType.empty()) pNewSchemaItem->setProperty("itemType", itemType);
         if (!insertLimitType.empty()) pNewSchemaItem->setProperty("insertLimitType", insertLimitType);
         if (!insertLimitData.empty()) pNewSchemaItem->setProperty("insertLimitData", insertLimitData);
+        pNewSchemaItem->setProperty("itemType", itemType);
         pNewSchemaItem->setProperty("category", category.empty() ? displayName : category );
         pNewSchemaItem->setMinInstances(minOccurs);
         pNewSchemaItem->setMaxInstances(maxOccurs);

+ 1 - 1
initfiles/componentfiles/configschema/xsd/dafilesrv.xsd

@@ -10,7 +10,7 @@
             <xs:attribute name="throttleCPULimit" type="xs:nonNegativeInteger" use="optional" default="75" hpcc:tooltip="if after the initial delay, the CPU % falls below this setting, the transaction will be allowed to continue, i.e. the limit can be exceeded this way. Overrides global settting."/>
         </xs:attributeGroup>
         <xs:sequence>
-            <xs:element name="DafilesrvProcess" hpcc:class="valueSet" hpcc:docid="daFs.t">
+            <xs:element name="DafilesrvProcess" hpcc:itemType="dafilesrv" hpcc:class="valueSet" hpcc:docid="daFs.t">
                 <xs:annotation>
                     <xs:documentation>Describes an DFUFileSrv installation</xs:documentation>
                 </xs:annotation>

+ 1 - 1
initfiles/componentfiles/configschema/xsd/eclagent.xsd

@@ -17,7 +17,7 @@
             <xs:attribute name="wuQueueName" hpcc:displayName="Workunit Queue Name" hpcc:group="Options" type="xs:string" use="optional" default="" hpcc:tooltip="eclAgent Workunit Execution Queue Name" hpcc:autogenforwizard="true" hpcc:autogensuffix="_queue"/> <!-- is this keyed? do we need new auto name option for suffix -->
         </xs:attributeGroup>
         <xs:sequence>
-            <xs:element name="EclAgentProcess" hpcc:class="component" hpcc:componentName="eclagent" hpcc:displayName="ECL Agent Process" maxOccurs="unbounded" hpcc:docid="EA.t1">
+            <xs:element name="EclAgentProcess" hpcc:class="component" hpcc:itemType="eclAgent" hpcc:displayName="ECL Agent Process" maxOccurs="unbounded" hpcc:docid="EA.t1">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element name="Instance" maxOccurs="unbounded" hpcc:displayName="Bound Computers">

+ 1 - 1
initfiles/componentfiles/configschema/xsd/esp.xsd

@@ -5,7 +5,7 @@
     <xs:include schemaLocation="types.xsd"/>
     <xs:complexType name="esp">
         <xs:sequence>
-            <xs:element name="EspProcess" hpcc:class="component" hpcc:category="ESP Process" hpcc:componentName="esp" hpcc:displayName="ESP Process"  hpcc:docid="ESP.t6" maxOccurs="unbounded">
+            <xs:element name="EspProcess" hpcc:class="component" hpcc:category="ESP Process" hpcc:itemType="esp" hpcc:displayName="ESP Process"  hpcc:docid="ESP.t6" maxOccurs="unbounded">
                 <xs:annotation>
                     <xs:documentation>ESP Service Bindings</xs:documentation>
                 </xs:annotation>

+ 1 - 1
initfiles/componentfiles/configschema/xsd/esp_service_smc.xsd

@@ -27,7 +27,7 @@
         </xs:attributeGroup>
 
         <xs:sequence>
-            <xs:element name="EspService" hpcc:class="component" hpcc:componentName="espsmc" hpcc:category="ESP Service" hpcc:displayName="ESP SMC" maxOccurs="unbounded" hpcc:docid="SMC-T01">
+            <xs:element name="EspService" hpcc:class="component" hpcc:category="ESP Service" hpcc:itemType="espsmc" hpcc:displayName="ESP SMC" maxOccurs="unbounded" hpcc:docid="SMC-T01">
                 <xs:complexType>
 
                     <xs:sequence>

+ 1 - 1
initfiles/componentfiles/configschema/xsd/esp_service_wsecl2.xsd

@@ -5,7 +5,7 @@
     <xs:include schemaLocation="types.xsd"/>
     <xs:complexType name="ws_ecl">
         <xs:sequence>
-            <xs:element name="EspService" maxOccurs="unbounded" hpcc:class="component" hpcc:category="ESP Service" hpcc:displayName="WS ECL??" hpcc:componentName="ws_ecl" hpcc:docid="MyWS2-T03">
+            <xs:element name="EspService" maxOccurs="unbounded" hpcc:class="component" hpcc:category="ESP Service" hpcc:itemType="ws_ecl" hpcc:displayName="WS ECL??" hpcc:docid="MyWS2-T03">
                 <xs:complexType>
                     <xs:sequence>
 

+ 19 - 12
initfiles/componentfiles/configschema/xsd/hardware.xsd

@@ -1,24 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"
-    xmlns:hpcc="someuri">
+<xs:schema
+        xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"
+        xmlns:hpcc="someuri">
     <xs:include schemaLocation="types.xsd"/>
-    <xs:complexType name="hardware">
+    <xs:complexType name="hardware" >
         <xs:sequence>
-            <xs:element name="Hardware">
+            <xs:element name="Hardware" >
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element name="ComputerType" maxOccurs="unbounded" use="required" hpcc:category="Computer Types" hpcc:class="valueSet">
+                        <xs:element name="ComputerType" maxOccurs="unbounded" use="required" hpcc:category="Computer Types"
+                                    hpcc:class="valueSet">
                             <xs:complexType>
                                 <xs:attribute name="name" group="Attributes" type="xs:string" hpcc:displayName="Name" use="required" hpcc:uniqueKey="computertype_name"/>
-                                <xs:attribute name="manufacturer" group="Attributes" hpcc:displayName="Manufacturer" type="xs:string"/>
+                                <xs:attribute name="manufacturer" group="Attributes" hpcc:displayName="Manufacturer"type="xs:string"/>
                                 <xs:attribute name="computerType" group="Attributes" hpcc:displayName="Computer Type" type="xs:string"/>
                                 <xs:attribute name="nicSpeed" group="Attributes" hpcc:displayName="NIC Speed" type="xs:nonNegativeInteger"/>
                                 <xs:attribute name="opSys">
                                     <xs:simpleType>
                                         <xs:restriction base="xs:string">
-                                            <xs:enumeration value="linux" hpcc:displayName="Linux"/>
-                                            <xs:enumeration value="solaris" hpcc:displayName="Solaris"/>
-                                            <xs:enumeration value="W2K" hpcc:displayName="Windows 2000"/>
+                                            <xs:enumeration value="linux"hpcc:displayName="Linux"/>
+                                            <xs:enumeration value="solaris"hpcc:displayName="Solaris"/>
+                                            <xs:enumeration value="W2K"hpcc:displayName="Windows 2000"/>
                                         </xs:restriction>
                                     </xs:simpleType>
                                 </xs:attribute>
@@ -31,13 +33,15 @@
                             </xs:complexType>
                         </xs:element>
 
-                        <xs:element name="Switch" maxOccurs="unbounded" use="required" hpcc:class="valueSet" hpcc:displayName="Switches">
+                        <xs:element name="Switch" maxOccurs="unbounded" hpcc:class="valueSet"
+                                    hpcc:doc="Describes a switch that is contained in the environment">
                             <xs:complexType>
-                                <xs:attribute name="name" group="Attributes" hpcc:displayName="Name" type="xs:string" use="required" hpcc:uniqueKey="switch_name"/>
+                                <xs:attribute name="name" type="xs:string"/>
                             </xs:complexType>
                         </xs:element>
 
-                        <xs:element name="Computer" maxOccurs="unbounded" use="required" hpcc:class="valueSet" hpcc:displayName="Computers">
+                        <xs:element name="Computer" maxOccurs="unbounded" use="required"hpcc:class="valueSet"
+                                    hpcc:displayName="Computers">
                             <xs:complexType>
                                 <xs:attribute name="name" group="Attributes" hpcc:displayName="Name" type="nodeName" use="required" hpcc:uniqueKey="computer_name"/>
                                 <xs:attribute name="netAddress" group="Attributes" hpcc:displayName="Net Address" type="ipV4Address" use="required" hpcc:uniqueKey="computer_netaddress"/>
@@ -47,6 +51,9 @@
                         </xs:element>
                     </xs:sequence>
                 </xs:complexType>
+
+
+
             </xs:element>
         </xs:sequence>
     </xs:complexType>

+ 1 - 1
initfiles/componentfiles/configschema/xsd/ldapserver.xsd

@@ -22,7 +22,7 @@
     <xs:include schemaLocation="types.xsd"/>
     <xs:complexType name="ldapserver">
         <xs:sequence>
-            <xs:element name="LDAPServerProcess" hpcc:class="component" hpcc:category="LDAP Process" hpcc:componentName="ldapserver" hpcc:displayName="Active Directory LDAP process" hpcc:docid="ldapSrv" maxOccurs="unbounded">
+            <xs:element name="LDAPServerProcess" hpcc:class="component" hpcc:category="LDAP Process" hpcc:itemType="ldapserver" hpcc:displayName="Active Directory LDAP process" hpcc:docid="ldapSrv" maxOccurs="unbounded">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element type="hwinstance" hpcc:displayName="Instances"/>

+ 1 - 1
initfiles/componentfiles/configschema/xsd/roxie.xsd

@@ -22,7 +22,7 @@
     <xs:include schemaLocation="types.xsd"/>
     <xs:complexType name="roxiecluster">
         <xs:sequence>
-            <xs:element name="RoxieCluster" maxOccurs="unbounded" hpcc:displayName="Roxie Cluster" hpcc:class="component" hpcc:componentName="roxiecluster">
+            <xs:element name="RoxieCluster" maxOccurs="unbounded" hpcc:itemType="roxiecluster" hpcc:displayName="Roxie Cluster" hpcc:class="component">
                 <!-- should make this default to the complexType name -->
                 <xs:complexType>
                     <xs:sequence>