r1 - 25 Jun 2008 - 09:32:11 - RandyLetnessYou are here: OSAF >  Journal Web  >  ContributorNotes > RandyLetnessNotes > CosmoOneDotZeroModelDocs > CosmoOneDotZeroDaoLayer

Cosmo 1.0 Dao Layer

The Data Access Object encapsulates access to persistent data. They are responsible for CRUD operations for persistent cosmo model objects. Because Cosmo uses Hibernate as an ORM, the DAO implementations are based on Spring's HibernateDaoSupport class, which provides access to a Hibernate Session . Cosmo uses Spring's declarative transaction framework which means the dao's require no transaction code. It is assumed that the transaction is controlled in another layer.

Item Fiilters

ContentDao includes an api for querying Item s using an ItemFilter . The ItemFilter model provides a way to specify criteria for retrieving Item s . Although not complete and not the most robust model, it allows for many different types of queries to be performed all using the same api.

An ItemFilter is basically a big AND query. All the criteria set on an ItemFilter is ANDed together to match results.

Examples:

Find all NoteItem s that belong to a collection and match a displayName:

    NoteItemFilter filter = new NoteItemFilter();
    filter.setParent(parent);
    filter.setDisplayName(Restrictions.eq("matchme"));
 
    Set<Item> results = contentDao.findItems(filter);
    

Find all NoteItem s that belong to a collection, match the displayName, and have an EventStamp and occur in a specified data range:

    NoteItemFilter filter = new NoteItemFilter();
    filter.setParent(parent);
    filter.setDisplayName(Restrictions.eq("matchme"));
    EventStampFilter eventFilter = new EventStampFilter();
    Period period = new Period(new DateTime("20070101T100000Z"), new DateTime("20070201T100000Z"));
    eventFilter.setPeriod(period);
    filter.getStampFilters().add(eventFilter);

    Set<Item> results = contentDao.findItems(filter);
    

For more information on how to use filters, refer to examples in the source (org.osaf.cosmo.service.impl.StandardTriageQueryProcessor) and the unit tests.

-- RandyLetness - 25 Jun 2008

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.