Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for parameter metaConfig #162

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
INTERLIS 2.3;

MODEL SimpleTable (de)
AT "mailto:[email protected]"
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.
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
INTERLIS 2.3;

MODEL SimpleTable (de)
AT "mailto:[email protected]"
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.
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?><TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3">
<HEADERSECTION SENDER="SOGIS-INTERLIS-REPOSITORY-CREATOR" VERSION="2.3">
<MODELS>
<MODEL NAME="DatasetIdx16" VERSION="2022-10-10" URI="mailto:[email protected]"></MODEL>
</MODELS>
</HEADERSECTION>
<DATASECTION>
<DatasetIdx16.DataIndex BID="b1">
<DatasetIdx16.DataIndex.DatasetMetadata TID="037f8229-ac14-42de-a299-81038f229790">
<id>metaconfig_simple_table_ini_20240502</id>
<version>2024-02-18</version>
<publishingDate>2024-02-18</publishingDate>
<owner>mailto:bjsvwweb</owner>
<title>
<DatasetIdx16.MultilingualText>
<LocalisedText>
<DatasetIdx16.LocalisedText>
<Text>simple_table_ini_20240502</Text>
</DatasetIdx16.LocalisedText>
</LocalisedText>
</DatasetIdx16.MultilingualText>
</title>
<shortDescription>
<DatasetIdx16.MultilingualMText>
<LocalisedText>
<DatasetIdx16.LocalisedMText>
<Text>Metaconfig file for simple_table_ini_20240502 - ('simple_table_ini_20240502', '.ini')</Text>
</DatasetIdx16.LocalisedMText>
</LocalisedText>
</DatasetIdx16.MultilingualMText>
</shortDescription>
<categories>
<DatasetIdx16.Code_>
<value>http://codes.interlis.ch/type/metaconfig</value>
</DatasetIdx16.Code_>
<DatasetIdx16.Code_>
<value>http://codes.interlis.ch/model/SO_AFU_Schutzbauten_20231212</value>
</DatasetIdx16.Code_>
</categories>
<files>
<DatasetIdx16.DataFile>
<fileFormat>text/plain</fileFormat>
<file>
<DatasetIdx16.File>
<path>files/simple_table_ini_20240502.ini</path>
</DatasetIdx16.File>
</file>
</DatasetIdx16.DataFile>
</files>
</DatasetIdx16.DataIndex.DatasetMetadata>
</DatasetIdx16.DataIndex>
</DATASECTION>
</TRANSFER>
21 changes: 17 additions & 4 deletions gretl/src/main/java/ch/so/agi/gretl/tasks/Ili2pgImportSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
}
}
4 changes: 2 additions & 2 deletions runtimeImage/start-gretl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
sogis/gretl:2.4 "-c" \
"/usr/local/bin/run-jnlp-client > /dev/null 2>&1;cd /home/gradle/project;$gretl_cmd"
Loading