use of org.hisp.dhis.expression.Expression in project dhis2-core by dhis2.
the class PredictorObjectBundleHook method preCreate.
@Override
public void preCreate(IdentifiableObject object, ObjectBundle bundle) {
if (!Predictor.class.isInstance(object)) {
return;
}
Predictor predictor = (Predictor) object;
Expression skipTest = predictor.getSampleSkipTest();
preheatService.connectReferences(predictor.getGenerator(), bundle.getPreheat(), bundle.getPreheatIdentifier());
if (skipTest != null) {
preheatService.connectReferences(skipTest, bundle.getPreheat(), bundle.getPreheatIdentifier());
}
sessionFactory.getCurrentSession().save(predictor.getGenerator());
if (skipTest != null) {
sessionFactory.getCurrentSession().save(skipTest);
}
if (predictor.getPeriodType() != null) {
PeriodType periodType = bundle.getPreheat().getPeriodTypeMap().get(predictor.getPeriodType().getName());
predictor.setPeriodType(periodType);
}
}
use of org.hisp.dhis.expression.Expression in project dhis2-core by dhis2.
the class PredictorObjectBundleHook method preUpdate.
@Override
public void preUpdate(IdentifiableObject object, IdentifiableObject persistedObject, ObjectBundle bundle) {
if (!Predictor.class.isInstance(object)) {
return;
}
Predictor predictor = (Predictor) object;
Expression skipTest = predictor.getSampleSkipTest();
preheatService.connectReferences(predictor.getGenerator(), bundle.getPreheat(), bundle.getPreheatIdentifier());
if (skipTest != null) {
preheatService.connectReferences(skipTest, bundle.getPreheat(), bundle.getPreheatIdentifier());
}
sessionFactory.getCurrentSession().save(predictor.getGenerator());
if (skipTest != null) {
sessionFactory.getCurrentSession().save(skipTest);
}
if (predictor.getPeriodType() != null) {
PeriodType periodType = bundle.getPreheat().getPeriodTypeMap().get(predictor.getPeriodType().getName());
predictor.setPeriodType(periodType);
}
}
use of org.hisp.dhis.expression.Expression in project dhis2-core by dhis2.
the class ExpressionUpgrader method upgradeExpressions.
private void upgradeExpressions() {
Collection<Expression> expressions = expressionService.getAllExpressions();
for (Expression expression : expressions) {
String expr = upgradeExpression(expression.getExpression());
if (expr != null) {
expression.setExpression(expr);
expressionService.updateExpression(expression);
}
}
}
Aggregations