use of org.finra.herd.model.jpa.NotificationJobActionEntity in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceImpl method createStorageUnitNotificationFromEntity.
/**
* Creates the storage unit notification registration from the persisted entity.
*
* @param storageUnitNotificationRegistrationEntity the storage unit notification registration entity
*
* @return the storage unit notification registration
*/
private StorageUnitNotificationRegistration createStorageUnitNotificationFromEntity(StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistrationEntity) {
// Create the storage unit notification.
StorageUnitNotificationRegistration storageUnitNotificationRegistration = new StorageUnitNotificationRegistration();
storageUnitNotificationRegistration.setId(storageUnitNotificationRegistrationEntity.getId());
storageUnitNotificationRegistration.setStorageUnitNotificationRegistrationKey(new NotificationRegistrationKey(storageUnitNotificationRegistrationEntity.getNamespace().getCode(), storageUnitNotificationRegistrationEntity.getName()));
storageUnitNotificationRegistration.setStorageUnitEventType(storageUnitNotificationRegistrationEntity.getNotificationEventType().getCode());
StorageUnitNotificationFilter filter = new StorageUnitNotificationFilter();
storageUnitNotificationRegistration.setStorageUnitNotificationFilter(filter);
// Business object definition entity cannot be null as per storage unit notification registration create request validation.
filter.setNamespace(storageUnitNotificationRegistrationEntity.getBusinessObjectDefinition().getNamespace().getCode());
filter.setBusinessObjectDefinitionName(storageUnitNotificationRegistrationEntity.getBusinessObjectDefinition().getName());
filter.setBusinessObjectFormatUsage(storageUnitNotificationRegistrationEntity.getUsage());
filter.setBusinessObjectFormatFileType(storageUnitNotificationRegistrationEntity.getFileType() != null ? storageUnitNotificationRegistrationEntity.getFileType().getCode() : null);
filter.setBusinessObjectFormatVersion(storageUnitNotificationRegistrationEntity.getBusinessObjectFormatVersion());
filter.setStorageName(storageUnitNotificationRegistrationEntity.getStorage() != null ? storageUnitNotificationRegistrationEntity.getStorage().getName() : null);
filter.setNewStorageUnitStatus(storageUnitNotificationRegistrationEntity.getNewStorageUnitStatus() != null ? storageUnitNotificationRegistrationEntity.getNewStorageUnitStatus().getCode() : null);
filter.setOldStorageUnitStatus(storageUnitNotificationRegistrationEntity.getOldStorageUnitStatus() != null ? storageUnitNotificationRegistrationEntity.getOldStorageUnitStatus().getCode() : null);
List<JobAction> jobActions = new ArrayList<>();
storageUnitNotificationRegistration.setJobActions(jobActions);
for (NotificationActionEntity notificationActionEntity : storageUnitNotificationRegistrationEntity.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());
}
}
storageUnitNotificationRegistration.setNotificationRegistrationStatus(storageUnitNotificationRegistrationEntity.getNotificationRegistrationStatus().getCode());
return storageUnitNotificationRegistration;
}
use of org.finra.herd.model.jpa.NotificationJobActionEntity in project herd by FINRAOS.
the class StorageUnitStatusChangeNotificationJobActionServiceImpl method buildJobParameters.
private List<Parameter> buildJobParameters(StorageUnitNotificationEventParamsDto storageUnitNotificationEventParams) throws IOException {
List<Parameter> parameters = new ArrayList<>();
BusinessObjectData businessObjectData = storageUnitNotificationEventParams.getBusinessObjectData();
NotificationJobActionEntity notificationJobActionEntity = storageUnitNotificationEventParams.getNotificationJobAction();
parameters.add(new Parameter(PARAM_NAMESPACE, storageUnitNotificationEventParams.getStorageUnitNotificationRegistration().getNamespace().getCode()));
parameters.add(new Parameter(PARAM_NOTIFICATION_NAME, storageUnitNotificationEventParams.getStorageUnitNotificationRegistration().getName()));
parameters.add(new Parameter(PARAM_STORAGE_UNIT_EVENT_TYPE, storageUnitNotificationEventParams.getEventType()));
parameters.add(new Parameter(PARAM_CORRELATION_DATA, notificationJobActionEntity.getCorrelationData()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA, jsonHelper.objectToJson(businessObjectData)));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DEFINITION_NAMESPACE, businessObjectData.getNamespace()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DEFINITION_NAME, businessObjectData.getBusinessObjectDefinitionName()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_USAGE, businessObjectData.getBusinessObjectFormatUsage()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_FILE_TYPE, businessObjectData.getBusinessObjectFormatFileType()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_VERSION, Integer.toString(businessObjectData.getBusinessObjectFormatVersion())));
parameters.add(new Parameter(PARAM_PARTITION_COLUMN_NAMES, herdStringHelper.buildStringWithDefaultDelimiter(storageUnitNotificationEventParams.getPartitionColumnNames())));
parameters.add(new Parameter(PARAM_PARTITION_VALUES, herdStringHelper.buildStringWithDefaultDelimiter(storageUnitNotificationEventParams.getPartitionValues())));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA_VERSION, Integer.toString(businessObjectData.getVersion())));
parameters.add(new Parameter(PARAM_STORAGE_NAME, storageUnitNotificationEventParams.getStorageName()));
parameters.add(new Parameter(PARAM_NEW_STORAGE_UNIT_STATUS, storageUnitNotificationEventParams.getNewStorageUnitStatus()));
parameters.add(new Parameter(PARAM_OLD_STORAGE_UNIT_STATUS, storageUnitNotificationEventParams.getOldStorageUnitStatus()));
return parameters;
}
use of org.finra.herd.model.jpa.NotificationJobActionEntity in project herd by FINRAOS.
the class NotificationEventServiceImpl method processBusinessObjectDataNotifications.
private List<Object> processBusinessObjectDataNotifications(String notificationEventType, List<BusinessObjectDataNotificationRegistrationEntity> businessObjectDataNotificationRegistrationEntities, BusinessObjectData businessObjectData, String newBusinessObjectDataStatus, String oldBusinessObjectDataStatus) {
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 (BusinessObjectDataNotificationRegistrationEntity businessObjectDataNotificationRegistration : businessObjectDataNotificationRegistrationEntities) {
// Retrieve the job notification actions needed to be triggered.
for (NotificationActionEntity notificationActionEntity : businessObjectDataNotificationRegistration.getNotificationActions()) {
// Trigger the job action.
if (notificationActionEntity instanceof NotificationJobActionEntity) {
NotificationJobActionEntity notificationJobActionEntity = (NotificationJobActionEntity) notificationActionEntity;
BusinessObjectDataNotificationEventParamsDto notificationEventParams = new BusinessObjectDataNotificationEventParamsDto();
notificationEventParams.setBusinessObjectDataNotificationRegistration(businessObjectDataNotificationRegistration);
notificationEventParams.setNotificationJobAction(notificationJobActionEntity);
notificationEventParams.setEventType(notificationEventType);
notificationEventParams.setBusinessObjectData(businessObjectData);
notificationEventParams.setPartitionColumnNames(partitionColumnNames);
notificationEventParams.setStorageName(businessObjectDataNotificationRegistration.getStorage() == null ? null : businessObjectDataNotificationRegistration.getStorage().getName());
notificationEventParams.setPartitionValues(partitionValues);
notificationEventParams.setNewBusinessObjectDataStatus(newBusinessObjectDataStatus);
notificationEventParams.setOldBusinessObjectDataStatus(oldBusinessObjectDataStatus);
notificationActions.add(triggerNotificationAction(NotificationTypeEntity.NOTIFICATION_TYPE_BDATA, notificationEventType, notificationEventParams));
}
}
}
return notificationActions;
}
use of org.finra.herd.model.jpa.NotificationJobActionEntity in project herd by FINRAOS.
the class BusinessObjectDataNotificationJobActionServiceImpl method buildJobParameters.
private List<Parameter> buildJobParameters(BusinessObjectDataNotificationEventParamsDto businessObjectDataNotificationEventParams) throws IOException {
List<Parameter> parameters = new ArrayList<>();
BusinessObjectData businessObjectData = businessObjectDataNotificationEventParams.getBusinessObjectData();
NotificationJobActionEntity notificationJobActionEntity = businessObjectDataNotificationEventParams.getNotificationJobAction();
parameters.add(new Parameter(PARAM_NAMESPACE, businessObjectDataNotificationEventParams.getBusinessObjectDataNotificationRegistration().getNamespace().getCode()));
parameters.add(new Parameter(PARAM_NOTIFICATION_NAME, businessObjectDataNotificationEventParams.getBusinessObjectDataNotificationRegistration().getName()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA_EVENT_TYPE, businessObjectDataNotificationEventParams.getEventType()));
parameters.add(new Parameter(PARAM_CORRELATION_DATA, notificationJobActionEntity.getCorrelationData()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA, jsonHelper.objectToJson(businessObjectData)));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DEFINITION_NAMESPACE, businessObjectData.getNamespace()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DEFINITION_NAME, businessObjectData.getBusinessObjectDefinitionName()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_USAGE, businessObjectData.getBusinessObjectFormatUsage()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_FILE_TYPE, businessObjectData.getBusinessObjectFormatFileType()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_VERSION, Integer.toString(businessObjectData.getBusinessObjectFormatVersion())));
parameters.add(new Parameter(PARAM_PARTITION_COLUMN_NAMES, herdStringHelper.buildStringWithDefaultDelimiter(businessObjectDataNotificationEventParams.getPartitionColumnNames())));
parameters.add(new Parameter(PARAM_PARTITION_VALUES, herdStringHelper.buildStringWithDefaultDelimiter(businessObjectDataNotificationEventParams.getPartitionValues())));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA_VERSION, Integer.toString(businessObjectData.getVersion())));
parameters.add(new Parameter(PARAM_NEW_BUSINESS_OBJECT_DATA_STATUS, businessObjectDataNotificationEventParams.getNewBusinessObjectDataStatus()));
parameters.add(new Parameter(PARAM_OLD_BUSINESS_OBJECT_DATA_STATUS, businessObjectDataNotificationEventParams.getOldBusinessObjectDataStatus()));
return parameters;
}
use of org.finra.herd.model.jpa.NotificationJobActionEntity 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;
}
Aggregations