Search in sources :

Example 1 with VersionedObject

use of org.hisp.dhis.common.VersionedObject in project dhis2-core by dhis2.

the class VersionedObjectObjectBundleHook method preUpdate.

@Override
public <T extends IdentifiableObject> void preUpdate(T object, T persistedObject, ObjectBundle bundle) {
    if (VersionedObject.class.isInstance(object)) {
        VersionedObject versionedObject = (VersionedObject) object;
        versionedObject.increaseVersion();
    }
}
Also used : VersionedObject(org.hisp.dhis.common.VersionedObject)

Example 2 with VersionedObject

use of org.hisp.dhis.common.VersionedObject in project dhis2-core by dhis2.

the class VersionedObjectObjectBundleHook method postCreate.

@Override
public <T extends IdentifiableObject> void postCreate(T persistedObject, ObjectBundle bundle) {
    VersionedObject versionedObject = null;
    if (Section.class.isInstance(persistedObject)) {
        versionedObject = ((Section) persistedObject).getDataSet();
    } else if (Option.class.isInstance(persistedObject)) {
        versionedObject = ((Option) persistedObject).getOptionSet();
    }
    if (versionedObject != null) {
        versionedObject.increaseVersion();
        sessionFactory.getCurrentSession().save(versionedObject);
    }
}
Also used : VersionedObject(org.hisp.dhis.common.VersionedObject) Option(org.hisp.dhis.option.Option)

Aggregations

VersionedObject (org.hisp.dhis.common.VersionedObject)2 Option (org.hisp.dhis.option.Option)1