public StorageUnitNotificationRegistrationEntity createStorageUnitNotificationRegistrationEntity(NotificationRegistrationKey notificationRegistrationKey,String notificationEventTypeCode,String businessObjectDefinitionNamespace,String businessObjectDefinitionName,String businessObjectFormatUsage,String businessObjectFormatFileType,Integer businessObjectFormatVersion,String storageName,String newStorageUnitStatus,String oldStorageUnitStatus,List<JobAction> jobActions,String notificationRegistrationStatus){
  NamespaceEntity namespaceEntity=namespaceDao.getNamespaceByCd(notificationRegistrationKey.getNamespace());
  if (namespaceEntity == null) {
    namespaceEntity=namespaceDaoTestHelper.createNamespaceEntity(notificationRegistrationKey.getNamespace());
  }
  NotificationEventTypeEntity notificationEventTypeEntity=notificationEventTypeDao.getNotificationEventTypeByCode(notificationEventTypeCode);
  if (notificationEventTypeEntity == null) {
    notificationEventTypeEntity=createNotificationEventTypeEntity(notificationEventTypeCode);
  }
  BusinessObjectDefinitionEntity businessObjectDefinitionEntity=businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(businessObjectDefinitionNamespace,businessObjectDefinitionName));
  if (businessObjectDefinitionEntity == null) {
    businessObjectDefinitionEntity=businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionNamespace,businessObjectDefinitionName,AbstractDaoTest.DATA_PROVIDER_NAME,AbstractDaoTest.BDEF_DESCRIPTION);
  }
  FileTypeEntity fileTypeEntity=null;
  if (StringUtils.isNotBlank(businessObjectFormatFileType)) {
    fileTypeEntity=fileTypeDao.getFileTypeByCode(businessObjectFormatFileType);
    if (fileTypeEntity == null) {
      fileTypeEntity=fileTypeDaoTestHelper.createFileTypeEntity(businessObjectFormatFileType);
    }
  }
  StorageEntity storageEntity=storageDao.getStorageByName(storageName);
  if (storageEntity == null) {
    storageEntity=storageDaoTestHelper.createStorageEntity(storageName,StoragePlatformEntity.S3);
  }
  StorageUnitStatusEntity newStorageUnitStatusEntity=null;
  if (StringUtils.isNotBlank(newStorageUnitStatus)) {
    newStorageUnitStatusEntity=storageUnitStatusDao.getStorageUnitStatusByCode(newStorageUnitStatus);
    if (newStorageUnitStatusEntity == null) {
      newStorageUnitStatusEntity=storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(newStorageUnitStatus);
    }
  }
  StorageUnitStatusEntity oldStorageUnitStatusEntity=null;
  if (StringUtils.isNotBlank(oldStorageUnitStatus)) {
    oldStorageUnitStatusEntity=storageUnitStatusDao.getStorageUnitStatusByCode(oldStorageUnitStatus);
    if (oldStorageUnitStatusEntity == null) {
      oldStorageUnitStatusEntity=storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(oldStorageUnitStatus);
    }
  }
  NotificationRegistrationStatusEntity notificationRegistrationStatusEntity=notificationRegistrationStatusDao.getNotificationRegistrationStatus(notificationRegistrationStatus);
  if (notificationRegistrationStatusEntity == null) {
    notificationRegistrationStatusEntity=createNotificationRegistrationStatusEntity(notificationRegistrationStatus);
  }
  StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistrationEntity=new StorageUnitNotificationRegistrationEntity();
  storageUnitNotificationRegistrationEntity.setNamespace(namespaceEntity);
  storageUnitNotificationRegistrationEntity.setName(notificationRegistrationKey.getNotificationName());
  storageUnitNotificationRegistrationEntity.setNotificationEventType(notificationEventTypeEntity);
  storageUnitNotificationRegistrationEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
  storageUnitNotificationRegistrationEntity.setUsage(businessObjectFormatUsage);
  storageUnitNotificationRegistrationEntity.setFileType(fileTypeEntity);
  storageUnitNotificationRegistrationEntity.setBusinessObjectFormatVersion(businessObjectFormatVersion);
  storageUnitNotificationRegistrationEntity.setStorage(storageEntity);
  storageUnitNotificationRegistrationEntity.setNewStorageUnitStatus(newStorageUnitStatusEntity);
  storageUnitNotificationRegistrationEntity.setOldStorageUnitStatus(oldStorageUnitStatusEntity);
  storageUnitNotificationRegistrationEntity.setNotificationRegistrationStatus(notificationRegistrationStatusEntity);
  if (!CollectionUtils.isEmpty(jobActions)) {
    List<NotificationActionEntity> notificationActionEntities=new ArrayList<>();
    storageUnitNotificationRegistrationEntity.setNotificationActions(notificationActionEntities);
    for (    JobAction jobAction : jobActions) {
      JobDefinitionEntity jobDefinitionEntity=jobDefinitionDao.getJobDefinitionByAltKey(jobAction.getNamespace(),jobAction.getJobName());
      if (jobDefinitionEntity == null) {
        jobDefinitionEntity=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(),AbstractDaoTest.ACTIVITI_ID));
      }
      NotificationJobActionEntity notificationJobActionEntity=new NotificationJobActionEntity();
      notificationActionEntities.add(notificationJobActionEntity);
      notificationJobActionEntity.setNotificationRegistration(storageUnitNotificationRegistrationEntity);
      notificationJobActionEntity.setJobDefinition(jobDefinitionEntity);
      notificationJobActionEntity.setCorrelationData(jobAction.getCorrelationData());
    }
  }
  return storageUnitNotificationRegistrationDao.saveAndRefresh(storageUnitNotificationRegistrationEntity);
}

public StorageUnitNotificationRegistrationEntity createStorageUnitNotificationRegistrationEntity ( NotificationRegistrationKey notificationRegistrationKey , String notificationEventTypeCode , String businessObjectDefinitionNamespace , String businessObjectDefinitionName , String businessObjectFormatUsage , String businessObjectFormatFileType , Integer businessObjectFormatVersion , String storageName , String newStorageUnitStatus , String oldStorageUnitStatus , List < JobAction > jobActions , String notificationRegistrationStatus ) { NamespaceEntity namespaceEntity = namespaceDao . getNamespaceByCd ( notificationRegistrationKey . getNamespace ( ) ) ; if ( namespaceEntity == null ) { namespaceEntity = namespaceDaoTestHelper . createNamespaceEntity ( notificationRegistrationKey . getNamespace ( ) ) ; } NotificationEventTypeEntity notificationEventTypeEntity = notificationEventTypeDao . getNotificationEventTypeByCode ( notificationEventTypeCode ) ; if ( notificationEventTypeEntity == null ) { notificationEventTypeEntity = createNotificationEventTypeEntity ( notificationEventTypeCode ) ; } BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao . getBusinessObjectDefinitionByKey ( new BusinessObjectDefinitionKey ( businessObjectDefinitionNamespace , businessObjectDefinitionName ) ) ; if ( businessObjectDefinitionEntity == null ) { businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper . createBusinessObjectDefinitionEntity ( businessObjectDefinitionNamespace , businessObjectDefinitionName , AbstractDaoTest . DATA_PROVIDER_NAME , AbstractDaoTest . BDEF_DESCRIPTION ) ; } FileTypeEntity fileTypeEntity = null ; if ( StringUtils . isNotBlank ( businessObjectFormatFileType ) ) { fileTypeEntity = fileTypeDao . getFileTypeByCode ( businessObjectFormatFileType ) ; if ( fileTypeEntity == null ) { fileTypeEntity = fileTypeDaoTestHelper . createFileTypeEntity ( businessObjectFormatFileType ) ; } } StorageEntity storageEntity = storageDao . getStorageByName ( storageName ) ; if ( storageEntity == null ) { storageEntity = storageDaoTestHelper . createStorageEntity ( storageName , StoragePlatformEntity . S3 ) ; } StorageUnitStatusEntity newStorageUnitStatusEntity = null ; if ( StringUtils . isNotBlank ( newStorageUnitStatus ) ) { newStorageUnitStatusEntity = storageUnitStatusDao . getStorageUnitStatusByCode ( newStorageUnitStatus ) ; if ( newStorageUnitStatusEntity == null ) { newStorageUnitStatusEntity = storageUnitStatusDaoTestHelper . createStorageUnitStatusEntity ( newStorageUnitStatus ) ; } } StorageUnitStatusEntity oldStorageUnitStatusEntity = null ; if ( StringUtils . isNotBlank ( oldStorageUnitStatus ) ) { oldStorageUnitStatusEntity = storageUnitStatusDao . getStorageUnitStatusByCode ( oldStorageUnitStatus ) ; if ( oldStorageUnitStatusEntity == null ) { oldStorageUnitStatusEntity = storageUnitStatusDaoTestHelper . createStorageUnitStatusEntity ( oldStorageUnitStatus ) ; } } NotificationRegistrationStatusEntity notificationRegistrationStatusEntity = notificationRegistrationStatusDao . getNotificationRegistrationStatus ( notificationRegistrationStatus ) ; if ( notificationRegistrationStatusEntity == null ) { notificationRegistrationStatusEntity = createNotificationRegistrationStatusEntity ( notificationRegistrationStatus ) ; } StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistrationEntity = new StorageUnitNotificationRegistrationEntity ( ) ; storageUnitNotificationRegistrationEntity . setNamespace ( namespaceEntity ) ; storageUnitNotificationRegistrationEntity . setName ( notificationRegistrationKey . getNotificationName ( ) ) ; storageUnitNotificationRegistrationEntity . setNotificationEventType ( notificationEventTypeEntity ) ; storageUnitNotificationRegistrationEntity . setBusinessObjectDefinition ( businessObjectDefinitionEntity ) ; storageUnitNotificationRegistrationEntity . setUsage ( businessObjectFormatUsage ) ; storageUnitNotificationRegistrationEntity . setFileType ( fileTypeEntity ) ; storageUnitNotificationRegistrationEntity . setBusinessObjectFormatVersion ( businessObjectFormatVersion ) ; storageUnitNotificationRegistrationEntity . setStorage ( storageEntity ) ; storageUnitNotificationRegistrationEntity . setNewStorageUnitStatus ( newStorageUnitStatusEntity ) ; storageUnitNotificationRegistrationEntity . setOldStorageUnitStatus ( oldStorageUnitStatusEntity ) ; storageUnitNotificationRegistrationEntity . setNotificationRegistrationStatus ( notificationRegistrationStatusEntity ) ; if ( ! CollectionUtils . isEmpty ( jobActions ) ) { List < NotificationActionEntity > notificationActionEntities = new ArrayList < > ( ) ; storageUnitNotificationRegistrationEntity . setNotificationActions ( notificationActionEntities ) ; for ( JobAction jobAction : jobActions ) { JobDefinitionEntity jobDefinitionEntity = jobDefinitionDao . getJobDefinitionByAltKey ( jobAction . getNamespace ( ) , jobAction . getJobName ( ) ) ; if ( jobDefinitionEntity == null ) { jobDefinitionEntity = 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 ( ) , AbstractDaoTest . ACTIVITI_ID ) ) ; } NotificationJobActionEntity notificationJobActionEntity = new NotificationJobActionEntity ( ) ; notificationActionEntities . add ( notificationJobActionEntity ) ; notificationJobActionEntity . setNotificationRegistration ( storageUnitNotificationRegistrationEntity ) ; notificationJobActionEntity . setJobDefinition ( jobDefinitionEntity ) ; notificationJobActionEntity . setCorrelationData ( jobAction . getCorrelationData ( ) ) ; } } return storageUnitNotificationRegistrationDao . saveAndRefresh ( storageUnitNotificationRegistrationEntity ) ; }
creates and persists a storage unit notification registration entity .
