gemire / daofusion

Automatically exported from code.google.com/p/daofusion
0 stars 1 forks source link

Bitemporal pattern support on Criteria API / CTO level #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The bitemporal pattern implementation currently integrates with standard
persistent entity model. The user is therefore responsible for creating
custom NestedPropertyCriteria or using generic NestedPropertyCriteria for
expressing bitemporal trace constraints.

For example, extending FilterCriterion to be applied to NestedPropertyCriteria:

public class BitemporalValidAtCriterion extends FilterCriterion {

    public BitemporalValidAtCriterion(AssociationPath associationPath) {
        this(associationPath, TimeUtils.now());
    }

    public BitemporalValidAtCriterion(AssociationPath associationPath,
final DateTime instant) {
        super(associationPath, null, new SimpleFilterCriterionProvider() {
            public Criterion getCriterion(String targetPropertyName,
Object[] filterObjectValues, Object[] directValues) {
                return TemporalRestrictions.validAt(instant);
            }
        });
    }

}

Together with following temporal restriction helper class (bitemporal
alternative to "org.hibernate.criterion.Restrictions":

public final class TemporalRestrictions {

    public static Criterion validAt(DateTime validAt){
        Date date = validAt.toGregorianCalendar().getTime();
        return Restrictions.and(
                Restrictions.le(BitemporalWrapper._VALID_FROM, date),
                Restrictions.gt(BitemporalWrapper._VALID_TO, date));
    }

}

Restrictions placed on bitemporal value, on the other hand, can be done
using plain FilterCriterion's (they just need to start at the bitemporal
collection and navigate through its "value" persistent property to the
actual value class).

Criteria Transfer Object (CTO) support for bitemporal pattern should then
build upon such Criteria API extensions. If we could do this, bitemporal
constraints can be expressed within the CTO itself -- no need for
extracting CTO column values and building bitemporal criteria by hand!

Original issue reported on code.google.com by Vojtech....@gmail.com on 14 Sep 2009 at 11:54

GoogleCodeExporter commented 9 years ago
Changes made to Criteria API / CTO should be reflected by appropriate 
integration
tests as well (e.g. extend the sample "eShop" domain model with bitemporal 
aspects).

Original comment by Vojtech....@gmail.com on 14 Sep 2009 at 11:59