From 9d820463f986f4509af1ceb4108d17e97898c7f3 Mon Sep 17 00:00:00 2001 From: margaretha Date: Mon, 25 Nov 2024 16:11:57 +0100 Subject: [PATCH] Replace operation:insertion with operation:injection (#778) Change-Id: I0c6212b3cb3a24a3a969fa9aea0bcd09e8a204ee --- Changes | 3 ++- .../korap/rewrite/CollectionRewrite.java | 7 ++----- .../de/ids_mannheim/korap/rewrite/KoralNode.java | 13 +++++++++++-- .../korap/rewrite/VirtualCorpusRewrite.java | 3 ++- .../de/ids_mannheim/korap/config/TestVariables.java | 2 +- .../korap/rewrite/VirtualCorpusRewriteTest.java | 6 +++--- .../korap/web/controller/AvailabilityTest.java | 8 ++++---- .../korap/web/controller/SearchControllerTest.java | 12 ++++++------ .../korap/web/controller/SearchPipeTest.java | 2 +- .../web/controller/SearchPublicMetadataTest.java | 2 +- .../controller/vc/VirtualCorpusReferenceTest.java | 2 +- .../resources/network-output/search-result.jsonld | 2 +- 12 files changed, 35 insertions(+), 27 deletions(-) diff --git a/Changes b/Changes index 06cc8b4c..43009a8f 100644 --- a/Changes +++ b/Changes @@ -3,7 +3,8 @@ - Add institution & landingPage to the resource web-service (#777) - Make URL mandatory for plugin registration (#573) - Remove hidden group from test database -- Implemented QueryContextRewrite (#755) +- Implemented QueryContextRewrite (#755) +- Replace operation:insertion with operation:injection (#778) # version 0.75 diff --git a/src/main/java/de/ids_mannheim/korap/rewrite/CollectionRewrite.java b/src/main/java/de/ids_mannheim/korap/rewrite/CollectionRewrite.java index 56b00928..970efdde 100644 --- a/src/main/java/de/ids_mannheim/korap/rewrite/CollectionRewrite.java +++ b/src/main/java/de/ids_mannheim/korap/rewrite/CollectionRewrite.java @@ -24,8 +24,7 @@ /** * CollectionRewrite determines which availability field values are - * possible for a user with respect to his mean and location of - * access. + * possible for a user with respect to login and location of access. * *

* KorAP differentiates 3 kinds of access: @@ -36,14 +35,12 @@ * * * Each of these accesses corresponds to a regular expression of - * license - * formats defined in kustvakt.conf. For a given access, only those + * license formats defined in kustvakt.conf. For a given access, only those * resources whose availability field matches its regular expression * are allowed to be retrieved. * * * @author margaretha - * @last-update 21 Nov 2017 * @see CorpusAccess */ public class CollectionRewrite implements RewriteTask.RewriteQuery { diff --git a/src/main/java/de/ids_mannheim/korap/rewrite/KoralNode.java b/src/main/java/de/ids_mannheim/korap/rewrite/KoralNode.java index 0893820b..52eb5dcc 100644 --- a/src/main/java/de/ids_mannheim/korap/rewrite/KoralNode.java +++ b/src/main/java/de/ids_mannheim/korap/rewrite/KoralNode.java @@ -114,6 +114,10 @@ public void replaceAt (String path, Object value, RewriteIdentifier ident) { } } + // EM: we agree to use injection instead because it has been introduced to + // public in several occasions. + // This method is similar to put + @Deprecated public void set (String name, Object value, RewriteIdentifier ident) { if (this.node.isObject()) { ObjectNode n = (ObjectNode) this.node; @@ -127,7 +131,7 @@ else if (value instanceof JsonNode) if (ident != null) name = ident.toString(); - this.rewrites.add("insertion", name); + this.rewrites.add("injection", name); } } @@ -136,7 +140,7 @@ public void setAll (ObjectNode other) { ObjectNode n = (ObjectNode) this.node; n.setAll(other); } - this.rewrites.add("insertion", null); + this.rewrites.add("injection", null); } public String get (String name) { @@ -173,6 +177,11 @@ public static class RewriteIdentifier { private String scope, value; private Object source; + public RewriteIdentifier (String scope) { + this.scope = scope; + } + + @Deprecated public RewriteIdentifier (String scope, String value) { this.scope = scope; this.value = value; diff --git a/src/main/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewrite.java b/src/main/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewrite.java index 3a64df9a..2fe7502c 100644 --- a/src/main/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewrite.java +++ b/src/main/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewrite.java @@ -102,7 +102,8 @@ private void removeOwner (String koralQuery, String vcOwner, koralNode.remove("ref", new RewriteIdentifier("ref", ref)); ref = ref.substring(vcOwner.length() + 1, ref.length()); - koralNode.set("ref", ref, new RewriteIdentifier("ref", ref)); + koralNode.put("ref", ref); +// koralNode.set("ref", ref, new RewriteIdentifier("ref", ref)); } private void rewriteVC (QueryDO vc, KoralNode koralNode) diff --git a/src/test/java/de/ids_mannheim/korap/config/TestVariables.java b/src/test/java/de/ids_mannheim/korap/config/TestVariables.java index e4658cee..b29d9473 100644 --- a/src/test/java/de/ids_mannheim/korap/config/TestVariables.java +++ b/src/test/java/de/ids_mannheim/korap/config/TestVariables.java @@ -44,7 +44,7 @@ public class TestVariables { + "\t\t}],\n" + "\t\t\"rewrites\": [{\n" + "\t\t\t\"@type\": \"koral:rewrite\",\n" + "\t\t\t\"src\": \"Kustvakt\",\n" - + "\t\t\t\"operation\": \"operation:insertion\",\n" + + "\t\t\t\"operation\": \"operation:injection\",\n" + "\t\t\t\"scope\": \"corpusSigle\"\n" + "\t\t}]\n" + "\t},\n" + "\t\"matches\": [{\n" + "\t\t\"field\": \"tokens\",\n" + "\t\t\"textClass\": \"wissenschaft populaerwissenschaft\",\n" diff --git a/src/test/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewriteTest.java b/src/test/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewriteTest.java index f35096c8..b3a308f3 100644 --- a/src/test/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewriteTest.java +++ b/src/test/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewriteTest.java @@ -70,7 +70,7 @@ private void testRefCachedVCWithUsername () node = node.at("/operands/1/rewrites"); assertEquals(2, node.size()); assertEquals(node.at("/0/operation").asText(), "operation:deletion"); - assertEquals(node.at("/1/operation").asText(), "operation:insertion"); + assertEquals(node.at("/1/operation").asText(), "operation:injection"); } @Test @@ -91,7 +91,7 @@ public void testRewriteFreeAndSystemVCRef () assertEquals(3, node.size()); assertEquals(node.at("/0/operation").asText(), "operation:deletion"); assertEquals(node.at("/1/operation").asText(), "operation:deletion"); - assertEquals(node.at("/2/operation").asText(), "operation:insertion"); + assertEquals(node.at("/2/operation").asText(), "operation:injection"); } @Test @@ -111,7 +111,7 @@ public void testRewritePubAndSystemVCRef () throws KustvaktException { assertEquals(3, node.size()); assertEquals(node.at("/0/operation").asText(), "operation:deletion"); assertEquals(node.at("/1/operation").asText(), "operation:deletion"); - assertEquals(node.at("/2/operation").asText(), "operation:insertion"); + assertEquals(node.at("/2/operation").asText(), "operation:injection"); } @Test diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java index 4ad3ba34..4cc98b04 100644 --- a/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java +++ b/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java @@ -26,7 +26,7 @@ private void checkAndFree (String json) throws KustvaktException { assertEquals(node.at("/collection/operands/0/value").asText(), "CC.*"); assertEquals(node.at("/collection/rewrites/0/operation").asText(), - "operation:insertion"); + "operation:injection"); assertEquals(node.at("/collection/rewrites/0/scope").asText(), "availability(FREE)"); } @@ -63,7 +63,7 @@ private void checkAndPublic (String json) throws KustvaktException { .asText(), "QAO-NC"); assertEquals(node.at("/collection/rewrites/0/operation").asText(), - "operation:insertion"); + "operation:injection"); assertEquals(node.at("/collection/rewrites/0/scope").asText(), "availability(PUB)"); } @@ -74,7 +74,7 @@ private void checkAndPublicWithACA (String json) throws KustvaktException { assertEquals(node.at("/collection/operation").asText(), "operation:and"); assertEquals(node.at("/collection/rewrites/0/operation").asText(), - "operation:insertion"); + "operation:injection"); assertEquals(node.at("/collection/rewrites/0/scope").asText(), "availability(PUB)"); assertEquals(node.at("/collection/operands/1/match").asText(), @@ -104,7 +104,7 @@ private void checkAndAllWithACA (String json) throws KustvaktException { assertEquals(node.at("/collection/operation").asText(), "operation:and"); assertEquals(node.at("/collection/rewrites/0/operation").asText(), - "operation:insertion"); + "operation:injection"); assertEquals(node.at("/collection/rewrites/0/scope").asText(), "availability(ALL)"); assertEquals(node.at("/collection/operands/1/match").asText(), diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java index 181ec65a..132f6b0a 100644 --- a/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java +++ b/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java @@ -120,7 +120,7 @@ public void testSearchQueryPublicCorpora () throws KustvaktException { assertEquals("CC.*", node.at("/collection/value").asText()); assertEquals("availability(FREE)", node.at("/collection/rewrites/0/scope").asText()); - assertEquals("operation:insertion", + assertEquals("operation:injection", node.at("/collection/rewrites/0/operation").asText()); } @@ -183,7 +183,7 @@ public void testSearchQueryFreeExtern () throws KustvaktException { assertEquals("CC.*", node.at("/collection/value").asText()); assertEquals("availability(FREE)", node.at("/collection/rewrites/0/scope").asText()); - assertEquals("operation:insertion", + assertEquals("operation:injection", node.at("/collection/rewrites/0/operation").asText()); } @@ -203,7 +203,7 @@ public void testSearchQueryFreeIntern () throws KustvaktException { assertEquals("CC.*", node.at("/collection/value").asText()); assertEquals("availability(FREE)", node.at("/collection/rewrites/0/scope").asText()); - assertEquals("operation:insertion", + assertEquals("operation:injection", node.at("/collection/rewrites/0/operation").asText()); } @@ -232,7 +232,7 @@ public void testSearchQueryExternAuthorized () throws KustvaktException { assertEquals("operation:or", node.at("/collection/operation").asText()); assertEquals("availability(PUB)", node.at("/collection/rewrites/0/scope").asText()); - assertEquals("operation:insertion", + assertEquals("operation:injection", node.at("/collection/rewrites/0/operation").asText()); } @@ -264,7 +264,7 @@ public void testSearchQueryInternAuthorized () throws KustvaktException { assertEquals("operation:or", node.at("/collection/operation").asText()); assertEquals("availability(ALL)", node.at("/collection/rewrites/0/scope").asText()); - assertEquals("operation:insertion", + assertEquals("operation:injection", node.at("/collection/rewrites/0/operation").asText()); } @@ -327,7 +327,7 @@ public void testSearchQueryWithCollectionQueryAuthorizedWithoutIP () assertEquals(Status.OK.getStatusCode(), response.getStatus()); JsonNode node = JsonUtils.readTree(response.readEntity(String.class)); assertNotNull(node); - assertEquals("operation:insertion", + assertEquals("operation:injection", node.at("/collection/rewrites/0/operation").asText()); assertEquals("availability(FREE)", node.at("/collection/rewrites/0/scope").asText()); diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/SearchPipeTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/SearchPipeTest.java index 03a019ef..39f1cf9d 100644 --- a/src/test/java/de/ids_mannheim/korap/web/controller/SearchPipeTest.java +++ b/src/test/java/de/ids_mannheim/korap/web/controller/SearchPipeTest.java @@ -117,7 +117,7 @@ public void testSearchWithPipes () assertEquals(2, node.at("/query/wrap/key").size()); assertEquals(1, node.at("/collection/rewrites").size()); assertEquals(node.at("/collection/rewrites/0/operation").asText(), - "operation:insertion"); + "operation:injection"); assertEquals(node.at("/collection/rewrites/0/scope").asText(), "availability(FREE)"); node = node.at("/query/wrap/rewrites"); diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/SearchPublicMetadataTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/SearchPublicMetadataTest.java index aeec05e8..cd5e6175 100644 --- a/src/test/java/de/ids_mannheim/korap/web/controller/SearchPublicMetadataTest.java +++ b/src/test/java/de/ids_mannheim/korap/web/controller/SearchPublicMetadataTest.java @@ -131,7 +131,7 @@ public void testSearchPublicMetadataWithSystemVC () "operation:deletion"); assertEquals(node.at("/rewrites/1/scope").asText(), "ref(system-vc)"); assertEquals(node.at("/rewrites/2/operation").asText(), - "operation:insertion"); + "operation:injection"); } @Test diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusReferenceTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusReferenceTest.java index 6b908e96..76377a2a 100644 --- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusReferenceTest.java +++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusReferenceTest.java @@ -193,7 +193,7 @@ public void testSearchWithRefPublishedVcGuest () throws KustvaktException { assertEquals(node.at("/0/scope").asText(), "@type(koral:docGroupRef)"); assertEquals(node.at("/1/operation").asText(), "operation:deletion"); assertEquals(node.at("/1/scope").asText(), "ref(marlin/published-vc)"); - assertEquals(node.at("/2/operation").asText(), "operation:insertion"); + assertEquals(node.at("/2/operation").asText(), "operation:injection"); } @Test diff --git a/src/test/resources/network-output/search-result.jsonld b/src/test/resources/network-output/search-result.jsonld index 2c364fd3..0dbf8558 100644 --- a/src/test/resources/network-output/search-result.jsonld +++ b/src/test/resources/network-output/search-result.jsonld @@ -64,7 +64,7 @@ { "@type": "koral:rewrite", "src": "Kustvakt", - "operation": "operation:insertion", + "operation": "operation:injection", "scope": "availability(FREE)" } ]