public void saveProperty(PropertyDto property) { try (DbSession session = mybatis.openSession(false)) { saveProperty(session, property); session.commit(); } }
@CheckForNull public PropertyDto selectGlobalProperty(String propertyKey) { try (DbSession session = mybatis.openSession(false)) { return selectGlobalProperty(session, propertyKey); } }
public List<PropertyDto> selectGlobalProperties() { try (DbSession session = mybatis.openSession(false)) { return selectGlobalProperties(session); } }
private List<PropertyDto> loadGlobalSettings(DbSession dbSession, Optional<String> key) { if (key.isPresent()) { return dbClient.propertiesDao().selectGlobalPropertiesByKeys(dbSession, Collections.singleton(key.get())); } return dbClient.propertiesDao().selectGlobalProperties(dbSession); }
private Optional<PropertyDto> selectPropertyDto(DbSession dbSession, String settingKey, Optional<ComponentDto> componentDto) { if (componentDto.isPresent()) { return Optional.ofNullable(dbClient.propertiesDao().selectProjectProperty(dbSession, componentDto.get().getId(), settingKey)); } else { return Optional.ofNullable(dbClient.propertiesDao().selectGlobalProperty(dbSession, settingKey)); } }
private void deleteSetting(DbSession dbSession, String settingKey, Optional<ComponentDto> componentDto) { if (componentDto.isPresent()) { dbClient.propertiesDao().deleteProjectProperty(settingKey, componentDto.get().getId(), dbSession); } else { dbClient.propertiesDao().deleteGlobalProperty(settingKey, dbSession); } }
public List<PropertyDto> selectProjectProperties(String resourceKey) { try (DbSession session = mybatis.openSession(false)) { return selectProjectProperties(session, resourceKey); } }
private boolean isFavourite(DbSession session, ComponentDto component) { PropertyQuery propertyQuery = PropertyQuery.builder() .setUserId(userSession.getUserId()) .setKey("favourite") .setComponentId(component.getId()) .build(); List<PropertyDto> componentFavourites = dbClient.propertiesDao().selectByQuery(propertyQuery, session); return componentFavourites.size() == 1; }
private void savePropertyImpl(DbSession dbSession, String key, @Nullable String value) { if (value == null) { dbClient.propertiesDao().deleteGlobalProperty(key, dbSession); } else { dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(key).setValue(value)); } // refresh the cache of settings delegate.setProperty(key, value); }
project.getDbKey()); assertThat(dbClient.propertiesDao().selectGlobalProperties(dbSession)).hasSize(3); assertThat(dbClient.propertiesDao().selectProjectProperties(dbSession, project.getDbKey())).hasSize(5); assertGlobalSetting("my.key", "1"); assertGlobalSetting("my.key.1.firstField", "oldFirstValue");
@CheckForNull public PropertyDto selectProjectProperty(long componentId, String propertyKey) { try (DbSession session = mybatis.openSession(false)) { return selectProjectProperty(session, componentId, propertyKey); } }
public void deleteProjectProperty(String key, Long projectId) { try (DbSession session = mybatis.openSession(false)) { deleteProjectProperty(key, projectId, session); session.commit(); } }
private Stream<SubscriberAndChannel> toSubscriberAndChannels(String dispatcherKey, String projectKey, NotificationChannel notificationChannel) { Set<Subscriber> usersForNotification = dbClient.propertiesDao().findUsersForNotification(dispatcherKey, notificationChannel.getKey(), projectKey); return usersForNotification .stream() .map(login -> new SubscriberAndChannel(login, notificationChannel)); }
public void deleteGlobalProperty(String key) { try (DbSession session = mybatis.openSession(false)) { deleteGlobalProperty(key, session); session.commit(); } }
/** * Returns true if at least one user is subscribed to at least one notification with given types. * Subscription can be global or on the specific project. */ public boolean hasProjectSubscribersForTypes(String projectUuid, Set<String> notificationTypes) { Collection<String> dispatcherKeys = new ArrayList<>(); for (NotificationDispatcher dispatcher : dispatchers) { if (notificationTypes.contains(dispatcher.getType())) { dispatcherKeys.add(dispatcher.getKey()); } } return dbClient.propertiesDao().hasProjectNotificationSubscribersForDispatchers(projectUuid, dispatcherKeys); }
private Map<String, ChildSettings> loadMainBranchConfigurations(DbSession dbSession, Set<String> dbKeys) { return dbKeys.stream().collect(uniqueIndex(Function.identity(), dbKey -> { ChildSettings settings = new ChildSettings(globalSettings); List<PropertyDto> propertyDtos = dbClient.propertiesDao() .selectProjectProperties(dbSession, dbKey); propertyDtos .forEach(property -> settings.setProperty(property.getKey(), property.getValue())); return settings; })); } }
public void assertExists(String channel, String dispatcher, int userId, @Nullable ComponentDto component) { List<PropertyDto> result = dbClient.propertiesDao().selectByQuery(PropertyQuery.builder() .setKey(String.join(".", PROP_NOTIFICATION_PREFIX, dispatcher, channel)) .setComponentId(component == null ? null : component.getId()) .setUserId(userId) .build(), dbSession).stream() .filter(prop -> component == null ? prop.getResourceId() == null : prop.getResourceId() != null) .collect(MoreCollectors.toList()); assertThat(result).hasSize(1); assertThat(result.get(0).getValue()).isEqualTo("true"); }
private Optional<PropertyDto> selectPropertyDto(DbSession dbSession, String settingKey, Optional<ComponentDto> componentDto) { if (componentDto.isPresent()) { return Optional.ofNullable(dbClient.propertiesDao().selectProjectProperty(dbSession, componentDto.get().getId(), settingKey)); } else { return Optional.ofNullable(dbClient.propertiesDao().selectGlobalProperty(dbSession, settingKey)); } }
private void savePropertyImpl(DbSession dbSession, String key, @Nullable String value) { if (value == null) { dbClient.propertiesDao().deleteGlobalProperty(key, dbSession); } else { dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(key).setValue(value)); } // refresh the cache of settings delegate.setProperty(key, value); }
private void assertSelected(String qGateId, long projectId) { assertThat(dbClient.propertiesDao().selectProjectProperty(projectId, SONAR_QUALITYGATE_PROPERTY).getValue()).isEqualTo(qGateId); } }