Skip to content

Commit

Permalink
Merge branch 'develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
thoniTUB authored Jun 4, 2024
2 parents 383dee0 + a5efb04 commit 5f34c51
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import lombok.Builder;
import lombok.Data;
import lombok.extern.jackson.Jacksonized;

@Data
@Builder
@Jacksonized
public class DatabaseConfig {

private static final String DEFAULT_PRIMARY_COLUMN = "pid";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
import java.util.Map;

import com.bakdata.conquery.models.datasets.Dataset;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.dropwizard.validation.ValidationMethod;
import jakarta.validation.Valid;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.jackson.Jacksonized;

@Data
@Builder
@Jacksonized
@NoArgsConstructor
@AllArgsConstructor
public class SqlConnectorConfig {
Expand All @@ -27,10 +32,19 @@ public class SqlConnectorConfig {
* Keys must match the name of existing {@link Dataset}s.
*/
@Getter(AccessLevel.PRIVATE)
private Map<String, DatabaseConfig> databaseConfigs;
private Map<String, @Valid DatabaseConfig> databaseConfigs;

public DatabaseConfig getDatabaseConfig(Dataset dataset) {
return databaseConfigs.get(dataset.getName());
}

@JsonIgnore
@ValidationMethod(message = "At lease 1 DatabaseConfig has to be present if SqlConnector config is enabled")
public boolean isValidSqlConnectorConfig() {
if (!enabled) {
return true;
}
return databaseConfigs != null && !databaseConfigs.isEmpty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Table extends Labeled<TableId> implements NamespacedIdentifiable<Ta
*/
@Nullable
@JsonManagedReference
private Column primaryColum;
private Column primaryColumn;

@ValidationMethod(message = "More than one column map to the same secondaryId")
@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

public class TablePrimaryColumnUtil {

public static Field<Object> findPrimaryColumn(Table table, DatabaseConfig sqlConfig) {
String primaryColumnName = table.getPrimaryColum() == null
? sqlConfig.getPrimaryColumn()
: table.getPrimaryColum().getName();
public static Field<Object> findPrimaryColumn(Table table, DatabaseConfig databaseConfig) {
String primaryColumnName = table.getPrimaryColumn() == null
? databaseConfig.getPrimaryColumn()
: table.getPrimaryColumn().getName();
return DSL.field(DSL.name(table.getName(), primaryColumnName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class RequiredTable {

public Table toTable(Dataset dataset, CentralRegistry centralRegistry) {
Table table = new Table();
table.setPrimaryColum(primaryColumn.toColumn(table, centralRegistry));
table.setPrimaryColumn(primaryColumn.toColumn(table, centralRegistry));
table.setDataset(dataset);
table.setName(name);
table.setColumns(Arrays.stream(columns)
Expand Down

0 comments on commit 5f34c51

Please sign in to comment.