if(ds instanceof EODatabaseDataSource) { ((EODatabaseDataSource)ds).setFetchSpecificationByName(fetchspecName); }
if(ds instanceof EODatabaseDataSource) { EOFetchSpecification fs = ((EODatabaseDataSource)ds).entity().fetchSpecificationNamed(fetchspecName); if(fs != null) { fs = (EOFetchSpecification) fs.clone(); } ((EODatabaseDataSource)ds).setFetchSpecification(fs); }
    protected void setupPhase() {        WODisplayGroup dg=displayGroup();        if (dg!=null) {       		NSArray sortOrderings = dg.sortOrderings();    		EODataSource ds = dataSource();        	if (!_hasBeenInitialized) {        		log.debug("Initializing display group");        		String fetchspecName = (String)d2wContext().valueForKey("restrictingFetchSpecification");        		if(fetchspecName != null) {        			if(ds instanceof EODatabaseDataSource) {        				((EODatabaseDataSource)ds).setFetchSpecificationByName(fetchspecName);        			}        		}         		if(sortOrderings == null) {        			sortOrderings = sortOrderings();        			setSortOrderingsOnDisplayGroup(sortOrderings, dg);        		}        		dg.setNumberOfObjectsPerBatch(numberOfObjectsPerBatch());        		dg.fetch();                dg.updateDisplayedObjects();                _hasBeenInitialized=true;                _hasToUpdate = false;        	}        	// AK: if we have a DB datasource, then we might want to refetch if the sort ordering changed        	// because if we have a fetch limit then the displayed matches on the first page come from the        	// results, not from the real order in the DB. Set "alwaysRefetchList" to false in your         	// rules to prevent that.        	if((sortOrderings != null) && (ds instanceof EODatabaseDataSource)) {        		EOFetchSpecification fs = ((EODatabaseDataSource)ds).fetchSpecification();        		if(!fs.sortOrderings().equals(sortOrderings)) {        			fs.setSortOrderings(sortOrderings);        			_hasToUpdate = _hasToUpdate ? true : alwaysRefetchList();        		}        	}        	// this will have the side effect of resetting the batch # to sth correct, in case            // the current index if out of range            log.debug("dg.currentBatchIndex() "+dg.currentBatchIndex());            dg.setCurrentBatchIndex(dg.currentBatchIndex());            if (listSize() > 0) {                d2wContext().takeValueForKey(dg.allObjects().objectAtIndex(0), "object");            }        }    }