@Override public List<VersionDto> findNotificationSchemaVersionsByAppId( String applicationId) { validateId(applicationId, "Can't find notification schema versions. Invalid application id: " + applicationId); List<NotificationSchema> notificationSchemas = notificationSchemaDao.findNotificationSchemasByAppId(applicationId); List<VersionDto> schemas = new ArrayList<>(); for (NotificationSchema notificationSchema : notificationSchemas) { schemas.add(notificationSchema.toVersionDto()); } return schemas; }
@Override public List<VersionDto> findUserNotificationSchemasByAppId(String applicationId) { validateId(applicationId, "Can't find schemas. Invalid application id: " + applicationId); List<NotificationSchema> notificationSchemas = notificationSchemaDao .findNotificationSchemasByAppIdAndType(applicationId, NotificationTypeDto.USER); List<VersionDto> schemas = new ArrayList<>(); for (NotificationSchema notificationSchema : notificationSchemas) { schemas.add(notificationSchema.toVersionDto()); } return schemas; }
@Override public NotificationSchemaDto findNotificationSchemaByAppIdAndTypeAndVersion( String appId, NotificationTypeDto type, int majorVersion) { validateId(appId, "Can't find notification schema. Invalid application id: " + appId); return getDto(notificationSchemaDao.findNotificationSchemasByAppIdAndTypeAndVersion( appId, type, majorVersion)); }
NotificationTypeDto type = notificationSchemaDto.getType(); if (type != null) { foundSchema = notificationSchemaDao.findLatestNotificationSchemaByAppId( notificationSchemaDto.getApplicationId(), type); } else { NotificationSchemaDto oldNotificationSchemaDto = getDto(notificationSchemaDao.findById(id)); if (oldNotificationSchemaDto != null) { oldNotificationSchemaDto.editFields(notificationSchemaDto); return getDto(notificationSchemaDao.save(new NotificationSchema(notificationSchemaDto)));
@Test public void testRemoveNotificationSchemasByAppId() throws Exception { Application application = generateApplication(null); generateNotificationSchema(application, 1, 1, null); notificationSchemaDao.removeNotificationSchemasByAppId(application.getStringId()); List<NotificationSchema> found = notificationSchemaDao.findNotificationSchemasByAppId(application.getStringId()); Assert.assertTrue(found.isEmpty()); }
@Override public void removeNotificationSchemasByAppId(String appId) { validateId(appId, "Can't remove notification schemas. Invalid application id: " + appId); LOG.debug("Cascade remove corresponding notification to application id [{}]", appId); unicastNotificationDao.removeNotificationsByAppId(appId); notificationSchemaDao.removeNotificationSchemasByAppId(appId); }
@Test public void testFindLatestNotificationSchemaByAppId() throws Exception { Application application = generateApplication(null); List<NotificationSchema> userSchemas = generateNotificationSchema(application, 1, 3, NotificationTypeDto.USER); List<NotificationSchema> systemSchemas = generateNotificationSchema(application, 2, 3, NotificationTypeDto.SYSTEM); NotificationSchema found = notificationSchemaDao.findLatestNotificationSchemaByAppId(application.getStringId(), NotificationTypeDto.USER); Assert.assertEquals(userSchemas.get(2), found); } }
protected List<NotificationSchema> generateNotificationSchema(Application app, int ctlVersion, int count, NotificationTypeDto type) { List<NotificationSchema> schemas = Collections.emptyList(); try { if (app == null) { app = generateApplication(null); } CtlSchema ctlSchema = generateCTLSchema(DEFAULT_FQN, ctlVersion, app.getTenant(), null); NotificationSchema schemaDto; schemas = new ArrayList<>(count); for (int i = 0; i < count; i++) { schemaDto = new NotificationSchema(); schemaDto.setApplication(app); schemaDto.setCreatedUsername("Test User"); schemaDto.setCtlSchema(ctlSchema); schemaDto.setVersion(i + 1); schemaDto.setName("Test Name"); schemaDto.setType(type); schemaDto = notificationSchemaDao.save(schemaDto); Assert.assertNotNull(schemaDto); schemas.add(schemaDto); } } catch (Exception ex) { LOG.error("Can't generate profile schema {}", ex); Assert.fail("Can't generate profile schema." + ex.getMessage()); } return schemas; }
@Override public NotificationSchemaDto findNotificationSchemaById(String id) { validateId(id, "Can't find notification schema. Invalid notification schema id: " + id); return getDto(notificationSchemaDao.findById(id)); }
String topicId = dto.getTopicId(); if (isNotBlank(schemaId) && isNotBlank(topicId)) { NotificationSchema schema = notificationSchemaDao.findById(schemaId); if (schema != null) { dto.setNfVersion(schema.getVersion());
@Override public List<NotificationSchemaDto> findNotificationSchemasByAppIdAndType( String appId, NotificationTypeDto type) { validateId(appId, "Can't find notification schemas. Invalid application id: " + appId); return convertDtoList(notificationSchemaDao.findNotificationSchemasByAppIdAndType(appId, type)); }
@Override public List<NotificationSchemaDto> findNotificationSchemasByAppId(String appId) { validateId(appId, "Can't find notification schemas. Invalid application id: " + appId); return convertDtoList(notificationSchemaDao.findNotificationSchemasByAppId(appId)); }
@Test public void testFindNotificationSchemasByAppIdAndTypeAndVersion() throws Exception { Application application = generateApplication(null); generateNotificationSchema(application, 1, 1, NotificationTypeDto.SYSTEM); List<NotificationSchema> userSchemas = generateNotificationSchema(application, 2, 3, NotificationTypeDto.USER); NotificationSchema expected = userSchemas.get(2); NotificationSchema found = notificationSchemaDao.findNotificationSchemasByAppIdAndTypeAndVersion(application.getStringId(), NotificationTypeDto.USER, expected.getVersion()); Assert.assertEquals(expected, found); }
notificationDto.setTopicId(topicId); notificationDto.setSecNum(-1); NotificationSchema schema = notificationSchemaDao.findById(schemaId); if (schema != null) { notificationDto.setNfVersion(schema.getVersion());
@Test public void testFindNotificationSchemasByAppIdAndType() throws Exception { Application application = generateApplication(null); List<NotificationSchema> userSchemas = generateNotificationSchema(application, 1, 2, NotificationTypeDto.USER); generateNotificationSchema(application, 2, 3, NotificationTypeDto.SYSTEM); List<NotificationSchema> found = notificationSchemaDao.findNotificationSchemasByAppIdAndType(application.getStringId(), NotificationTypeDto.USER); Assert.assertEquals(userSchemas, found); }
@Test public void testFindNotificationSchemasByAppId() throws Exception { Application application = generateApplication(null); List<NotificationSchema> schemas = generateNotificationSchema(application, 1, 1, null); List<NotificationSchema> found = notificationSchemaDao.findNotificationSchemasByAppId(application.getStringId()); Assert.assertEquals(schemas, found); }