* query has been modified and results are needed.
*/
protected void query() {
log.debug( "Entry: PhotoQuery.query" );
photos.clear();
ODMGXAWrapper txw = new ODMGXAWrapper();
Implementation odmg = ODMG.getODMGImplementation();
Transaction tx = odmg.currentTransaction();
try {
PersistenceBroker broker = ((HasBroker) tx).getBroker();
Criteria crit = new Criteria();
// Go through all the fields and create the criteria
for ( int n = 0; n < criterias.length; n++ ) {
if ( criterias[n] != null ) {
criterias[n].setupQuery( crit );
}
}
if ( limitFolder != null ) {
Collection folderIds = getSubfolderIds( limitFolder );
// crit.addEqualTo( "folders.folderId", new Integer( limitFolder.getFolderId() ) );
crit.addIn( "folders.folderId", folderIds );
}
QueryByCriteria q = new QueryByCriteria( PhotoInfo.class, crit );
Collection result = broker.getCollectionByQuery( q );
photos.addAll( result );
txw.commit();
} catch ( Exception e ) {
log.warn( "Error executing query: " + e.getMessage() );
e.printStackTrace( System.out );
txw.abort();
}
queryModified = false;
log.debug( "Exit: PhotoQuery.query" );