This commit is contained in:
Ren RenJuan 2014-01-27 03:33:17 +00:00
parent b2163785a7
commit b0d8fbacd7
3 changed files with 24 additions and 140 deletions

View File

@ -2,120 +2,41 @@
#include "se/Response.hpp" #include "se/Response.hpp"
#include "se/ResponseExtension.hpp" #include "se/ResponseExtension.hpp"
#include "se/LPE/LPChkRespExtension.hpp" #include "se/LPE/LPChkRespExtension.hpp"
#include <xalanc/XalanDOM/XalanNamedNodeMap.hpp>
#include <xalanc/XalanDOM/XalanDOMString.hpp>
extern mdLogger mdLog;
/* /*
* Have to use static funcion instead of static variable * Have to use static funcion instead of static variable
* since there is not guarantee about the construct/destruct * since there is not guarantee about the construct/destruct
* order of a static instance of any types * order of a static instance of any types
*/ */
const std::string LPChkRespExtension::KVLIST_EXPR() const std::string LPChkRespExtension::CKCLAIM_EXPR()
{ {
return EXTENSION_EXPR() + "/launch:claims"; return EXTENSION_EXPR() + "/launch:cd/launch:name";
} }
LPChkRespExtension::LPChkRespExtension() : LPChkRespExtension::LPChkRespExtension() : typeIsClaims(true)
initialised(false),
kvLists()
{ {
} }
void LPChkRespExtension::fromXML(XMLDocument *xmlDoc) void LPChkRespExtension::fromXML(XMLDocument *xmlDoc)
{ {
int kvListCount = xmlDoc->getNodeCount("count(" + KVLIST_EXPR() + ")"); const std::string respElement = CKCLAIM_EXPR();
if (kvListCount == 0) try {
const XalanNode * response = xmlDoc->getElement(respElement);
if (response) {
}
}
catch(std::exception e)
{ {
initialised = false; mdLog.logN(1,"%s.",e.what());
}
else
{
for (int i = 1; i <= kvListCount; i++)
{
const std::string currentKVListXPath =
ReceiveSE::replaceIndex(KVLIST_EXPR() + "[IDX]", i);
const std::string kvListName =
xmlDoc->getNodeValue(currentKVListXPath + "/@name");
kvLists[kvListName] = createKVList(xmlDoc, currentKVListXPath);
} }
initialised = true;
}
} }
const std::set<std::string> LPChkRespExtension::getLists() const
{
std::set<std::string> kvListNames;
ExtensionList::const_iterator extensionListIterator;
for (extensionListIterator = kvLists.begin();
extensionListIterator != kvLists.end();
extensionListIterator++)
{
kvListNames.insert(extensionListIterator->first);
}
return kvListNames;
}
const std::set<std::string> LPChkRespExtension::getListItems(
const std::string &listName) const
{
std::set<std::string> itemNames;
ExtensionList::const_iterator extensionListIterator = kvLists.find(listName);
if (extensionListIterator != kvLists.end())
{
KeyValueList::const_iterator keyValueListIterator;
for (keyValueListIterator = extensionListIterator->second.begin();
keyValueListIterator != extensionListIterator->second.end();
keyValueListIterator++)
{
itemNames.insert(keyValueListIterator->first);
}
}
return itemNames;
}
const std::string LPChkRespExtension::getItem(
const std::string &listName,
const std::string &key) const
{
std::string itemValue;
ExtensionList::const_iterator extensionListIterator = kvLists.find(listName);
if (extensionListIterator != kvLists.end())
{
KeyValueList::const_iterator keyValueListIterator =
extensionListIterator->second.find(key);
if (keyValueListIterator != extensionListIterator->second.end())
{
itemValue = keyValueListIterator->second;
}
}
return itemValue;
}
const KeyValueList LPChkRespExtension::createKVList(
XMLDocument *xmlDoc,
const std::string &kvListXPath)
{
int kvItemCount = xmlDoc->getNodeCount("count(" + kvListXPath + "/kv:item)");
KeyValueList kvList;
for (int i = 1; i <= kvItemCount; i++)
{
std::string itemXPath = ReceiveSE::replaceIndex(kvListXPath + "/kv:item[IDX]", i);
std::string key = xmlDoc->getNodeValue(itemXPath + "/@key");
std::string value = xmlDoc->getNodeValue(itemXPath);
kvList[key] = value;
}
return kvList;
}

View File

@ -3,9 +3,8 @@
#include <set> #include <set>
#include <string> #include <string>
#include <mdLogger.h>
#include <se/ResponseExtension.hpp> #include <se/ResponseExtension.hpp>
#include "Drafttanepplaunchphase.hpp"
class XMLDocument; class XMLDocument;
@ -15,52 +14,16 @@ class LPChkRespExtension : public ResponseExtension
LPChkRespExtension(); LPChkRespExtension();
virtual void fromXML(XMLDocument *xmlDoc); virtual void fromXML(XMLDocument *xmlDoc);
virtual bool isInitialised() const; bool affirmativeResponse();
/**
* Retrieves the names of all key-value lists that have been added to the
* object.
*
* @return the set of list names
*/
const std::set<std::string> getLists() const;
/**
* Retrieves the names of all item keys, for a specified key-value list
* name.
*
* @param listName
* the name of the key-value list
*
* @return the set of item keys
*/
const std::set<std::string> getListItems(const std::string &listName) const;
/**
* Retrieves the value of a given key-value item.
*
* @param listName
* the name of the key-value list
* @param key
* the key of the item
*
* @return the value of the item
*/
const std::string getItem(const std::string &listName, const std::string &key) const;
private: private:
const KeyValueList createKVList( const XMLDocument *xmlDoc;
XMLDocument *xmlDoc,
const std::string &kvListXPath);
bool initialised; bool typeIsClaims; // False implies type is availablity
ExtensionList kvLists; bool response; // true/false attribute in reply
static const std::string KVLIST_EXPR(); static const std::string CKCLAIM_EXPR();
}; };
inline bool LPChkRespExtension::isInitialised() const
{
return initialised;
}
#endif /* LPCK_RESPONSE_EXTENSION_H_ */ #endif /* LPCK_RESPONSE_EXTENSION_H_ */

View File

@ -187,7 +187,7 @@ void ausRegEPPTK::doOTEB()
theseLogs->logN(0,"Case %d Failed, harness catch.",cmd++); theseLogs->logN(0,"Case %d Failed, harness catch.",cmd++);
} }
theseLogs->logN(1,"(%d) LPE Check of unicycles.bike",cmd++); theseLogs->logN(1,"(%d) Perform Claims type Check of unicycles.bike",cmd++);
DomainCheckCommand oteCommand_2("unicycles.bike"); DomainCheckCommand oteCommand_2("unicycles.bike");
LPChkCmdExtension chkE(&claims); LPChkCmdExtension chkE(&claims);