Skip to content

Commit

Permalink
- WIP
Browse files Browse the repository at this point in the history
	- Loading Env

Signed-off-by: Gleb Aronsky <[email protected]>
  • Loading branch information
Gleb Aronsky committed Oct 29, 2014
1 parent 894d0dc commit 660c1c3
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 15 deletions.
32 changes: 27 additions & 5 deletions configurator/SchemaAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "SchemaMapManager.hpp"
#include "ConfiguratorMain.hpp"
#include "jlog.hpp"
#include "SchemaKey.hpp"
#include "SchemaKeyRef.hpp"
#include "SchemaSimpleType.hpp"

Expand Down Expand Up @@ -290,13 +291,14 @@ void CAttribute::populateEnvXPath(StringBuffer strXPath, unsigned int index)
{
assert(this->getName() != NULL);

//strXPath.setLength(strXPath.length()-3); // remove [N] from XPath;
//strXPath.appendf("[%d]", index);

strXPath.append("/").append("[@").append(this->getName()).append("]");

this->setEnvXPath(strXPath.str());

// PROGLOG("Mapping attribute with XPATH of %s to %p", this->getEnvXPath(), this);
PROGLOG("Mapping attribute with XPATH of %s to %p", this->getEnvXPath(), this);

CConfigSchemaHelper::getInstance()->getSchemaMapManager()->addMapOfXPathToAttribute(this->getEnvXPath(), this);
CConfigSchemaHelper::getInstance()->appendAttributeXPath(this->getEnvXPath());
Expand Down Expand Up @@ -396,11 +398,11 @@ void CAttribute::setEnvValueFromXML(const char *p)

}

if (this->m_pReverseKeyRefArray != NULL)
if (this->m_ReverseKeyRefArray.length() > 0)
{
for (int idx = 0; this->m_pReverseKeyRefArray->length(); idx++)
for (int idx = 0; this->m_ReverseKeyRefArray.length(); idx++)
{
CKeyRef *pKeyRef = &(this->m_pReverseKeyRefArray->item(idx));
CKeyRef *pKeyRef = static_cast<CKeyRef*>((this->m_ReverseKeyRefArray.item(idx)));

assert(pKeyRef != NULL);

Expand All @@ -418,6 +420,26 @@ void CAttribute::setEnvValueFromXML(const char *p)
this->setInstanceAsValid(true);
}

void CAttribute::appendReverseKeyRef(const CKeyRef *pKeyRef)
{
assert(pKeyRef != NULL);

if (pKeyRef != NULL)
{
this->m_ReverseKeyRefArray.append(static_cast<void*>(const_cast<CKeyRef*>(pKeyRef)));
}
}

void CAttribute::appendReverseKey(const CKey *pKey)
{
assert(pKey != NULL);

if (pKey != NULL)
{
this->m_ReverseKeyArray.append(static_cast<void*>(const_cast<CKey*>(pKey)));
}
}

CAttribute* CAttribute::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath)
{
assert(pSchemaRoot != NULL);
Expand Down Expand Up @@ -858,7 +880,7 @@ void CAttributeArray::getQML(StringBuffer &strQML, int idx) const

void CAttributeArray::populateEnvXPath(StringBuffer strXPath, unsigned int index)
{
assert(index == 1); // Only 1 array of elements per node
//assert(index == 1); // Only 1 array of elements per node

this->setEnvXPath(strXPath);

Expand Down
22 changes: 18 additions & 4 deletions configurator/SchemaAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
class CSimpleTypeArray;
class CKeyRefArray;
class CKeyArray;
class CKey;
class CKeyRef;

class CAttribute : public CXSDNodeWithType
{
public:

CAttribute(CXSDNodeBase* pParentNode, const char* pName = NULL) : CXSDNodeWithType::CXSDNodeWithType(pParentNode, XSD_ATTRIBUTE), m_strName(pName),
m_strDefault(""), m_strUse(""), m_pAnnotation(NULL), m_pSimpleTypeArray(NULL), m_pReverseKeyRefArray(NULL), m_pReverseKeyArray(NULL), m_bInstanceValueValid(false)
m_strDefault(""), m_strUse(""), m_pAnnotation(NULL), m_pSimpleTypeArray(NULL), m_bInstanceValueValid(false)
{
}

CAttribute(CXSDNodeBase* pParentNode, const char* pName, const char* pType, const char* pDefault, const char* pUse) : CXSDNodeWithType::CXSDNodeWithType(pParentNode, XSD_ATTRIBUTE), m_strName(pName), m_pAnnotation(NULL),
m_strDefault(pDefault), m_strUse(pUse), m_pSimpleTypeArray(NULL), m_pReverseKeyRefArray(NULL), m_bInstanceValueValid(false)
m_strDefault(pDefault), m_strUse(pUse), m_pSimpleTypeArray(NULL), m_bInstanceValueValid(false)
{
}

Expand Down Expand Up @@ -64,6 +66,9 @@ class CAttribute : public CXSDNodeWithType

virtual void setEnvValueFromXML(const char *p);

void appendReverseKey(const CKey *pKey);
void appendReverseKeyRef(const CKeyRef *pKeyRef);

protected:

void setInstanceAsValid(bool bValid = true)
Expand Down Expand Up @@ -97,8 +102,17 @@ class CAttribute : public CXSDNodeWithType

CAnnotation *m_pAnnotation;
CSimpleTypeArray *m_pSimpleTypeArray;
CKeyRefArray *m_pReverseKeyRefArray;
CKeyArray *m_pReverseKeyArray;
//CIArrayOf< CKey> m_ReverseKeyArray;
//CIArrayOf< CKeyRef> m_ReverseKeyRefArray;
//MAKEValueArray(CKey, SchemaKeyArray)
//MAKEValueArray(CKeyRef, SchemaKeyRefArray)
//MAKEValueArray(void *, jlib_decl SchemaKeyArray)
//MAKEValueArray(void *, jlib_decl SchemaKeyRefArray)
PointerArray m_ReverseKeyArray;
PointerArray m_ReverseKeyRefArray;
//CKeyRefArray *const m_pReverseKeyRefArray;
//CKeyArray *const m_pReverseKeyArray;

bool m_bInstanceValueValid;

private:
Expand Down
14 changes: 12 additions & 2 deletions configurator/SchemaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,10 @@ void CElement::populateEnvXPath(StringBuffer strXPath, unsigned int index)

this->setEnvXPath(strXPath);


//strXPath.setLength(strXPath.length()-3); // remove [N] from XPath;
//strXPath.appendf("[%d]", this->getParentIndex()+1);

if (m_pComplexTypeArray != NULL)
{
m_pComplexTypeArray->populateEnvXPath(strXPath);
Expand Down Expand Up @@ -987,11 +991,17 @@ void CElementArray::populateEnvXPath(StringBuffer strXPath, unsigned int index)

StringBuffer mapKey(strXPath);

int elemCount = 1;

for (int idx=0; idx < this->length(); idx++)
{
(this->item(idx)).populateEnvXPath(strXPath, 1);
if ((this->item(idx)).getIsInXSD() == true)
{
elemCount = 1;
}
(this->item(idx)).populateEnvXPath(strXPath, elemCount++);

mapKey.setf("%s[%d]", this->getXSDXPath(), idx+1);
mapKey.setf("%s[%d]", this->getXSDXPath(), index);

CConfigSchemaHelper::getInstance()->getSchemaMapManager()->addMapOfXPathToElementArray(mapKey.str(), this);
}
Expand Down
3 changes: 2 additions & 1 deletion configurator/SchemaElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class CElement : public CXSDNodeWithType
return this->m_pElementRefNode;
}

void addReverseKeyRef(const CKeyRef *pKeyRef);
//void addReverseKeyRef(const CKeyRef *pKeyRef);
//void addReverseKey(const CKeyRef *pKey);

bool isATab() const;
bool isLastTab(const int idx) const;
Expand Down
26 changes: 23 additions & 3 deletions configurator/SchemaKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ CKey* CKey::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, co

strXPathExt.append("/").append(XSD_TAG_ANNOTATION);
pKey->m_pAnnotation = CAnnotation::load(pKey, pSchemaRoot, strXPathExt.str());

/*CElement *pElement = dynamic_cast<CElement*>(pKey->getParentNodeByType(XSD_ELEMENT));
assert(pElement != NULL);
if (pElement != NULL && pKey->m_pFieldArray != NULL && pKey->m_pFieldArray->length() > 0 && pKey->m_pSelector != NULL)
{
StringBuffer strXPathOfKeyAttribute(pElement->getEnvXPath());
strXPathOfKeyAttribute.append("/").append(pKey->m_pSelector->getXPath()).append("/").append(pKey->m_pFieldArray->item(0).get);
CAttribute *pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(strXPathOfKeyAttribute.str());
assert(pElement != NULL);
if (pElement != NULL)
{
//pElement->addReverseKey(pKey);
pElement->get
}
}*/
}

return pKey;
Expand All @@ -99,11 +119,11 @@ bool CKey::checkConstraint(const char *pValue) const
return false;
}

StringBuffer strXSDPathForConstraint(this->getXSDXPath());
StringBuffer strXPathForConstraintCheck(this->getEnvXPath());

strXSDPathForConstraint.appendf("/%s", this->m_pSelector->getXPath());
strXPathForConstraintCheck.appendf("/%s", this->m_pSelector->getXPath());

const CElement *pElement = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getElementFromXSDXPath(strXSDPathForConstraint.str());
const CElement *pElement = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getElementFromXPath(strXPathForConstraintCheck.str());

if (pElement == NULL)
{
Expand Down

0 comments on commit 660c1c3

Please sign in to comment.