SchemaAttributes.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2015 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 "jptree.hpp"
  14. #include "jarray.hpp"
  15. #include "jlog.hpp"
  16. #include "SchemaAttributes.hpp"
  17. #include "SchemaCommon.hpp"
  18. #include "SchemaAppInfo.hpp"
  19. #include "SchemaSimpleType.hpp"
  20. #include "DocumentationMarkup.hpp"
  21. #include "ConfigSchemaHelper.hpp"
  22. #include "ExceptionStrings.hpp"
  23. #include "SchemaMapManager.hpp"
  24. #include "ConfiguratorMain.hpp"
  25. #include "SchemaKey.hpp"
  26. #include "SchemaKeyRef.hpp"
  27. #include "SchemaSimpleType.hpp"
  28. #include "SchemaAppInfo.hpp"
  29. #include "JSONMarkUp.hpp"
  30. #include "SchemaEnumeration.hpp"
  31. #include "SchemaElement.hpp"
  32. using namespace CONFIGURATOR;
  33. #define StringBuffer ::StringBuffer
  34. #define IPropertyTree ::IPropertyTree
  35. CAttribute::~CAttribute()
  36. {
  37. }
  38. bool CAttribute::isHidden()
  39. {
  40. if(this->getAnnotation()->getAppInfo() != nullptr && !stricmp(this->getAnnotation()->getAppInfo()->getViewType(),"hidden"))
  41. return true;
  42. return false;
  43. }
  44. const char* CAttribute::getTitle() const
  45. {
  46. if (this->m_pAnnotation != nullptr && this->m_pAnnotation->getAppInfo() != nullptr && this->m_pAnnotation->getAppInfo()->getTitle() != nullptr && this->m_pAnnotation->getAppInfo()->getTitle()[0] != 0)
  47. return this->m_pAnnotation->getAppInfo()->getTitle();
  48. else
  49. return this->getName();
  50. }
  51. const char* CAttribute::getXML(const char* pComponent)
  52. {
  53. if (m_strXML.length() == 0)
  54. m_strXML.append(getName()).append("=\"").append(getDefault()).append("\"");
  55. return m_strXML.str();
  56. }
  57. void CAttribute::dump(::std::ostream& cout, unsigned int offset) const
  58. {
  59. offset+= STANDARD_OFFSET_1;
  60. quickOutHeader(cout,XSD_ATTRIBUTE_STR, offset);
  61. QUICK_OUT(cout, Name, offset);
  62. QUICK_OUT(cout, Type, offset);
  63. QUICK_OUT(cout, Default,offset);
  64. QUICK_OUT(cout, Use, offset);
  65. QUICK_OUT(cout, XSDXPath, offset);
  66. QUICK_OUT(cout, EnvXPath, offset);
  67. QUICK_OUT(cout, EnvValueFromXML, offset);
  68. if (m_pAnnotation != nullptr)
  69. m_pAnnotation->dump(cout, offset);
  70. if (m_pSimpleTypeArray != nullptr)
  71. m_pSimpleTypeArray->dump(cout, offset);
  72. quickOutFooter(cout,XSD_ATTRIBUTE_STR, offset);
  73. }
  74. void CAttribute::getDocumentation(StringBuffer &strDoc) const
  75. {
  76. const char *pName = this->getTitle();
  77. const char *pToolTip = nullptr;
  78. const char *pDefaultValue = this->getDefault();
  79. const char *pRequired = this->getUse();
  80. if (m_pAnnotation != nullptr && m_pAnnotation->getAppInfo() != nullptr)
  81. {
  82. const CAppInfo *pAppInfo = m_pAnnotation->getAppInfo();
  83. const char* pViewType = pAppInfo->getViewType();
  84. if (pViewType != nullptr && stricmp("hidden", pViewType) == 0)
  85. return; // HIDDEN
  86. else
  87. pToolTip = pAppInfo->getToolTip();
  88. const char* pReq = pAppInfo->getRequired();
  89. if (pReq != nullptr && stricmp("True", pReq) == 0)
  90. pRequired = TAG_REQUIRED;
  91. }
  92. strDoc.appendf("<%s>\n", DM_TABLE_ROW);
  93. strDoc.appendf("<%s>%s</%s>\n", DM_TABLE_ENTRY, pName, DM_TABLE_ENTRY);
  94. strDoc.appendf("<%s>%s</%s>\n", DM_TABLE_ENTRY, pToolTip, DM_TABLE_ENTRY);
  95. if (m_pSimpleTypeArray == nullptr)
  96. strDoc.appendf("<%s>%s</%s>\n", DM_TABLE_ENTRY, pDefaultValue, DM_TABLE_ENTRY);
  97. else
  98. {
  99. StringBuffer strDocTemp(pDefaultValue);
  100. m_pSimpleTypeArray->getDocumentation(strDocTemp);
  101. strDoc.appendf("<%s>%s</%s>\n", DM_TABLE_ENTRY, strDocTemp.str(), DM_TABLE_ENTRY);
  102. }
  103. if (m_pAnnotation != nullptr && m_pAnnotation->getAppInfo() != nullptr && m_pAnnotation->getAppInfo()->getDocLineBreak() == true)
  104. strDoc.appendf("<%s>%s%s</%s>\n", DM_TABLE_ENTRY, DM_LINE_BREAK2, pRequired, DM_TABLE_ENTRY);
  105. else
  106. strDoc.appendf("<%s>%s</%s>\n", DM_TABLE_ENTRY, pRequired, DM_TABLE_ENTRY);
  107. strDoc.appendf("</%s>\n", DM_TABLE_ROW);
  108. }
  109. void CAttribute::getJSON(StringBuffer &strJSON, unsigned int offset, int idx) const
  110. {
  111. StringBuffer strToolTip;
  112. StringBuffer strValues;
  113. if (this->getAnnotation() && this->getAnnotation()->getAppInfo() && this->getAnnotation()->getAppInfo()->getToolTip())
  114. {
  115. strToolTip.set(this->getAnnotation()->getAppInfo()->getToolTip());
  116. }
  117. if (this->getSimpleTypeArray() && this->getSimpleTypeArray()->length() > 0 &&
  118. this->getSimpleTypeArray()->item(0).getRestriction() && this->getSimpleTypeArray()->item(0).getRestriction()->getEnumerationArray() &&
  119. this->getSimpleTypeArray()->item(0).getRestriction()->getEnumerationArray()->length() > 0) // why would I have more than 1 simpletype here for a dropdown?
  120. {
  121. int nLength = this->getSimpleTypeArray()->item(0).getRestriction()->getEnumerationArray()->length();
  122. for (int lidx = 0; lidx < nLength; lidx++)
  123. {
  124. if (lidx > 0)
  125. {
  126. strValues.append("\" , \"");
  127. }
  128. strValues.append(this->getSimpleTypeArray()->item(0).getRestriction()->getEnumerationArray()->item(lidx).getValue());
  129. }
  130. }
  131. StringBuffer strInstanceValues;
  132. StringBuffer strKeys;
  133. const CElementArray *pElementArray = dynamic_cast<const CElementArray*>(this->getParentNodeByType(XSD_ELEMENT_ARRAY));
  134. if (pElementArray != nullptr && pElementArray->getParentNodeByType(XSD_ELEMENT_ARRAY) != nullptr && pElementArray->getParentNodeByType(XSD_ELEMENT_ARRAY)->getNodeType() != XSD_SCHEMA)
  135. {
  136. for (int i = 0; i < pElementArray->ordinality(); i++)
  137. {
  138. if (i != 0)
  139. {
  140. strInstanceValues.append(", ");
  141. strKeys.append(",");
  142. }
  143. else
  144. {
  145. strInstanceValues.append("[");
  146. strKeys.append("[");
  147. }
  148. const CAttribute *pAttribute = const_cast<const CAttribute*>(&(pElementArray->item(i).getComplexTypeArray()->item(0).getAttributeArray()->item(idx)));
  149. assert(pAttribute != nullptr);
  150. strInstanceValues.appendf("\"%s\"",pAttribute->getInstanceValue());
  151. strKeys.appendf("\"%s\"",pAttribute->getEnvXPath());
  152. }
  153. strInstanceValues.append("]");
  154. strKeys.append("]");
  155. }
  156. else
  157. {
  158. strInstanceValues.appendf("\"%s\"",this->getInstanceValue());
  159. }
  160. CJSONMarkUpHelper::createUIContent(strJSON, offset, strValues.length() > 0 ? JSON_TYPE_DROP_DOWN : JSON_TYPE_INPUT, this->getTitle(),\
  161. strKeys.length() > 0 ? strKeys.str() : this->getEnvXPath(), strToolTip.str(), this->getDefault(), strValues.str(), strInstanceValues.str());
  162. }
  163. void CAttribute::populateEnvXPath(StringBuffer strXPath, unsigned int index)
  164. {
  165. assert(this->getName() != nullptr);
  166. //These two lines cause installset.xsd segmentation fault in debug. Will come back to this later
  167. const char *pChar = strrchr(strXPath.str(),'[');
  168. assert(pChar != nullptr && strlen(pChar) >= 3);
  169. /*strXPath.setLength(strXPath.length()-strlen(pChar)); // remove [N] from XPath;
  170. strXPath.appendf("[%d]", index);*/
  171. strXPath.append("/").append("[@").append(this->getName()).append("]");
  172. this->setEnvXPath(strXPath.str());
  173. //PROGLOG("Mapping attribute with XPATH of %s to %p", this->getEnvXPath(), this);
  174. CConfigSchemaHelper::getInstance()->getSchemaMapManager()->addMapOfXPathToAttribute(this->getEnvXPath(), this);
  175. CConfigSchemaHelper::getInstance()->appendAttributeXPath(this->getEnvXPath());
  176. if (this->m_pSimpleTypeArray != nullptr)
  177. m_pSimpleTypeArray->populateEnvXPath(strXPath);
  178. }
  179. void CAttribute::loadXMLFromEnvXml(const IPropertyTree *pEnvTree)
  180. {
  181. assert(this->getEnvXPath() != nullptr);
  182. assert(this->getConstParentNode()->getEnvXPath() != nullptr);
  183. StringBuffer strXPath(this->getConstParentNode()->getEnvXPath());
  184. if (pEnvTree->hasProp(strXPath.str()) == true)
  185. {
  186. StringBuffer strAttribName("@");
  187. strAttribName.append(this->getName());
  188. this->setEnvValueFromXML(pEnvTree->queryPropTree(strXPath.str())->queryProp(strAttribName.str()));
  189. setInstanceAsValid();
  190. if (this->m_pSimpleTypeArray != nullptr)
  191. m_pSimpleTypeArray->loadXMLFromEnvXml(pEnvTree);
  192. }
  193. else if (stricmp(this->getUse(), XML_ENV_VALUE_REQUIRED) == 0) // check if this a required attribute
  194. {
  195. assert(false); // required value missing
  196. throw MakeExceptionFromMap(EX_STR_MISSING_REQUIRED_ATTRIBUTE);
  197. }
  198. }
  199. bool CAttribute::setEnvValueFromXML(const char *p)
  200. {
  201. if (p == nullptr)
  202. {
  203. if (this->getDefault() != nullptr && *(this->getDefault()) != 0)
  204. {
  205. this->setInstanceValue(this->getDefault());
  206. this->setInstanceAsValid(true);
  207. return true;
  208. }
  209. if (this->getUse() != nullptr && stricmp(this->getUse(), TAG_REQUIRED) != 0)
  210. return true;
  211. else
  212. {
  213. this->setInstanceAsValid(false);
  214. //assert (!"Missing attribute property, property not marked as optional");
  215. return false;
  216. }
  217. }
  218. if (this->getTypeNode() != nullptr)
  219. {
  220. const CXSDBuiltInDataType *pNodeBuiltInType = dynamic_cast<const CXSDBuiltInDataType*>(this->getTypeNode());
  221. if (pNodeBuiltInType != nullptr && pNodeBuiltInType->checkConstraint(p) == false)
  222. {
  223. this->setInstanceAsValid(false);
  224. //assert (!"Invalid value for data type");
  225. return false;
  226. }
  227. if (this->getTypeNode()->getNodeType() == XSD_SIMPLE_TYPE)
  228. const CSimpleType *pNodeSimpleType = dynamic_cast<const CSimpleType*>(this->getTypeNode());
  229. }
  230. if (this->m_ReverseKeyRefArray.length() > 0)
  231. {
  232. for (int idx = 0; this->m_ReverseKeyRefArray.length(); idx++)
  233. {
  234. CKeyRef *pKeyRef = static_cast<CKeyRef*>((this->m_ReverseKeyRefArray.item(idx)));
  235. assert(pKeyRef != nullptr);
  236. if (pKeyRef->checkConstraint(p) == false)
  237. {
  238. this->setInstanceAsValid(false);
  239. assert (!"Constraint Violated");
  240. return false;
  241. }
  242. }
  243. }
  244. this->setInstanceValue(p);
  245. this->setInstanceAsValid(true);
  246. return true;
  247. }
  248. void CAttribute::appendReverseKeyRef(const CKeyRef *pKeyRef)
  249. {
  250. assert(pKeyRef != nullptr);
  251. if (pKeyRef != nullptr)
  252. this->m_ReverseKeyRefArray.append(static_cast<void*>(const_cast<CKeyRef*>(pKeyRef)));
  253. }
  254. void CAttribute::appendReverseKey(const CKey *pKey)
  255. {
  256. assert(pKey != nullptr);
  257. if (pKey != nullptr)
  258. this->m_ReverseKeyArray.append(static_cast<void*>(const_cast<CKey*>(pKey)));
  259. }
  260. CAttribute* CAttribute::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath)
  261. {
  262. assert(pSchemaRoot != nullptr);
  263. if (pSchemaRoot == nullptr)
  264. return nullptr;
  265. CAttribute *pAttribute = new CAttribute(pParentNode);
  266. pAttribute->setXSDXPath(xpath);
  267. Owned<IAttributeIterator> iterAttrib = pSchemaRoot->queryPropTree(xpath)->getAttributes(true);
  268. ForEach(*iterAttrib)
  269. {
  270. if (strcmp(iterAttrib->queryName(), XML_ATTR_NAME) == 0)
  271. pAttribute->setName(iterAttrib->queryValue());
  272. else if (strcmp(iterAttrib->queryName(), XML_ATTR_DEFAULT) == 0)
  273. pAttribute->setDefault(iterAttrib->queryValue());
  274. else if (strcmp(iterAttrib->queryName(), XML_ATTR_USE) == 0)
  275. pAttribute->setUse(iterAttrib->queryValue());
  276. else if (strcmp(iterAttrib->queryName(), XML_ATTR_TYPE) == 0)
  277. {
  278. const char *pType = iterAttrib->queryValue();
  279. assert(pType != nullptr && *pType != 0);
  280. if (pType != nullptr && *pType != 0)
  281. {
  282. pAttribute->setType(pType);
  283. CConfigSchemaHelper::getInstance()->addNodeForTypeProcessing(pAttribute);
  284. }
  285. }
  286. }
  287. StringBuffer strXPathExt(xpath);
  288. strXPathExt.append("/").append(XSD_TAG_ANNOTATION);
  289. CAnnotation *pAnnotation = CAnnotation::load(pAttribute, pSchemaRoot, strXPathExt.str());
  290. if (pAnnotation != nullptr)
  291. pAttribute->setAnnotation(pAnnotation);
  292. strXPathExt.setf("%s/%s",xpath, XSD_TAG_SIMPLE_TYPE);
  293. CSimpleTypeArray *pSimpleTypeArray = CSimpleTypeArray::load(pAttribute, pSchemaRoot, strXPathExt.str());
  294. if (pSimpleTypeArray != nullptr)
  295. pAttribute->setSimpleTypeArray(pSimpleTypeArray);
  296. return pAttribute;
  297. }
  298. const char* CAttributeArray::getXML(const char* /*pComponent*/)
  299. {
  300. if (m_strXML.length() == 0)
  301. {
  302. int length = this->length();
  303. for (int idx = 0; idx < length; idx++)
  304. {
  305. CAttribute &Attribute = this->item(idx);
  306. m_strXML.append(" ").append(Attribute.getXML(nullptr));
  307. if (idx+1 < length)
  308. m_strXML.append("\n");
  309. }
  310. }
  311. return m_strXML.str();
  312. }
  313. CAttributeArray* CAttributeArray::load(const char* pSchemaFile)
  314. {
  315. assert(pSchemaFile != nullptr);
  316. if (pSchemaFile == nullptr)
  317. return nullptr;
  318. Linked<IPropertyTree> pSchemaRoot;
  319. StringBuffer schemaPath;
  320. schemaPath.appendf("%s%s", DEFAULT_SCHEMA_DIRECTORY, pSchemaFile);
  321. pSchemaRoot.setown(createPTreeFromXMLFile(schemaPath.str()));
  322. StringBuffer strXPathExt("./");
  323. strXPathExt.append(XSD_TAG_ATTRIBUTE);
  324. return CAttributeArray::load(nullptr, pSchemaRoot, strXPathExt.str());
  325. }
  326. CAttributeArray* CAttributeArray::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath)
  327. {
  328. assert(pSchemaRoot != nullptr);
  329. if (pSchemaRoot == nullptr || xpath == nullptr)
  330. return nullptr;
  331. StringBuffer strXPathExt(xpath);
  332. CAttributeArray *pAttribArray = new CAttributeArray(pParentNode);
  333. pAttribArray->setXSDXPath(xpath);
  334. Owned<IPropertyTreeIterator> attributeIter = pSchemaRoot->getElements(xpath, ipt_ordered);
  335. int count = 1;
  336. ForEach(*attributeIter)
  337. {
  338. strXPathExt.setf("%s[%d]", xpath, count);
  339. CAttribute *pAttrib = CAttribute::load(pAttribArray, pSchemaRoot, strXPathExt.str());
  340. if (pAttrib != nullptr)
  341. pAttribArray->append(*pAttrib);
  342. count++;
  343. }
  344. if (pAttribArray->length() == 0)
  345. {
  346. delete pAttribArray;
  347. return nullptr;
  348. }
  349. return pAttribArray;
  350. }
  351. void CAttributeArray::dump(::std::ostream &cout, unsigned int offset) const
  352. {
  353. offset+= STANDARD_OFFSET_1;
  354. quickOutHeader(cout, XSD_ATTRIBUTE_ARRAY_STR, offset);
  355. QUICK_OUT(cout, XSDXPath, offset);
  356. QUICK_OUT(cout, EnvXPath, offset);
  357. QUICK_OUT_ARRAY(cout, offset);
  358. quickOutFooter(cout, XSD_ATTRIBUTE_ARRAY_STR, offset);
  359. }
  360. void CAttributeArray::getDocumentation(StringBuffer &strDoc) const
  361. {
  362. assert(this->getConstParentNode() != nullptr);
  363. strDoc.append(DM_SECT4_BEGIN);
  364. if (this->getConstParentNode()->getNodeType() == XSD_COMPLEX_TYPE && this->getConstParentNode()->getConstParentNode()->getNodeType() != XSD_COMPLEX_TYPE)
  365. {
  366. strDoc.appendf("%s%s%s", DM_TITLE_BEGIN, "Attributes", DM_TITLE_END); // Attributes is hard coded default
  367. DEBUG_MARK_STRDOC;
  368. }
  369. else
  370. {
  371. strDoc.append(DM_TITLE_BEGIN).append(DM_TITLE_END);
  372. DEBUG_MARK_STRDOC;
  373. }
  374. const CComplexType *pParentComplexType = dynamic_cast<const CComplexType*>(this->getConstParentNode());
  375. const CAttributeGroup *pParentAttributeGroup = dynamic_cast<const CAttributeGroup*>(this->getConstParentNode());
  376. strDoc.append(DM_TABLE_BEGIN);
  377. DEBUG_MARK_STRDOC;
  378. strDoc.append(DM_TABLE_ID_BEGIN);
  379. DEBUG_MARK_STRDOC;
  380. if (pParentComplexType != nullptr && pParentComplexType->getAnnotation() != nullptr && pParentComplexType->getAnnotation()->getAppInfo() != nullptr && pParentComplexType->getAnnotation()->getAppInfo()->getDocTableID() != nullptr)
  381. {
  382. strDoc.append(pParentComplexType->getAnnotation()->getAppInfo()->getDocTableID());
  383. DEBUG_MARK_STRDOC;
  384. }
  385. else if (pParentAttributeGroup != nullptr && pParentAttributeGroup->getAnnotation() != nullptr && pParentAttributeGroup->getAnnotation()->getAppInfo() != nullptr && pParentAttributeGroup->getAnnotation()->getAppInfo()->getDocTableID() != nullptr)
  386. {
  387. strDoc.append(pParentAttributeGroup->getAnnotation()->getAppInfo()->getDocTableID());
  388. DEBUG_MARK_STRDOC;
  389. }
  390. else
  391. {
  392. static unsigned undefined_counter = 1;
  393. strDoc.append(DM_TABLE_ID_UNDEFINED).append("-").append(undefined_counter++);
  394. DEBUG_MARK_STRDOC;
  395. }
  396. strDoc.append(DM_TABLE_ID_END);
  397. DEBUG_MARK_STRDOC;
  398. strDoc.append(DM_TGROUP4_BEGIN);
  399. strDoc.append(DM_COL_SPEC4);
  400. strDoc.append(DM_TBODY_BEGIN);
  401. DEBUG_MARK_STRDOC;
  402. QUICK_DOC_ARRAY(strDoc);
  403. DEBUG_MARK_STRDOC;
  404. strDoc.append(DM_TBODY_END);
  405. strDoc.append(DM_TGROUP4_END);
  406. strDoc.append(DM_TABLE_END);
  407. strDoc.append(DM_SECT4_END);
  408. }
  409. void CAttributeArray::getJSON(StringBuffer &strJSON, unsigned int offset, int idx ) const
  410. {
  411. offset += STANDARD_OFFSET_2;
  412. for (int lidx=0; lidx < this->length(); lidx++)
  413. {
  414. quickOutPad(strJSON, offset);
  415. strJSON.append("{");
  416. (this->item(lidx)).getJSON(strJSON, offset, lidx);
  417. if (lidx >= 0 && this->length() > 1 && lidx+1 < this->length())
  418. {
  419. strJSON.append("},\n");
  420. }
  421. }
  422. strJSON.append("}");
  423. offset -= STANDARD_OFFSET_2;
  424. }
  425. void CAttributeArray::populateEnvXPath(StringBuffer strXPath, unsigned int index)
  426. {
  427. this->setEnvXPath(strXPath);
  428. QUICK_ENV_XPATH_WITH_INDEX(strXPath, index)
  429. }
  430. void CAttributeArray::loadXMLFromEnvXml(const IPropertyTree *pEnvTree)
  431. {
  432. assert(pEnvTree != nullptr);
  433. if (pEnvTree->hasProp(this->getEnvXPath()) == false)
  434. throw MakeExceptionFromMap(EX_STR_XPATH_DOES_NOT_EXIST_IN_TREE);
  435. else
  436. {
  437. try
  438. {
  439. QUICK_LOAD_ENV_XML(pEnvTree)
  440. }
  441. catch (IException *e)
  442. {
  443. if (e->errorCode() == EX_STR_MISSING_REQUIRED_ATTRIBUTE)
  444. throw e;
  445. }
  446. }
  447. }
  448. const CAttribute* CAttributeArray::findAttributeWithName(const char *pName, bool bCaseInsensitive) const
  449. {
  450. assert (pName != nullptr && pName[0] != 0);
  451. if (pName == nullptr || pName[0] == 0 || this->length() == 0)
  452. return nullptr;
  453. for (int idx = 0; idx < this->length(); idx++)
  454. {
  455. if (bCaseInsensitive == true)
  456. {
  457. if (stricmp(this->item(idx).getName(), pName) == 0)
  458. return &(this->item(idx));
  459. }
  460. else
  461. {
  462. if (strcmp(this->item(idx).getName(), pName) == 0)
  463. return &(this->item(idx));
  464. }
  465. }
  466. return nullptr;
  467. }
  468. const void CAttributeArray::getAttributeNames(StringArray &names, StringArray &titles) const
  469. {
  470. for(int i = 0; i < this->length(); i++)
  471. {
  472. if(!this->item(i).isHidden())
  473. {
  474. names.append(this->item(i).getName());
  475. titles.append(this->item(i).getTitle());
  476. }
  477. }
  478. }
  479. bool CAttributeArray::getCountOfValueMatches(const char *pValue) const
  480. {
  481. return false;
  482. }