Skip to content

Commit

Permalink
Replace operation:insertion with operation:injection (#778)
Browse files Browse the repository at this point in the history
Change-Id: I0c6212b3cb3a24a3a969fa9aea0bcd09e8a204ee
  • Loading branch information
margaretha committed Nov 27, 2024
1 parent d0f4af8 commit 9d82046
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <br/><br/>
* KorAP differentiates 3 kinds of access:
Expand All @@ -36,14 +35,12 @@
* </ul>
*
* 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 {
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/de/ids_mannheim/korap/rewrite/KoralNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
}
Expand Down Expand Up @@ -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)");
}
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand All @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/network-output/search-result.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{
"@type": "koral:rewrite",
"src": "Kustvakt",
"operation": "operation:insertion",
"operation": "operation:injection",
"scope": "availability(FREE)"
}
]
Expand Down

0 comments on commit 9d82046

Please sign in to comment.