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);
}
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);
}
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;
}
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;
}
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));
}
Aggregations