use of net.nemerosa.ontrack.extension.git.model.BasicGitConfiguration in project ontrack by nemerosa.
the class GitProjectConfigurationPropertyType method fromStorage.
@Override
public GitProjectConfigurationProperty fromStorage(JsonNode node) {
String configurationName = node.path("configuration").asText();
// Looks the configuration up
BasicGitConfiguration configuration = configurationService.getConfiguration(configurationName);
// OK
return new GitProjectConfigurationProperty(configuration);
}
use of net.nemerosa.ontrack.extension.git.model.BasicGitConfiguration in project ontrack by nemerosa.
the class GitConfigurationMigrationAction11 method migrate.
@Override
public void migrate(Connection connection) throws Exception {
// For all Git configurations
try (PreparedStatement ps = connection.prepareStatement("SELECT * FROM CONFIGURATIONS WHERE TYPE = ?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {
ps.setString(1, BasicGitConfiguration.class.getName());
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
// Configuration as JSON
String json = rs.getString("CONTENT");
// Parses the configuration
ObjectNode node = (ObjectNode) objectMapper.readTree(json);
// Gets all fields of the node
List<String> fieldNames = Lists.newArrayList(node.fieldNames());
// Removes any field that does not belong to the BasicGitConfiguration class
fieldNames.stream().filter(fieldName -> !validFields.contains(fieldName)).forEach(node::remove);
// Updating
rs.updateString("CONTENT", objectMapper.writeValueAsString(node));
rs.updateRow();
}
}
}
}
Aggregations