use of org.hisp.dhis.dataset.CompleteDataSetRegistration in project dhis2-core by dhis2.
the class J2MEDataValueSMSListener method registerCompleteDataSet.
private void registerCompleteDataSet(DataSet dataSet, Period period, OrganisationUnit organisationUnit, String storedBy) {
CompleteDataSetRegistration registration = new CompleteDataSetRegistration();
DataElementCategoryOptionCombo optionCombo = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
if (registrationService.getCompleteDataSetRegistration(dataSet, period, organisationUnit, optionCombo) == null) {
registration.setDataSet(dataSet);
registration.setPeriod(period);
registration.setSource(organisationUnit);
registration.setDate(new Date());
registration.setStoredBy(storedBy);
registration.setPeriodName(registration.getPeriod().toString());
registrationService.saveCompleteDataSetRegistration(registration, false);
}
}
use of org.hisp.dhis.dataset.CompleteDataSetRegistration in project dhis2-core by dhis2.
the class AnalyticsServiceTest method parseDataSetRegistrations.
/**
* Adds data set registrations based on input from vales
*
* @param lines the arraylist of arrays of property values.
*/
private void parseDataSetRegistrations(ArrayList<String[]> lines) {
String storedBy = "johndoe";
Date now = new Date();
for (String[] line : lines) {
DataSet dataSet = dataSetService.getDataSet(line[0]);
Period period = periodService.getPeriod(line[1]);
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(line[2]);
CompleteDataSetRegistration completeDataSetRegistration = new CompleteDataSetRegistration(dataSet, period, organisationUnit, ocDef, now, storedBy);
completeDataSetRegistrationService.saveCompleteDataSetRegistration(completeDataSetRegistration);
}
assertEquals("Import of data set registrations failed, number of imports are wrong", completeDataSetRegistrationService.getAllCompleteDataSetRegistrations().size(), 15);
}
use of org.hisp.dhis.dataset.CompleteDataSetRegistration in project dhis2-core by dhis2.
the class DataSetCompletenessServiceTest method testGetDataSetCompletenessByOrganisationUnitC.
@Test
public void testGetDataSetCompletenessByOrganisationUnitC() {
dataSetA.getSources().add(unitE);
dataSetA.getSources().add(unitF);
dataSetA.getSources().add(unitG);
dataSetA.getSources().add(unitH);
dataSetIdA = dataSetService.addDataSet(dataSetA);
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitE, null, onTimeA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitF, null, tooLateA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitG, null, onTimeA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitH, null, tooLateA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitE, null, onTimeB, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitF, null, tooLateB, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitG, null, onTimeB, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitH, null, tooLateB, ""));
Collection<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness(periodIdA, unitIdsA, dataSetIdA, null);
assertNotNull(results);
assertEquals(3, results.size());
assertTrue(results.contains(new DataSetCompletenessResult(unitB.getName(), 2, 2, 1)));
assertTrue(results.contains(new DataSetCompletenessResult(unitC.getName(), 2, 2, 1)));
assertTrue(results.contains(new DataSetCompletenessResult(unitA.getName(), 4, 4, 2)));
results = registrationCompletenessService.getDataSetCompleteness(periodIdC, unitIdsA, dataSetIdA, null);
assertNotNull(results);
assertEquals(3, results.size());
assertTrue(results.contains(new DataSetCompletenessResult(unitB.getName(), 6, 4, 2)));
assertTrue(results.contains(new DataSetCompletenessResult(unitC.getName(), 6, 4, 2)));
assertTrue(results.contains(new DataSetCompletenessResult(unitA.getName(), 12, 8, 4)));
}
use of org.hisp.dhis.dataset.CompleteDataSetRegistration in project dhis2-core by dhis2.
the class DataSetCompletenessServiceTest method testGetDataSetCompletenessByDataSetC.
@Test
public void testGetDataSetCompletenessByDataSetC() {
dataSetA.getSources().add(unitA);
dataSetA.getSources().add(unitB);
dataSetA.getSources().add(unitC);
dataSetA.getSources().add(unitE);
dataSetA.getSources().add(unitF);
dataSetA.getSources().add(unitG);
dataSetA.getSources().add(unitH);
dataSetService.addDataSet(dataSetA);
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitB, null, onTimeA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitC, null, tooLateA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitE, null, onTimeA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitF, null, tooLateA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitG, null, onTimeA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitE, null, onTimeB, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitF, null, onTimeB, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitG, null, tooLateB, ""));
List<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness(periodIdA, unitIdA, null);
assertNotNull(results);
assertEquals(1, results.size());
assertTrue(results.contains(new DataSetCompletenessResult(dataSetA.getName(), 7, 5, 3)));
results = registrationCompletenessService.getDataSetCompleteness(periodIdC, unitIdA, null);
assertNotNull(results);
assertEquals(1, results.size());
assertTrue(results.contains(new DataSetCompletenessResult(dataSetA.getName(), 21, 8, 5)));
}
use of org.hisp.dhis.dataset.CompleteDataSetRegistration in project dhis2-core by dhis2.
the class DataSetCompletenessServiceTest method testGetDataSetCompletenessByOrganisationUnitA.
@Test
public void testGetDataSetCompletenessByOrganisationUnitA() {
dataSetA.getSources().add(unitE);
dataSetA.getSources().add(unitF);
dataSetA.getSources().add(unitG);
dataSetA.getSources().add(unitH);
dataSetIdA = dataSetService.addDataSet(dataSetA);
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitE, null, tooLateA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitF, null, tooLateA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodA, unitG, null, tooLateA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitE, null, onTimeA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitF, null, onTimeA, ""));
registrationService.saveCompleteDataSetRegistration(new CompleteDataSetRegistration(dataSetA, periodB, unitG, null, onTimeA, ""));
Collection<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness(periodIdA, unitIdsA, dataSetIdA, null);
assertNotNull(results);
assertEquals(3, results.size());
assertTrue(results.contains(new DataSetCompletenessResult(unitB.getName(), 2, 2, 0)));
assertTrue(results.contains(new DataSetCompletenessResult(unitC.getName(), 2, 1, 0)));
assertTrue(results.contains(new DataSetCompletenessResult(unitA.getName(), 4, 3, 0)));
results = registrationCompletenessService.getDataSetCompleteness(periodIdC, unitIdsA, dataSetIdA, null);
assertNotNull(results);
assertEquals(3, results.size());
assertTrue(results.contains(new DataSetCompletenessResult(unitB.getName(), 6, 4, 2)));
assertTrue(results.contains(new DataSetCompletenessResult(unitC.getName(), 6, 2, 1)));
assertTrue(results.contains(new DataSetCompletenessResult(unitA.getName(), 12, 6, 3)));
}
Aggregations