From a14dda6e2fe122eac3b038ea60d546171e42f0b6 Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Mon, 26 Feb 2024 11:06:14 +0100 Subject: [PATCH] Rename function to IsInsideExternalXtf --- ...java => IsInsideExternalXtfIoxPlugin.java} | 6 ++--- src/model/GeoW_FunctionsExt.ili | 2 +- .../MandatoryConstraintThis.ili | 24 +++++++++---------- .../TestData.xtf | 0 .../ch.so.agi.av.hoheitsgrenzen_excerpt.xtf | 0 .../swissBOUNDARIES3D_1_3_excerpt.xtf | 0 ... => IsInsideExternalXtfIoxPluginTest.java} | 22 ++++++++--------- 7 files changed, 27 insertions(+), 27 deletions(-) rename src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/{IsInsideExternalDatasetIoxPlugin.java => IsInsideExternalXtfIoxPlugin.java} (97%) rename src/test/data/{IsInsideExternalDataset => IsInsideExternalXtf}/MandatoryConstraintThis.ili (62%) rename src/test/data/{IsInsideExternalDataset => IsInsideExternalXtf}/TestData.xtf (100%) rename src/test/data/{IsInsideExternalDataset => IsInsideExternalXtf}/ch.so.agi.av.hoheitsgrenzen_excerpt.xtf (100%) rename src/test/data/{IsInsideExternalDataset => IsInsideExternalXtf}/swissBOUNDARIES3D_1_3_excerpt.xtf (100%) rename src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/{IsInsideExternalDatasetIoxPluginTest.java => IsInsideExternalXtfIoxPluginTest.java} (67%) diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPlugin.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalXtfIoxPlugin.java similarity index 97% rename from src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPlugin.java rename to src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalXtfIoxPlugin.java index b62dd16..8ae2356 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPlugin.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalXtfIoxPlugin.java @@ -22,12 +22,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -public final class IsInsideExternalDatasetIoxPlugin extends BaseIsInsideFunction { +public final class IsInsideExternalXtfIoxPlugin extends BaseIsInsideFunction { private static File dataDirectory; private static Map> modelFilesFromDataDirectory; private static Map> modelFilesFromJars; private static final Map VALID_AREA_CACHE = new HashMap<>(); - private static final String QUALIFIED_ILI_NAME = "GeoW_FunctionsExt.IsInsideExternalDataset"; + private static final String QUALIFIED_ILI_NAME = "GeoW_FunctionsExt.IsInsideExternalXtf"; @Override public String getQualifiedIliName() { @@ -113,7 +113,7 @@ private Collection getUrlsForModel(String model) { * @return A {@link File} representing the directory or {@code null}. */ private File getDataDirectory() { - Class pluginClass = IsInsideExternalDatasetIoxPlugin.class; + Class pluginClass = IsInsideExternalXtfIoxPlugin.class; URL resource = pluginClass.getResource(pluginClass.getSimpleName() + ".class"); if (resource == null) { logger.addEvent(logger.logErrorMsg(MessageFormat.format("{0}: Could not resolve data directory, resource is null.", this.getQualifiedIliName()))); diff --git a/src/model/GeoW_FunctionsExt.ili b/src/model/GeoW_FunctionsExt.ili index c364083..35c9593 100644 --- a/src/model/GeoW_FunctionsExt.ili +++ b/src/model/GeoW_FunctionsExt.ili @@ -32,7 +32,7 @@ MODEL GeoW_FunctionsExt !!@ fn.param = "DatasetName: Qualifizierter Name des Attributes aus dem Transfermodell, in welchem die Objekte zur Prüfung bereitliegen. Objects: Objekt(e), über die TID identifiziert, welche zur Prüfung beigezogen werden. TestObject: Objekt, welches zu prüfen ist. TestObjectgeometry: Geometriefeld, bezogen auf das unter Testobject übergebene Objekt"; !!@ fn.return = "Boolean"; !!@ fn.since = "2022-12-05"; - FUNCTION IsInsideExternalDataset (DatasetName: TEXT; Objects: TEXT; TestObject: OBJECT OF ANYCLASS; TestObjectgeometry: TEXT): BOOLEAN; + FUNCTION IsInsideExternalXtf (DatasetName: TEXT; Objects: TEXT; TestObject: OBJECT OF ANYCLASS; TestObjectgeometry: TEXT): BOOLEAN; !!@ fn.description = "Prüft, ob ein Objekt innerhalb einer gegebenen Testgeometrie liegt, welche aus einem externen Datensatz innerhalb der Ressourcen stammt. Der externe Datensatz muss sich in einer INTERLIS 2.3 Transferdatei befinden, die über den angegebenen Pfad als Ressource erreichbar ist."; !!@ fn.param = "TransferFile: Qualifizierter Name der Transferdatei-Ressource. DatasetName: Qualifizierter Name des Attributes aus dem Transfermodell, in welchem die Objekte zur Prüfung bereitliegen. Objects: Objekt(e), über die TID identifiziert, welche zur Prüfung beigezogen werden. TestObject: Objekt, welches zu prüfen ist. TestObjectgeometry: Geometriefeld, bezogen auf das unter Testobject übergebene Objekt"; diff --git a/src/test/data/IsInsideExternalDataset/MandatoryConstraintThis.ili b/src/test/data/IsInsideExternalXtf/MandatoryConstraintThis.ili similarity index 62% rename from src/test/data/IsInsideExternalDataset/MandatoryConstraintThis.ili rename to src/test/data/IsInsideExternalXtf/MandatoryConstraintThis.ili index 2d3036b..42e6dfc 100644 --- a/src/test/data/IsInsideExternalDataset/MandatoryConstraintThis.ili +++ b/src/test/data/IsInsideExternalXtf/MandatoryConstraintThis.ili @@ -24,54 +24,54 @@ MODEL TestSuite CLASS Area EXTENDS ConstraintTestClass = testAttributeArea : AREA WITH (STRAIGHTS) VERTEX CHKoord3d WITHOUT OVERLAPS > 0.001; - MANDATORY CONSTRAINT Area: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230, 9245, 9247, 9257", THIS, "testAttributeArea") == expected; + MANDATORY CONSTRAINT Area: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230, 9245, 9247, 9257", THIS, "testAttributeArea") == expected; END Area; CLASS Surface EXTENDS ConstraintTestClass = testAttributeSurface : SURFACE WITH (STRAIGHTS) VERTEX CHKoord WITHOUT OVERLAPS > 0.001; - MANDATORY CONSTRAINT Surface: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributeSurface") == expected; + MANDATORY CONSTRAINT Surface: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributeSurface") == expected; END Surface; CLASS MultiSurface EXTENDS ConstraintTestClass = testAttributeMultiSurface : MULTISURFACE WITH (STRAIGHTS) VERTEX CHKoord3d WITHOUT OVERLAPS > 0.001; - MANDATORY CONSTRAINT MultiSurface: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributeMultiSurface") == expected; + MANDATORY CONSTRAINT MultiSurface: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributeMultiSurface") == expected; END MultiSurface; CLASS Polyline3d EXTENDS ConstraintTestClass = testAttributePolyline3d : POLYLINE WITH (STRAIGHTS) VERTEX CHKoord3d; - MANDATORY CONSTRAINT Polyline3d: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributePolyline3d") == expected; + MANDATORY CONSTRAINT Polyline3d: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributePolyline3d") == expected; END Polyline3d; CLASS MultiPolyline EXTENDS ConstraintTestClass = testAttributeMultiPolyline : MULTIPOLYLINE WITH (STRAIGHTS) VERTEX CHKoord; - MANDATORY CONSTRAINT MultiPolyline: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributeMultiPolyline") == expected; + MANDATORY CONSTRAINT MultiPolyline: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributeMultiPolyline") == expected; END MultiPolyline; CLASS Point2d EXTENDS ConstraintTestClass = testAttributePoint2d : CHKoord; - MANDATORY CONSTRAINT Point2D: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributePoint2d") == expected; + MANDATORY CONSTRAINT Point2D: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributePoint2d") == expected; END Point2d; CLASS Point3d EXTENDS ConstraintTestClass = testAttributePoint3d : CHKoord3d; - MANDATORY CONSTRAINT Point3d: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributePoint3d") == expected; + MANDATORY CONSTRAINT Point3d: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributePoint3d") == expected; END Point3d; CLASS MultiCoord EXTENDS ConstraintTestClass = testAttributeMultiCoord : CHMultiKoord; - MANDATORY CONSTRAINT MultiCoord: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributeMultiCoord") == expected; + MANDATORY CONSTRAINT MultiCoord: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9230,9245,9247,9257", THIS, "testAttributeMultiCoord") == expected; END MultiCoord; CLASS IsInsideCHBaseGeometrie EXTENDS ConstraintTestClass = testAttributeIsInsideCHBaseGeometrie : CHKoord; - MANDATORY CONSTRAINT IsInsideCHBaseGeometrie: GeoW_FunctionsExt.IsInsideExternalDataset("SO_Hoheitsgrenzen_Publikation_20170626.Hoheitsgrenzen.Kantonsgrenze.Geometrie", "fubar", THIS, "testAttributeIsInsideCHBaseGeometrie") == expected; + MANDATORY CONSTRAINT IsInsideCHBaseGeometrie: GeoW_FunctionsExt.IsInsideExternalXtf("SO_Hoheitsgrenzen_Publikation_20170626.Hoheitsgrenzen.Kantonsgrenze.Geometrie", "fubar", THIS, "testAttributeIsInsideCHBaseGeometrie") == expected; END IsInsideCHBaseGeometrie; CLASS InvalidConstraints = geometryAttribute : CHKoord; - MANDATORY CONSTRAINT MalformedDatasetName: GeoW_FunctionsExt.IsInsideExternalDataset("DatasetNameWithoutQualifiedAttribute", "906645", THIS, "geometryAttribute"); - MANDATORY CONSTRAINT NonExistentDatasetName: GeoW_FunctionsExt.IsInsideExternalDataset("DoesNotExist.AwesomeTopic.AwesomeClass.NondescriptAttribute", "788070", THIS, "geometryAttribute"); - MANDATORY CONSTRAINT NonExistentTransferIds: GeoW_FunctionsExt.IsInsideExternalDataset("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9999,100000000", THIS, "geometryAttribute"); + MANDATORY CONSTRAINT MalformedDatasetName: GeoW_FunctionsExt.IsInsideExternalXtf("DatasetNameWithoutQualifiedAttribute", "906645", THIS, "geometryAttribute"); + MANDATORY CONSTRAINT NonExistentDatasetName: GeoW_FunctionsExt.IsInsideExternalXtf("DoesNotExist.AwesomeTopic.AwesomeClass.NondescriptAttribute", "788070", THIS, "geometryAttribute"); + MANDATORY CONSTRAINT NonExistentTransferIds: GeoW_FunctionsExt.IsInsideExternalXtf("swissBOUNDARIES3D_ili2_LV95_V1_3.TLM_GRENZEN.TLM_KANTONSGEBIET.Shape", "9999,100000000", THIS, "geometryAttribute"); END InvalidConstraints; END FunctionTestTopic; diff --git a/src/test/data/IsInsideExternalDataset/TestData.xtf b/src/test/data/IsInsideExternalXtf/TestData.xtf similarity index 100% rename from src/test/data/IsInsideExternalDataset/TestData.xtf rename to src/test/data/IsInsideExternalXtf/TestData.xtf diff --git a/src/test/data/IsInsideExternalDataset/ch.so.agi.av.hoheitsgrenzen_excerpt.xtf b/src/test/data/IsInsideExternalXtf/ch.so.agi.av.hoheitsgrenzen_excerpt.xtf similarity index 100% rename from src/test/data/IsInsideExternalDataset/ch.so.agi.av.hoheitsgrenzen_excerpt.xtf rename to src/test/data/IsInsideExternalXtf/ch.so.agi.av.hoheitsgrenzen_excerpt.xtf diff --git a/src/test/data/IsInsideExternalDataset/swissBOUNDARIES3D_1_3_excerpt.xtf b/src/test/data/IsInsideExternalXtf/swissBOUNDARIES3D_1_3_excerpt.xtf similarity index 100% rename from src/test/data/IsInsideExternalDataset/swissBOUNDARIES3D_1_3_excerpt.xtf rename to src/test/data/IsInsideExternalXtf/swissBOUNDARIES3D_1_3_excerpt.xtf diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPluginTest.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalXtfIoxPluginTest.java similarity index 67% rename from src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPluginTest.java rename to src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalXtfIoxPluginTest.java index 3456f6d..9502f2d 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPluginTest.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalXtfIoxPluginTest.java @@ -9,36 +9,36 @@ import java.io.File; import java.lang.reflect.Field; -class IsInsideExternalDatasetIoxPluginTest { - private static final String TEST_DATA = "IsInsideExternalDataset/TestData.xtf"; +class IsInsideExternalXtfIoxPluginTest { + private static final String TEST_DATA = "IsInsideExternalXtf/TestData.xtf"; ValidationTestHelper vh; @BeforeEach void setUp() throws NoSuchFieldException, IllegalAccessException { - IsInsideExternalDatasetIoxPlugin interlisFunction = new IsInsideExternalDatasetIoxPlugin(); + IsInsideExternalXtfIoxPlugin interlisFunction = new IsInsideExternalXtfIoxPlugin(); - Field dataDirectory = IsInsideExternalDatasetIoxPlugin.class.getDeclaredField("dataDirectory"); + Field dataDirectory = IsInsideExternalXtfIoxPlugin.class.getDeclaredField("dataDirectory"); dataDirectory.setAccessible(true); - dataDirectory.set(null, new File("src/test/data/IsInsideExternalDataset").getAbsoluteFile()); + dataDirectory.set(null, new File("src/test/data/IsInsideExternalXtf").getAbsoluteFile()); vh = new ValidationTestHelper(); vh.addFunction(interlisFunction); } @Test - void isInsideExternalDataset() throws Ili2cFailure, IoxException { - vh.runValidation(new String[]{TEST_DATA}, new String[]{"IsInsideExternalDataset/MandatoryConstraintThis.ili"}); + void isInsideExternalXtf() throws Ili2cFailure, IoxException { + vh.runValidation(new String[]{TEST_DATA}, new String[]{"IsInsideExternalXtf/MandatoryConstraintThis.ili"}); Assert.equals(6, vh.getErrs().size()); - AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "TestSuite.FunctionTestTopic.InvalidConstraints.MalformedDatasetName: Unable to evaluate GeoW_FunctionsExt.IsInsideExternalDataset. Expected qualified attribute name but got ."); - AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "TestSuite.FunctionTestTopic.InvalidConstraints.NonExistentDatasetName: Unable to evaluate GeoW_FunctionsExt.IsInsideExternalDataset. Could not find Transferfile containing model ."); - AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "TestSuite.FunctionTestTopic.InvalidConstraints.NonExistentTransferIds: Unable to evaluate GeoW_FunctionsExt.IsInsideExternalDataset. Could not find objects with TID <100000000, 9999> in transfer file"); + AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "TestSuite.FunctionTestTopic.InvalidConstraints.MalformedDatasetName: Unable to evaluate GeoW_FunctionsExt.IsInsideExternalXtf. Expected qualified attribute name but got ."); + AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "TestSuite.FunctionTestTopic.InvalidConstraints.NonExistentDatasetName: Unable to evaluate GeoW_FunctionsExt.IsInsideExternalXtf. Could not find Transferfile containing model ."); + AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "TestSuite.FunctionTestTopic.InvalidConstraints.NonExistentTransferIds: Unable to evaluate GeoW_FunctionsExt.IsInsideExternalXtf. Could not find objects with TID <100000000, 9999> in transfer file"); AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "Mandatory Constraint TestSuite.FunctionTestTopic.InvalidConstraints.MalformedDatasetName is not true."); AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "Mandatory Constraint TestSuite.FunctionTestTopic.InvalidConstraints.NonExistentDatasetName is not true."); AssertionHelper.assertLogEventsContainMessage(vh.getErrs(), "Mandatory Constraint TestSuite.FunctionTestTopic.InvalidConstraints.NonExistentTransferIds is not true."); Assert.equals(1, vh.getWarn().size()); // Interlis 2.4 XTF files do not work. - AssertionHelper.assertLogEventsContainMessage(vh.getWarn(), "GeoW_FunctionsExt.IsInsideExternalDataset: Error while reading xtf file \\S*TestData.xtf. Expected TRANSFER, but transfer found."); + AssertionHelper.assertLogEventsContainMessage(vh.getWarn(), "GeoW_FunctionsExt.IsInsideExternalXtf: Error while reading xtf file \\S*TestData.xtf. Expected TRANSFER, but transfer found."); } }