Search in sources :

Example 11 with JobAction

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

the class BusinessObjectDataNotificationRegistrationServiceTest method testUpdateBusinessObjectDataNotificationRegistrationInvalidParameters.

@Test
public void testUpdateBusinessObjectDataNotificationRegistrationInvalidParameters() {
    NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
    BusinessObjectDataNotificationRegistrationUpdateRequest request;
    // Create and persist the relative database entities.
    notificationRegistrationServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataNotificationRegistrationTesting(NAMESPACE, Arrays.asList(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), NOTIFICATION_EVENT_TYPE), BDEF_NAMESPACE_2, BDEF_NAME_2, Arrays.asList(FORMAT_FILE_TYPE_CODE, FORMAT_FILE_TYPE_CODE_2), Arrays.asList(STORAGE_NAME, STORAGE_NAME_2), Arrays.asList(BDATA_STATUS, BDATA_STATUS_2, BDATA_STATUS_3, BDATA_STATUS_4), notificationRegistrationDaoTestHelper.getTestJobActions2());
    // Create and persist a business object data notification registration entity.
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2, notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    // Try to update a business object data notification using non-existing notification event type.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest("I_DO_NOT_EXIST", new BusinessObjectDataNotificationFilter(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an ObjectNotFoundException when using non-existing notification event type.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Notification event type with code \"%s\" doesn't exist.", request.getBusinessObjectDataEventType()), e.getMessage());
    }
    // Try to update a business object data notification using non-supported notification event type.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NOTIFICATION_EVENT_TYPE, new BusinessObjectDataNotificationFilter(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an IllegalArgumentException when using non-supported notification event type.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Notification event type \"%s\" is not supported for business object data notification registration.", request.getBusinessObjectDataEventType()), e.getMessage());
    }
    // Try to update a business object data notification using non-existing business object definition name.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an ObjectNotFoundException when using non-existing business object definition name.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Business object definition with name \"%s\" doesn't exist for namespace \"%s\".", request.getBusinessObjectDataNotificationFilter().getBusinessObjectDefinitionName(), request.getBusinessObjectDataNotificationFilter().getNamespace()), e.getMessage());
    }
    // Try to update a business object data notification using non-existing business object format file type.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an ObjectNotFoundException when using non-existing business object format file type.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("File type with code \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationFilter().getBusinessObjectFormatFileType()), e.getMessage());
    }
    // Try to update a business object data notification using non-existing storage name.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an ObjectNotFoundException when using non-existing storage name.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Storage with name \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationFilter().getStorageName()), e.getMessage());
    }
    // Try to update a business object data notification using non-existing new business object data status.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, "I_DO_NOT_EXIST", BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an ObjectNotFoundException when using non-existing new business object data status.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Business object data status \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationFilter().getNewBusinessObjectDataStatus()), e.getMessage());
    }
    // Try to update a business object data notification using non-existing old business object data status.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, "I_DO_NOT_EXIST"), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an ObjectNotFoundException when using non-existing old business object data status.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Business object data status \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationFilter().getOldBusinessObjectDataStatus()), e.getMessage());
    }
    // Try to create a business object data notification when using new and old business object data statuses that are the same (case-insensitive).
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS.toUpperCase(), BDATA_STATUS.toLowerCase()), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an IllegalArgumentException when using new and old business object data statuses that are the same");
    } catch (IllegalArgumentException e) {
        assertEquals("The new business object data status is the same as the old one.", e.getMessage());
    }
    // Try to create a business object data notification for business object data
    // registration notification event type with an old business object data status specified.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an IllegalArgumentException when old business object data status is specified " + "for a business object data registration notification event type.");
    } catch (IllegalArgumentException e) {
        assertEquals("The old business object data status cannot be specified with a business object data registration event type.", e.getMessage());
    }
    // Try to update a business object data notification registration using non-existing job definition.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), Arrays.asList(new JobAction(NAMESPACE, "I_DO_NOT_EXIST", CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED);
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an ObjectNotFoundException when using non-existing job definition.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Job definition with namespace \"%s\" and job name \"%s\" doesn't exist.", request.getJobActions().get(0).getNamespace(), request.getJobActions().get(0).getJobName()), e.getMessage());
    }
    // Try to update a business object data notification using non-existing notification registration status.
    request = new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), "I_DO_NOT_EXIST");
    try {
        businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, request);
        fail("Should throw an ObjectNotFoundException when using non-existing notification registration status.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("The notification registration status \"%s\" doesn't exist.", request.getNotificationRegistrationStatus()), e.getMessage());
    }
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDataNotificationFilter(org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataNotificationRegistrationUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationUpdateRequest) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 12 with JobAction

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

the class BusinessObjectDataNotificationRegistrationServiceTest method testCreateBusinessObjectDataNotificationRegistrationUpperCaseParameters.

@Test
public void testCreateBusinessObjectDataNotificationRegistrationUpperCaseParameters() {
    // Create and persist the relative database entities using lower case values.
    notificationRegistrationServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataNotificationRegistrationTesting(NAMESPACE.toLowerCase(), Arrays.asList(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name()), BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), Arrays.asList(FORMAT_FILE_TYPE_CODE.toLowerCase()), Arrays.asList(STORAGE_NAME.toLowerCase()), Arrays.asList(BDATA_STATUS.toLowerCase(), BDATA_STATUS_2.toLowerCase()), Arrays.asList(new JobAction(NAMESPACE.toLowerCase(), JOB_NAME.toLowerCase(), BLANK_TEXT)));
    // Create a business object data notification using upper case input parameters.
    BusinessObjectDataNotificationRegistration resultBusinessObjectDataNotificationRegistration = businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(new BusinessObjectDataNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE.toUpperCase(), NOTIFICATION_NAME.toUpperCase()), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name().toUpperCase(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, STORAGE_NAME.toUpperCase(), BDATA_STATUS.toUpperCase(), BDATA_STATUS_2.toUpperCase()), Arrays.asList(new JobAction(NAMESPACE.toUpperCase(), JOB_NAME.toUpperCase(), CORRELATION_DATA.toUpperCase())), NotificationRegistrationStatusEntity.ENABLED.toUpperCase()));
    // Validate the returned object.
    assertEquals(new BusinessObjectDataNotificationRegistration(resultBusinessObjectDataNotificationRegistration.getId(), new NotificationRegistrationKey(NAMESPACE.toLowerCase(), NOTIFICATION_NAME.toUpperCase()), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, STORAGE_NAME.toLowerCase(), BDATA_STATUS.toLowerCase(), BDATA_STATUS_2.toLowerCase()), Arrays.asList(new JobAction(NAMESPACE.toLowerCase(), JOB_NAME.toLowerCase(), CORRELATION_DATA.toUpperCase())), NotificationRegistrationStatusEntity.ENABLED), resultBusinessObjectDataNotificationRegistration);
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDataNotificationRegistrationCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationCreateRequest) BusinessObjectDataNotificationFilter(org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter) BusinessObjectDataNotificationRegistration(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistration) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 13 with JobAction

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

the class BusinessObjectDataNotificationRegistrationServiceTest method testUpdateBusinessObjectDataNotificationRegistrationLowerCaseParameters.

@Test
public void testUpdateBusinessObjectDataNotificationRegistrationLowerCaseParameters() {
    // Create database entities required for testing using upper case alternate key values.
    notificationRegistrationServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataNotificationRegistrationTesting(NAMESPACE.toUpperCase(), Arrays.asList(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name().toUpperCase(), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name().toUpperCase()), BDEF_NAMESPACE_2.toUpperCase(), BDEF_NAME_2.toUpperCase(), Arrays.asList(FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE_2.toUpperCase()), Arrays.asList(STORAGE_NAME.toUpperCase(), STORAGE_NAME_2.toUpperCase()), Arrays.asList(BDATA_STATUS.toUpperCase(), BDATA_STATUS_2.toUpperCase(), BDATA_STATUS_3.toUpperCase(), BDATA_STATUS_4.toUpperCase()), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toUpperCase(), JOB_NAME_2.toUpperCase(), null)));
    // Create and persist a business object data notification registration entity using upper case alternate key values.
    NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE.toUpperCase(), NOTIFICATION_NAME.toUpperCase());
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name().toUpperCase(), BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, STORAGE_NAME.toUpperCase(), BDATA_STATUS.toUpperCase(), BDATA_STATUS_2.toUpperCase(), Arrays.asList(new JobAction(JOB_NAMESPACE.toUpperCase(), JOB_NAME.toUpperCase(), CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED);
    // Update the business object data notification using lower case input parameters.
    BusinessObjectDataNotificationRegistration resultBusinessObjectDataNotificationRegistration = businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(new NotificationRegistrationKey(NAMESPACE.toLowerCase(), NOTIFICATION_NAME.toLowerCase()), new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name().toLowerCase(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE_2.toLowerCase(), BDEF_NAME_2.toLowerCase(), FORMAT_USAGE_CODE_2.toLowerCase(), FORMAT_FILE_TYPE_CODE_2.toLowerCase(), FORMAT_VERSION_2, STORAGE_NAME_2.toLowerCase(), BDATA_STATUS_3.toLowerCase(), NO_BDATA_STATUS), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toLowerCase(), JOB_NAME_2.toLowerCase(), CORRELATION_DATA_2.toLowerCase())), "enabled"));
    // Validate the returned object.
    assertEquals(new BusinessObjectDataNotificationRegistration(resultBusinessObjectDataNotificationRegistration.getId(), notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name().toUpperCase(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE_2.toUpperCase(), BDEF_NAME_2.toUpperCase(), FORMAT_USAGE_CODE_2.toLowerCase(), FORMAT_FILE_TYPE_CODE_2.toUpperCase(), FORMAT_VERSION_2, STORAGE_NAME_2.toUpperCase(), BDATA_STATUS_3.toUpperCase(), NO_BDATA_STATUS), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toUpperCase(), JOB_NAME_2.toUpperCase(), CORRELATION_DATA_2.toLowerCase())), NotificationRegistrationStatusEntity.ENABLED), resultBusinessObjectDataNotificationRegistration);
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDataNotificationFilter(org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter) BusinessObjectDataNotificationRegistration(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistration) BusinessObjectDataNotificationRegistrationUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationUpdateRequest) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 14 with JobAction

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

the class BusinessObjectDataNotificationRegistrationServiceImpl method createBusinessObjectDataNotificationFromEntity.

/**
 * Creates the business object data notification registration from the persisted entity.
 *
 * @param businessObjectDataNotificationRegistrationEntity the business object data notification registration entity
 *
 * @return the business object data notification registration
 */
private BusinessObjectDataNotificationRegistration createBusinessObjectDataNotificationFromEntity(BusinessObjectDataNotificationRegistrationEntity businessObjectDataNotificationRegistrationEntity) {
    // Create the business object data notification.
    BusinessObjectDataNotificationRegistration businessObjectDataNotificationRegistration = new BusinessObjectDataNotificationRegistration();
    businessObjectDataNotificationRegistration.setId(businessObjectDataNotificationRegistrationEntity.getId());
    businessObjectDataNotificationRegistration.setBusinessObjectDataNotificationRegistrationKey(new NotificationRegistrationKey(businessObjectDataNotificationRegistrationEntity.getNamespace().getCode(), businessObjectDataNotificationRegistrationEntity.getName()));
    businessObjectDataNotificationRegistration.setBusinessObjectDataEventType(businessObjectDataNotificationRegistrationEntity.getNotificationEventType().getCode());
    BusinessObjectDataNotificationFilter filter = new BusinessObjectDataNotificationFilter();
    businessObjectDataNotificationRegistration.setBusinessObjectDataNotificationFilter(filter);
    // Business object definition entity cannot be null as per business object data notification registration create request validation.
    filter.setNamespace(businessObjectDataNotificationRegistrationEntity.getBusinessObjectDefinition().getNamespace().getCode());
    filter.setBusinessObjectDefinitionName(businessObjectDataNotificationRegistrationEntity.getBusinessObjectDefinition().getName());
    filter.setBusinessObjectFormatUsage(businessObjectDataNotificationRegistrationEntity.getUsage());
    filter.setBusinessObjectFormatFileType(businessObjectDataNotificationRegistrationEntity.getFileType() != null ? businessObjectDataNotificationRegistrationEntity.getFileType().getCode() : null);
    filter.setBusinessObjectFormatVersion(businessObjectDataNotificationRegistrationEntity.getBusinessObjectFormatVersion());
    filter.setStorageName(businessObjectDataNotificationRegistrationEntity.getStorage() != null ? businessObjectDataNotificationRegistrationEntity.getStorage().getName() : null);
    filter.setNewBusinessObjectDataStatus(businessObjectDataNotificationRegistrationEntity.getNewBusinessObjectDataStatus() != null ? businessObjectDataNotificationRegistrationEntity.getNewBusinessObjectDataStatus().getCode() : null);
    filter.setOldBusinessObjectDataStatus(businessObjectDataNotificationRegistrationEntity.getOldBusinessObjectDataStatus() != null ? businessObjectDataNotificationRegistrationEntity.getOldBusinessObjectDataStatus().getCode() : null);
    List<JobAction> jobActions = new ArrayList<>();
    businessObjectDataNotificationRegistration.setJobActions(jobActions);
    for (NotificationActionEntity notificationActionEntity : businessObjectDataNotificationRegistrationEntity.getNotificationActions()) {
        if (notificationActionEntity instanceof NotificationJobActionEntity) {
            NotificationJobActionEntity notificationJobActionEntity = (NotificationJobActionEntity) notificationActionEntity;
            JobAction jobAction = new JobAction();
            jobActions.add(jobAction);
            jobAction.setNamespace(notificationJobActionEntity.getJobDefinition().getNamespace().getCode());
            jobAction.setJobName(notificationJobActionEntity.getJobDefinition().getName());
            jobAction.setCorrelationData(notificationJobActionEntity.getCorrelationData());
        }
    }
    businessObjectDataNotificationRegistration.setNotificationRegistrationStatus(businessObjectDataNotificationRegistrationEntity.getNotificationRegistrationStatus().getCode());
    return businessObjectDataNotificationRegistration;
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDataNotificationFilter(org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter) ArrayList(java.util.ArrayList) BusinessObjectDataNotificationRegistration(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistration) NotificationJobActionEntity(org.finra.herd.model.jpa.NotificationJobActionEntity) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) NotificationActionEntity(org.finra.herd.model.jpa.NotificationActionEntity)

Example 15 with JobAction

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

the class BusinessObjectDataNotificationRegistrationServiceImpl method updateBusinessObjectDataNotificationRegistration.

@NamespacePermissions({ @NamespacePermission(fields = "#key?.namespace", permissions = NamespacePermissionEnum.WRITE), @NamespacePermission(fields = "#request?.businessObjectDataNotificationFilter?.namespace", permissions = NamespacePermissionEnum.READ), @NamespacePermission(fields = "#request?.jobActions?.![namespace]", permissions = NamespacePermissionEnum.EXECUTE) })
@Override
public BusinessObjectDataNotificationRegistration updateBusinessObjectDataNotificationRegistration(NotificationRegistrationKey key, BusinessObjectDataNotificationRegistrationUpdateRequest request) {
    // Validate and trim the key.
    validateBusinessObjectDataNotificationRegistrationKey(key);
    // Validate and trim the request parameters.
    validateBusinessObjectDataNotificationRegistrationUpdateRequest(request);
    // Retrieve and ensure that a business object data notification exists with the specified key.
    BusinessObjectDataNotificationRegistrationEntity oldBusinessObjectDataNotificationRegistrationEntity = businessObjectDataNotificationRegistrationDaoHelper.getBusinessObjectDataNotificationRegistrationEntity(key);
    String oldBusinessObjectDataNotificationRegistrationName = oldBusinessObjectDataNotificationRegistrationEntity.getName();
    // Retrieve the namespace with the specified namespace code.
    NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(key.getNamespace());
    // Retrieve and validate the notification event type entity.
    NotificationEventTypeEntity notificationEventTypeEntity = getAndValidateNotificationEventTypeEntity(request.getBusinessObjectDataEventType());
    // Get the business object data notification filter.
    BusinessObjectDataNotificationFilter filter = request.getBusinessObjectDataNotificationFilter();
    // Retrieve and ensure that business object definition exists. Since namespace is specified, retrieve a business object definition by it's key.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(filter.getNamespace(), filter.getBusinessObjectDefinitionName()));
    // If specified, retrieve and ensure that file type exists.
    FileTypeEntity fileTypeEntity = null;
    if (StringUtils.isNotBlank(filter.getBusinessObjectFormatFileType())) {
        fileTypeEntity = fileTypeDaoHelper.getFileTypeEntity(filter.getBusinessObjectFormatFileType());
    }
    // If specified, retrieve and ensure that storage exists.
    StorageEntity storageEntity = null;
    if (StringUtils.isNotBlank(filter.getStorageName())) {
        storageEntity = storageDaoHelper.getStorageEntity(filter.getStorageName());
    }
    // If specified, retrieve and ensure that new business object data status exists.
    BusinessObjectDataStatusEntity newBusinessObjectDataStatus = null;
    if (StringUtils.isNotBlank(filter.getNewBusinessObjectDataStatus())) {
        newBusinessObjectDataStatus = businessObjectDataStatusDaoHelper.getBusinessObjectDataStatusEntity(filter.getNewBusinessObjectDataStatus());
    }
    // If specified, retrieve and ensure that old business object data status exists.
    BusinessObjectDataStatusEntity oldBusinessObjectDataStatus = null;
    if (StringUtils.isNotBlank(filter.getOldBusinessObjectDataStatus())) {
        oldBusinessObjectDataStatus = businessObjectDataStatusDaoHelper.getBusinessObjectDataStatusEntity(filter.getOldBusinessObjectDataStatus());
    }
    // TODO: We need to add a null/empty list check here, if/when list of job actions will become optional (due to addition of other action types).
    for (JobAction jobAction : request.getJobActions()) {
        // Ensure that job definition exists.
        jobDefinitionDaoHelper.getJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName());
    }
    // Retrieve and validate the notification registration status entity.
    NotificationRegistrationStatusEntity notificationRegistrationStatusEntity = notificationRegistrationStatusDaoHelper.getNotificationRegistrationStatusEntity(request.getNotificationRegistrationStatus());
    // Delete the business object data notification.
    businessObjectDataNotificationRegistrationDao.delete(oldBusinessObjectDataNotificationRegistrationEntity);
    // Create a business object data notification registration entity from the request information.
    BusinessObjectDataNotificationRegistrationEntity newBusinessObjectDataNotificationRegistrationEntity = createBusinessObjectDataNotificationEntity(namespaceEntity, notificationEventTypeEntity, businessObjectDefinitionEntity, fileTypeEntity, storageEntity, newBusinessObjectDataStatus, oldBusinessObjectDataStatus, new NotificationRegistrationKey(namespaceEntity.getCode(), oldBusinessObjectDataNotificationRegistrationName), request.getBusinessObjectDataNotificationFilter(), request.getJobActions(), notificationRegistrationStatusEntity);
    // Persist the new entity.
    newBusinessObjectDataNotificationRegistrationEntity = businessObjectDataNotificationRegistrationDao.saveAndRefresh(newBusinessObjectDataNotificationRegistrationEntity);
    // Create and return the business object data notification object from the persisted entity.
    return createBusinessObjectDataNotificationFromEntity(newBusinessObjectDataNotificationRegistrationEntity);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) BusinessObjectDataNotificationFilter(org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) BusinessObjectDataStatusEntity(org.finra.herd.model.jpa.BusinessObjectDataStatusEntity) StorageEntity(org.finra.herd.model.jpa.StorageEntity) NotificationEventTypeEntity(org.finra.herd.model.jpa.NotificationEventTypeEntity) JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) NotificationRegistrationStatusEntity(org.finra.herd.model.jpa.NotificationRegistrationStatusEntity) BusinessObjectDataNotificationRegistrationEntity(org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) NamespacePermissions(org.finra.herd.model.annotation.NamespacePermissions)

Aggregations

JobAction (org.finra.herd.model.api.xml.JobAction)59 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)49 Test (org.junit.Test)41 BusinessObjectDataNotificationFilter (org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter)23 StorageUnitNotificationFilter (org.finra.herd.model.api.xml.StorageUnitNotificationFilter)17 ArrayList (java.util.ArrayList)15 BusinessObjectDataNotificationRegistration (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistration)15 StorageEntity (org.finra.herd.model.jpa.StorageEntity)12 BusinessObjectDataNotificationRegistrationCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationCreateRequest)11 StorageUnitNotificationRegistration (org.finra.herd.model.api.xml.StorageUnitNotificationRegistration)11 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)9 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)9 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)8 StorageUnitNotificationRegistrationCreateRequest (org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest)8 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)8 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)8 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)8 NotificationEventTypeEntity (org.finra.herd.model.jpa.NotificationEventTypeEntity)8 BusinessObjectDataNotificationRegistrationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationUpdateRequest)7 Job (org.finra.herd.model.api.xml.Job)6