-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a164bd5
commit 1c16a3d
Showing
13 changed files
with
418 additions
and
14 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
gretl/src/integrationTest/java/ch/so/agi/gretl/jobs/Ili2pgReplaceFileTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package ch.so.agi.gretl.jobs; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.Statement; | ||
import java.util.HashSet; | ||
|
||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.testcontainers.containers.PostgisContainerProvider; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
import ch.ehi.ili2db.base.DbNames; | ||
import ch.so.agi.gretl.util.GradleVariable; | ||
import ch.so.agi.gretl.util.IntegrationTestUtil; | ||
import ch.so.agi.gretl.util.IntegrationTestUtilSql; | ||
|
||
public class Ili2pgReplaceFileTest { | ||
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s"; | ||
|
||
@ClassRule | ||
public static PostgreSQLContainer postgres = | ||
(PostgreSQLContainer) new PostgisContainerProvider() | ||
.newInstance().withDatabaseName("gretl") | ||
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER) | ||
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS) | ||
.withInitScript("init_postgresql.sql") | ||
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2)); | ||
|
||
@Test | ||
public void importLocalFile_Ok() throws Exception { | ||
Connection con = null; | ||
try { | ||
GradleVariable[] gvs = {GradleVariable.newGradleProperty(IntegrationTestUtilSql.VARNAME_PG_CON_URI, postgres.getJdbcUrl())}; | ||
IntegrationTestUtil.runJob("src/integrationTest/jobs/Ili2pgReplaceFile", gvs); | ||
|
||
// check results | ||
con = IntegrationTestUtilSql.connectPG(postgres); | ||
Statement s = con.createStatement(); | ||
ResultSet rs = s.executeQuery("SELECT count(*) FROM beispiel2.boflaechen"); | ||
|
||
assertTrue(rs.next()); | ||
|
||
assertEquals(2, rs.getInt(1)); | ||
|
||
rs = s.executeQuery("SELECT "+DbNames.DATASETS_TAB_DATASETNAME+" FROM beispiel2."+DbNames.DATASETS_TAB); | ||
HashSet<String> datasets=new HashSet<String>(); | ||
while(rs.next()) { | ||
datasets.add(rs.getString(1)); | ||
} | ||
assertEquals(1, datasets.size()); | ||
assertTrue(datasets.contains("A_Dataset")); | ||
rs.close(); | ||
s.close(); | ||
|
||
} finally { | ||
IntegrationTestUtilSql.closeCon(con); | ||
} | ||
} | ||
|
||
// Nicht ganz sicher, ob es wirklich alles testet, was getestet werden soll. | ||
// Das ilidata.xml ist lokal und die Datei wird gefunden mittels ID. Soweit finde ich, | ||
// dass wohl so ziemlich das wichtige getestet wird. | ||
// Wenn man ein externes ilidata.xml verwendet, wird die Datei "richtig" | ||
// heruntergeladen. Dieser Schritt entfaellt beim lokalen ilidata.xml | ||
@Test | ||
public void importIlidataFile_Ok() throws Exception { | ||
Connection con = null; | ||
try { | ||
GradleVariable[] gvs = {GradleVariable.newGradleProperty(IntegrationTestUtilSql.VARNAME_PG_CON_URI, postgres.getJdbcUrl())}; | ||
IntegrationTestUtil.runJob("src/integrationTest/jobs/Ili2pgReplaceIlidataFile", gvs); | ||
|
||
// check results | ||
con = IntegrationTestUtilSql.connectPG(postgres); | ||
Statement s = con.createStatement(); | ||
ResultSet rs = s.executeQuery("SELECT count(*) FROM agi_av_mopublic.strassenname_pos"); | ||
|
||
assertTrue(rs.next()); | ||
|
||
assertEquals(1, rs.getInt(1)); | ||
|
||
rs = s.executeQuery("SELECT "+DbNames.DATASETS_TAB_DATASETNAME+" FROM agi_av_mopublic."+DbNames.DATASETS_TAB); | ||
HashSet<String> datasets=new HashSet<String>(); | ||
while(rs.next()) { | ||
datasets.add(rs.getString(1)); | ||
} | ||
assertEquals(1, datasets.size()); | ||
assertTrue(datasets.contains("2549")); | ||
rs.close(); | ||
s.close(); | ||
|
||
} finally { | ||
IntegrationTestUtilSql.closeCon(con); | ||
} | ||
} | ||
|
||
|
||
} |
Binary file modified
BIN
+1 Byte
(100%)
gretl/src/integrationTest/jobs/Csv2Excel/20230124_sap_Gebaeude.xlsx
Binary file not shown.
Binary file modified
BIN
+1.96 KB
(100%)
gretl/src/integrationTest/jobs/DatabaseDocumentExport/ada_ilimodels.xml.pdf
Binary file not shown.
82 changes: 82 additions & 0 deletions
82
gretl/src/integrationTest/jobs/Ili2pgReplaceFile/Beispiel2.ili
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
INTERLIS 2.3; | ||
|
||
CONTRACTED MODEL Beispiel2 | ||
AT "mailto:ceis@localhost" | ||
VERSION "2016-07-08" = | ||
|
||
DOMAIN | ||
LKoord = COORD 2480000.00 .. 2850000.00, 1060000.00 .. 1320000.00, | ||
ROTATION 2 -> 1; | ||
Art = TEXT*6; | ||
|
||
TOPIC Bodenbedeckung = | ||
|
||
CLASS GebaeudeArt = | ||
Art : MANDATORY Art; | ||
Beschreibung : MTEXT; | ||
END GebaeudeArt; | ||
|
||
CLASS BoFlaechen = | ||
Flaeche : 1.0 .. 10000.0; | ||
Art : ( | ||
Gebaeude, | ||
befestigt, | ||
humusiert, | ||
Gewaesser, | ||
bestockt, | ||
vegetationslos); | ||
Form : AREA WITH (STRAIGHTS, ARCS) VERTEX LKoord | ||
WITHOUT OVERLAPS > 0.10; | ||
END BoFlaechen; | ||
|
||
CLASS Gebaeude = | ||
END Gebaeude; | ||
|
||
ASSOCIATION GebaeudeArt2 = | ||
Art -- {1} GebaeudeArt; | ||
Gebaeude -<> {0..*} Gebaeude; | ||
END GebaeudeArt2; | ||
|
||
ASSOCIATION GebaeudeFlaeche= | ||
Flaeche -- {0..1} BoFlaechen; | ||
Gebaeude -<> {0..*} Gebaeude; | ||
END GebaeudeFlaeche; | ||
|
||
END Bodenbedeckung; | ||
|
||
TOPIC GebaeudeRegister = | ||
DEPENDS ON Bodenbedeckung; | ||
|
||
CLASS GebaeudeDetail = | ||
END GebaeudeDetail; | ||
|
||
ASSOCIATION GebaeudeDetails = | ||
Gebaeude (EXTERNAL) -<#> {1} Beispiel2.Bodenbedeckung.Gebaeude; | ||
Detail -- {0..1} GebaeudeDetail; | ||
END GebaeudeDetails; | ||
|
||
END GebaeudeRegister; | ||
|
||
END Beispiel2. | ||
|
||
MODEL Beispiel2Zusatz | ||
AT "mailto:ceis@localhost" | ||
VERSION "2016-03-29" = | ||
IMPORTS Beispiel2; | ||
|
||
|
||
VIEW TOPIC BodenbedeckungZusatz = | ||
DEPENDS ON Beispiel2.Bodenbedeckung; | ||
|
||
|
||
VIEW IndustrieGebaeude | ||
PROJECTION OF Beispiel2.Bodenbedeckung.GebaeudeArt; | ||
= | ||
ALL OF GebaeudeArt; | ||
MANDATORY CONSTRAINT INTERLIS.lenM(Beschreibung)==4; | ||
END IndustrieGebaeude; | ||
|
||
END BodenbedeckungZusatz; | ||
|
||
END Beispiel2Zusatz. | ||
|
24 changes: 24 additions & 0 deletions
24
gretl/src/integrationTest/jobs/Ili2pgReplaceFile/Beispiel2a.xtf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3"> | ||
<HEADERSECTION SENDER="ili2c-4.5.22-20160520" VERSION="2.3"><MODELS><MODEL NAME="Beispiel2" VERSION="2011-12-22" URI="http://interlis.ch"></MODEL></MODELS></HEADERSECTION> | ||
<DATASECTION> | ||
<Beispiel2.Bodenbedeckung BID="b1"> | ||
<Beispiel2.Bodenbedeckung.GebaeudeArt TID="ok1"> | ||
<Art>5</Art> | ||
</Beispiel2.Bodenbedeckung.GebaeudeArt> | ||
<Beispiel2.Bodenbedeckung.GebaeudeArt TID="ok2"> | ||
<Art>123456</Art> | ||
</Beispiel2.Bodenbedeckung.GebaeudeArt> | ||
<Beispiel2.Bodenbedeckung.GebaeudeArt TID="ok6"> | ||
<Art>5</Art> | ||
<Beschreibung>Art 5 | ||
newline </Beschreibung> | ||
</Beispiel2.Bodenbedeckung.GebaeudeArt> | ||
<Beispiel2.Bodenbedeckung.BoFlaechen TID="ok200"> | ||
<Flaeche>5</Flaeche> | ||
</Beispiel2.Bodenbedeckung.BoFlaechen> | ||
<Beispiel2.Bodenbedeckung.BoFlaechen TID="ok204"> | ||
<Art>Gebaeude</Art> | ||
</Beispiel2.Bodenbedeckung.BoFlaechen> | ||
</Beispiel2.Bodenbedeckung> | ||
</DATASECTION> | ||
</TRANSFER> |
28 changes: 28 additions & 0 deletions
28
gretl/src/integrationTest/jobs/Ili2pgReplaceFile/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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 'ili2pgimport' | ||
|
||
task ili2pgschemaimport(type: Ili2pgImportSchema){ | ||
database = [db_uri, db_user, db_pass] | ||
models = "Beispiel2" | ||
defaultSrsCode = "2056" | ||
modeldir = "%ILI_FROM_DB;"+rootProject.projectDir.toString() + ";http://models.interlis.ch" | ||
dbschema = "Beispiel2" | ||
createBasketCol = true | ||
createDatasetCol = true | ||
} | ||
|
||
task ili2pgimport(dependsOn:ili2pgschemaimport, type: Ili2pgReplace){ | ||
database = [db_uri, db_user, db_pass] | ||
dbschema = "Beispiel2" | ||
dataFile = ['Beispiel2a.xtf'] | ||
dataset = ['A_Dataset'] | ||
} |
Empty file.
29 changes: 29 additions & 0 deletions
29
gretl/src/integrationTest/jobs/Ili2pgReplaceIlidataFile/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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 'ili2pgimport' | ||
|
||
task ili2pgschemaimport(type: Ili2pgImportSchema) { | ||
database = [db_uri, db_user, db_pass] | ||
models = "SO_AGI_MOpublic_20190424" | ||
defaultSrsCode = "2056" | ||
modeldir = "%ILI_FROM_DB;"+rootProject.projectDir.toString() + ";https://geo.so.ch/models;http://models.interlis.ch" | ||
dbschema = "agi_av_mopublic" | ||
createBasketCol = true | ||
createDatasetCol = true | ||
} | ||
|
||
task ili2pgimport(dependsOn:ili2pgschemaimport, type: Ili2pgReplace) { | ||
database = [db_uri, db_user, db_pass] | ||
modeldir = "%ILI_FROM_DB;"+rootProject.projectDir.toString() + ";https://geo.so.ch/models;http://models.interlis.ch" | ||
dbschema = "agi_av_mopublic" | ||
dataFile = ['ilidata:2549.ch.so.agi.av.mopublic'] | ||
dataset = ['2549'] | ||
} |
27 changes: 27 additions & 0 deletions
27
gretl/src/integrationTest/jobs/Ili2pgReplaceIlidataFile/files/2549.ch.so.agi.av.mopublic.xtf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3"> | ||
<HEADERSECTION SENDER="ili2pg-4.9.0-eb3a0d51869bd2adeeb51fe7aba4b526fe002c1a" VERSION="2.3"> | ||
<MODELS> | ||
<MODEL NAME="SO_AGI_MOpublic_20190424" VERSION="2018-04-30" URI="http://www.geo.so.ch/models/AGI"/> | ||
</MODELS> | ||
</HEADERSECTION> | ||
<DATASECTION> | ||
<SO_AGI_MOpublic_20190424.MOpublic BID="2549"> | ||
<SO_AGI_MOpublic_20190424.MOpublic.Strassenname_Pos TID="1f59e188-21ed-4e7c-970e-96a390f0b5e0"> | ||
<Strassenname>Günsbergstrasse</Strassenname> | ||
<Pos> | ||
<COORD> | ||
<C1>2611466.841</C1> | ||
<C2>1234175.678</C2> | ||
</COORD> | ||
</Pos> | ||
<Orientierung>-76.95</Orientierung> | ||
<HAli>Center</HAli> | ||
<VAli>Half</VAli> | ||
<BFS_Nr>2549</BFS_Nr> | ||
<Importdatum>2023-10-19T22:40:04.063</Importdatum> | ||
<Nachfuehrung>2010-01-07</Nachfuehrung> | ||
</SO_AGI_MOpublic_20190424.MOpublic.Strassenname_Pos> | ||
</SO_AGI_MOpublic_20190424.MOpublic> | ||
</DATASECTION> | ||
</TRANSFER> |
84 changes: 84 additions & 0 deletions
84
gretl/src/integrationTest/jobs/Ili2pgReplaceIlidataFile/ilidata.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3"> | ||
<HEADERSECTION SENDER="SOGIS-20230218" VERSION="2.3"> | ||
<MODELS> | ||
<MODEL NAME="DatasetIdx16" VERSION="2022-10-10" URI="mailto:[email protected]"/> | ||
</MODELS> | ||
</HEADERSECTION> | ||
<DATASECTION> | ||
<IliRepository09.RepositoryIndex BID="DatasetIdx16.DataIndex"> | ||
<DatasetIdx16.DataIndex.DatasetMetadata TID="140"> | ||
<id>2549.ch.so.agi.av.mopublic</id> | ||
<version>current</version> | ||
<model> | ||
<DatasetIdx16.ModelLink> | ||
<name>SO_AGI_MOpublic_20190424</name> | ||
<locationHint>https://geo.so.ch/models</locationHint> | ||
</DatasetIdx16.ModelLink> | ||
</model> | ||
<epsgCode>2056</epsgCode> | ||
<publishingDate>2023-10-22</publishingDate> | ||
<owner>https://agi.so.ch</owner> | ||
<boundary> | ||
<DatasetIdx16.BoundingBox> | ||
<westlimit>7.340693492284002</westlimit> | ||
<southlimit>47.074299169536175</southlimit> | ||
<eastlimit>8.03269288687543</eastlimit> | ||
<northlimit>47.50119805032911</northlimit> | ||
</DatasetIdx16.BoundingBox> | ||
</boundary> | ||
<title> | ||
<DatasetIdx16.MultilingualText> | ||
<LocalisedText> | ||
<DatasetIdx16.LocalisedText> | ||
<Language>de</Language> | ||
<Text>Amtliche Vermessung (MOpublic)</Text> | ||
</DatasetIdx16.LocalisedText> | ||
</LocalisedText> | ||
</DatasetIdx16.MultilingualText> | ||
</title> | ||
<shortDescription> | ||
<DatasetIdx16.MultilingualMText> | ||
<LocalisedText> | ||
<DatasetIdx16.LocalisedMText> | ||
<Language>de</Language> | ||
<Text><![CDATA[Datenbereitstellung gemäss einem vereinfachten, kantonalen Datenmodell. <br><br> Die amtliche Vermessung hält als Bestandteil des Grundbuches die genauen Grenzverläufe der Grundstücke fest und schafft damit die Basis zur Sicherung des Grundeigentums. Nebst den aktuellen Grundstücksgrenzen sind in den Daten der amtlichen Vermessung auch weitere Objekte wie Gebäude, Strassen, Gebäudeadressen, Fixpunkte usw. abgebildet.]]></Text> | ||
</DatasetIdx16.LocalisedMText> | ||
</LocalisedText> | ||
</DatasetIdx16.MultilingualMText> | ||
</shortDescription> | ||
<technicalContact>https://agi.so.ch</technicalContact> | ||
<knownWMS> | ||
<DatasetIdx16.WebService_> | ||
<value>https://geo.so.ch/api/wms</value> | ||
</DatasetIdx16.WebService_> | ||
</knownWMS> | ||
<knownWFS> | ||
<DatasetIdx16.WebService_> | ||
<value>https://geo.so.ch/api/wfs</value> | ||
</DatasetIdx16.WebService_> | ||
</knownWFS> | ||
<furtherWS> | ||
<DatasetIdx16.WebService_> | ||
<value>https://geo.so.ch/api/data/v1</value> | ||
</DatasetIdx16.WebService_> | ||
</furtherWS> | ||
<knownPortal> | ||
<DatasetIdx16.WebSite_> | ||
<value>https://geo.so.ch/map?l=ch.so.agi.av.grundstuecke</value> | ||
</DatasetIdx16.WebSite_> | ||
</knownPortal> | ||
<files> | ||
<DatasetIdx16.DataFile> | ||
<fileFormat>application/interlis+xml;version=2.3</fileFormat> | ||
<file> | ||
<DatasetIdx16.File> | ||
<path>files/2549.ch.so.agi.av.mopublic.xtf</path> | ||
</DatasetIdx16.File> | ||
</file> | ||
</DatasetIdx16.DataFile> | ||
</files> | ||
</DatasetIdx16.DataIndex.DatasetMetadata> | ||
</IliRepository09.RepositoryIndex> | ||
</DATASECTION> | ||
</TRANSFER> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.