Previous | Next
WireHose Developers Guide

Fetching feeds to crawl

First, a method which fetches the set of feeds to crawl.

  1. Add this method to
    static NSArray fetchFeedsToCrawl(EOEditingContext ec) {
        NSMutableArray qualifiers = new NSMutableArray();
        // fetch all feeds that haven't been fetched in the last hour
        qualifiers.addObject(new EOKeyValueQualifier(
            new NSTimestamp().timestampByAddingGregorianUnits(0, 0, 0, -1, 0, 0)));
        // and all feeds which weren't invalid last time we fetched
            "RSSFeed", "lastFetchInvalid", EOQualifier.QualifierOperatorEqual, false));
        EOQualifier q = new EOAndQualifier(qualifiers);
        EOFetchSpecification fs = new EOFetchSpecification("RSSFeed", q, null);
        return ec.objectsWithFetchSpecification(fs);

    Note: The qualifierForBooleanAttribute method constructs a qualifier to match boolean values in a database independent fashion. It works by inspecting the current definition of the boolean attribute to determine whether to use a Boolean, String or Integer to represent true or false. Note that here we are using "lastFetchInvalid", which is what the attribute is called in the model. When setting or getting a boolean value on the feed, you'll use the setLastFetchWasInvalid and lastFetchWasInvalid methods defined earlier.

Previous | Next