use of org.hisp.dhis.scheduling.parameters.DataSynchronizationJobParameters in project dhis2-core by dhis2.
the class DataSynchronizationJob method execute.
@Override
public void execute(JobConfiguration jobConfiguration, JobProgress progress) {
DataSynchronizationJobParameters jobParameters = (DataSynchronizationJobParameters) jobConfiguration.getJobParameters();
dataValueSynchronization.synchronizeData(jobParameters.getPageSize());
notifier.notify(jobConfiguration, "Data value sync successful");
completenessSynchronization.synchronizeData();
notifier.notify(jobConfiguration, "Complete data set registration sync successful");
notifier.notify(jobConfiguration, "Data value and Complete data set registration sync successful");
}
use of org.hisp.dhis.scheduling.parameters.DataSynchronizationJobParameters in project dhis2-core by dhis2.
the class JobConfigurationObjectBundleHookTest method validateInternalNonConfigurableShownValidationErrorE7010Configurable.
@Test
void validateInternalNonConfigurableShownValidationErrorE7010Configurable() {
Mockito.when(jobConfigurationService.getJobConfigurationByUid(Mockito.eq("jsdhJSJHD"))).thenReturn(analyticsTableJobConfig);
Mockito.when(jobService.getJob(Mockito.eq(JobType.DATA_SYNC))).thenReturn(job);
Mockito.when(job.validate()).thenReturn(new ErrorReport(Class.class, ErrorCode.E7010));
analyticsTableJobConfig.setJobType(JobType.DATA_SYNC);
JobConfiguration jobConfiguration = new JobConfiguration();
jobConfiguration.setUid("jsdhJSJHD");
jobConfiguration.setJobType(JobType.DATA_SYNC);
jobConfiguration.setCronExpression(CRON_HOURLY);
jobConfiguration.setEnabled(true);
DataSynchronizationJobParameters jobParameters = new DataSynchronizationJobParameters();
jobParameters.setPageSize(200);
jobConfiguration.setJobParameters(jobParameters);
List<ErrorReport> errorReports = hook.validate(jobConfiguration, null);
Assertions.assertEquals(1, errorReports.size());
Assertions.assertEquals(ErrorCode.E7010, errorReports.get(0).getErrorCode());
}
use of org.hisp.dhis.scheduling.parameters.DataSynchronizationJobParameters in project dhis2-core by dhis2.
the class V2_35_2__Update_data_sync_job_parameters_with_system_setting_value method updateJobParamaters.
private void updateJobParamaters(final Context context, int dataValuesPageSize) throws JsonProcessingException, SQLException {
if (dataValuesPageSize > 0) {
Map<Integer, JobParameters> updatedJobParameters = new HashMap<>();
String sql = "SELECT jobconfigurationid, jsonbjobparameters FROM jobconfiguration " + "WHERE jobtype = '" + JobType.DATA_SYNC.name() + "';";
try (Statement stmt = context.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) {
DataSynchronizationJobParameters jobparams = reader.readValue(rs.getString("jsonbjobparameters"));
jobparams.setPageSize(dataValuesPageSize);
updatedJobParameters.put(rs.getInt("jobconfigurationid"), jobparams);
}
}
for (Map.Entry<Integer, JobParameters> jobParams : updatedJobParameters.entrySet()) {
try (PreparedStatement ps = context.getConnection().prepareStatement("UPDATE jobconfiguration SET jsonbjobparameters = ? where jobconfigurationid = ?;")) {
PGobject pg = new PGobject();
pg.setType("jsonb");
pg.setValue(writer.writeValueAsString(jobParams.getValue()));
ps.setObject(1, pg);
ps.setInt(2, jobParams.getKey());
ps.execute();
}
}
}
}
Aggregations