use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class DataDimensionExtractor method getReportingRate.
/**
* Returns a {@link ReportingRate}.
*
* @param idScheme the identifier scheme.
* @param dataSetId the data set identifier.
* @param metric the reporting rate metric.
*/
ReportingRate getReportingRate(final IdScheme idScheme, final String dataSetId, final String metric) {
final DataSet dataSet = idObjectManager.getObject(DataSet.class, idScheme, dataSetId);
final boolean metricValid = isValidEnum(ReportingRateMetric.class, metric);
if (dataSet == null || !metricValid) {
return null;
}
return new ReportingRate(dataSet, ReportingRateMetric.valueOf(metric));
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class HibernateDataSetStore method getDataSetsByPeriodType.
@Override
public List<DataSet> getDataSetsByPeriodType(PeriodType periodType) {
PeriodType refreshedPeriodType = periodService.reloadPeriodType(periodType);
CriteriaBuilder builder = getCriteriaBuilder();
JpaQueryParameters<DataSet> parameters = newJpaParameters().addPredicate(root -> builder.equal(root.get("periodType"), refreshedPeriodType));
return getList(builder, parameters);
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class DefaultDataSetNotificationService method createBatchForSummaryNotifications.
private MessageBatch createBatchForSummaryNotifications(Set<DataSetNotificationTemplate> templates) {
MessageBatch batch = new MessageBatch();
String messageText = "";
boolean summaryCreated = false;
Long pendingOus;
for (DataSetNotificationTemplate template : templates) {
DhisMessage dhisMessage = new DhisMessage();
for (DataSet dataSet : template.getDataSets()) {
if (isValidForSending(getDataSetPeriod(dataSet), template)) {
summaryCreated = true;
pendingOus = dataSet.getSources().stream().filter(ou -> !isCompleted(createRespectiveRegistrationObject(dataSet, ou))).count();
messageText += String.format(SUMMARY_TEXT, pendingOus, getPeriodString(dataSet.getPeriodType().createPeriod()), dataSet.getName()) + TEXT_SEPARATOR;
}
}
if (summaryCreated) {
dhisMessage.message = new NotificationMessage(createSubjectString(template), messageText);
dhisMessage.recipients = resolveInternalRecipients(template);
batch.dhisMessages.add(dhisMessage);
messageText = "";
}
}
log.info(String.format("%d summary dataset notifications created.", batch.dhisMessages.size()));
return batch;
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class HibernateCompleteDataSetRegistrationStore method getCompleteDataSetRegistration.
@Override
public CompleteDataSetRegistration getCompleteDataSetRegistration(DataSet dataSet, Period period, OrganisationUnit source, CategoryOptionCombo attributeOptionCombo) {
Period storedPeriod = periodStore.reloadPeriod(period);
if (storedPeriod == null) {
return null;
}
CriteriaBuilder builder = getCriteriaBuilder();
return getSingleResult(builder, newJpaParameters().addPredicate(root -> builder.equal(root, new CompleteDataSetRegistration(dataSet, storedPeriod, source, attributeOptionCombo))));
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class ExpressionService2Test method setUp.
@BeforeEach
public void setUp() {
target = new DefaultExpressionService(hibernateGenericStore, constantService, dimensionService, idObjectManager, statementBuilder, i18nManager, cacheProvider);
categoryOptionA = new CategoryOption("Under 5");
categoryOptionB = new CategoryOption("Over 5");
categoryOptionC = new CategoryOption("Male");
categoryOptionD = new CategoryOption("Female");
categoryA = new Category("Age", DataDimensionType.DISAGGREGATION);
categoryB = new Category("Gender", DataDimensionType.DISAGGREGATION);
categoryA.getCategoryOptions().add(categoryOptionA);
categoryA.getCategoryOptions().add(categoryOptionB);
categoryB.getCategoryOptions().add(categoryOptionC);
categoryB.getCategoryOptions().add(categoryOptionD);
categoryCombo = new CategoryCombo("Age and gender", DataDimensionType.DISAGGREGATION);
categoryCombo.getCategories().add(categoryA);
categoryCombo.getCategories().add(categoryB);
categoryCombo.generateOptionCombos();
List<CategoryOptionCombo> optionCombos = Lists.newArrayList(categoryCombo.getOptionCombos());
cocA = optionCombos.get(0);
cocA.setUid(CodeGenerator.generateUid());
cocB = optionCombos.get(1);
cocB.setUid(CodeGenerator.generateUid());
deA = createDataElement('A');
deB = createDataElement('B');
deC = createDataElement('C');
deD = createDataElement('D');
deE = createDataElement('E', categoryCombo);
coc = rnd.nextObject(CategoryOptionCombo.class);
coc.setName(DEFAULT_CATEGORY_COMBO_NAME);
optionCombos.add(coc);
opA = new DataElementOperand(deA, coc);
opB = new DataElementOperand(deB, coc);
opC = new DataElementOperand(deC, coc);
opD = new DataElementOperand(deD, coc);
opE = new DataElementOperand(deB, cocA);
opF = new DataElementOperand(deA, cocA, cocB);
period = createPeriod(getDate(2000, 1, 1), getDate(2000, 1, 31));
pteaA = rnd.nextObject(ProgramTrackedEntityAttributeDimensionItem.class);
pdeA = rnd.nextObject(ProgramDataElementDimensionItem.class);
piA = rnd.nextObject(ProgramIndicator.class);
unitA = createOrganisationUnit('A');
unitB = createOrganisationUnit('B');
unitC = createOrganisationUnit('C');
constantA = rnd.nextObject(Constant.class);
constantA.setName("ConstantA");
constantA.setValue(2.0);
constantB = rnd.nextObject(Constant.class);
constantB.setName("ConstantB");
constantB.setValue(5.0);
groupA = createOrganisationUnitGroup('A');
groupA.addOrganisationUnit(unitA);
groupA.addOrganisationUnit(unitB);
groupA.addOrganisationUnit(unitC);
groupB = createOrganisationUnitGroup('B');
groupB.addOrganisationUnit(unitB);
DataSet dataSetA = createDataSet('A');
dataSetA.setUid("a23dataSetA");
dataSetA.addOrganisationUnit(unitA);
reportingRate = new ReportingRate(dataSetA);
expressionA = "#{" + opA.getDimensionItem() + "}+#{" + opB.getDimensionItem() + "}";
expressionB = "#{" + deC.getUid() + SEPARATOR + coc.getUid() + "}-#{" + deD.getUid() + SEPARATOR + coc.getUid() + "}";
expressionC = "#{" + deA.getUid() + SEPARATOR + coc.getUid() + "}+#{" + deE.getUid() + "}-10";
expressionD = "#{" + deA.getUid() + SEPARATOR + coc.getUid() + "}+" + SYMBOL_DAYS;
expressionE = "#{" + deA.getUid() + SEPARATOR + coc.getUid() + "}*C{" + constantA.getUid() + "}";
expressionF = "#{" + deA.getUid() + SEPARATOR + coc.getUid() + "}";
expressionG = expressionF + "+#{" + deB.getUid() + "}-#{" + deC.getUid() + "}";
expressionH = "#{" + deA.getUid() + SEPARATOR + coc.getUid() + "}*OUG{" + groupA.getUid() + "}";
expressionI = "#{" + opA.getDimensionItem() + "}*" + "#{" + deB.getDimensionItem() + "}+" + "C{" + constantA.getUid() + "}+5-" + "D{" + pdeA.getDimensionItem() + "}+" + "A{" + pteaA.getDimensionItem() + "}-10+" + "I{" + piA.getDimensionItem() + "}";
expressionJ = "#{" + opA.getDimensionItem() + "}+#{" + opB.getDimensionItem() + "}";
expressionK = "1.5*avg(" + expressionJ + ")";
expressionL = expressionA + "+avg(" + expressionJ + ")+1.5*stddev(" + expressionJ + ")+" + expressionB;
expressionM = "#{" + deA.getUid() + SEPARATOR + SYMBOL_WILDCARD + "}-#{" + deB.getUid() + SEPARATOR + coc.getUid() + "}";
expressionN = "#{" + deA.getUid() + SEPARATOR + cocA.getUid() + SEPARATOR + cocB.getUid() + "}-#{" + deB.getUid() + SEPARATOR + cocA.getUid() + "}";
expressionO = "#{" + opA.getDimensionItem() + "}+sum(#{" + opB.getDimensionItem() + "})";
expressionP = "#{" + deB.getUid() + SEPARATOR + coc.getUid() + "}";
expressionR = "#{" + deB.getUid() + SEPARATOR + coc.getUid() + "}" + " + R{" + reportingRate.getUid() + ".REPORTING_RATE}";
}
Aggregations