use of org.hisp.dhis.scheduling.parameters.PushAnalysisJobParameters in project dhis2-core by dhis2.
the class PushAnalysisJob method execute.
@Override
public void execute(JobConfiguration jobConfiguration, JobProgress progress) {
PushAnalysisJobParameters parameters = (PushAnalysisJobParameters) jobConfiguration.getJobParameters();
pushAnalysisService.runPushAnalysis(parameters.getPushAnalysis(), jobConfiguration);
}
use of org.hisp.dhis.scheduling.parameters.PushAnalysisJobParameters in project dhis2-core by dhis2.
the class V2_34_7__Convert_push_analysis_job_parameters_into_list_of_string method migrate.
@Override
public void migrate(Context context) throws Exception {
String pushAnalysisUid = null;
try (Statement statement = context.getConnection().createStatement()) {
ResultSet resultSet = statement.executeQuery("select jsonbjobparameters->1->'pushAnalysis' from public.jobconfiguration where jobtype = '" + JobType.PUSH_ANALYSIS.name() + "';");
if (resultSet.next()) {
pushAnalysisUid = resultSet.getString(1);
pushAnalysisUid = StringUtils.strip(pushAnalysisUid, "\"");
}
}
if (pushAnalysisUid != null) {
ObjectMapper mapper = new ObjectMapper();
mapper.activateDefaultTyping(BasicPolymorphicTypeValidator.builder().allowIfBaseType(JobParameters.class).build());
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JavaType resultingJavaType = mapper.getTypeFactory().constructType(JobParameters.class);
ObjectWriter writer = mapper.writerFor(resultingJavaType);
try (PreparedStatement ps = context.getConnection().prepareStatement("UPDATE jobconfiguration SET jsonbjobparameters = ? where jobtype = ?;")) {
PushAnalysisJobParameters jobParameters = new PushAnalysisJobParameters(pushAnalysisUid);
PGobject pg = new PGobject();
pg.setType("jsonb");
pg.setValue(writer.writeValueAsString(jobParameters));
ps.setObject(1, pg);
ps.setString(2, JobType.PUSH_ANALYSIS.name());
ps.execute();
log.info("JobType " + JobType.PUSH_ANALYSIS.name() + " has been updated.");
}
}
}
use of org.hisp.dhis.scheduling.parameters.PushAnalysisJobParameters in project dhis2-core by dhis2.
the class PushAnalysisController method sendPushAnalysis.
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/{uid}/run")
public void sendPushAnalysis(@PathVariable() String uid) throws WebMessageException, IOException {
PushAnalysis pushAnalysis = pushAnalysisService.getByUid(uid);
if (pushAnalysis == null) {
throw new WebMessageException(notFound("Push analysis with uid " + uid + " was not found"));
}
JobConfiguration pushAnalysisJobConfiguration = new JobConfiguration("pushAnalysisJob from controller", JobType.PUSH_ANALYSIS, "", new PushAnalysisJobParameters(uid), true, true);
schedulingManager.executeNow(pushAnalysisJobConfiguration);
}
Aggregations