ComponentFromXSD.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2018 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "deployutils.hpp"
  14. #include "jliball.hpp"
  15. //#include "computerpicker.hpp"
  16. //#include "configenvhelper.hpp"
  17. //#include "configengcallback.hpp"
  18. //#include "xslprocessor.hpp"
  19. //#include "jwrapper.hpp"
  20. //#include "wizardInputs.hpp"
  21. #include "build-config.h"
  22. //#include "confighelper.hpp"
  23. #include "ComponentFromXSD.hpp"
  24. #include "EnvHelper.hpp"
  25. #include "SWProcess.hpp"
  26. namespace ech
  27. {
  28. #define TRACE_SCHEMA_NODE(msg, schemaNode)
  29. //#define CONFIGMGR_JSPATH "./"
  30. #define STANDARD_COMPFILESDIR INSTALL_DIR
  31. #define STANDARD_CONFIGXMLDIR COMPONENTFILES_DIR"/configxml"
  32. ComponentFromXSD::ComponentFromXSD(EnvHelper* peh):m_eh(peh), m_pCompTree(NULL),m_pDefTree(NULL),
  33. m_pSchemaRoot(NULL),m_numAttrs(0),m_allSubTypes(true),m_genOptional(true),m_wizFlag(true)
  34. {
  35. m_pEnv.set(peh->getEnvTree());
  36. }
  37. ComponentFromXSD::~ComponentFromXSD()
  38. {
  39. m_pEnv.clear();
  40. m_pSchemaRoot.clear();
  41. }
  42. void ComponentFromXSD::CreateAttributeFromSchema(IPropertyTree& attr,
  43. const char *compName, const char* childElementName)
  44. {
  45. StringBuffer attrname;
  46. StringBuffer strBuf;
  47. StringBuffer aName;
  48. StringBuffer value, tempPath, wizDefVal;
  49. attrname.append(attr.queryProp(XML_ATTR_NAME));
  50. const char *use = attr.queryProp("@use");
  51. if (!m_genOptional && use && *use && !strcmp(use, "optional"))
  52. {
  53. if (childElementName)
  54. {
  55. StringBuffer xpath;
  56. xpath.clear().append(childElementName);
  57. IPropertyTree* pChild = m_pCompTree->queryPropTree(xpath.str());
  58. if (!pChild)
  59. pChild = m_pCompTree->addPropTree(childElementName, createPTree());
  60. }
  61. return;
  62. }
  63. if (m_wizFlag)
  64. {
  65. if (attr.hasProp("./xs:annotation/xs:appinfo/autogenforwizard"))
  66. {
  67. value.clear().append(attr.queryProp("./xs:annotation/xs:appinfo/autogenforwizard"));
  68. if (!strcmp(value.str(),"1"))
  69. {
  70. getValueForTypeInXSD(attr, compName, wizDefVal);
  71. }
  72. }
  73. else
  74. return ;
  75. }
  76. if (childElementName)
  77. attrname.append(childElementName);
  78. const char *defaultValue = attr.queryProp("@default");
  79. StringBuffer sbdefaultValue;
  80. if (defaultValue)
  81. {
  82. sbdefaultValue.clear().append(defaultValue);
  83. sbdefaultValue.replaceString("\\", "\\\\");
  84. }
  85. if (wizDefVal.length() > 0)
  86. {
  87. sbdefaultValue.clear().append(wizDefVal);
  88. }
  89. if (m_pCompTree)
  90. {
  91. StringBuffer xpath;
  92. if (!childElementName)
  93. {
  94. xpath.clear().append("@").append(attrname);
  95. m_pCompTree->addProp(xpath, sbdefaultValue.str());
  96. }
  97. else
  98. {
  99. xpath.clear().append(childElementName);
  100. IPropertyTree* pChild = m_pCompTree->queryPropTree(xpath.str());
  101. if (!pChild)
  102. pChild = m_pCompTree->addPropTree(childElementName, createPTree());
  103. xpath.clear().append("@").append(attr.queryProp(XML_ATTR_NAME));
  104. pChild->addProp(xpath, sbdefaultValue.str());
  105. }
  106. }
  107. }
  108. void ComponentFromXSD::AddAttributeFromSchema(IPropertyTree& schemaNode,
  109. const char *elemName, StringBuffer& compName, const char* childElementName)
  110. {
  111. CreateAttributeFromSchema(schemaNode, compName, childElementName);
  112. }
  113. void ComponentFromXSD::AddAttributesFromSchema(IPropertyTree* pSchema,
  114. StringBuffer& compName, const char* childElementName)
  115. {
  116. if (pSchema)
  117. {
  118. //add attributes defined for this element
  119. Owned<IPropertyTreeIterator> attrIter = pSchema->getElements("xs:complexType/xs:attribute");
  120. ForEach(*attrIter)
  121. {
  122. AddAttributeFromSchema(attrIter->query(), "", compName, childElementName);
  123. }
  124. if (childElementName && !strcmp(childElementName, XML_TAG_INSTANCE))
  125. {
  126. const char* pszNameAttr = "<xs:attribute name='name' type='xs:string' use='optional'><xs:annotation><xs:appinfo><viewType>hidden</viewType></xs:appinfo></xs:annotation></xs:attribute>";
  127. Owned<IPropertyTree> pSchemaAttrNode = createPTreeFromXMLString(pszNameAttr);
  128. AddAttributeFromSchema(*pSchemaAttrNode, "", compName, childElementName);
  129. }
  130. // or if it's an attribute group, then try this variety...
  131. attrIter.setown(pSchema->getElements("xs:attribute"));
  132. ForEach(*attrIter)
  133. {
  134. AddAttributeFromSchema(attrIter->query(), "", compName, childElementName);
  135. }
  136. Owned<IPropertyTreeIterator> simple = pSchema->getElements("*");
  137. ForEach(*simple)
  138. {
  139. IPropertyTree &element = simple->query();
  140. const char* pszElementName = element.queryName();
  141. if (!strcmp(pszElementName, "xs:complexContent"))
  142. AddAttributesFromSchema(&element, compName, NULL);
  143. }
  144. }
  145. }
  146. void ComponentFromXSD::ProcessElementSchemaNode(IPropertyTree* pElement,
  147. IPropertyTree* pParentElement, StringBuffer& sbCompName)
  148. {
  149. bool bOptSubType = false;
  150. if (pElement)
  151. {
  152. TRACE_SCHEMA_NODE("ProcessElementSchemaNode", pElement);
  153. const char* szParentElementName = pParentElement->queryProp(XML_ATTR_NAME);
  154. const char* szElementName = pElement->queryProp(XML_ATTR_NAME);
  155. const char* szCaption = szElementName;
  156. //const char* tabName = pElement->queryProp("xs:annotation/xs:appinfo/title");
  157. //if (tabName)
  158. // szCaption = tabName;
  159. IPropertyTree* pViewSchemaNode = pElement; //default for child view
  160. IPropertyTree* pInstanceNode = pParentElement;//default for child view
  161. bool bInstanceView = false;
  162. bool bViewChildNodes = true;
  163. if (pElement->hasProp("xs:annotation/xs:appinfo/viewType"))
  164. {
  165. const char* viewType = pElement->queryProp("xs:annotation/xs:appinfo/viewType");
  166. const char* viewChildNodes = pElement->queryProp("xs:annotation/xs:appinfo/viewChildNodes");
  167. bViewChildNodes = viewChildNodes && !stricmp(viewChildNodes, "true");
  168. bool needParent = true;
  169. //select first parent node that matches schema
  170. if (pInstanceNode && needParent)
  171. {
  172. Owned<IPropertyTreeIterator> it = pInstanceNode->getElements(szElementName);
  173. if (it->first() && it->isValid())
  174. pInstanceNode = &it->query();
  175. }
  176. if (!strcmp(viewType, "Instance") || !strcmp(viewType, "instance") ||
  177. !strcmp(viewType, "RoxiePorts") || !strcmp(viewType, "RoxieSlaves"))
  178. bOptSubType = true;
  179. }
  180. bool bHasElements = schemaNodeHasElements(pElement) != NULL;
  181. if (bViewChildNodes)
  182. {
  183. bool bHasAttribs = schemaNodeHasAttributes(pElement);
  184. bool bHasAttribGroups = schemaNodeHasAttributeGroups(pElement);
  185. bool bMaxOccursOnce = !pElement->hasProp(XML_ATTR_MAXOCCURS) || !strcmp(pElement->queryProp(XML_ATTR_MAXOCCURS), "1");
  186. bOptSubType = !bMaxOccursOnce;
  187. //figure out the type of child view to create
  188. if (bHasElements)
  189. {
  190. // MORE - this assumes there is only one nested element type and that it is repeated....
  191. StringBuffer sbElemName(szElementName);
  192. if (bHasAttribs) //has child elements and attributes
  193. {
  194. Owned<IPropertyTreeIterator> iter = pElement->getElements("*");
  195. ForEach(*iter)
  196. {
  197. IPropertyTree &subSchemaElement = iter->query();
  198. const char* szSubElementName = subSchemaElement.queryName();
  199. StringBuffer sbSubElemName(szSubElementName);
  200. TRACE_SCHEMA_NODE("ProcessSchemaElement", &subSchemaElement);
  201. if (m_allSubTypes || !bOptSubType)
  202. ProcessComplexTypeSchemaNode(&subSchemaElement, m_pSchemaRoot, sbElemName);
  203. }
  204. }
  205. else
  206. {
  207. //no attributes
  208. if (bMaxOccursOnce)
  209. {
  210. //has child elements but no attribs and only occurs once
  211. //so skip this element and create node list view for its children
  212. pViewSchemaNode = schemaNodeHasElements(pElement);
  213. if (pInstanceNode)
  214. {
  215. IPropertyTree* pNewInstanceNode = pInstanceNode->queryPropTree(szElementName);
  216. if (!pNewInstanceNode)
  217. pNewInstanceNode = pInstanceNode->addPropTree(szElementName, createPTree());
  218. pInstanceNode = pNewInstanceNode;
  219. }
  220. szElementName = pViewSchemaNode->queryProp(XML_ATTR_NAME);
  221. }
  222. }
  223. }
  224. else
  225. {
  226. //no child elements
  227. if (bHasAttribs)
  228. {
  229. if (!bMaxOccursOnce) //occurs multiple times
  230. {
  231. //select first parent node that matches schema
  232. if (pInstanceNode)
  233. {
  234. Owned<IPropertyTreeIterator> it = pInstanceNode->getElements(szParentElementName);
  235. if (it->first() && it->isValid())
  236. pInstanceNode = &it->query();
  237. }
  238. }
  239. }
  240. else
  241. {
  242. const char* type = pElement->queryProp("@type");
  243. if (type && !strcmp(type, "xs:string"))
  244. {
  245. if (m_pCompTree)
  246. {
  247. StringBuffer sb(sbCompName);
  248. if (!m_pCompTree->queryPropTree(sbCompName.str()))
  249. m_pCompTree->addPropTree(sbCompName.str(), createPTree());
  250. sb.append("/").append(szElementName);
  251. m_pCompTree->addPropTree(sb.str()/*szElementName*/, createPTree());
  252. }
  253. }
  254. }
  255. }
  256. }
  257. if (m_allSubTypes || !bOptSubType)
  258. AddAttributesFromSchema(pViewSchemaNode, sbCompName, szElementName);
  259. /*
  260. if (bOptSubType && m_viewChildNodes.get() && m_multiRowNodes.get())
  261. {
  262. if (bHasElements)
  263. m_viewChildNodes->addProp("Node", szElementName);
  264. else
  265. m_multiRowNodes->addProp("Node", szElementName);
  266. }
  267. */
  268. if (pInstanceNode)
  269. {
  270. //select first child node for which we are creating view
  271. Owned<IPropertyTreeIterator> it = pInstanceNode->getElements(pElement->queryProp(XML_ATTR_NAME));
  272. pInstanceNode = (it->first() && it->isValid()) ? &it->query() : NULL;
  273. }
  274. }
  275. }
  276. void ComponentFromXSD::ProcessComplexTypeSchemaNode(IPropertyTree* schemaNode,
  277. IPropertyTree* pParentElement, StringBuffer& sbCompName)
  278. {
  279. if (schemaNode)
  280. {
  281. TRACE_SCHEMA_NODE("ProcessComplexTypeSchemaNode", schemaNode);
  282. const char* szParentElementName = pParentElement->queryProp(XML_ATTR_NAME);
  283. //now process the rest...
  284. Owned<IPropertyTreeIterator> iter = schemaNode->getElements(XSD_TAG_ATTRIBUTE_GROUP);
  285. ForEach(*iter)
  286. {
  287. IPropertyTree &schemaElement = iter->query();
  288. const char* name = schemaElement.queryProp("@ref");
  289. StringBuffer xPath;
  290. xPath.append("//xs:attributeGroup[@name='").append(name).append("']");
  291. Owned<IPropertyTreeIterator> iter2 = m_pSchemaRoot->getElements(xPath.str());
  292. ForEach(*iter2)
  293. {
  294. IPropertyTree &agDef = iter2->query();
  295. if (agDef.hasProp("xs:annotation/xs:appinfo/title"))
  296. name = agDef.queryProp("xs:annotation/xs:appinfo/title");
  297. AddAttributesFromSchema(&agDef, sbCompName, NULL);
  298. break; // should be exactly one!
  299. // MORE - this will not get scoping correct. Do I care?
  300. }
  301. }
  302. iter.setown(schemaNode->getElements("*"));
  303. ForEach(*iter)
  304. {
  305. IPropertyTree &schemaElement = iter->query();
  306. const char* szSchemaElementName = schemaElement.queryName();
  307. if (!strcmp(szSchemaElementName, XSD_TAG_SEQUENCE) || !strcmp(szSchemaElementName, XSD_TAG_CHOICE))
  308. {
  309. Owned<IPropertyTreeIterator> iter2 = schemaElement.getElements(XSD_TAG_ELEMENT);
  310. ForEach(*iter2)
  311. {
  312. IPropertyTree* pElement = &iter2->query();
  313. ProcessElementSchemaNode(pElement, pParentElement, sbCompName);
  314. }
  315. }
  316. }
  317. }
  318. }
  319. bool ComponentFromXSD::generateHeaders()
  320. {
  321. StringBuffer sbPropName;
  322. if (!m_pSchemaRoot)
  323. throw MakeStringException(-1, "Missing schema property tree");
  324. IPropertyTree *schemaNode = m_pSchemaRoot->queryPropTree("xs:element");
  325. if (m_compName.length() == 0)
  326. m_compName.append(schemaNode->queryProp(XML_ATTR_NAME));
  327. if (!strcmp(m_compName.str(), "Eclserver"))
  328. m_compName.clear().append(XML_TAG_ECLSERVERPROCESS);
  329. Owned<IPropertyTreeIterator> iter = schemaNode->getElements("*");
  330. ForEach(*iter)
  331. {
  332. IPropertyTree &schemaElement = iter->query();
  333. const char* szElementName = schemaElement.queryName();
  334. TRACE_SCHEMA_NODE("ProcessSchemaElement", &schemaElement);
  335. //if node is xs:complexType and xs:complexContent then process children
  336. if (!strcmp(szElementName, XSD_TAG_COMPLEX_TYPE) ||
  337. !strcmp(szElementName, XSD_TAG_COMPLEX_CONTENT))
  338. {
  339. //if this schema node has any attributes then add an attribute tab
  340. //
  341. bool bHasAttribs = schemaNodeHasAttributes(&schemaElement);
  342. if (bHasAttribs)
  343. {
  344. AddAttributesFromSchema(schemaNode, m_compName, NULL);
  345. }
  346. }
  347. ProcessComplexTypeSchemaNode(&schemaElement, m_pSchemaRoot, m_compName);
  348. }
  349. return true;
  350. }
  351. void ComponentFromXSD::setCompTree(const char* buildSetName, IPropertyTree* pTree, IPropertyTree* schemaTree, bool allSubTypes)
  352. {
  353. m_buildSetName.clear().append(buildSetName);
  354. m_pCompTree = pTree;
  355. m_allSubTypes = allSubTypes;
  356. m_pSchemaRoot.set(schemaTree);
  357. }
  358. void ComponentFromXSD::getValueForTypeInXSD(IPropertyTree& attr,
  359. const char *compName, StringBuffer& wizDefVal)
  360. {
  361. StringBuffer tempPath;
  362. const char* type = attr.queryProp("@type");
  363. const char* name = attr.queryProp("@name");
  364. //first check for all the tags autogen then proceed with type checking.
  365. if (attr.hasProp("./xs:annotation/xs:appinfo/autogendefaultvalue"))
  366. {
  367. tempPath.clear().append("./xs:annotation/xs:appinfo/autogendefaultvalue");
  368. if (!strcmp(attr.queryProp(tempPath.str()), "$defaultenvfile"))
  369. {
  370. const IProperties* pParams = m_eh->getEnvConfigOptions().getProperties();
  371. wizDefVal.clear().append(pParams->queryProp("configs")).append("/environment.xml");
  372. }
  373. else if (!strcmp(attr.queryProp(tempPath.str()), "$componentfilesdir"))
  374. {
  375. tempPath.clear().append("EnvSettings/path");
  376. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  377. if (!wizDefVal.length())
  378. wizDefVal.append(STANDARD_COMPFILESDIR);
  379. wizDefVal.append(PATHSEPSTR"componentfiles");
  380. }
  381. else if (!strcmp(attr.queryProp(tempPath.str()), "$processname"))
  382. {
  383. tempPath.clear().appendf("Software/%s[1]/@name",compName);
  384. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  385. }
  386. else if(!strcmp(attr.queryProp(tempPath.str()), "$hthorcluster"))
  387. {
  388. tempPath.clear().append(XML_TAG_SOFTWARE "/" XML_TAG_TOPOLOGY "/" XML_TAG_CLUSTER);
  389. Owned<IPropertyTreeIterator> iterClusters = m_pEnv->getElements(tempPath.str());
  390. ForEach (*iterClusters)
  391. {
  392. IPropertyTree* pCluster = &iterClusters->query();
  393. if (pCluster->queryPropTree(XML_TAG_ROXIECLUSTER) ||
  394. pCluster->queryPropTree(XML_TAG_THORCLUSTER))
  395. continue;
  396. else
  397. {
  398. wizDefVal.clear().append(pCluster->queryProp(XML_ATTR_NAME));
  399. break;
  400. }
  401. }
  402. }
  403. else
  404. {
  405. wizDefVal.clear().append(attr.queryProp(tempPath.str()));
  406. tempPath.clear().appendf("Software/%s[1]/@buildSet", compName);
  407. if (m_pEnv->queryProp(tempPath.str()))
  408. {
  409. SWProcess * swp = (SWProcess *)m_eh->getEnvSWComp(m_buildSetName.str());
  410. if (((SWProcess *)m_eh->getEnvSWComp(m_buildSetName.str()))->getInstanceCount() > 1)
  411. {
  412. tempPath.clear().append("./xs:annotation/xs:appinfo/autogendefaultformultinode");
  413. if (attr.hasProp(tempPath.str()))
  414. wizDefVal.clear().append(attr.queryProp(tempPath.str()));
  415. }
  416. }
  417. }
  418. }
  419. else if(attr.hasProp("./xs:annotation/xs:appinfo/autogenprefix") ||
  420. attr.hasProp("./xs:annotation/xs:appinfo/autogensuffix"))
  421. {
  422. StringBuffer sb;
  423. StringBuffer nameOfComp;
  424. tempPath.clear().appendf("./Software/%s[1]/@name",m_compName.str());
  425. nameOfComp.clear().append(m_pEnv->queryProp(tempPath.str()));
  426. tempPath.clear().append("./xs:annotation/xs:appinfo/autogenprefix");
  427. if (attr.hasProp(tempPath.str()))
  428. sb.clear().append(attr.queryProp(tempPath.str())).append(nameOfComp);
  429. tempPath.clear().append("./xs:annotation/xs:appinfo/autogensuffix");
  430. if (attr.hasProp(tempPath.str()))
  431. {
  432. if (sb.length())
  433. sb.append(attr.queryProp(tempPath.str()));
  434. else
  435. sb.append(nameOfComp).append(attr.queryProp(tempPath.str()));
  436. }
  437. wizDefVal.clear().append(sb);
  438. }
  439. else if (!strcmp(type,"computerType"))
  440. {
  441. if (m_wizFlag)
  442. {
  443. StringBuffer ipAddr;
  444. tempPath.clear().appendf("./Programs/Build/BuildSet[%s=\"%s\"]",XML_ATTR_PROCESS_NAME,m_compName.str());
  445. IPropertyTree* pCompTree = m_pEnv->queryPropTree(tempPath.str());
  446. if (pCompTree)
  447. {
  448. StringArray ipArray;
  449. ((SWProcess *)m_eh->getEnvSWComp(m_buildSetName.str()))->getInstanceNetAddresses(ipArray);
  450. if ( ipArray.ordinality() > 0 )
  451. {
  452. ForEachItemIn(x, ipArray)
  453. {
  454. if (ipArray.ordinality() == 1)
  455. ipAddr.append(ipArray.item(x));
  456. else
  457. ipAddr.append(ipArray.item(x)).append(",");
  458. tempPath.clear().appendf("./Hardware/Computer[@netAddress=\"%s\"]",ipAddr.str());
  459. IPropertyTree* pHard = m_pEnv->queryPropTree(tempPath.str());
  460. if (pHard)
  461. {
  462. tempPath.clear().append("@name");
  463. wizDefVal.clear().append(pHard->queryProp(tempPath.str()));
  464. }
  465. }
  466. }
  467. }
  468. }
  469. }
  470. else if(!strcmp(type,"serverListType"))
  471. {
  472. if (m_wizFlag)
  473. {
  474. StringBuffer ipAddr;
  475. tempPath.clear().appendf("./Programs/Build/BuildSet[%s=\"%s\"]",XML_ATTR_PROCESS_NAME, m_compName.str());
  476. IPropertyTree* pCompTree = m_pEnv->queryPropTree(tempPath.str());
  477. if (pCompTree)
  478. {
  479. StringArray ipArray;
  480. ((SWProcess*)m_eh->getEnvSWComp(m_buildSetName.str()))->getInstanceNetAddresses(ipArray);
  481. if ( ipArray.ordinality() > 0 )
  482. {
  483. wizDefVal.clear().append(ipArray.item(0));
  484. }
  485. }
  486. }
  487. }
  488. else if(!strcmp(type,"xs:string"))
  489. {
  490. StringBuffer nameOfComp;
  491. tempPath.clear().appendf("./Software/%s[1]/@name",m_compName.str());
  492. nameOfComp.clear().append(m_pEnv->queryProp(tempPath.str()));
  493. if (!strcmp(name, "dbUser"))
  494. {
  495. wizDefVal.clear().append(m_eh->getConfig("dbuser", CONFIG_ALL));
  496. }
  497. else if (!strcmp(name, "dbPassword"))
  498. {
  499. wizDefVal.clear().append(m_eh->getConfig("dbpassword", CONFIG_ALL));
  500. }
  501. }
  502. else if (!strcmp(type,"mysqlType"))
  503. {
  504. tempPath.clear().append("./Software/MySQLProcess[1]/@name");
  505. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  506. }
  507. else if (!strcmp(type,"espprocessType"))
  508. {
  509. tempPath.clear().append("./Software/EspProcess[1]/@name");
  510. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  511. }
  512. else if (!strcmp(type,"mysqlloggingagentType"))
  513. {
  514. tempPath.clear().append("./Software/MySQLLoggingAgent[1]/@name");
  515. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  516. }
  517. else if (!strcmp(type,"esploggingagentType"))
  518. {
  519. tempPath.clear().append("./Software/ESPLoggingAgent[1]/@name");
  520. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  521. }
  522. else if (!strcmp(type,"loggingmanagerType"))
  523. {
  524. tempPath.clear().append("./Software/LoggingManager[1]/@name");
  525. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  526. }
  527. else if (!strcmp(type,"daliServersType"))
  528. {
  529. tempPath.clear().append("./Software/DaliServerProcess[1]/@name");
  530. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  531. }
  532. else if (!strcmp(type,"ldapServerType"))
  533. {
  534. tempPath.clear().append("./Software/LdapServerProcess[1]/@name");
  535. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  536. }
  537. else if (!strcmp(type, "roxieClusterType"))
  538. {
  539. tempPath.clear().append("./Software/RoxieCluster[1]/@name");
  540. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  541. }
  542. else if (!strcmp(type, "eclServerType"))
  543. {
  544. tempPath.clear().append("./Software/EclServerProcess[1]/@name");
  545. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  546. }
  547. else if (!strcmp(type, "eclCCServerType"))
  548. {
  549. tempPath.clear().append("./Software/EclCCServerProcess[1]/@name");
  550. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  551. }
  552. else if (!strcmp(type, "espProcessType"))
  553. {
  554. tempPath.clear().append("./Software/EspProcess[1]/@name");
  555. wizDefVal.clear().append(m_pEnv->queryProp(tempPath.str()));
  556. }
  557. else if (!strcmp(type, "espBindingType"))
  558. {
  559. IPropertyTree* pAppInfo = attr.queryPropTree("xs:annotation/xs:appinfo");
  560. StringBuffer xpath;
  561. const char* serviceType = NULL;
  562. if (pAppInfo)
  563. {
  564. serviceType = pAppInfo->queryProp("serviceType");
  565. if (serviceType)
  566. xpath.clear().append("Software/EspService");
  567. }
  568. else
  569. xpath.clear().appendf("Software/*[@buildSet='%s']", type);
  570. wizDefVal.clear();
  571. Owned<IPropertyTreeIterator> iterEspServices = m_pEnv->getElements(xpath);
  572. short blank = 0;
  573. ForEach (*iterEspServices)
  574. {
  575. IPropertyTree* pEspService = &iterEspServices->query();
  576. if (serviceType)
  577. {
  578. xpath.clear().appendf("Properties[@type='%s']", serviceType);
  579. if (pEspService->queryPropTree(xpath.str()) == NULL)
  580. continue;
  581. }
  582. Owned<IPropertyTreeIterator> iter = m_pEnv->getElements("Software/EspProcess[1]");
  583. ForEach (*iter)
  584. {
  585. IPropertyTree* pEspProcess = &iter->query();
  586. xpath.clear().appendf("EspBinding[@service='%s']", pEspService->queryProp(XML_ATTR_NAME));
  587. if (pEspProcess->queryPropTree(xpath.str()) != NULL)
  588. wizDefVal.append(pEspProcess->queryProp(XML_ATTR_NAME)).append("/").append(pEspService->queryProp(XML_ATTR_NAME));
  589. }
  590. }
  591. }
  592. else if (!strcmp(type, "ipAddressAndPort"))
  593. {
  594. StringBuffer defaultPort;
  595. tempPath.clear().append("./xs:annotation/xs:appinfo/defaultPort");
  596. defaultPort.append(attr.queryProp(tempPath.str()));
  597. tempPath.clear().append("./xs:annotation/xs:appinfo/autogenxpath");
  598. if (attr.hasProp(tempPath.str()))
  599. {
  600. StringBuffer computerName;
  601. computerName.append(m_pEnv->queryProp(attr.queryProp(tempPath.str())));
  602. tempPath.clear().appendf("./Hardware/Computer[@name=\"%s\"]",computerName.str());
  603. if (m_pEnv->hasProp(tempPath.str()))
  604. {
  605. IPropertyTree* pHard = m_pEnv->queryPropTree(tempPath.str());
  606. if (pHard)
  607. wizDefVal.clear().append(pHard->queryProp("./" XML_ATTR_NETADDRESS)).append(":").append(defaultPort);
  608. }
  609. }
  610. }
  611. }
  612. }