Exemple #1
0
MojErr MojDbSearchCursor::loadObjects(const ObjectSet& ids)
{
    MojInt32 warns = 0;
    for (ObjectSet::ConstIterator i = ids.begin(); i != ids.end(); ++i) {
        // get item by id
        MojObject obj;
        MojDbStorageItem* item = NULL;
        bool found = false;
        MojErr err = m_storageQuery->getById(*i, item, found);
        if (err == MojErrInternalIndexOnFind) {
            warns++;
            continue;
        }

        MojErrCheck(err);
        if (found) {
            // get object from item
            err = item->toObject(obj, *m_kindEngine);
            MojErrCheck(err);
            // filter results
            if (m_queryFilter.get() && !m_queryFilter->test(obj))
                continue;
            // create object item
            MojRefCountedPtr<MojDbObjectItem> item(new MojDbObjectItem(obj));
            MojAllocCheck(item.get());
            // add to vec
            err = m_items.push(item);
            MojErrCheck(err);
        }
    }
    if (warns > 0)
        MojLogWarning(MojDb::s_log, _T("Search warnings: %d \n"), warns);
    return MojErrNone;
}
MojErr MojDbSearchCursor::loadObjects(const ObjectSet& ids)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

    MojInt32 warns = 0;
    for (ObjectSet::ConstIterator i = ids.begin(); i != ids.end(); ++i) {
        // get item by id
        MojObject obj;
        MojDbStorageItem* item = NULL;
        bool found = false;
        MojErr err = m_storageQuery->getById(*i, item, found);
        if (err == MojErrInternalIndexOnFind) {
            warns++;
            continue;
        }

        MojErrCheck(err);
        if (found) {
            // get object from item
            err = item->toObject(obj, *m_kindEngine);
            MojErrCheck(err);
            // filter results
            if (m_queryFilter.get() && !MojBoolResult(m_queryFilter->test, obj))
                continue;
            // create object item
            MojRefCountedPtr<MojDbObjectItem> item(new MojDbObjectItem(obj));
            MojAllocCheck(item.get());
            // add to vec
            err = m_items.push(item);
            MojErrCheck(err);
        }
    }
    if (warns > 0)
        LOG_DEBUG("[db_mojodb] Search warnings: %d \n", warns);
    return MojErrNone;
}