Skip to content

Commit

Permalink
use more general way to create source
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-andres committed Oct 8, 2024
1 parent 1f3f1ea commit 033406b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
1 change: 0 additions & 1 deletion gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ sourceCompatibility = 21
dependencies {
implementation gradleApi()
implementation project(':core')
implementation project(':yml')
implementation group: 'org.jooq', name: 'jooq-codegen', version: '3.19.11'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public class GenerateJooqMetamodelTask extends DefaultTask {
private Path outputPath;

@Input
private String ymlSource;
private String source;

@TaskAction
public void generateJooqMetamodel() throws Exception {
AdamJooqMetamodelGenerator generator = new AdamJooqMetamodelGenerator(packageName, outputPath, ymlSource,
AdamJooqMetamodelGenerator generator = new AdamJooqMetamodelGenerator(packageName, outputPath, getSource(),
jooqConfig);
generator.run();
}
Expand Down Expand Up @@ -55,12 +55,12 @@ public void setOutputPath(Path outputPath) {
this.outputPath = outputPath;
}

public String getYmlSource() {
return ymlSource;
public String getSource() {
return source;
}

public void setYmlSource(String ymlSource) {
this.ymlSource = ymlSource;
public void setSource(String source) {
this.source = source;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;

import ch.ergon.adam.core.db.SourceAndSinkFactory;
import ch.ergon.adam.core.db.schema.Field;
import ch.ergon.adam.core.db.schema.ForeignKey;
import ch.ergon.adam.core.db.schema.Index;
import ch.ergon.adam.core.db.schema.Schema;
import ch.ergon.adam.core.db.schema.Table;
import ch.ergon.adam.yml.YmlFactory;

public class AdamDatabase extends AbstractDatabase {
public static final String YML_SOURCE_PROPERTY = "ymlSource";
public static final String SOURCE_PROPERTY = "source";
private Schema schema;
private SchemaDefinition schemaDefinition;

Expand Down Expand Up @@ -178,8 +178,8 @@ private <T> List<T> mutableList(T value) {

private void ensureSchema() {
if (schema == null) {
String source = (String) getProperties().get(YML_SOURCE_PROPERTY);
schema = new YmlFactory().createSource(source).getSchema();
String source = (String) getProperties().get(SOURCE_PROPERTY);
schema = SourceAndSinkFactory.getInstance().getSource(source).getSchema();
schemaDefinition = new SchemaDefinition(this, "", null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public class AdamJooqMetamodelGenerator {

private String packageName;
private Path outputPath;
private String ymlSource;
private String source;
private String jooqConfig;

public AdamJooqMetamodelGenerator(String packageName, Path outputPath, String ymlSource, String jooqConfig) {
public AdamJooqMetamodelGenerator(String packageName, Path outputPath, String source, String jooqConfig) {
this.packageName = packageName;
this.outputPath = outputPath;
this.ymlSource = ymlSource;
this.source = source;
this.jooqConfig = jooqConfig;
}

Expand All @@ -43,7 +43,7 @@ private Configuration buildConfiguration() {
Generator generator = new Generator();
Database database = new Database();
database.setName(AdamDatabase.class.getName());
database.getProperties().add(new Property().withKey(AdamDatabase.YML_SOURCE_PROPERTY).withValue(ymlSource));
database.getProperties().add(new Property().withKey(AdamDatabase.SOURCE_PROPERTY).withValue(source));
generator.setDatabase(database);

Strategy strategy = new Strategy();
Expand Down

0 comments on commit 033406b

Please sign in to comment.