@Override public NotificationSchemaDto toDto() { NotificationSchemaDto dto = super.toDto(); dto.setType(type); return dto; }
private NotificationSchemaDto createDefaultNotificationSchema(String appId, String createdUsername) { NotificationSchemaDto notificationSchemaDto = new NotificationSchemaDto(); notificationSchemaDto.setApplicationId(appId); CTLSchemaDto ctlSchema = ctlService.getOrCreateEmptySystemSchema(createdUsername); notificationSchemaDto.setCtlSchemaId(ctlSchema.getId()); notificationSchemaDto.setName(DEFAULT_SCHEMA_NAME); notificationSchemaDto.setCreatedUsername(createdUsername); notificationSchemaDto.setType(NotificationTypeDto.USER); notificationSchemaDto = notificationService.saveNotificationSchema(notificationSchemaDto); if (notificationSchemaDto == null) { throw new RuntimeException("Can't save default notification schema "); //NOSONAR } return notificationSchemaDto; }
@Override public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { if (isEmpty(notificationSchema.getId())) { notificationSchema.setCreatedUsername(getCurrentUser().getUsername()); checkApplicationId(notificationSchema.getApplicationId()); } else { NotificationSchemaDto storedNotificationSchema = controlService.getNotificationSchema( notificationSchema.getId()); Utils.checkNotNull(storedNotificationSchema); checkApplicationId(storedNotificationSchema.getApplicationId()); } notificationSchema.setType(NotificationTypeDto.USER); return controlService.saveNotificationSchema(notificationSchema); } catch (Exception ex) { throw Utils.handleException(ex); } }
notificationSchemaDto.setType(NotificationTypeDto.USER); NotificationSchemaDto savedSchema = notificationService.saveNotificationSchema(notificationSchemaDto);
protected NotificationSchemaDto generateNotificationSchemaDto(String appId, NotificationTypeDto type) { NotificationSchemaDto schema = new NotificationSchemaDto(); ApplicationDto app = null; if (isBlank(appId)) { app = generateApplicationDto(); appId = app.getId(); } else { app = applicationService.findAppById(appId); } schema.setApplicationId(appId); schema.setName(NOTIFICATION_SCHEMA_NAME); schema.setType(type != null ? type : NotificationTypeDto.USER); CTLSchemaDto ctlSchema = null; try { ctlSchema = ctlService.saveCtlSchema(generateCTLSchemaDto(app.getTenantId())); } catch (DatabaseProcessingException e) { ctlSchema = ctlService.getOrCreateEmptySystemSchema(USER_NAME); } schema.setCtlSchemaId(ctlSchema.getId()); return notificationService.saveNotificationSchema(schema); }