@Override public void removeConfSchemasByAppId(String appId) { validateSqlId(appId, "Incorrect application id " + appId + ". Can't remove configuration schema."); LOG.debug("Removing configuration schemas and correspond configuration by application id"); List<ConfigurationSchema> configurationSchemaList = configurationSchemaDao.findByApplicationId(appId); for (ConfigurationSchema configurationSchema : configurationSchemaList) { if (configurationSchema != null) { removeCascadeConfigurationSchema(idToString(configurationSchema)); } } }
@Override public ConfigurationSchemaDto saveConfSchema(ConfigurationSchemaDto configurationSchema) { ConfigurationSchemaDto savedConfigSchema = null; if (configurationSchema != null) { String appId = configurationSchema.getApplicationId(); if (isValidId(appId)) { LOG.debug("Finding default endpoint group for application id [{}]", appId); EndpointGroup endpointGroup = endpointGroupDao.findByAppIdAndWeight(appId, 0); if (endpointGroup != null) { savedConfigSchema = saveConfSchema(configurationSchema, idToString(endpointGroup)); } else { LOG.warn("Can't find default group for application [{}]", appId); } } else { LOG.warn("Can't find endpoint group. Invalid application id [{}]", appId); } } else { LOG.warn("Configuration schema object is null"); } return savedConfigSchema; }
@Override public List<VersionDto> findVacantSchemasByEndpointGroupId(String endpointGroupId) { validateId(endpointGroupId, "Can't find vacant schemas. Invalid endpoint group id: " + endpointGroupId); EndpointGroup group = endpointGroupDao.findById(endpointGroupId); List<Configuration> configurations = configurationDao.findActualByEndpointGroupId( endpointGroupId); List<String> usedSchemaIds = new ArrayList<>(); for (Configuration configuration : configurations) { ConfigurationSchema schema = configuration.getConfigurationSchema(); if (schema != null) { usedSchemaIds.add(idToString(schema.getId())); } } List<ConfigurationSchema> schemas = configurationSchemaDao.findVacantSchemas( group.getApplicationId(), usedSchemaIds); List<VersionDto> schemaDtoList = new ArrayList<>(); for (ConfigurationSchema schema : schemas) { schemaDtoList.add(schema.toVersionDto()); } return schemaDtoList; }
private ChangeNotificationDto createNotification(ConfigurationDto configurationDto, HistoryDto historyDto) { LOG.debug("Create notification after configuration update."); ChangeNotificationDto changeNotificationDto = null; if (historyDto != null) { changeNotificationDto = new ChangeNotificationDto(); changeNotificationDto.setAppId(configurationDto.getApplicationId()); changeNotificationDto.setAppSeqNumber(historyDto.getSequenceNumber()); String endpointGroupId = configurationDto.getEndpointGroupId(); if (isValidId(endpointGroupId)) { EndpointGroup group = endpointGroupDao.findById(endpointGroupId); if (group != null) { changeNotificationDto.setGroupId(idToString(group)); changeNotificationDto.setGroupSeqNumber(group.getSequenceNumber()); } else { LOG.debug("Can't find endpoint group by id [{}].", endpointGroupId); } } else { LOG.debug("Incorrect endpoint group id [{}].", endpointGroupId); } } else { LOG.debug("Can't save history information."); } return changeNotificationDto; }
@Override public ChangeConfigurationNotification deleteConfigurationRecord( String schemaId, String groupId, String deactivatedUsername) { ChangeConfigurationNotification configurationNotification = null; validateSqlId(schemaId, "Incorrect configuration schema id " + schemaId + "."); validateSqlId(groupId, "Incorrect group id " + groupId + "."); ConfigurationDto configurationDto = getDto(configurationDao.deactivateOldConfiguration( schemaId, groupId, deactivatedUsername)); if (configurationDto != null) { HistoryDto historyDto = addHistory(configurationDto, ChangeType.REMOVE_CONF); ChangeNotificationDto changeNotificationDto = createNotification( configurationDto, historyDto); configurationNotification = new ChangeConfigurationNotification(); configurationNotification.setConfigurationDto(configurationDto); configurationNotification.setChangeNotificationDto(changeNotificationDto); } Configuration configuration = configurationDao.findInactiveBySchemaIdAndGroupId( schemaId, groupId); if (configuration != null) { configurationDao.removeById(idToString(configuration)); } return configurationNotification; }
schemaId, groupId); if (oldInactiveConfiguration != null) { configurationDto.setId(idToString(oldInactiveConfiguration.getId())); configurationDto.setSequenceNumber(oldInactiveConfiguration.getSequenceNumber()); } else if (oldActiveConfiguration != null) {