|
In the future, it would be nice to add support for updates and deletes to the Criteria API - something like:
MeasurementDefinitionCriteria {
List<Integer> filterMeasurementDefinitionIds;
...
other existing filters, which help narrow down the list of definitions to update
...
// new part of the API
Long updateCollectionInterval; // if non-null, set the collectionInterval
Boolean updateEnabled; // if non-null, override enabled/disabled bit
}
Here, we've enhanced the criteria API to include new parameter types,
MeasurementScheduleManagerBean {
int updateMeasurementDefinitionsByCriteria(subject, criteria) {
// check authorization to ensure caller has permission to update monitoring defaults
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
// potentially add authz fragments to the generated query, to restrict the update list
CriteriaQueryRunner<MeasurementDefinition> queryRunner = null;
queryRunner = new CriteriaQueryRunner(criteria, generator, entityManager);
return queryRunner.executeUpdate();
}
}
Notice that a new method would be added to the CriteriaQueryRunner The benefit with this type of solution is that it enables users to So with just a little work at the CriteriaQueryGenerator and Note: a criteria-based solution could use the same style to perform
SomeManagerBean {
int deleteSomethingByCriteria(subject, criteria) {
// check authorization to ensure caller has permission to delete
something
CriteriaQueryGenerator generator = new
CriteriaQueryGenerator(subject, criteria);
CriteriaQueryRunner<SomeThing> queryRunner = null;
queryRunner = new CriteriaQueryRunner(criteria, generator, entityManager);
return queryRunner.executeDelete();
}
}
Again, the benefit is that it exposes the familiar, fine-grained search |