use of org.finra.herd.model.jpa.NotificationEventTypeEntity in project herd by FINRAOS.
the class BusinessObjectDataNotificationRegistrationDaoImpl method getBusinessObjectDataNotificationRegistrations.
@Override
public List<BusinessObjectDataNotificationRegistrationEntity> getBusinessObjectDataNotificationRegistrations(String notificationEventTypeCode, BusinessObjectDataKey businessObjectDataKey, String newBusinessObjectDataStatus, String oldBusinessObjectDataStatus, String notificationRegistrationStatus) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDataNotificationRegistrationEntity> criteria = builder.createQuery(BusinessObjectDataNotificationRegistrationEntity.class);
// The criteria root is the business object data notification registration entity.
Root<BusinessObjectDataNotificationRegistrationEntity> businessObjectDataNotificationEntityRoot = criteria.from(BusinessObjectDataNotificationRegistrationEntity.class);
// Join to the other tables we can filter on.
Join<BusinessObjectDataNotificationRegistrationEntity, NamespaceEntity> namespaceEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.namespace);
Join<BusinessObjectDataNotificationRegistrationEntity, NotificationEventTypeEntity> notificationEventTypeEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.notificationEventType);
Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.businessObjectDefinition);
Join<BusinessObjectDefinitionEntity, NamespaceEntity> businessObjectDefinitionNamespaceEntityJoin = businessObjectDefinitionEntityJoin.join(BusinessObjectDefinitionEntity_.namespace);
Join<BusinessObjectDataNotificationRegistrationEntity, FileTypeEntity> fileTypeEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.fileType, JoinType.LEFT);
Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDataStatusEntity> newBusinessObjectDataStatusEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.newBusinessObjectDataStatus, JoinType.LEFT);
Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDataStatusEntity> oldBusinessObjectDataStatusEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.oldBusinessObjectDataStatus, JoinType.LEFT);
Join<BusinessObjectDataNotificationRegistrationEntity, NotificationRegistrationStatusEntity> notificationRegistrationStatusEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.notificationRegistrationStatus);
// Create the standard restrictions (i.e. the standard where clauses).
List<Predicate> predicates = new ArrayList<>();
predicates.add(builder.equal(builder.upper(notificationEventTypeEntityJoin.get(NotificationEventTypeEntity_.code)), notificationEventTypeCode.toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionNamespaceEntityJoin.get(NamespaceEntity_.code)), businessObjectDataKey.getNamespace().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)), businessObjectDataKey.getBusinessObjectDefinitionName().toUpperCase()));
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.usage)), builder.equal(builder.upper(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.usage)), businessObjectDataKey.getBusinessObjectFormatUsage().toUpperCase())));
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.fileType)), builder.equal(builder.upper(fileTypeEntityJoin.get(FileTypeEntity_.code)), businessObjectDataKey.getBusinessObjectFormatFileType().toUpperCase())));
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.businessObjectFormatVersion)), builder.equal(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.businessObjectFormatVersion), businessObjectDataKey.getBusinessObjectFormatVersion())));
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.newBusinessObjectDataStatus)), builder.equal(builder.upper(newBusinessObjectDataStatusEntityJoin.get(BusinessObjectDataStatusEntity_.code)), newBusinessObjectDataStatus.toUpperCase())));
// Please note that old business object data status parameter value is null for a business object data registration event.
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.oldBusinessObjectDataStatus)), builder.equal(builder.upper(oldBusinessObjectDataStatusEntityJoin.get(BusinessObjectDataStatusEntity_.code)), oldBusinessObjectDataStatus == null ? null : oldBusinessObjectDataStatus.toUpperCase())));
predicates.add(builder.equal(builder.upper(notificationRegistrationStatusEntityJoin.get(NotificationRegistrationStatusEntity_.code)), notificationRegistrationStatus.toUpperCase()));
// Order the results by namespace and notification name.
List<Order> orderBy = new ArrayList<>();
orderBy.add(builder.asc(namespaceEntityJoin.get(NamespaceEntity_.code)));
orderBy.add(builder.asc(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.name)));
// Add the clauses for the query.
criteria.select(businessObjectDataNotificationEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(orderBy);
// Execute the query and return the results.
return entityManager.createQuery(criteria).getResultList();
}
use of org.finra.herd.model.jpa.NotificationEventTypeEntity in project herd by FINRAOS.
the class NotificationRegistrationServiceTestHelper method createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting.
/**
* Create and persist database entities required for testing.
*
* @param namespace the namespace of the storage unit notification registration
* @param notificationEventTypes the list of notification event types
* @param businessObjectDefinitionNamespace the namespace of the business object definition
* @param businessObjectDefinitionName the name of the business object definition
* @param fileTypes the list of file types
* @param storageNames the list of storage names
* @param storageUnitStatuses the list of storage unit statuses
* @param jobActions the list of job actions
*/
public void createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(String namespace, List<String> notificationEventTypes, String businessObjectDefinitionNamespace, String businessObjectDefinitionName, List<String> fileTypes, List<String> storageNames, List<String> storageUnitStatuses, List<JobAction> jobActions) {
// Create a namespace entity, if not exists.
NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(namespace);
if (namespaceEntity == null) {
namespaceDaoTestHelper.createNamespaceEntity(namespace);
}
// Create specified notification event types, if not exist.
if (!CollectionUtils.isEmpty(notificationEventTypes)) {
for (String notificationEventType : notificationEventTypes) {
NotificationEventTypeEntity notificationEventTypeEntity = notificationEventTypeDao.getNotificationEventTypeByCode(notificationEventType);
if (notificationEventTypeEntity == null) {
notificationRegistrationDaoTestHelper.createNotificationEventTypeEntity(notificationEventType);
}
}
}
// Create specified business object definition, if not exists.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(businessObjectDefinitionNamespace, businessObjectDefinitionName));
if (businessObjectDefinitionEntity == null) {
// Create and persist a business object definition entity.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionNamespace, businessObjectDefinitionName, AbstractServiceTest.DATA_PROVIDER_NAME, AbstractServiceTest.BDEF_DESCRIPTION);
}
// Create specified file type entities, if not exist.
if (!CollectionUtils.isEmpty(fileTypes)) {
for (String businessObjectFormatFileType : fileTypes) {
fileTypeDaoTestHelper.createFileTypeEntity(businessObjectFormatFileType);
}
}
// Create specified storage entities, if not exist.
if (!CollectionUtils.isEmpty(storageNames)) {
for (String storageName : storageNames) {
storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3);
}
}
// Create specified business object data status entities, if not exist.
if (!CollectionUtils.isEmpty(storageUnitStatuses)) {
for (String storageUnitStatus : storageUnitStatuses) {
StorageUnitStatusEntity storageUnitStatusEntity = storageUnitStatusDao.getStorageUnitStatusByCode(storageUnitStatus);
if (storageUnitStatusEntity == null) {
storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(storageUnitStatus);
}
}
}
// Create specified job definition entities.
if (!CollectionUtils.isEmpty(jobActions)) {
for (JobAction jobAction : jobActions) {
jobDefinitionDaoTestHelper.createJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName(), String.format("Description of \"%s.%s\" job definition.", jobAction.getNamespace(), jobAction.getJobName()), String.format("%s.%s.%s", jobAction.getNamespace(), jobAction.getJobName(), AbstractServiceTest.ACTIVITI_ID));
}
}
}
use of org.finra.herd.model.jpa.NotificationEventTypeEntity in project herd by FINRAOS.
the class NotificationRegistrationServiceTestHelper method createDatabaseEntitiesForBusinessObjectDataNotificationRegistrationTesting.
/**
* Create and persist database entities required for testing.
*
* @param namespace the namespace of the business object data notification registration
* @param notificationEventTypes the list of notification event types
* @param businessObjectDefinitionNamespace the namespace of the business object definition
* @param businessObjectDefinitionName the name of the business object definition
* @param fileTypes the list of file types
* @param storageNames the list of storage names
* @param businessObjectDataStatuses the list of business object data statuses
* @param jobActions the list of job actions
*/
public void createDatabaseEntitiesForBusinessObjectDataNotificationRegistrationTesting(String namespace, List<String> notificationEventTypes, String businessObjectDefinitionNamespace, String businessObjectDefinitionName, List<String> fileTypes, List<String> storageNames, List<String> businessObjectDataStatuses, List<JobAction> jobActions) {
// Create a namespace entity, if not exists.
NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(namespace);
if (namespaceEntity == null) {
namespaceDaoTestHelper.createNamespaceEntity(namespace);
}
// Create specified notification event types, if not exist.
if (!CollectionUtils.isEmpty(notificationEventTypes)) {
for (String notificationEventType : notificationEventTypes) {
NotificationEventTypeEntity notificationEventTypeEntity = notificationEventTypeDao.getNotificationEventTypeByCode(notificationEventType);
if (notificationEventTypeEntity == null) {
notificationRegistrationDaoTestHelper.createNotificationEventTypeEntity(notificationEventType);
}
}
}
// Create specified business object definition, if not exists.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(businessObjectDefinitionNamespace, businessObjectDefinitionName));
if (businessObjectDefinitionEntity == null) {
// Create and persist a business object definition entity.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionNamespace, businessObjectDefinitionName, AbstractServiceTest.DATA_PROVIDER_NAME, AbstractServiceTest.BDEF_DESCRIPTION);
}
// Create specified file type entities, if not exist.
if (!CollectionUtils.isEmpty(fileTypes)) {
for (String businessObjectFormatFileType : fileTypes) {
fileTypeDaoTestHelper.createFileTypeEntity(businessObjectFormatFileType);
}
}
// Create specified storage entities, if not exist.
if (!CollectionUtils.isEmpty(storageNames)) {
for (String storageName : storageNames) {
storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3);
}
}
// Create specified business object data status entities, if not exist.
if (!CollectionUtils.isEmpty(businessObjectDataStatuses)) {
for (String businessObjectDataStatus : businessObjectDataStatuses) {
BusinessObjectDataStatusEntity businessObjectDataStatusEntity = businessObjectDataStatusDao.getBusinessObjectDataStatusByCode(businessObjectDataStatus);
if (businessObjectDataStatusEntity == null) {
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(businessObjectDataStatus);
}
}
}
// Create specified job definition entities.
if (!CollectionUtils.isEmpty(jobActions)) {
for (JobAction jobAction : jobActions) {
jobDefinitionDaoTestHelper.createJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName(), String.format("Description of \"%s.%s\" job definition.", jobAction.getNamespace(), jobAction.getJobName()), String.format("%s.%s.%s", jobAction.getNamespace(), jobAction.getJobName(), AbstractServiceTest.ACTIVITI_ID));
}
}
}
use of org.finra.herd.model.jpa.NotificationEventTypeEntity in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationDaoImpl method getStorageUnitNotificationRegistrations.
@Override
public List<StorageUnitNotificationRegistrationEntity> getStorageUnitNotificationRegistrations(String notificationEventTypeCode, BusinessObjectDataKey businessObjectDataKey, String storageName, String newStorageUnitStatus, String oldStorageUnitStatus, String notificationRegistrationStatus) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<StorageUnitNotificationRegistrationEntity> criteria = builder.createQuery(StorageUnitNotificationRegistrationEntity.class);
// The criteria root is the storage unit notification registration entity.
Root<StorageUnitNotificationRegistrationEntity> storageUnitNotificationRegistrationEntityRoot = criteria.from(StorageUnitNotificationRegistrationEntity.class);
// Join to the other tables we can filter on.
Join<StorageUnitNotificationRegistrationEntity, NamespaceEntity> namespaceEntityJoin = storageUnitNotificationRegistrationEntityRoot.join(StorageUnitNotificationRegistrationEntity_.namespace);
Join<StorageUnitNotificationRegistrationEntity, NotificationEventTypeEntity> notificationEventTypeEntityJoin = storageUnitNotificationRegistrationEntityRoot.join(StorageUnitNotificationRegistrationEntity_.notificationEventType);
Join<StorageUnitNotificationRegistrationEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = storageUnitNotificationRegistrationEntityRoot.join(StorageUnitNotificationRegistrationEntity_.businessObjectDefinition);
Join<BusinessObjectDefinitionEntity, NamespaceEntity> businessObjectDefinitionNamespaceEntityJoin = businessObjectDefinitionEntityJoin.join(BusinessObjectDefinitionEntity_.namespace);
Join<StorageUnitNotificationRegistrationEntity, StorageEntity> storageEntityJoin = storageUnitNotificationRegistrationEntityRoot.join(StorageUnitNotificationRegistrationEntity_.storage);
Join<StorageUnitNotificationRegistrationEntity, FileTypeEntity> fileTypeEntityJoin = storageUnitNotificationRegistrationEntityRoot.join(StorageUnitNotificationRegistrationEntity_.fileType, JoinType.LEFT);
Join<StorageUnitNotificationRegistrationEntity, StorageUnitStatusEntity> newStorageUnitStatusEntityJoin = storageUnitNotificationRegistrationEntityRoot.join(StorageUnitNotificationRegistrationEntity_.newStorageUnitStatus, JoinType.LEFT);
Join<StorageUnitNotificationRegistrationEntity, StorageUnitStatusEntity> oldStorageUnitStatusEntityJoin = storageUnitNotificationRegistrationEntityRoot.join(StorageUnitNotificationRegistrationEntity_.oldStorageUnitStatus, JoinType.LEFT);
Join<StorageUnitNotificationRegistrationEntity, NotificationRegistrationStatusEntity> notificationRegistrationStatusEntityJoin = storageUnitNotificationRegistrationEntityRoot.join(StorageUnitNotificationRegistrationEntity_.notificationRegistrationStatus);
// Create the standard restrictions (i.e. the standard where clauses).
List<Predicate> predicates = new ArrayList<>();
predicates.add(builder.equal(builder.upper(notificationEventTypeEntityJoin.get(NotificationEventTypeEntity_.code)), notificationEventTypeCode.toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionNamespaceEntityJoin.get(NamespaceEntity_.code)), businessObjectDataKey.getNamespace().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)), businessObjectDataKey.getBusinessObjectDefinitionName().toUpperCase()));
predicates.add(builder.equal(builder.upper(storageEntityJoin.get(StorageEntity_.name)), storageName.toUpperCase()));
predicates.add(builder.or(builder.isNull(storageUnitNotificationRegistrationEntityRoot.get(StorageUnitNotificationRegistrationEntity_.usage)), builder.equal(builder.upper(storageUnitNotificationRegistrationEntityRoot.get(StorageUnitNotificationRegistrationEntity_.usage)), businessObjectDataKey.getBusinessObjectFormatUsage().toUpperCase())));
predicates.add(builder.or(builder.isNull(storageUnitNotificationRegistrationEntityRoot.get(StorageUnitNotificationRegistrationEntity_.fileType)), builder.equal(builder.upper(fileTypeEntityJoin.get(FileTypeEntity_.code)), businessObjectDataKey.getBusinessObjectFormatFileType().toUpperCase())));
predicates.add(builder.or(builder.isNull(storageUnitNotificationRegistrationEntityRoot.get(StorageUnitNotificationRegistrationEntity_.businessObjectFormatVersion)), builder.equal(storageUnitNotificationRegistrationEntityRoot.get(StorageUnitNotificationRegistrationEntity_.businessObjectFormatVersion), businessObjectDataKey.getBusinessObjectFormatVersion())));
predicates.add(builder.or(builder.isNull(storageUnitNotificationRegistrationEntityRoot.get(StorageUnitNotificationRegistrationEntity_.newStorageUnitStatus)), builder.equal(builder.upper(newStorageUnitStatusEntityJoin.get(StorageUnitStatusEntity_.code)), newStorageUnitStatus.toUpperCase())));
// Please note that old business object data status parameter value is null for a business object data registration event.
predicates.add(builder.or(builder.isNull(storageUnitNotificationRegistrationEntityRoot.get(StorageUnitNotificationRegistrationEntity_.oldStorageUnitStatus)), builder.equal(builder.upper(oldStorageUnitStatusEntityJoin.get(StorageUnitStatusEntity_.code)), oldStorageUnitStatus == null ? null : oldStorageUnitStatus.toUpperCase())));
predicates.add(builder.equal(builder.upper(notificationRegistrationStatusEntityJoin.get(NotificationRegistrationStatusEntity_.code)), notificationRegistrationStatus.toUpperCase()));
// Order the results by namespace and notification name.
List<Order> orderBy = new ArrayList<>();
orderBy.add(builder.asc(namespaceEntityJoin.get(NamespaceEntity_.code)));
orderBy.add(builder.asc(storageUnitNotificationRegistrationEntityRoot.get(StorageUnitNotificationRegistrationEntity_.name)));
// Add the clauses for the query.
criteria.select(storageUnitNotificationRegistrationEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(orderBy);
// Execute the query and return the results.
return entityManager.createQuery(criteria).getResultList();
}
use of org.finra.herd.model.jpa.NotificationEventTypeEntity in project herd by FINRAOS.
the class NotificationRegistrationDaoTestHelper method createNotificationEventTypeEntity.
/**
* Creates and persists a new notification event type entity.
*
* @param code the notification event type code
*
* @return the newly created notification event type entity
*/
public NotificationEventTypeEntity createNotificationEventTypeEntity(String code) {
NotificationEventTypeEntity notificationEventTypeEntity = new NotificationEventTypeEntity();
notificationEventTypeEntity.setCode(code);
notificationEventTypeEntity.setDescription(String.format("Description of \"%s\".", code));
return notificationEventTypeDao.saveAndRefresh(notificationEventTypeEntity);
}
Aggregations