コード例 #1
0
void VR_DataProcessor::updateListByDataAccessor(const pugi::xml_node& dataAccessor_result)
{
    VR_LOGD_FUNC();
    pugi::xml_node listNode = dataAccessor_result.select_node("//list").node();
    std::string listId = listNode.attribute("id").as_string();
    std::string xpathStr = "//list[@id='" + listId + "']";
    pugi::xml_node oldListNode = _listData.select_node(xpathStr.c_str()).node();
    if (NULL != oldListNode) {
        _listData.remove_child(oldListNode);
    }
    _listData.append_copy(listNode);
    return;
}
コード例 #2
0
void VR_DataProcessor::addItemsToDispaly(pugi::xml_node& hintsOrSelectListsNodeScxml)
{
    VR_LOGD_FUNC();
    // get the params (hints) and get some data into _listDataForUI
    std::string listIdScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().attribute("id").as_string();
    std::string pageSizeStrScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().child("header").child("pageSize").child_value();
    int pageSizeScxml = atoi(pageSizeStrScxml.c_str());
    std::string startIndexStrScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().child("header").child("startIndex").child_value();
    int startIndexScxml = atoi(startIndexStrScxml.c_str());
    std::string xpathStr = "/list[@id='" + listIdScxml + "']/items/item";
    pugi::xpath_node_set itemXpathNodes = _listData.select_nodes(xpathStr.c_str());
    int count = itemXpathNodes.size();
    VR_LOGD("pageSize = %d, startIndex = %d, all count = %d", pageSizeScxml, startIndexScxml, count);
    if (count < 1) {
        VR_ERROR("when receive the paper operaction of display,can't find listid=%s in DE\n", listIdScxml.c_str());
    }
    else {
        pugi::xml_node listNodeScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node(); 
        // pugi::xml_node listNodeScxml = hintsOrSelectListsNodeScxml.child("list");
        listNodeScxml.remove_child("items");
        pugi::xml_node itemsNodeScxml = listNodeScxml.append_child("items");
        for (int i = 0; i < pageSizeScxml; ++i) {
            int index = startIndexScxml + i;
            if (index < itemXpathNodes.size()) {
                pugi::xml_node nodeIt = itemXpathNodes[index].node();
                itemsNodeScxml.append_copy(nodeIt);
            }
            else {
                VR_LOG("pagesize=%d", pageSizeScxml);
                VR_LOG("startIndex=%d", startIndexScxml);
                VR_LOG("when add items to dispaly list, item has reached end!");
                break;
            }
        }
    }
}
コード例 #3
0
void VR_DataProcessor::updateListByActionResult(pugi::xml_node& action_result)
{
    VR_LOGD_FUNC();
    pugi::xml_node listNode = action_result.select_node("//list").node();
    // save the node in DE
    std::string listId = std::string("list_") + action_result.attribute("op").as_string(); // listNode.attribute("id").as_string();
    listNode.remove_attribute("id");
    listNode.append_attribute("id").set_value(listId.c_str());
    std::string xpathStr = "//list[@id='" + listId + "']";
    pugi::xml_node oldListNode = _listData.select_node(xpathStr.c_str()).node();
    if (NULL != oldListNode) {
        _listData.remove_child(oldListNode);
    }
    _listData.append_copy(listNode);
    return;
}
コード例 #4
0
void VR_DataProcessor::addItemsToHintsDispaly(pugi::xml_node& hintsOrSelectListsNodeScxml, bool isNavi, bool isInfo)
{
    VR_LOGD_FUNC();
    // get the params (hints) and get some data into _listDataForUI
    std::string listIdScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().attribute("id").as_string();
    std::string pageSizeStrScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().child("header").child("pageSize").child_value();
    int pageSizeScxml = atoi(pageSizeStrScxml.c_str());
    std::string startIndexStrScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().child("header").child("startIndex").child_value();
    int startIndexScxml = atoi(startIndexStrScxml.c_str());
    std::string xpathStr = "/list[@id='" + listIdScxml + "']/items/item";
    pugi::xpath_node_set allNodes = _listData.select_nodes(xpathStr.c_str());

    // remove info and navi
    pugi::xml_document docRet;
    pugi::xpath_node_set::iterator it = allNodes.begin();
    while (it != allNodes.end()) {
        docRet.append_copy(it->node());
        ++it;
    }
    if (!isInfo) {
        // remove show="information"
        pugi::xpath_node_set infoNodeSet = docRet.select_nodes("//item[@show='information']");
        pugi::xpath_node_set::iterator it = infoNodeSet.begin();
        if (it != infoNodeSet.end()) {
            docRet.remove_child(it->node());
        }
    }

    if (!isNavi) {
        // remove show="navi"
        pugi::xpath_node_set naviNodeSet = docRet.select_nodes("//item[@show='navi']");
        pugi::xpath_node_set::iterator it = naviNodeSet.begin();
        if (it != naviNodeSet.end()) {
            docRet.remove_child(it->node());
        }
    }
    pugi::xpath_node_set itemXpathNodes = docRet.select_nodes("//item");
    // end

    int count = itemXpathNodes.size();
    VR_LOG("pageSize = %d, startIndex = %d, all count = %d", pageSizeScxml, startIndexScxml, count);
    if (count < 1) {
        VR_ERROR("when receive the paper operaction of display,can't find listid=%s in DE\n", listIdScxml.c_str());
    }
    else {
        pugi::xml_node listNodeScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node();
        // pugi::xml_node listNodeScxml = hintsOrSelectListsNodeScxml.child("list");
        listNodeScxml.remove_child("items");
        pugi::xml_node itemsNodeScxml = listNodeScxml.append_child("items");
        for (int i = 0; i < pageSizeScxml; ++i) {
            int index = startIndexScxml + i;
            if (index < itemXpathNodes.size()) {
                pugi::xml_node nodeIt = itemXpathNodes[index].node();
                itemsNodeScxml.append_copy(nodeIt);
            }
            else {
                VR_LOG("pagesize=%d", pageSizeScxml);
                VR_LOG("startIndex=%d", startIndexScxml);
                VR_LOG("when add items to dispaly list, item has reached end!");
                break;
            }
        }
    }
}