diff --git a/gretl/src/integrationTest/java/ch/so/agi/gretl/jobs/Ili2pgImportSchemaTest.java b/gretl/src/integrationTest/java/ch/so/agi/gretl/jobs/Ili2pgImportSchemaTest.java index 225cccc2..0a87999a 100644 --- a/gretl/src/integrationTest/java/ch/so/agi/gretl/jobs/Ili2pgImportSchemaTest.java +++ b/gretl/src/integrationTest/java/ch/so/agi/gretl/jobs/Ili2pgImportSchemaTest.java @@ -113,4 +113,58 @@ public void schemaImport_Options1_Ok() throws Exception { } } + @Test + public void schemaImport_MetaConfigIliData_Ok() throws Exception { + Connection con = null; + try { + GradleVariable[] gvs = {GradleVariable.newGradleProperty(IntegrationTestUtilSql.VARNAME_PG_CON_URI, postgres.getJdbcUrl())}; + IntegrationTestUtil.runJob("src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData", gvs); + + // check results + con = IntegrationTestUtilSql.connectPG(postgres); + Statement s = con.createStatement(); + ResultSet rs = s.executeQuery("SELECT setting FROM simple_table_ilidata.t_ili2db_settings WHERE tag ILIKE 'ch.ehi.ili2db.metaConfigFileName'"); + + if(!rs.next()) { + fail(); + } + + assertTrue(rs.getString(1).contains("ilidata:metaconfig_simple_table_ini_20240502")); + + if(rs.next()) { + fail(); + } + + } finally { + IntegrationTestUtilSql.closeCon(con); + } + } + + @Test + public void schemaImport_MetaConfigFile_Ok() throws Exception { + Connection con = null; + try { + GradleVariable[] gvs = {GradleVariable.newGradleProperty(IntegrationTestUtilSql.VARNAME_PG_CON_URI, postgres.getJdbcUrl())}; + IntegrationTestUtil.runJob("src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile", gvs); + + // check results + con = IntegrationTestUtilSql.connectPG(postgres); + Statement s = con.createStatement(); + ResultSet rs = s.executeQuery("SELECT setting FROM simple_table_metaconfigfile.t_ili2db_settings WHERE tag ILIKE 'ch.ehi.ili2db.metaConfigFileName'"); + + if(!rs.next()) { + fail(); + } + + assertTrue(rs.getString(1).contains("simple_table_ini_20240502.ini")); + + if(rs.next()) { + fail(); + } + + } finally { + IntegrationTestUtilSql.closeCon(con); + } + } + } diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/SimpleTable.ili b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/SimpleTable.ili new file mode 100644 index 00000000..76e35c36 --- /dev/null +++ b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/SimpleTable.ili @@ -0,0 +1,21 @@ +INTERLIS 2.3; + +MODEL SimpleTable (de) +AT "mailto:agi@bd.so.ch" +VERSION "2024-05-02" = + + DOMAIN + + LKoord = COORD 2460000.000 .. 2870000.000 [INTERLIS.M], 1045000.000 .. 1310000.000 [INTERLIS.M] ,ROTATION 2 -> 1; + + TOPIC SimpleTopic = + + CLASS Table = + Anzahl : MANDATORY 1 .. 1000; + Bezeichnung : MANDATORY MTEXT*64; + Geometrie : MANDATORY SimpleTable.LKoord; + END Table; + + END SimpleTopic; + +END SimpleTable. diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/build.gradle b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/build.gradle new file mode 100755 index 00000000..d32a5bd6 --- /dev/null +++ b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/build.gradle @@ -0,0 +1,18 @@ +import ch.so.agi.gretl.tasks.* + +apply plugin: 'ch.so.agi.gretl' + +def GRETLTEST_DBURI = 'gretltest_dburi_pg' +def db_uri = findProperty(GRETLTEST_DBURI) != null ? findProperty(GRETLTEST_DBURI) : 'jdbc:postgresql://localhost:5432/gretl' + +def db_user = "ddluser" +def db_pass = "ddluser" + +defaultTasks 'ili2pgschemaimport' + +task ili2pgschemaimport(type: Ili2pgImportSchema){ + database = [db_uri, db_user, db_pass] + dbschema = "simple_table_metaconfigfile" + modeldir = "%ILI_FROM_DB;" + rootProject.projectDir.toString() + ";https://geo.so.ch/models;http://models.interlis.ch" + metaConfig = "simple_table_ini_20240502.ini" +} \ No newline at end of file diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/settings.gradle b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/simple_table_ini_20240502.ini b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/simple_table_ini_20240502.ini new file mode 100644 index 00000000..e062f691 --- /dev/null +++ b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigFile/simple_table_ini_20240502.ini @@ -0,0 +1,24 @@ +[ch.ehi.ili2db] +models = SimpleTable +beautifyEnumDispName = True +coalesceArray = True +coalesceCatalogueRef = True +coalesceMultiLine = True +coalesceMultiPoint = True +coalesceMultiSurface = True +createBasketCol = False +createEnumTabs = True +createEnumTabsWithId = False +createNumChecks = False +createUnique = False +createFk = True +createFkIdx = True +createMetaInfo = True +createTidCol = True +createTypeConstraint = False +defaultSrsAuth = EPSG +defaultSrsCode = 2056 +expandMultilingual = True +smart2Inheritance = True +sqlEnableNull = True +strokeArcs = True \ No newline at end of file diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/SimpleTable.ili b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/SimpleTable.ili new file mode 100644 index 00000000..76e35c36 --- /dev/null +++ b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/SimpleTable.ili @@ -0,0 +1,21 @@ +INTERLIS 2.3; + +MODEL SimpleTable (de) +AT "mailto:agi@bd.so.ch" +VERSION "2024-05-02" = + + DOMAIN + + LKoord = COORD 2460000.000 .. 2870000.000 [INTERLIS.M], 1045000.000 .. 1310000.000 [INTERLIS.M] ,ROTATION 2 -> 1; + + TOPIC SimpleTopic = + + CLASS Table = + Anzahl : MANDATORY 1 .. 1000; + Bezeichnung : MANDATORY MTEXT*64; + Geometrie : MANDATORY SimpleTable.LKoord; + END Table; + + END SimpleTopic; + +END SimpleTable. diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/build.gradle b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/build.gradle new file mode 100755 index 00000000..372537ae --- /dev/null +++ b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/build.gradle @@ -0,0 +1,18 @@ +import ch.so.agi.gretl.tasks.* + +apply plugin: 'ch.so.agi.gretl' + +def GRETLTEST_DBURI = 'gretltest_dburi_pg' +def db_uri = findProperty(GRETLTEST_DBURI) != null ? findProperty(GRETLTEST_DBURI) : 'jdbc:postgresql://localhost:5432/gretl' + +def db_user = "ddluser" +def db_pass = "ddluser" + +defaultTasks 'ili2pgschemaimport' + +task ili2pgschemaimport(type: Ili2pgImportSchema){ + database = [db_uri, db_user, db_pass] + dbschema = "simple_table_ilidata" + modeldir = "%ILI_FROM_DB;" + rootProject.projectDir.toString() + ";https://geo.so.ch/models;http://models.interlis.ch" + metaConfig = "ilidata:metaconfig_simple_table_ini_20240502" +} \ No newline at end of file diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/files/simple_table_ini_20240502.ini b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/files/simple_table_ini_20240502.ini new file mode 100644 index 00000000..e062f691 --- /dev/null +++ b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/files/simple_table_ini_20240502.ini @@ -0,0 +1,24 @@ +[ch.ehi.ili2db] +models = SimpleTable +beautifyEnumDispName = True +coalesceArray = True +coalesceCatalogueRef = True +coalesceMultiLine = True +coalesceMultiPoint = True +coalesceMultiSurface = True +createBasketCol = False +createEnumTabs = True +createEnumTabsWithId = False +createNumChecks = False +createUnique = False +createFk = True +createFkIdx = True +createMetaInfo = True +createTidCol = True +createTypeConstraint = False +defaultSrsAuth = EPSG +defaultSrsCode = 2056 +expandMultilingual = True +smart2Inheritance = True +sqlEnableNull = True +strokeArcs = True \ No newline at end of file diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/ilidata.xml b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/ilidata.xml new file mode 100644 index 00000000..b2e03fe9 --- /dev/null +++ b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/ilidata.xml @@ -0,0 +1,53 @@ + + + + + + + + + + metaconfig_simple_table_ini_20240502 + 2024-02-18 + 2024-02-18 + mailto:bjsvwweb + + <DatasetIdx16.MultilingualText> + <LocalisedText> + <DatasetIdx16.LocalisedText> + <Text>simple_table_ini_20240502</Text> + </DatasetIdx16.LocalisedText> + </LocalisedText> + </DatasetIdx16.MultilingualText> + + + + + + Metaconfig file for simple_table_ini_20240502 - ('simple_table_ini_20240502', '.ini') + + + + + + + http://codes.interlis.ch/type/metaconfig + + + http://codes.interlis.ch/model/SO_AFU_Schutzbauten_20231212 + + + + + text/plain + + + files/simple_table_ini_20240502.ini + + + + + + + + \ No newline at end of file diff --git a/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/settings.gradle b/gretl/src/integrationTest/jobs/Ili2pgImportSchema_MetaConfigIliData/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/gretl/src/main/java/ch/so/agi/gretl/tasks/Ili2pgImportSchema.java b/gretl/src/main/java/ch/so/agi/gretl/tasks/Ili2pgImportSchema.java index 03ca2181..ce92d173 100644 --- a/gretl/src/main/java/ch/so/agi/gretl/tasks/Ili2pgImportSchema.java +++ b/gretl/src/main/java/ch/so/agi/gretl/tasks/Ili2pgImportSchema.java @@ -79,10 +79,10 @@ public class Ili2pgImportSchema extends Ili2pgAbstractTask { public boolean expandMultilingual = false; @Input @Optional - public boolean coalesceJson = false; + public boolean coalesceJson = false; @Input @Optional - public boolean coalesceArray = false; + public boolean coalesceArray = false; @Input @Optional public boolean createTypeConstraint = false; @@ -158,6 +158,9 @@ public class Ili2pgImportSchema extends Ili2pgAbstractTask { @Input @Optional public boolean createMetaInfo = false; + @Input + @Optional + public String metaConfig = null; @TaskAction public void importSchema() { @@ -174,12 +177,12 @@ public void importSchema() { } } settings.setXtffile(iliFilename); - + if (iliMetaAttrs != null) { String iliMetaAttrsFilename = this.getProject().file(iliMetaAttrs).getPath(); settings.setIliMetaAttrsFile(iliMetaAttrsFilename); } - + init(settings); run(function, settings); } @@ -330,5 +333,15 @@ private void init(Config settings) { if (createMetaInfo) { settings.setCreateMetaInfo(true); } + if (metaConfig != null) { + String metaConfigFile = null; + if (metaConfig.startsWith("ilidata")) { + metaConfigFile = metaConfig; + } else { + java.io.File file = this.getProject().file(metaConfig); + metaConfigFile = file.getAbsolutePath(); + } + settings.setMetaConfigFile(metaConfigFile); + } } } diff --git a/runtimeImage/start-gretl.sh b/runtimeImage/start-gretl.sh index bd22f9ef..4cea6cd8 100755 --- a/runtimeImage/start-gretl.sh +++ b/runtimeImage/start-gretl.sh @@ -41,5 +41,5 @@ docker run -i --rm \ --network="host" \ -v "$job_directory":/home/gradle/project \ --user $UID \ - sogis/gretl "-c" \ - "/usr/local/bin/run-jnlp-client > /dev/null 2>&1;cd /home/gradle/project;$gretl_cmd" \ No newline at end of file + sogis/gretl:2.4 "-c" \ + "/usr/local/bin/run-jnlp-client > /dev/null 2>&1;cd /home/gradle/project;$gretl_cmd"