Search in sources :

Example 11 with JobCreateRequest

use of org.finra.herd.model.api.xml.JobCreateRequest in project herd by FINRAOS.

the class StorageUnitStatusChangeNotificationJobActionServiceImpl method performNotificationAction.

@Override
public Object performNotificationAction(NotificationEventParamsDto notificationEventParams) throws Exception {
    if (notificationEventParams instanceof StorageUnitNotificationEventParamsDto) {
        StorageUnitNotificationEventParamsDto storageUnitNotificationEventParams = (StorageUnitNotificationEventParamsDto) notificationEventParams;
        JobCreateRequest request = new JobCreateRequest();
        JobDefinitionEntity jobDefinitionEntity = storageUnitNotificationEventParams.getNotificationJobAction().getJobDefinition();
        request.setNamespace(jobDefinitionEntity.getNamespace().getCode());
        request.setJobName(jobDefinitionEntity.getName());
        request.setParameters(buildJobParameters(storageUnitNotificationEventParams));
        /*
             * Log enough information so we can trace back what notification registration triggered what workflow.
             * This also allows us to reproduce the workflow execution if needed by logging the entire jobCreateRequest in JSON format.
             */
        if (LOGGER.isInfoEnabled()) {
            StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistration = storageUnitNotificationEventParams.getStorageUnitNotificationRegistration();
            LOGGER.info("Starting a job due to a notification. notificationRegistrationKey={} jobCreateRequest={}", jsonHelper.objectToJson(notificationRegistrationHelper.getNotificationRegistrationKey(storageUnitNotificationRegistration)), jsonHelper.objectToJson(request));
        }
        return jobService.createAndStartJob(request);
    } else {
        throw new IllegalStateException("Notification event parameters DTO passed to the method must be an instance of StorageUnitNotificationEventParamsDto.");
    }
}
Also used : JobDefinitionEntity(org.finra.herd.model.jpa.JobDefinitionEntity) StorageUnitNotificationEventParamsDto(org.finra.herd.model.dto.StorageUnitNotificationEventParamsDto) StorageUnitNotificationRegistrationEntity(org.finra.herd.model.jpa.StorageUnitNotificationRegistrationEntity) JobCreateRequest(org.finra.herd.model.api.xml.JobCreateRequest)

Aggregations

JobCreateRequest (org.finra.herd.model.api.xml.JobCreateRequest)11 Test (org.junit.Test)7 Parameter (org.finra.herd.model.api.xml.Parameter)6 Job (org.finra.herd.model.api.xml.Job)5 JobDefinitionCreateRequest (org.finra.herd.model.api.xml.JobDefinitionCreateRequest)4 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)3 ArrayList (java.util.ArrayList)2 JdbcExecutionRequest (org.finra.herd.model.api.xml.JdbcExecutionRequest)1 JdbcExecutionResponse (org.finra.herd.model.api.xml.JdbcExecutionResponse)1 JdbcStatement (org.finra.herd.model.api.xml.JdbcStatement)1 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)1 BusinessObjectDataNotificationEventParamsDto (org.finra.herd.model.dto.BusinessObjectDataNotificationEventParamsDto)1 StorageUnitNotificationEventParamsDto (org.finra.herd.model.dto.StorageUnitNotificationEventParamsDto)1 BusinessObjectDataNotificationRegistrationEntity (org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity)1 StorageUnitNotificationRegistrationEntity (org.finra.herd.model.jpa.StorageUnitNotificationRegistrationEntity)1 Transactional (org.springframework.transaction.annotation.Transactional)1