Search in sources :

Example 31 with NotificationRegistrationKey

use of org.finra.herd.model.api.xml.NotificationRegistrationKey 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)

Example 32 with NotificationRegistrationKey

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

the class NotificationRegistrationDaoTest method testGetNotificationRegistrationAssertReturnNullWhenRegistrationDoesNotExist.

@Test
public void testGetNotificationRegistrationAssertReturnNullWhenRegistrationDoesNotExist() {
    NotificationRegistrationKey businessObjectDataNotificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(businessObjectDataNotificationRegistrationKey, NOTIFICATION_EVENT_TYPE, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS, notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
    NotificationRegistrationEntity notificationRegistration = notificationRegistrationDao.getNotificationRegistration(businessObjectDataNotificationRegistrationKey.getNamespace(), "DOES_NOT_EXIST");
    assertNull(notificationRegistration);
}
Also used : NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) NotificationRegistrationEntity(org.finra.herd.model.jpa.NotificationRegistrationEntity) BusinessObjectDataNotificationRegistrationEntity(org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity) Test(org.junit.Test)

Example 33 with NotificationRegistrationKey

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

the class NotificationRegistrationDaoTestHelper method getExpectedNotificationRegistrationKeys.

/**
 * Returns a list of test business object data notification registration keys expected to be returned by the relative
 * getNotificationRegistrationKeysByNamespace() method.
 *
 * @return the list of expected notification registration keys
 */
public List<NotificationRegistrationKey> getExpectedNotificationRegistrationKeys() {
    List<NotificationRegistrationKey> keys = new ArrayList<>();
    keys.add(new NotificationRegistrationKey(AbstractDaoTest.NAMESPACE, AbstractDaoTest.NOTIFICATION_NAME));
    keys.add(new NotificationRegistrationKey(AbstractDaoTest.NAMESPACE, AbstractDaoTest.NOTIFICATION_NAME_2));
    return keys;
}
Also used : ArrayList(java.util.ArrayList) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey)

Example 34 with NotificationRegistrationKey

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

the class NotificationRegistrationDaoTestHelper method getTestNotificationRegistrationKeys.

/**
 * Returns a list of test notification registration keys.
 *
 * @return the list of test notification registration keys
 */
public List<NotificationRegistrationKey> getTestNotificationRegistrationKeys() {
    List<NotificationRegistrationKey> keys = new ArrayList<>();
    keys.add(new NotificationRegistrationKey(AbstractDaoTest.NAMESPACE, AbstractDaoTest.NOTIFICATION_NAME));
    keys.add(new NotificationRegistrationKey(AbstractDaoTest.NAMESPACE, AbstractDaoTest.NOTIFICATION_NAME_2));
    keys.add(new NotificationRegistrationKey(AbstractDaoTest.NAMESPACE_2, AbstractDaoTest.NOTIFICATION_NAME));
    keys.add(new NotificationRegistrationKey(AbstractDaoTest.NAMESPACE_2, AbstractDaoTest.NOTIFICATION_NAME_2));
    return keys;
}
Also used : ArrayList(java.util.ArrayList) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey)

Example 35 with NotificationRegistrationKey

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

the class BusinessObjectDataNotificationJobActionServiceTest method testGetIdentifyingInformation.

@Test
public void testGetIdentifyingInformation() throws Exception {
    // Create a job definition.
    JobDefinition jobDefinition = jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_LOG_VARIABLES_NO_REGEX_WITH_CLASSPATH);
    // Create a job action.
    List<JobAction> jobActions = new ArrayList<>();
    jobActions.add(new JobAction(jobDefinition.getNamespace(), jobDefinition.getJobName(), CORRELATION_DATA));
    // Create and persist a business object data notification registration entity.
    BusinessObjectDataNotificationRegistrationEntity businessObjectDataNotificationRegistrationEntity = notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, null, null, jobActions, NotificationRegistrationStatusEntity.ENABLED);
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    // Create and initiate an instance of the business object data notification event parameters DTO.
    BusinessObjectDataNotificationEventParamsDto businessObjectDataNotificationEventParams = new BusinessObjectDataNotificationEventParamsDto();
    businessObjectDataNotificationEventParams.setBusinessObjectData(businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity));
    businessObjectDataNotificationEventParams.setBusinessObjectDataNotificationRegistration(businessObjectDataNotificationRegistrationEntity);
    businessObjectDataNotificationEventParams.setEventType(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name());
    businessObjectDataNotificationEventParams.setNotificationJobAction((NotificationJobActionEntity) businessObjectDataNotificationRegistrationEntity.getNotificationActions().toArray()[0]);
    businessObjectDataNotificationEventParams.setStorageName(STORAGE_NAME);
    // Get the notification action service for the business object data registration event.
    NotificationActionService notificationActionService = notificationActionFactory.getNotificationActionHandler(NotificationTypeEntity.NOTIFICATION_TYPE_BDATA, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name());
    // Validate the identifying information for the notification event.
    String expectedValue = String.format("namespace: \"%s\", actionId: \"%s\" with " + businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey) + ", storageName: \"%s\"", businessObjectDataNotificationRegistrationEntity.getNamespace().getCode(), ((NotificationJobActionEntity) businessObjectDataNotificationRegistrationEntity.getNotificationActions().toArray()[0]).getId(), STORAGE_NAME);
    assertEquals(expectedValue, notificationActionService.getIdentifyingInformation(businessObjectDataNotificationEventParams, businessObjectDataHelper));
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) ArrayList(java.util.ArrayList) BusinessObjectDataNotificationEventParamsDto(org.finra.herd.model.dto.BusinessObjectDataNotificationEventParamsDto) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataNotificationRegistrationEntity(org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) JobDefinition(org.finra.herd.model.api.xml.JobDefinition) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Aggregations

NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)141 Test (org.junit.Test)129 JobAction (org.finra.herd.model.api.xml.JobAction)49 BusinessObjectDataNotificationFilter (org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter)46 StorageUnitNotificationFilter (org.finra.herd.model.api.xml.StorageUnitNotificationFilter)44 BusinessObjectDataNotificationRegistration (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistration)27 StorageUnitNotificationRegistration (org.finra.herd.model.api.xml.StorageUnitNotificationRegistration)26 BusinessObjectDataNotificationRegistrationEntity (org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity)17 ArrayList (java.util.ArrayList)16 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)15 BusinessObjectDataNotificationRegistrationCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationCreateRequest)14 StorageUnitNotificationRegistrationEntity (org.finra.herd.model.jpa.StorageUnitNotificationRegistrationEntity)14 BusinessObjectDataNotificationRegistrationKeys (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationKeys)13 StorageUnitNotificationRegistrationKeys (org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationKeys)13 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)11 BusinessObjectDataNotificationRegistrationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationUpdateRequest)11 StorageUnitNotificationRegistrationCreateRequest (org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest)11 StorageUnitNotificationRegistrationUpdateRequest (org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationUpdateRequest)11 StorageEntity (org.finra.herd.model.jpa.StorageEntity)10 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)9