Commit 6339338a authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Enriko Käsper

See merge request teis/scheduler-service!18
parents 31517e1d 15df01b6
Subproject commit ea6a5ec3ed936121c971ce84c1cc87ade857c3e1
Subproject commit 4cc0c5b4d4bdbda2ae6a33ba337e3be218799eeb
theGroup=ee.sm.ti.teis
theVersion=1.6.0
commonsVersion=1.5.1
commonApiGatewayVersion=1.5.1
adminApiGatewayVersion=1.3.0
pluginVersion=1.0.1
theVersion=1.7.0
commonsVersion=1.8.0
commonApiGatewayVersion=1.8.0
adminApiGatewayVersion=1.4.0
pluginVersion=1.1.1
mapstructVersion=1.3.0.Final
package ee.sm.ti.teis.scheduler.admin;
import ee.sm.ti.teis.admingateway.systemjobs.JobDefinitionDto;
import ee.sm.ti.teis.admingateway.systemjobs.JobExecutionDto;
import ee.sm.ti.teis.exceptions.TeisBusinessException;
import ee.sm.ti.teis.exceptions.TeisResourceNotFoundException;
import ee.sm.ti.teis.scheduler.job.definition.JobDefinitionEntity;
import ee.sm.ti.teis.scheduler.job.definition.JobDefinitionMapper;
import ee.sm.ti.teis.scheduler.job.definition.JobDefinitionRepository;
import ee.sm.ti.teis.scheduler.job.execution.JobExecutionEntity;
import ee.sm.ti.teis.scheduler.job.execution.JobExecutionMapper;
......@@ -20,6 +23,7 @@ public class AdminBusinessService {
private final JobExecutionMapper jobExecutionMapper;
private final JobExecutionRepository jobExecutionRepository;
private final JobDefinitionRepository jobDefinitionRepository;
private final JobDefinitionMapper jobDefinitionMapper;
public void startSystemJob(String jobId) {
if (jobLauncherService.isAnyProcessRunning(jobId)) {
......@@ -35,4 +39,10 @@ public class AdminBusinessService {
List<JobExecutionEntity> jobExecutionEntities = jobExecutionRepository.findAllByJobDefinitionIdOrderByCreatedAtAsc(jobId);
return jobExecutionMapper.toGwDtoList(jobExecutionEntities);
}
}
public List<JobDefinitionDto> getSystemJobs() {
List<JobDefinitionEntity> definitions = jobDefinitionRepository.findAll();
return jobDefinitionMapper.toGwDtoList(definitions);
}
}
......@@ -33,4 +33,13 @@ public class AdminJobListener {
return response;
}
@RabbitListener(queues = {QueueConfig.GW_GET_JOB_DEFINITIONS_JOB})
@PreAuthorize("@accessController.hasOfficialPrivilege({'TI_VIEW_SYSTEM_JOBS'})")
public GetSystemJobDefinitionsResponse getSystemJobDefinitions(GetSystemJobDefinitionsRequest request) {
List<JobDefinitionDto> systemJobExecutions = adminBusinessService.getSystemJobs();
GetSystemJobDefinitionsResponse response = new GetSystemJobDefinitionsResponse();
response.setPayload(systemJobExecutions, request.getRequestMetaDTO());
return response;
}
}
package ee.sm.ti.teis.scheduler.config;
import ee.sm.ti.teis.admingateway.systemjobs.GetSystemJobDefinitionsRequest;
import ee.sm.ti.teis.admingateway.systemjobs.GetSystemJobsRequest;
import ee.sm.ti.teis.admingateway.systemjobs.StartSystemJobRequest;
import ee.sm.ti.teis.configuration.QueueList;
......@@ -21,6 +22,7 @@ public class QueueConfig implements QueueList {
public static final String GW_START_ADMIN_JOB = "scheduler-service.gw.startSystemJobRequest";
public static final String GW_GET_JOB_EXECUTIONS_JOB = "scheduler-service.gw.getSystemJobExecutionsRequest";
public static final String GW_GET_JOB_DEFINITIONS_JOB = "scheduler-service.gw.getSystemJobDefinitionsRequest";
private static final int JOBS_EVENT_QUEUE_TTL = 30000;
......@@ -33,6 +35,7 @@ public class QueueConfig implements QueueList {
addGwQueue(queues, "gwStartSystemJobQueue", new StartSystemJobRequest().routingKey(), GW_START_ADMIN_JOB);
addGwQueue(queues, "gwGetSystemJobExecutionsQueue", new GetSystemJobsRequest().routingKey(), GW_GET_JOB_EXECUTIONS_JOB);
addGwQueue(queues, "gwGetSystemJobDefinitionsQueue", new GetSystemJobDefinitionsRequest().routingKey(), GW_GET_JOB_DEFINITIONS_JOB);
addGwQueue(queues, "gwResetTestData", TestDataImportService.RESET_TEST_DATA_ROUTING_KEY, queueName);
}
}
package ee.sm.ti.teis.scheduler.job.definition;
import ee.sm.ti.teis.admingateway.systemjobs.JobDefinitionDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface JobDefinitionMapper {
JobDefinitionDto toGwDto(JobDefinitionEntity jobDefinition);
List<JobDefinitionDto> toGwDtoList(List<JobDefinitionEntity> jobDefinitionList);
}
......@@ -6,4 +6,5 @@ import java.util.List;
public interface JobDefinitionRepository extends CrudRepository<JobDefinitionEntity, String> {
List<JobDefinitionEntity> findAllByDisabled(Boolean disabled);
List<JobDefinitionEntity> findAll();
}
--liquibase formatted sql
--changeset jyrgen:2020-07-15.TEIS-1438.update-file-checksum
INSERT INTO job_definition (id, name, schedule_type, schedule_cron, schedule_interval, status, created_at)
VALUES
('files.calculateChecksums', 'Failidele, millel puudub räsi arvutus, taasarvutus', 'CRON', '0 0 2 ? * 1', -1, 'IDLE', NOW());
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment