Exemplo n.º 1
0
bool StoreClient::remove(class_id_t class_id, const URI& uri,
                         bool recursive, notif_t* notifs) {
    Region* r = checkOwner(store, readOnly, region, class_id);

    // Remove the object itself
    bool result = r->remove(class_id, uri);
    if (!result) return result;

    // remove the parent link
    try {
        const std::pair<URI, prop_id_t>& parent = r->getParent(class_id, uri);
        std::vector<std::pair<URI, prop_id_t> > parents;
        std::vector<std::pair<URI, prop_id_t> >::iterator pit;
        class_id_t parent_class = store->prop_map.at(parent.second)->getId();
        delChild(parent_class, parent.first, parent.second,
                 class_id, uri);
    } catch (std::out_of_range e) {
        // no parent link found
    }

    if (!recursive) return result;

    // Remove all the children if requested
    removeChildren(class_id, uri, notifs);

    return result;
}
Exemplo n.º 2
0
bool StoreClient::addChild(class_id_t parent_class,
                           const URI& parent_uri, 
                           prop_id_t parent_prop,
                           class_id_t child_class,
                           const URI& child_uri) {
    // verify that parent URI and class exists
    store->getRegion(parent_class)->get(parent_uri);

    // verify that the parent property exists for this class
    if (store->prop_map.at(parent_prop)->getId() != parent_class)
        throw std::invalid_argument("Parent class does not contain property");

    // verify that the parent URI is a prefix of child URI
    const std::string& puri = parent_uri.toString();
    const std::string& curi = child_uri.toString();
    if (puri.length() >= curi.length() ||
        0 != curi.compare(0, puri.length(), puri))
        throw std::invalid_argument("Parent URI must be a prefix of child URI");

    // add relationship to child's region.  Note that
    // it's OK if the child URI doesn't exist
    Region* r = checkOwner(store, readOnly, region, child_class);
    return r->addChild(parent_class, parent_uri, parent_prop, 
                       child_class, child_uri);
}
Exemplo n.º 3
0
bool StoreClient::remove(class_id_t class_id, const URI& uri,
                         bool recursive, notif_t* notifs) {
    Region* r = checkOwner(store, readOnly, region, class_id);

    // Remove the object itself
    bool result = r->remove(class_id, uri);
    if (!result) return result;

    // remove the parent link
    try {
        std::pair<URI, prop_id_t> parent(URI::ROOT, 0);
        if (r->getParent(class_id, uri, parent)) {
            class_id_t parent_class = store->prop_map.at(parent.second)->getId();
            delChild(parent_class, parent.first, parent.second,
                     class_id, uri);
        }
    } catch (const std::out_of_range&) {
        // parent prop info not found
    }

    if (!recursive) return result;

    // Remove all the children if requested
    removeChildren(class_id, uri, notifs);

    return result;
}
Exemplo n.º 4
0
void StoreClient::delChild(class_id_t parent_class,
                           const URI& parent_uri, 
                           prop_id_t parent_prop,
                           class_id_t child_class,
                           const URI& child_uri) {
    Region* r = checkOwner(store, readOnly, region, child_class);
    r->delChild(parent_class, parent_uri, parent_prop, 
                child_class, child_uri);
}
Exemplo n.º 5
0
bool StoreClient::putIfModified(class_id_t class_id,
                                const URI& uri, 
                                const boost::shared_ptr<const ObjectInstance>& oi) {
    Region* r = checkOwner(store, readOnly, region, class_id);
    return r->putIfModified(class_id, uri, oi);
}