use of org.finra.herd.model.jpa.NotificationActionEntity in project herd by FINRAOS.
the class NotificationEventServiceImpl method processStorageUnitNotifications.
private List<Object> processStorageUnitNotifications(String notificationEventType, List<StorageUnitNotificationRegistrationEntity> storageUnitNotificationRegistrationEntities, BusinessObjectData businessObjectData, String storageName, String newStorageUnitStatus, String oldStorageUnitStatus) {
List<Object> notificationActions = new ArrayList<>();
// Build a list of partition value that includes primary and sub-partition values, if any are specified in the business object data key.
List<String> partitionValues = businessObjectDataHelper.getPrimaryAndSubPartitionValues(businessObjectData);
// Get a list of partition columns from the associated business object format.
List<String> partitionColumnNames = null;
BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(businessObjectData.getNamespace(), businessObjectData.getBusinessObjectDefinitionName(), businessObjectData.getBusinessObjectFormatUsage(), businessObjectData.getBusinessObjectFormatFileType(), businessObjectData.getBusinessObjectFormatVersion()));
if (businessObjectFormatEntity != null) {
// Get business object format model object to directly access schema columns and partitions.
BusinessObjectFormat businessObjectFormat = businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity);
// Proceed only if this format has schema with partition columns specified.
if (businessObjectFormat.getSchema() != null && !CollectionUtils.isEmpty(businessObjectFormat.getSchema().getPartitions())) {
// Do not provide more partition column names than there are primary and
// sub-partition values that this business object data is registered with.
partitionColumnNames = new ArrayList<>();
List<SchemaColumn> partitionColumns = businessObjectFormat.getSchema().getPartitions();
for (int i = 0; i < Math.min(partitionValues.size(), partitionColumns.size()); i++) {
partitionColumnNames.add(partitionColumns.get(i).getName());
}
}
}
for (StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistration : storageUnitNotificationRegistrationEntities) {
// Retrieve the job notification actions needed to be triggered.
for (NotificationActionEntity notificationActionEntity : storageUnitNotificationRegistration.getNotificationActions()) {
// Trigger the job action.
if (notificationActionEntity instanceof NotificationJobActionEntity) {
NotificationJobActionEntity notificationJobActionEntity = (NotificationJobActionEntity) notificationActionEntity;
StorageUnitNotificationEventParamsDto notificationEventParams = new StorageUnitNotificationEventParamsDto();
notificationEventParams.setStorageUnitNotificationRegistration(storageUnitNotificationRegistration);
notificationEventParams.setNotificationJobAction(notificationJobActionEntity);
notificationEventParams.setEventType(notificationEventType);
notificationEventParams.setBusinessObjectData(businessObjectData);
notificationEventParams.setPartitionColumnNames(partitionColumnNames);
notificationEventParams.setStorageName(storageName);
notificationEventParams.setPartitionValues(partitionValues);
notificationEventParams.setNewStorageUnitStatus(newStorageUnitStatus);
notificationEventParams.setOldStorageUnitStatus(oldStorageUnitStatus);
notificationActions.add(triggerNotificationAction(NotificationTypeEntity.NOTIFICATION_TYPE_STORAGE_UNIT, notificationEventType, notificationEventParams));
}
}
}
return notificationActions;
}
use of org.finra.herd.model.jpa.NotificationActionEntity in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceImpl method createStorageUnitNotificationEntity.
/**
* Creates a new storage unit notification registration entity from the request information.
*
* @param namespaceEntity the namespace entity
* @param notificationEventTypeEntity the notification event type entity
* @param businessObjectDefinitionEntity the business object definition entity
* @param fileTypeEntity the file type entity
* @param storageEntity the storage entity
* @param newStorageUnitStatusEntity the new storage unit status entity
* @param oldStorageUnitStatusEntity the old storage unit status entity
* @param key the storage unit notification registration key
* @param storageUnitNotificationFilter the storage unit notification filter
* @param jobActions the list of notification job actions
* @param notificationRegistrationStatusEntity the notification registration status entity
*
* @return the newly created storage unit notification registration entity
*/
private StorageUnitNotificationRegistrationEntity createStorageUnitNotificationEntity(NamespaceEntity namespaceEntity, NotificationEventTypeEntity notificationEventTypeEntity, BusinessObjectDefinitionEntity businessObjectDefinitionEntity, FileTypeEntity fileTypeEntity, StorageEntity storageEntity, StorageUnitStatusEntity newStorageUnitStatusEntity, StorageUnitStatusEntity oldStorageUnitStatusEntity, NotificationRegistrationKey key, StorageUnitNotificationFilter storageUnitNotificationFilter, List<JobAction> jobActions, NotificationRegistrationStatusEntity notificationRegistrationStatusEntity) {
// Create a new entity.
StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistrationEntity = new StorageUnitNotificationRegistrationEntity();
storageUnitNotificationRegistrationEntity.setNamespace(namespaceEntity);
storageUnitNotificationRegistrationEntity.setName(key.getNotificationName());
storageUnitNotificationRegistrationEntity.setNotificationEventType(notificationEventTypeEntity);
storageUnitNotificationRegistrationEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
if (StringUtils.isNotBlank(storageUnitNotificationFilter.getBusinessObjectFormatUsage())) {
storageUnitNotificationRegistrationEntity.setUsage(storageUnitNotificationFilter.getBusinessObjectFormatUsage());
}
storageUnitNotificationRegistrationEntity.setFileType(fileTypeEntity);
storageUnitNotificationRegistrationEntity.setBusinessObjectFormatVersion(storageUnitNotificationFilter.getBusinessObjectFormatVersion());
storageUnitNotificationRegistrationEntity.setStorage(storageEntity);
storageUnitNotificationRegistrationEntity.setNewStorageUnitStatus(newStorageUnitStatusEntity);
storageUnitNotificationRegistrationEntity.setOldStorageUnitStatus(oldStorageUnitStatusEntity);
storageUnitNotificationRegistrationEntity.setNotificationRegistrationStatus(notificationRegistrationStatusEntity);
// Create the relative entities for job actions.
// 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).
List<NotificationActionEntity> notificationActionEntities = new ArrayList<>();
storageUnitNotificationRegistrationEntity.setNotificationActions(notificationActionEntities);
for (JobAction jobAction : jobActions) {
// Retrieve and ensure that job definition exists.
JobDefinitionEntity jobDefinitionEntity = jobDefinitionDaoHelper.getJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName());
// Create a new entity.
NotificationJobActionEntity notificationJobActionEntity = new NotificationJobActionEntity();
notificationActionEntities.add(notificationJobActionEntity);
notificationJobActionEntity.setJobDefinition(jobDefinitionEntity);
notificationJobActionEntity.setCorrelationData(jobAction.getCorrelationData());
notificationJobActionEntity.setNotificationRegistration(storageUnitNotificationRegistrationEntity);
}
return storageUnitNotificationRegistrationEntity;
}
use of org.finra.herd.model.jpa.NotificationActionEntity in project herd by FINRAOS.
the class BusinessObjectDataNotificationRegistrationServiceImpl method createBusinessObjectDataNotificationEntity.
/**
* Creates a new business object data notification registration entity from the request information.
*
* @param namespaceEntity the namespace entity
* @param notificationEventTypeEntity the notification event type entity
* @param businessObjectDefinitionEntity the business object definition entity
* @param fileTypeEntity the file type entity
* @param storageEntity the storage entity
* @param newBusinessObjectDataStatusEntity the new business object data status entity
* @param oldBusinessObjectDataStatusEntity the old business object data status entity
* @param key the business object data notification registration key
* @param businessObjectDataNotificationFilter the business object data notification filter
* @param jobActions the list of notification job actions
* @param notificationRegistrationStatusEntity the notification registration status entity
*
* @return the newly created business object data notification registration entity
*/
private BusinessObjectDataNotificationRegistrationEntity createBusinessObjectDataNotificationEntity(NamespaceEntity namespaceEntity, NotificationEventTypeEntity notificationEventTypeEntity, BusinessObjectDefinitionEntity businessObjectDefinitionEntity, FileTypeEntity fileTypeEntity, StorageEntity storageEntity, BusinessObjectDataStatusEntity newBusinessObjectDataStatusEntity, BusinessObjectDataStatusEntity oldBusinessObjectDataStatusEntity, NotificationRegistrationKey key, BusinessObjectDataNotificationFilter businessObjectDataNotificationFilter, List<JobAction> jobActions, NotificationRegistrationStatusEntity notificationRegistrationStatusEntity) {
// Create a new entity.
BusinessObjectDataNotificationRegistrationEntity businessObjectDataNotificationRegistrationEntity = new BusinessObjectDataNotificationRegistrationEntity();
businessObjectDataNotificationRegistrationEntity.setNamespace(namespaceEntity);
businessObjectDataNotificationRegistrationEntity.setName(key.getNotificationName());
businessObjectDataNotificationRegistrationEntity.setNotificationEventType(notificationEventTypeEntity);
businessObjectDataNotificationRegistrationEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
if (StringUtils.isNotBlank(businessObjectDataNotificationFilter.getBusinessObjectFormatUsage())) {
businessObjectDataNotificationRegistrationEntity.setUsage(businessObjectDataNotificationFilter.getBusinessObjectFormatUsage());
}
businessObjectDataNotificationRegistrationEntity.setFileType(fileTypeEntity);
businessObjectDataNotificationRegistrationEntity.setBusinessObjectFormatVersion(businessObjectDataNotificationFilter.getBusinessObjectFormatVersion());
businessObjectDataNotificationRegistrationEntity.setStorage(storageEntity);
businessObjectDataNotificationRegistrationEntity.setNewBusinessObjectDataStatus(newBusinessObjectDataStatusEntity);
businessObjectDataNotificationRegistrationEntity.setOldBusinessObjectDataStatus(oldBusinessObjectDataStatusEntity);
businessObjectDataNotificationRegistrationEntity.setNotificationRegistrationStatus(notificationRegistrationStatusEntity);
// Create the relative entities for job actions.
// 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).
List<NotificationActionEntity> notificationActionEntities = new ArrayList<>();
businessObjectDataNotificationRegistrationEntity.setNotificationActions(notificationActionEntities);
for (JobAction jobAction : jobActions) {
// Retrieve and ensure that job definition exists.
JobDefinitionEntity jobDefinitionEntity = jobDefinitionDaoHelper.getJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName());
// Create a new entity.
NotificationJobActionEntity notificationJobActionEntity = new NotificationJobActionEntity();
notificationActionEntities.add(notificationJobActionEntity);
notificationJobActionEntity.setJobDefinition(jobDefinitionEntity);
notificationJobActionEntity.setCorrelationData(jobAction.getCorrelationData());
notificationJobActionEntity.setNotificationRegistration(businessObjectDataNotificationRegistrationEntity);
}
return businessObjectDataNotificationRegistrationEntity;
}
Aggregations