From 76572615ccddc282216944f838fa2b6099b09e91 Mon Sep 17 00:00:00 2001
From: larsbengel <77848869+larsbengel@users.noreply.github.com>
Date: Sun, 14 Jun 2026 22:35:52 +0200
Subject: [PATCH 01/14] some new stuff for serialisation web interface
---
.../SerialisationCalleeFactory.java | 4 ++
.../serialisation/SerialisationFactory.java | 39 +++++++++++++++++++
.../SerialisationInfoResponse.java | 4 ++
.../serialisation/SerialisationPost.java | 4 ++
.../serialisation/SerialisationResponse.java | 4 ++
5 files changed, 55 insertions(+)
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationCalleeFactory.java
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationFactory.java
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationInfoResponse.java
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationPost.java
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationResponse.java
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationCalleeFactory.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationCalleeFactory.java
new file mode 100644
index 000000000..ce5984633
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationCalleeFactory.java
@@ -0,0 +1,4 @@
+package org.tweetyproject.web.services.serialisation;
+
+public class SerialisationCalleeFactory {
+}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationFactory.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationFactory.java
new file mode 100644
index 000000000..d249434af
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationFactory.java
@@ -0,0 +1,39 @@
+package org.tweetyproject.web.services.serialisation;
+
+public class SerialisationFactory {
+
+ public enum Command {
+ GET_REDUCT("get_reduct", "Get Reduct for the given state"),
+ IS_TERMINAL("is_terminal", "Determine whether the given state is terminal"),
+ GET_SELECTION("get_selection", "Get the selectable initial sets of the state");
+
+ /** ID of the command */
+ public final String id;
+ /** Label of the command */
+ public final String label;
+
+ /**
+ * Constructor for Command enum.
+ *
+ * @param id ID of the command
+ * @param label Label of the command
+ */
+ Command(String id, String label) {
+ this.id = id;
+ this.label = label;
+ }
+
+ /**
+ * Retrieves the Command enum based on the provided ID.
+ *
+ * @param id ID of the command
+ * @return The corresponding Command enum, or null if not found
+ */
+ public static Command getCommand(String id) {
+ for (Command m : Command.values())
+ if (m.id.equals(id))
+ return m;
+ return null;
+ }
+ }
+}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationInfoResponse.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationInfoResponse.java
new file mode 100644
index 000000000..7174db814
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationInfoResponse.java
@@ -0,0 +1,4 @@
+package org.tweetyproject.web.services.serialisation;
+
+public class SerialisationInfoResponse {
+}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationPost.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationPost.java
new file mode 100644
index 000000000..b71be7d8a
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationPost.java
@@ -0,0 +1,4 @@
+package org.tweetyproject.web.services.serialisation;
+
+public class SerialisationPost {
+}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationResponse.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationResponse.java
new file mode 100644
index 000000000..533f19c4e
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationResponse.java
@@ -0,0 +1,4 @@
+package org.tweetyproject.web.services.serialisation;
+
+public class SerialisationResponse {
+}
From a91813f7bcaf8ec1249b3830d4edff3786967bff Mon Sep 17 00:00:00 2001
From: larsbengel <77848869+larsbengel@users.noreply.github.com>
Date: Mon, 15 Jun 2026 00:26:42 +0200
Subject: [PATCH 02/14] added web interface for serialisability
---
.../web/services/RequestController.java | 106 +++++
.../SerialisationCalleeFactory.java | 111 +++++
.../serialisation/SerialisationFactory.java | 123 +++--
.../SerialisationGetModelsCallee.java | 49 ++
.../SerialisationGetReductCallee.java | 53 +++
.../SerialisationGetSelectionCallee.java | 64 +++
.../SerialisationGetSequencesCallee.java | 56 +++
.../SerialisationInfoResponse.java | 277 ++++++++++-
.../SerialisationIsTerminalCallee.java | 60 +++
.../serialisation/SerialisationPost.java | 215 ++++++++-
.../serialisation/SerialisationResponse.java | 446 +++++++++++++++++-
.../RequestControllerSerialisationTest.java | 338 +++++++++++++
12 files changed, 1865 insertions(+), 33 deletions(-)
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetModelsCallee.java
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetReductCallee.java
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetSelectionCallee.java
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetSequencesCallee.java
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationIsTerminalCallee.java
create mode 100644 org-tweetyproject-web/src/test/java/org/tweetyproject/web/services/RequestControllerSerialisationTest.java
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
index 81a1b77a8..c1a48e8b0 100644
--- a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
@@ -51,6 +51,9 @@
import org.tweetyproject.arg.bipolar.syntax.BipolarArgumentationFramework;
import org.tweetyproject.arg.dung.reasoner.IncompleteReasoner;
import org.tweetyproject.arg.dung.semantics.Semantics;
+import org.tweetyproject.arg.dung.serialisability.semantics.SerialisationSequence;
+import org.tweetyproject.arg.dung.serialisability.syntax.SelectionFunction;
+import org.tweetyproject.arg.dung.serialisability.syntax.TerminationFunction;
import org.tweetyproject.arg.dung.syntax.Argument;
import org.tweetyproject.arg.dung.syntax.Attack;
import org.tweetyproject.arg.dung.syntax.DungTheory;
@@ -129,6 +132,7 @@
import org.tweetyproject.arg.dung.semantics.Extension;
import javafx.util.Pair;
+import org.tweetyproject.web.services.serialisation.*;
import javax.validation.Valid;
import java.util.logging.Level;
@@ -1452,4 +1456,106 @@ private PafServicesInfoResponse getPafInfo(String email) {
response.setSolvers(AbstractPafReasonerFactory.getSolvers());
return response;
}
+
+ /**
+ * Handles HTTP POST requests for Serialisation operations.
+ *
+ *
Supported commands:
+ *
+ *
{@code info} – return supported commands and functions
+ *
{@code get_reduct} – compute the reduct for the given AF and extension
+ *
{@code get_selection} – get the selectable initial sets for the given AF and selection function
+ *
{@code is_terminal} – determine whether the given AF and extension are a terminal state according to the termination function
+ *
+ *
+ * @param serPost the request payload
+ * @return a {@link Response} containing the computed result or service info
+ */
+ @PostMapping(value = "/serialisation", produces = "application/json", consumes = "application/json")
+ @ResponseBody
+ public Response handleRequest(@RequestBody SerialisationPost serPost) {
+ if (serPost.getCmd().equals("info"))
+ return getSerInfo(serPost.getEmail());
+
+ SerialisationCalleeFactory.Command cmd = SerialisationCalleeFactory.Command.getCommand(serPost.getCmd());
+ if (cmd == null)
+ return new SerialisationResponse();
+
+ DungTheory theory = AbstractExtensionReasonerFactory.getDungTheory(
+ serPost.getNr_of_arguments(),
+ serPost.getAttacks());
+ Extension extension = SerialisationFactory.getExtension(serPost.getExtension());
+ SelectionFunction alpha = SerialisationFactory.getSelectionFunction(serPost.getSelectionFunction());
+ TerminationFunction beta = SerialisationFactory.getTerminationFunction(serPost.getTerminationFunction());
+ Callee callee = SerialisationCalleeFactory.getCallee(cmd, alpha, beta, theory, extension);
+
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ SerialisationResponse reasonerResponse = new SerialisationResponse(
+ serPost.getCmd(), serPost.getEmail(), serPost.getNr_of_arguments(), serPost.getAttacks(),
+ serPost.getExtension(), serPost.getSelectionFunction(),
+ serPost.getTerminationFunction(), null, 0,
+ serPost.getUnit_timeout(), "ERROR");
+ TimeUnit unit = Utils.getTimeoutUnit(serPost.getUnit_timeout());
+ int user_timeout = Utils.checkUserTimeout(serPost.getTimeout(), SERVICES_TIMEOUT_DUNG, unit);
+ try {
+ String result_str;
+ switch (cmd) {
+ case GET_SEQUENCES -> {
+ Future> future = executor.submit(callee);
+ Pair, Long> result = Utils.runServicesWithTimeout(future, user_timeout, unit);
+ result_str = result.getKey().toString();
+ } case GET_REDUCT -> {
+ Future future = executor.submit(callee);
+ Pair result = Utils.runServicesWithTimeout(future, user_timeout, unit);
+ result_str = result.getKey().toString();
+ } case IS_TERMINAL -> {
+ Future future = executor.submit(callee);
+ Pair result = Utils.runServicesWithTimeout(future, user_timeout, unit);
+ result_str = result.getKey().toString();
+ } case GET_SELECTION,GET_MODELS -> {
+ Future>> future = executor.submit(callee);
+ Pair>, Long> result = Utils.runServicesWithTimeout(future, user_timeout, unit);
+ result_str = result.getKey().toString();
+ } default -> throw new IllegalArgumentException("unknown command " + cmd);
+
+ /*
+
+ */
+
+ }
+ // TODO update result type; need to make distinction here i guess
+ Future future = executor.submit(callee);
+ Pair result = Utils.runServicesWithTimeout(future, user_timeout, unit);
+ executor.shutdownNow();
+ reasonerResponse.setAnswer(result_str);
+ reasonerResponse.setTime(result.getValue());
+ reasonerResponse.setStatus("SUCCESS");
+ } catch (TimeoutException e) {
+ reasonerResponse.setTime(serPost.getTimeout());
+ reasonerResponse.setAnswer(null);
+ reasonerResponse.setStatus("TIMEOUT");
+ executor.shutdownNow();
+ } catch (Exception e) {
+ reasonerResponse.setTime(0.0);
+ reasonerResponse.setAnswer(null);
+ reasonerResponse.setStatus("Error");
+ executor.shutdownNow();
+ }
+ return reasonerResponse;
+ }
+
+ private SerialisationInfoResponse getSerInfo(String email) {
+ SerialisationInfoResponse response = new SerialisationInfoResponse();
+ response.setReply("info");
+ response.setEmail(email);
+ response.setBackend_timeout(SERVICES_TIMEOUT_DUNG);
+ response.setSelectionFunctions(SerialisationFactory.getSelectionFunctions());
+ response.setTerminationFunctions(SerialisationFactory.getTerminationFunction());
+ SerialisationCalleeFactory.Command[] com = SerialisationCalleeFactory.getCommands();
+ ArrayList command_ids = new ArrayList<>();
+ for (SerialisationCalleeFactory.Command c : com)
+ command_ids.add(c.id);
+ response.setCommands(command_ids);
+ return response;
+ }
}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationCalleeFactory.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationCalleeFactory.java
index ce5984633..2fde191f0 100644
--- a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationCalleeFactory.java
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationCalleeFactory.java
@@ -1,4 +1,115 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
package org.tweetyproject.web.services.serialisation;
+import org.tweetyproject.arg.dung.semantics.Extension;
+import org.tweetyproject.arg.dung.serialisability.syntax.SelectionFunction;
+import org.tweetyproject.arg.dung.serialisability.syntax.TerminationFunction;
+import org.tweetyproject.arg.dung.syntax.DungTheory;
+import org.tweetyproject.web.services.Callee;
+
+/**
+ * The SerialisationCalleeFactory class is responsible for creating instances of Callee
+ * based on the specified Command, DungTheory, Extension, Selection and termination function parameters.
+ * It also defines an enumeration of commands with associated IDs and labels.
+ */
public class SerialisationCalleeFactory {
+ /**
+ * Enumeration of commands supported by the factory, each with a unique ID and label.
+ */
+ public enum Command {
+
+ /** get reduct */
+ GET_REDUCT("get_reduct", "Get Reduct for the given state"),
+ /** is the state terminal */
+ IS_TERMINAL("is_terminal", "Determine whether the given state is terminal"),
+ /** get selection of initial sets */
+ GET_SELECTION("get_selection", "Get the selectable initial sets of the state"),
+ /** get models */
+ GET_MODELS("get_models", "Get the extensions for the given functions"),
+ /** get sequences */
+ GET_SEQUENCES("get_sequences", "Get all serialisation sequences for the given functions");
+
+ /** ID of the command */
+ public final String id;
+ /** Label of the command */
+ public final String label;
+
+ /**
+ * Constructor for Command enum.
+ *
+ * @param id ID of the command
+ * @param label Label of the command
+ */
+ Command(String id, String label) {
+ this.id = id;
+ this.label = label;
+ }
+
+ /**
+ * Retrieves the Command enum based on the provided ID.
+ *
+ * @param id ID of the command
+ * @return The corresponding Command enum, or null if not found
+ */
+ public static Command getCommand(String id) {
+ for (Command m : Command.values())
+ if (m.id.equals(id))
+ return m;
+ return null;
+ }
+ }
+
+ /**
+ * Retrieves an array of all available Command enums.
+ *
+ * @return An array of Command enums
+ */
+ public static Command[] getCommands() {
+ return Command.values();
+ }
+
+ /**
+ * Creates and returns a Callee instance based on the provided Command, AbstractExtensionReasoner,
+ * and DungTheory parameters.
+ *
+ * @param cmd The command to be executed
+ * @param alpha The selection function
+ * @param beta The termination function
+ * @param bbase The DungTheory to be processed
+ * @param extension The extension to be processed
+ * @return A Callee instance corresponding to the specified command
+ * @throws RuntimeException If the specified command is not found
+ */
+ public static Callee getCallee(Command cmd, SelectionFunction alpha, TerminationFunction beta, DungTheory bbase, Extension extension) {
+ switch (cmd) {
+ case GET_REDUCT -> {
+ return new SerialisationGetReductCallee(bbase, extension);
+ } case IS_TERMINAL -> {
+ return new SerialisationIsTerminalCallee(bbase, extension, beta);
+ } case GET_SELECTION -> {
+ return new SerialisationGetSelectionCallee(bbase, alpha);
+ } case GET_MODELS -> {
+ return new SerialisationGetModelsCallee(bbase, alpha, beta);
+ } case GET_SEQUENCES -> {
+ return new SerialisationGetSequencesCallee(bbase, alpha, beta);
+ } default -> throw new RuntimeException("Command not found: " + cmd);
+ }
+ }
}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationFactory.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationFactory.java
index d249434af..a0a7d4720 100644
--- a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationFactory.java
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationFactory.java
@@ -1,39 +1,104 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
package org.tweetyproject.web.services.serialisation;
-public class SerialisationFactory {
+import org.tweetyproject.arg.dung.semantics.Extension;
+import org.tweetyproject.arg.dung.serialisability.syntax.SelectionFunction;
+import org.tweetyproject.arg.dung.serialisability.syntax.TerminationFunction;
+import org.tweetyproject.arg.dung.syntax.Argument;
+import org.tweetyproject.arg.dung.syntax.DungTheory;
- public enum Command {
- GET_REDUCT("get_reduct", "Get Reduct for the given state"),
- IS_TERMINAL("is_terminal", "Determine whether the given state is terminal"),
- GET_SELECTION("get_selection", "Get the selectable initial sets of the state");
+import java.util.List;
- /** ID of the command */
- public final String id;
- /** Label of the command */
- public final String label;
+/**
+ * Main factory for retrieving serialisation related things
+ *
+ * @author Lars Bengel
+ */
+public class SerialisationFactory {
+ /**
+ * parses an extension from a list of integers
+ * @param extension extension as a list on integers
+ * @return the parsed extension
+ */
+ public static Extension getExtension(List extension) {
+ if (extension==null) return null;
+ Extension result = new Extension<>();
+ for (Integer i : extension) {
+ result.add(new Argument(Integer.toString(i)));
+ }
+ return result;
+ }
- /**
- * Constructor for Command enum.
- *
- * @param id ID of the command
- * @param label Label of the command
- */
- Command(String id, String label) {
- this.id = id;
- this.label = label;
+ /**
+ * determine the selection function
+ * @param selectionFunction string id of selection functions
+ * @return the selection function
+ */
+ public static SelectionFunction getSelectionFunction(String selectionFunction) {
+ if (selectionFunction==null) return null;
+ switch (selectionFunction) {
+ case "ADM" -> {
+ return SelectionFunction.ADMISSIBLE;
+ } case "UC" -> {
+ return SelectionFunction.UNCHALLENGED;
+ } case "GR" -> {
+ return SelectionFunction.GROUNDED;
+ } default -> throw new IllegalArgumentException("unknown selection function " + selectionFunction);
}
+ }
- /**
- * Retrieves the Command enum based on the provided ID.
- *
- * @param id ID of the command
- * @return The corresponding Command enum, or null if not found
- */
- public static Command getCommand(String id) {
- for (Command m : Command.values())
- if (m.id.equals(id))
- return m;
- return null;
+ /**
+ * get all available selection functions
+ * @return the selection functions
+ */
+ public static List getSelectionFunctions() {
+ return List.of("ADM", "UC", "GR");
+ }
+
+ /**
+ * determine the termination function
+ * @param terminationFunction string idf of termination function
+ * @return the termination function
+ */
+ public static TerminationFunction getTerminationFunction(String terminationFunction) {
+ if (terminationFunction==null) return null;
+ switch (terminationFunction) {
+ case "ADM" -> {
+ return TerminationFunction.ADMISSIBLE;
+ } case "UC" -> {
+ return TerminationFunction.UNCHALLENGED;
+ } case "CO" -> {
+ return TerminationFunction.COMPLETE;
+ } case "PR" -> {
+ return TerminationFunction.PREFERRED;
+ } case "ST" -> {
+ return TerminationFunction.STABLE;
+ } default -> throw new IllegalArgumentException("unknown selection function " + terminationFunction);
}
}
+
+ /**
+ * get all available termination functions
+ * @return the termination functions
+ */
+ public static List getTerminationFunction() {
+ return List.of("ADM", "CO", "UC", "PR", "ST");
+ }
}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetModelsCallee.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetModelsCallee.java
new file mode 100644
index 000000000..5505fb4c6
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetModelsCallee.java
@@ -0,0 +1,49 @@
+package org.tweetyproject.web.services.serialisation;
+
+import org.tweetyproject.arg.dung.reasoner.SerialisedExtensionReasoner;
+import org.tweetyproject.arg.dung.semantics.Extension;
+import org.tweetyproject.arg.dung.serialisability.syntax.SelectionFunction;
+import org.tweetyproject.arg.dung.serialisability.syntax.TerminationFunction;
+import org.tweetyproject.arg.dung.syntax.DungTheory;
+import org.tweetyproject.web.services.Callee;
+
+import java.util.Collection;
+
+/**
+ * Callee for the getModels operation of the SerialisedExtensionReasoner for the given selection and termination functions
+ */
+public class SerialisationGetModelsCallee extends Callee {
+ /** The DungTheory on which the evaluation is performed */
+ private final DungTheory bbase;
+
+ /** The selection function to use */
+ private final SelectionFunction selectionFunction;
+
+ /** The termination function to use */
+ private final TerminationFunction terminationFunction;
+
+ /**
+ * Constructs a new SerialisationGetModelsCallee with the specified DungTheory and functions.
+ *
+ * @param bbase The base DungTheory on which the serialisation is performed
+ * @param alpha The selection function to be used
+ * @param beta The termination function to be used
+ */
+ public SerialisationGetModelsCallee(DungTheory bbase, SelectionFunction alpha, TerminationFunction beta) {
+ this.bbase = bbase;
+ this.selectionFunction = alpha;
+ this.terminationFunction = beta;
+ }
+
+ /**
+ * Executes the getModels operation using the specified DungTheory the fitting serialised reasoner.
+ *
+ * @return the set of models
+ * @throws Exception If an error occurs during the getModels operation
+ */
+ @Override
+ public Collection> call() throws Exception {
+ SerialisedExtensionReasoner reasoner = new SerialisedExtensionReasoner(this.selectionFunction, this.terminationFunction);
+ return reasoner.getModels(this.bbase);
+ }
+}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetReductCallee.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetReductCallee.java
new file mode 100644
index 000000000..aff4f6357
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetReductCallee.java
@@ -0,0 +1,53 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
+package org.tweetyproject.web.services.serialisation;
+
+import org.tweetyproject.arg.dung.semantics.Extension;
+import org.tweetyproject.arg.dung.syntax.DungTheory;
+import org.tweetyproject.web.services.Callee;
+
+public class SerialisationGetReductCallee extends Callee {
+ /** The Extension used for obtaining the reduct */
+ private final Extension extension;
+
+ /** The DungTheory on which the getReduct operation is performed */
+ private final DungTheory bbase;
+
+ /**
+ * Constructs a new SerialisationGetReductCallee with the specified DungTheory and Extension.
+ *
+ * @param bbase The base DungTheory on which the getReduct operation is performed
+ * @param extension The extension by which the getReduct operation is performed
+ */
+ public SerialisationGetReductCallee(DungTheory bbase, Extension extension) {
+ this.extension = extension;
+ this.bbase = bbase;
+ }
+
+ /**
+ * Executes the getReduct operation using the specified extension and base DungTheory.
+ *
+ * @return The Reduct
+ * @throws Exception If an error occurs during the getReduct operation
+ */
+ @Override
+ public DungTheory call() throws Exception {
+ return this.bbase.getReduct(this.extension);
+ }
+}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetSelectionCallee.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetSelectionCallee.java
new file mode 100644
index 000000000..7f2ce26b9
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetSelectionCallee.java
@@ -0,0 +1,64 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
+package org.tweetyproject.web.services.serialisation;
+
+import org.tweetyproject.arg.dung.reasoner.SimpleInitialReasoner;
+import org.tweetyproject.arg.dung.semantics.Extension;
+import org.tweetyproject.arg.dung.serialisability.syntax.SelectionFunction;
+import org.tweetyproject.arg.dung.syntax.DungTheory;
+import org.tweetyproject.web.services.Callee;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+
+import static org.tweetyproject.arg.dung.reasoner.SimpleInitialReasoner.Initial.*;
+
+public class SerialisationGetSelectionCallee extends Callee {
+ /** The DungTheory on which the selection function is performed */
+ private final DungTheory bbase;
+
+ /** The selection function to use */
+ private final SelectionFunction selectionFunction;
+
+ /**
+ * Constructs a new SerialisationGetSelectionCallee with the specified DungTheory and Selection function.
+ *
+ * @param bbase The base DungTheory on which the termination status is checked
+ * @param alpha The selection function to be used
+ */
+ public SerialisationGetSelectionCallee(DungTheory bbase, SelectionFunction alpha) {
+ this.bbase = bbase;
+ this.selectionFunction = alpha;
+ }
+
+ /**
+ * Executes the getSelection operation using the specified DungTheory and selection function.
+ *
+ * @return the set of selectable initial sets
+ * @throws Exception If an error occurs during the getSelection operation
+ */
+ @Override
+ public Collection> call() throws Exception {
+ Map>> initialSets = SimpleInitialReasoner
+ .partitionInitialSets(this.bbase);
+ return this.selectionFunction.execute(new HashSet<>(initialSets.get(UA)), new HashSet<>(initialSets.get(UC)),
+ new HashSet<>(initialSets.get(C)));
+ }
+}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetSequencesCallee.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetSequencesCallee.java
new file mode 100644
index 000000000..09a989181
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationGetSequencesCallee.java
@@ -0,0 +1,56 @@
+package org.tweetyproject.web.services.serialisation;
+
+import org.tweetyproject.arg.dung.reasoner.SerialisedExtensionReasoner;
+import org.tweetyproject.arg.dung.semantics.Extension;
+import org.tweetyproject.arg.dung.serialisability.semantics.SerialisationSequence;
+import org.tweetyproject.arg.dung.serialisability.syntax.SelectionFunction;
+import org.tweetyproject.arg.dung.serialisability.syntax.TerminationFunction;
+import org.tweetyproject.arg.dung.syntax.DungTheory;
+import org.tweetyproject.web.services.Callee;
+
+import java.util.Collection;
+
+/**
+ * Callee for the getSequences operation of the SerialisedExtensionReasoner for the given selection and termination functions
+ */
+public class SerialisationGetSequencesCallee extends Callee {
+ /**
+ * The DungTheory on which the evaluation is performed
+ */
+ private final DungTheory bbase;
+
+ /**
+ * The selection function to use
+ */
+ private final SelectionFunction selectionFunction;
+
+ /**
+ * The termination function to use
+ */
+ private final TerminationFunction terminationFunction;
+
+ /**
+ * Constructs a new SerialisationGetSequencesCallee with the specified DungTheory and functions.
+ *
+ * @param bbase The base DungTheory on which the serialisation is performed
+ * @param alpha The selection function to be used
+ * @param beta The termination function to be used
+ */
+ public SerialisationGetSequencesCallee(DungTheory bbase, SelectionFunction alpha, TerminationFunction beta) {
+ this.bbase = bbase;
+ this.selectionFunction = alpha;
+ this.terminationFunction = beta;
+ }
+
+ /**
+ * Executes the getSequences operation using the specified DungTheory the fitting serialised reasoner.
+ *
+ * @return the set of sequences
+ * @throws Exception If an error occurs during the getSequences operation
+ */
+ @Override
+ public Collection call() throws Exception {
+ SerialisedExtensionReasoner reasoner = new SerialisedExtensionReasoner(this.selectionFunction, this.terminationFunction);
+ return reasoner.getSequences(this.bbase);
+ }
+}
\ No newline at end of file
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationInfoResponse.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationInfoResponse.java
index 7174db814..46a8ea542 100644
--- a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationInfoResponse.java
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationInfoResponse.java
@@ -1,4 +1,279 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
package org.tweetyproject.web.services.serialisation;
-public class SerialisationInfoResponse {
+import java.util.List;
+import java.util.Objects;
+
+import org.tweetyproject.web.services.Response;
+
+
+/**
+ * The SerialisationInfoResponse class extends the Response class and represents
+ * a response containing information about Dung argumentation services.
+ */
+public class SerialisationInfoResponse extends Response {
+
+ /** The reply message in the Serialisation info response */
+ private String reply;
+
+ /** The email associated with the Serialisation info response */
+ private String email;
+
+ /** The backend timeout value specified in the Serialisation info response */
+ private int backend_timeout;
+
+ /** The list of supported selection functions in the Serialisation info response */
+ private List selectionFunctions;
+
+ /** The list of supported termination functions in the Serialisation info response */
+ private List terminationFunctions;
+
+ /** The list of supported commands in the Serialisation info response */
+ private List commands;
+
+ /**
+ * Default constructor for SerialisationInfoResponse.
+ */
+ public SerialisationInfoResponse() {
+ }
+
+ /**
+ * Parameterized constructor for SerialisationInfoResponse.
+ *
+ * @param reply The reply message
+ * @param email The email associated with the response
+ * @param backend_timeout The backend timeout value
+ * @param selectionFunctions The list of supported selection functions
+ * @param terminationFunctions The list of supported termination functions
+ * @param commands The list of supported commands
+ */
+ public SerialisationInfoResponse(String reply, String email, int backend_timeout, List selectionFunctions, List terminationFunctions, List commands) {
+ this.reply = reply;
+ this.email = email;
+ this.backend_timeout = backend_timeout;
+ this.selectionFunctions = selectionFunctions;
+ this.terminationFunctions = terminationFunctions;
+ this.commands = commands;
+ }
+
+ /**
+ * Gets the reply message associated with this response.
+ *
+ * @return The current reply message as a string.
+ */
+ public String getReply() {
+ return this.reply;
+ }
+
+ /**
+ * Sets the reply message for this response.
+ *
+ * @param reply The reply message to set.
+ */
+ public void setReply(String reply) {
+ this.reply = reply;
+ }
+
+ /**
+ * Gets the email address associated with this response.
+ *
+ * @return The email address as a string.
+ */
+ public String getEmail() {
+ return this.email;
+ }
+
+ /**
+ * Sets the email address for this response.
+ *
+ * @param email The email address to set.
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * Gets the backend timeout setting for the service.
+ *
+ * @return The backend timeout in integer form.
+ */
+ public int getBackend_timeout() {
+ return this.backend_timeout;
+ }
+
+ /**
+ * Sets the backend timeout for the service.
+ *
+ * @param backend_timeout The backend timeout value in seconds.
+ */
+ public void setBackend_timeout(int backend_timeout) {
+ this.backend_timeout = backend_timeout;
+ }
+
+ /**
+ * Gets the list of selection functions associated with the service.
+ *
+ * @return A list of selection functions as strings.
+ */
+ public List getSelectionFunctions() {
+ return this.selectionFunctions;
+ }
+
+ /**
+ * Gets the list of termination functions associated with the service.
+ *
+ * @return A list of termination functions as strings.
+ */
+ public List getTerminationFunctions() {
+ return this.terminationFunctions;
+ }
+
+ /**
+ * Gets the list of commands associated with the service.
+ *
+ * @return A list of commands as strings.
+ */
+ public List getCommands() {
+ return this.commands;
+ }
+
+ /**
+ * Sets the list of commands for the service.
+ *
+ * @param commands A list of command strings to be utilized by the service.
+ */
+ public void setCommands(List commands) {
+ this.commands = commands;
+ }
+
+ /**
+ * Sets the list of selectionFunctions for the service.
+ *
+ * @param selectionFunctions A list of command strings to be utilized by the service.
+ */
+ public void setSelectionFunctions(List selectionFunctions) {
+ this.selectionFunctions = selectionFunctions;
+ }
+
+ /**
+ * Sets the list of terminationFunctions for the service.
+ *
+ * @param terminationFunctions A list of command strings to be utilized by the service.
+ */
+ public void setTerminationFunctions(List terminationFunctions) {
+ this.terminationFunctions = terminationFunctions;
+ }
+
+ // Fluent setters
+
+ /**
+ * Sets the reply message and returns this instance for method chaining.
+ *
+ * @param reply The reply message to set.
+ * @return This instance to facilitate further modifications.
+ */
+ public SerialisationInfoResponse reply(String reply) {
+ setReply(reply);
+ return this;
+ }
+
+ /**
+ * Sets the email address and returns this instance for method chaining.
+ *
+ * @param email The email address to set.
+ * @return This instance to facilitate further modifications.
+ */
+ public SerialisationInfoResponse email(String email) {
+ setEmail(email);
+ return this;
+ }
+
+ /**
+ * Sets the backend timeout and returns this instance for method chaining.
+ *
+ * @param backend_timeout The backend timeout in seconds to set.
+ * @return This instance to facilitate further modifications.
+ */
+ public SerialisationInfoResponse backend_timeout(int backend_timeout) {
+ setBackend_timeout(backend_timeout);
+ return this;
+ }
+
+ /**
+ * Sets the selectionFunctions and returns this instance for method chaining.
+ *
+ * @param selectionFunctions A list of selectionFunctions strings to set.
+ * @return This instance to facilitate further modifications.
+ */
+ public SerialisationInfoResponse selectionFunctions(List selectionFunctions) {
+ setSelectionFunctions(selectionFunctions);
+ return this;
+ }
+
+ /**
+ * Sets the terminationFunctions and returns this instance for method chaining.
+ *
+ * @param terminationFunctions A list of terminationFunctions strings to set.
+ * @return This instance to facilitate further modifications.
+ */
+ public SerialisationInfoResponse terminationFunctions(List terminationFunctions) {
+ setTerminationFunctions(terminationFunctions);
+ return this;
+ }
+
+ /**
+ * Sets the commands and returns this instance for method chaining.
+ *
+ * @param commands A list of command strings to set.
+ * @return This instance to facilitate further modifications.
+ */
+ public SerialisationInfoResponse commands(List commands) {
+ setCommands(commands);
+ return this;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof SerialisationInfoResponse)) {
+ return false;
+ }
+ SerialisationInfoResponse infoResponse = (SerialisationInfoResponse) o;
+ return Objects.equals(reply, infoResponse.reply) && Objects.equals(email, infoResponse.email) && backend_timeout == infoResponse.backend_timeout && Objects.equals(selectionFunctions, infoResponse.selectionFunctions) && Objects.equals(terminationFunctions, infoResponse.terminationFunctions) && Objects.equals(commands, infoResponse.commands);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(reply, email, backend_timeout, selectionFunctions, terminationFunctions, commands);
+ }
+
+ @Override
+ public String toString() {
+ return "{" +
+ " reply='" + getReply() + "'" +
+ ", email='" + getEmail() + "'" +
+ ", backend_timeout='" + getBackend_timeout() + "'" +
+ ", selectionFunctions='" + getSelectionFunctions() + "'" +
+ ", terminationFunctions='" + getTerminationFunctions() + "'" +
+ ", commands='" + getCommands() + "'" +
+ "}";
+ }
}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationIsTerminalCallee.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationIsTerminalCallee.java
new file mode 100644
index 000000000..b34d24bae
--- /dev/null
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationIsTerminalCallee.java
@@ -0,0 +1,60 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
+package org.tweetyproject.web.services.serialisation;
+
+import org.tweetyproject.arg.dung.semantics.Extension;
+import org.tweetyproject.arg.dung.serialisability.syntax.TerminationFunction;
+import org.tweetyproject.arg.dung.syntax.DungTheory;
+import org.tweetyproject.web.services.Callee;
+
+public class SerialisationIsTerminalCallee extends Callee {
+
+ /** The Extension used for obtaining the termination status */
+ private final Extension extension;
+
+ /** The DungTheory on which the termination function is performed */
+ private final DungTheory bbase;
+
+ /** The termination function to use */
+ private final TerminationFunction terminationFunction;
+
+ /**
+ * Constructs a new SerialisationIsTerminalCallee with the specified DungTheory, Extension and Termination function.
+ *
+ * @param bbase The base DungTheory on which the termination status is checked
+ * @param extension The extension by which the termination function is tested
+ * @param beta The termination function to be used
+ */
+ public SerialisationIsTerminalCallee(DungTheory bbase, Extension extension, TerminationFunction beta) {
+ this.bbase = bbase;
+ this.extension = extension;
+ this.terminationFunction = beta;
+ }
+
+ /**
+ * Executes the isTerminal operation using the specified extension and DungTheory by the termination function.
+ *
+ * @return "true" if the given state is terminal
+ * @throws Exception If an error occurs during the isTerminal operation
+ */
+ @Override
+ public Boolean call() throws Exception {
+ return this.terminationFunction.execute(this.bbase, this.extension);
+ }
+}
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationPost.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationPost.java
index b71be7d8a..d622b1591 100644
--- a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationPost.java
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationPost.java
@@ -1,4 +1,217 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
package org.tweetyproject.web.services.serialisation;
+import java.util.List;
+
+/**
+ * The SerialisationPost class represents a data structure for holding information
+ * related to a serialisation request sent via HTTP POST.
+ */
public class SerialisationPost {
-}
+
+ /** The command type for the serialisation request */
+ private String cmd;
+
+ /** The email associated with the serialisation request */
+ private String email;
+
+ /** The number of arguments in the serialisation request */
+ private int nr_of_arguments;
+
+ /** The attacks information in the serialisation request */
+ private List> attacks;
+
+ /** The extension in the serialisation request */
+ private List extension;
+
+ /** The selection function specified in the serialisation request */
+ private String selectionFunction;
+
+ /** The termination function specified in the serialisation request */
+ private String terminationFunction;
+
+ /** The timeout value (in seconds) specified in the serialisation request */
+ private int timeout;
+
+ /** The unit timeout value specified in the serialisation request */
+ private String unit_timeout;
+
+ /**
+ * Gets the unit timeout value specified in the serialisation request.
+ *
+ * @return The unit timeout value
+ */
+ public String getUnit_timeout() {
+ return unit_timeout;
+ }
+
+ /**
+ * Sets the unit timeout value in the serialisation request.
+ *
+ * @param unit_timeout The unit timeout value to be set
+ */
+ public void setUnit_timeout(String unit_timeout) {
+ this.unit_timeout = unit_timeout;
+ }
+
+ /**
+ * Gets the command type in the serialisation request.
+ *
+ * @return The command type
+ */
+ public String getCmd() {
+ return this.cmd;
+ }
+
+ /**
+ * Sets the command type in the serialisation request.
+ *
+ * @param cmd The command type to be set
+ */
+ public void setCmd(String cmd) {
+ this.cmd = cmd;
+ }
+
+ /**
+ * Gets the email associated with the serialisation request.
+ *
+ * @return The email associated with the request
+ */
+ public String getEmail() {
+ return this.email;
+ }
+
+ /**
+ * Sets the email associated with the serialisation request.
+ *
+ * @param email The email to be set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * Gets the number of arguments in the serialisation request.
+ *
+ * @return The number of arguments
+ */
+ public int getNr_of_arguments() {
+ return this.nr_of_arguments;
+ }
+
+ /**
+ * Sets the number of arguments in the serialisation request.
+ *
+ * @param nr_of_arguments The number of arguments to be set
+ */
+ public void setNr_of_arguments(int nr_of_arguments) {
+ this.nr_of_arguments = nr_of_arguments;
+ }
+
+ /**
+ * Gets the attacks information in the serialisation request.
+ *
+ * @return The attacks information
+ */
+ public List> getAttacks() {
+ return this.attacks;
+ }
+
+ /**
+ * Sets the attacks information in the serialisation request.
+ *
+ * @param attacks The attacks information to be set
+ */
+ public void setAttacks(List> attacks) {
+ this.attacks = attacks;
+ }
+
+ /**
+ * Gets the extension in the serialisation request.
+ *
+ * @return The extension
+ */
+ public List getExtension() {
+ return this.extension;
+ }
+
+ /**
+ * Sets the extension in the serialisation request.
+ *
+ * @param extension The extension to be set
+ */
+ public void setExtension(List extension) {
+ this.extension = extension;
+ }
+
+ /**
+ * Gets the selection function specified in the serialisation request.
+ *
+ * @return The selection function specified
+ */
+ public String getSelectionFunction() {
+ return this.selectionFunction;
+ }
+
+ /**
+ * Sets the selection function in the serialisation request.
+ *
+ * @param selectionFunction The selection function to be set
+ */
+ public void setSelectionFunction(String selectionFunction) {
+ this.selectionFunction = selectionFunction;
+ }
+
+ /**
+ * Gets the termination function specified in the serialisation request.
+ *
+ * @return The termination function specified
+ */
+ public String getTerminationFunction() {
+ return this.terminationFunction;
+ }
+
+ /**
+ * Sets the termination function in the serialisation request.
+ *
+ * @param terminationFunction The termination function to be set
+ */
+ public void setTerminationFunction(String terminationFunction) {
+ this.terminationFunction = terminationFunction;
+ }
+
+ /**
+ * Gets the timeout value (in seconds) specified in the serialisation request.
+ *
+ * @return The timeout value
+ */
+ public int getTimeout() {
+ return this.timeout;
+ }
+
+ /**
+ * Sets the timeout value (in seconds) in the serialisation request.
+ *
+ * @param timeout The timeout value to be set
+ */
+ public void setTimeout(int timeout) {
+ this.timeout = timeout;
+ }
+}
\ No newline at end of file
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationResponse.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationResponse.java
index 533f19c4e..6784913c3 100644
--- a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationResponse.java
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/serialisation/SerialisationResponse.java
@@ -1,4 +1,446 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
package org.tweetyproject.web.services.serialisation;
-public class SerialisationResponse {
-}
+import java.util.List;
+import java.util.Objects;
+
+import org.tweetyproject.web.services.Response;
+
+/**
+ * The SerialisationResponse class extends the Response class and represents
+ * a response containing information related to a serialisation
+ * result.
+ */
+public class SerialisationResponse extends Response {
+
+ /** The reply message in the serialisation response */
+ private String reply;
+
+ /** The email associated with the serialisation response */
+ private String email;
+
+ /** The number of arguments in the serialisation response */
+ private int nr_of_arguments;
+
+ /** The attacks information in the serialisation response */
+ private List> attacks;
+
+ /** The extension in the serialisation response */
+ private List extension;
+
+ /** The selection function specified in the serialisation response */
+ private String selectionFunction;
+
+ /** The termination function specified in the serialisation response */
+ private String terminationFunction;
+
+ /** The answer provided by the serialisation response */
+ private String answer;
+
+ /** The time taken for the serialisation operation (in seconds) */
+ private double time;
+
+ /** The unit time specified in the serialisation response */
+ private String unit_time;
+
+ /** The status of the serialisation response */
+ private String status;
+
+ /**
+ * Default constructor for SerialisationResponse.
+ */
+ public SerialisationResponse() {
+ }
+
+ /**
+ * Parameterized constructor for SerialisationResponse.
+ *
+ * @param reply The reply message
+ * @param email The email associated with the response
+ * @param nr_of_arguments The number of arguments
+ * @param attacks The attacks information
+ * @param extension The extension
+ * @param selectionFunction The semantics specified
+ * @param terminationFunction The solver specified
+ * @param answer The answer provided
+ * @param time The time taken for the operation
+ * @param unit_time The unit time specified
+ * @param status The status of the response
+ */
+ public SerialisationResponse(String reply, String email, int nr_of_arguments, List> attacks, List extension,
+ String selectionFunction, String terminationFunction, String answer, double time, String unit_time, String status) {
+ this.reply = reply;
+ this.email = email;
+ this.nr_of_arguments = nr_of_arguments;
+ this.attacks = attacks;
+ this.extension = extension;
+ this.selectionFunction = selectionFunction;
+ this.terminationFunction = terminationFunction;
+ this.answer = answer;
+ this.time = time;
+ this.unit_time = unit_time;
+ this.status = status;
+ }
+
+ /**
+ * Gets the reply message in the serialisation response.
+ *
+ * @return The reply message in the serialisation response.
+ */
+ public String getReply() {
+ return reply;
+ }
+
+ /**
+ * Sets the reply message in the serialisation response.
+ *
+ * @param reply The reply message in the serialisation response.
+ */
+ public void setReply(String reply) {
+ this.reply = reply;
+ }
+
+ /**
+ * Gets the email associated with the serialisation response.
+ *
+ * @return The email associated with the serialisation response.
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * Sets the email associated with the serialisation response.
+ *
+ * @param email The email associated with the serialisation response.
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * Gets the number of arguments in the serialisation response.
+ *
+ * @return The number of arguments in the serialisation response.
+ */
+ public int getNr_of_arguments() {
+ return nr_of_arguments;
+ }
+
+ /**
+ * Sets the number of arguments in the serialisation response.
+ *
+ * @param nr_of_arguments The number of arguments in the serialisation response.
+ */
+ public void setNr_of_arguments(int nr_of_arguments) {
+ this.nr_of_arguments = nr_of_arguments;
+ }
+
+ /**
+ * Gets the attacks information in the serialisation response.
+ *
+ * @return The attacks information in the serialisation response.
+ */
+ public List> getAttacks() {
+ return attacks;
+ }
+
+ /**
+ * Sets the attacks information in the serialisation response.
+ *
+ * @param attacks The attacks information in the serialisation response.
+ */
+ public void setAttacks(List> attacks) {
+ this.attacks = attacks;
+ }
+
+ /**
+ * Gets the extension in the serialisation response.
+ *
+ * @return The extension in the serialisation response.
+ */
+ public List getExtension() {
+ return extension;
+ }
+
+ /**
+ * Sets the extension in the serialisation response.
+ *
+ * @param extension The extension in the serialisation response.
+ */
+ public void setExtension(List extension) {
+ this.extension = extension;
+ }
+
+ /**
+ * Gets the selection function specified in the serialisation response.
+ *
+ * @return The selection function specified in the serialisation response.
+ */
+ public String getSelectionFunction() {
+ return selectionFunction;
+ }
+
+ /**
+ * Sets the selection function specified in the serialisation response.
+ *
+ * @param selectionFunction The selection function specified in the serialisation response.
+ */
+ public void setSelectionFunction(String selectionFunction) {
+ this.selectionFunction = selectionFunction;
+ }
+
+ /**
+ * Gets the termination function specified in the serialisation response.
+ *
+ * @return The termination function specified in the serialisation response.
+ */
+ public String getTerminationFunction() {
+ return terminationFunction;
+ }
+
+ /**
+ * Sets the termination function specified in the serialisation response.
+ *
+ * @param terminationFunction The termination function specified in the serialisation response.
+ */
+ public void setTerminationFunction(String terminationFunction) {
+ this.terminationFunction = terminationFunction;
+ }
+
+ /**
+ * Gets the answer provided by the serialisation response.
+ *
+ * @return The answer provided by the serialisation response.
+ */
+ public String getAnswer() {
+ return answer;
+ }
+
+ /**
+ * Sets the answer provided by the serialisation response.
+ *
+ * @param answer The answer provided by the serialisation response.
+ */
+ public void setAnswer(String answer) {
+ this.answer = answer;
+ }
+
+ /**
+ * Gets the time taken for the serialisation operation (in seconds).
+ *
+ * @return The time taken for the serialisation operation (in seconds).
+ */
+ public double getTime() {
+ return time;
+ }
+
+ /**
+ * Sets the time taken for the serialisation operation (in seconds).
+ *
+ * @param time The time taken for the serialisation operation (in seconds).
+ */
+ public void setTime(double time) {
+ this.time = time;
+ }
+
+ /**
+ * Gets the unit time specified in the serialisation response.
+ *
+ * @return The unit time specified in the serialisation response.
+ */
+ public String getUnit_time() {
+ return unit_time;
+ }
+
+ /**
+ * Sets the unit time specified in the serialisation response.
+ *
+ * @param unit_time The unit time specified in the serialisation response.
+ */
+ public void setUnit_time(String unit_time) {
+ this.unit_time = unit_time;
+ }
+
+ /**
+ * Gets the status of the serialisation response.
+ *
+ * @return The status of the serialisation response.
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status of the serialisation response.
+ *
+ * @param status The status of the serialisation response.
+ */
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ * Sets the reply message in the serialisation response.
+ *
+ * @param reply The reply message in the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse reply(String reply) {
+ setReply(reply);
+ return this;
+ }
+
+ /**
+ * Sets the email associated with the serialisation response.
+ *
+ * @param email The email associated with the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse email(String email) {
+ setEmail(email);
+ return this;
+ }
+
+ /**
+ * Sets the number of arguments in the serialisation response.
+ *
+ * @param nr_of_arguments The number of arguments in the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse nr_of_arguments(int nr_of_arguments) {
+ setNr_of_arguments(nr_of_arguments);
+ return this;
+ }
+
+ /**
+ * Sets the attacks information in the serialisation response.
+ *
+ * @param attacks The attacks information in the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse attacks(List> attacks) {
+ setAttacks(attacks);
+ return this;
+ }
+
+ /**
+ * Sets the extension in the serialisation response.
+ *
+ * @param extension The extension in the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse extension(List extension) {
+ setExtension(extension);
+ return this;
+ }
+
+ /**
+ * Sets the selection function specified in the serialisation response.
+ *
+ * @param selectionFunction The selection function specified in the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse selectionFunction(String selectionFunction) {
+ setSelectionFunction(selectionFunction);
+ return this;
+ }
+
+ /**
+ * Sets the termination function specified in the serialisation response.
+ *
+ * @param terminationFunction The termination function specified in the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse terminationFunction(String terminationFunction) {
+ setTerminationFunction(terminationFunction);
+ return this;
+ }
+
+ /**
+ * Sets the answer provided by the serialisation response.
+ *
+ * @param answer The answer provided by the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse answer(String answer) {
+ setAnswer(answer);
+ return this;
+ }
+
+ /**
+ * Sets the time taken for the serialisation operation (in seconds).
+ *
+ * @param time The time taken for the serialisation operation (in seconds).
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse time(int time) {
+ setTime(time);
+ return this;
+ }
+
+ /**
+ * Sets the status of the serialisation response.
+ *
+ * @param status The status of the serialisation response.
+ * @return The current instance of SerialisationResponse.
+ */
+ public SerialisationResponse status(String status) {
+ setStatus(status);
+ return this;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof SerialisationResponse)) {
+ return false;
+ }
+ SerialisationResponse tweetyResponse = (SerialisationResponse) o;
+ return Objects.equals(reply, tweetyResponse.reply) && Objects.equals(email, tweetyResponse.email)
+ && nr_of_arguments == tweetyResponse.nr_of_arguments && Objects.equals(attacks, tweetyResponse.attacks) && Objects.equals(extension, tweetyResponse.extension)
+ && Objects.equals(selectionFunction, tweetyResponse.selectionFunction) && Objects.equals(terminationFunction, tweetyResponse.terminationFunction)
+ && Objects.equals(answer, tweetyResponse.answer) && time == tweetyResponse.time
+ && Objects.equals(status, tweetyResponse.status);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(reply, email, nr_of_arguments, attacks, selectionFunction, terminationFunction, answer, time, status);
+ }
+
+ @Override
+ public String toString() {
+ return "{" +
+ " reply='" + getReply() + "'" +
+ ", email='" + getEmail() + "'" +
+ ", nr_of_arguments='" + getNr_of_arguments() + "'" +
+ ", attacks='" + getAttacks() + "'" +
+ ", extension='" + getExtension() + "'" +
+ ", selectionFunction='" + getSelectionFunction() + "'" +
+ ", terminationFunction='" + getTerminationFunction() + "'" +
+ ", answer='" + getAnswer() + "'" +
+ ", time='" + getTime() + "'" +
+ ", status='" + getStatus() + "'" +
+ "}";
+ }
+
+}
\ No newline at end of file
diff --git a/org-tweetyproject-web/src/test/java/org/tweetyproject/web/services/RequestControllerSerialisationTest.java b/org-tweetyproject-web/src/test/java/org/tweetyproject/web/services/RequestControllerSerialisationTest.java
new file mode 100644
index 000000000..2290e2cbe
--- /dev/null
+++ b/org-tweetyproject-web/src/test/java/org/tweetyproject/web/services/RequestControllerSerialisationTest.java
@@ -0,0 +1,338 @@
+/*
+ * This file is part of "TweetyProject", a collection of Java libraries for
+ * logical aspects of artificial intelligence and knowledge representation.
+ *
+ * TweetyProject is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2026 The TweetyProject Team
+ */
+package org.tweetyproject.web.services;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.tweetyproject.arg.dung.semantics.Semantics;
+import org.tweetyproject.web.services.bipolar.BipolarSemantics;
+
+import java.util.stream.Stream;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+
+/**
+ * @author Lars Bengel
+ */
+@SpringBootTest
+@AutoConfigureMockMvc
+class RequestControllerSerialisationTest {
+ @Autowired
+ private MockMvc mvc;
+
+ @Test
+ public void getInfos() throws Exception {
+ var post = post("/serialisation").contentType(MediaType.APPLICATION_JSON)
+ // language=JSON
+ .content("""
+ {
+ "cmd": "info"
+ }
+ """);
+
+ mvc.perform(post).andExpect(status().isOk())
+ // language=JSON
+ .andExpect(content().json("""
+ {
+ "reply": "info",
+ "email": null,
+ "backend_timeout": 600,
+ "selectionFunctions": [
+ "ADM","UC","GR"
+ ],
+ "terminationFunctions": [
+ "ADM","CO","UC","PR","ST"
+ ],
+ "commands": [
+ "get_reduct",
+ "is_terminal",
+ "get_selection",
+ "get_models",
+ "get_sequences"
+ ]
+ }
+ """, true));
+ }
+
+ @Test
+ public void getReduct() throws Exception {
+ var post = post("/serialisation").contentType(MediaType.APPLICATION_JSON)
+ // language=JSON
+ .content("""
+ {
+ "cmd": "get_reduct",
+ "nr_of_arguments": 4,
+ "attacks": [[1, 2],[2,3],[3,4],[4,3]],
+ "extension": [1],
+ "timeout": 10,
+ "unit_timeout": "s"
+ }
+ """);
+
+ mvc.perform(post).andExpect(status().isOk())
+ // language=JSON
+ .andExpect(content().json("""
+ {
+ "reply": "get_reduct",
+ "email": null,
+ "nr_of_arguments": 4,
+ "attacks": [
+ [
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 3
+ ],
+ [
+ 3,
+ 4
+ ],
+ [
+ 4,
+ 3
+ ]
+ ],
+ "extension": [1],
+ "selectionFunction": null,
+ "terminationFunction": null,
+ "answer": "<{ 3, 4 },[(3,4), (4,3)]>",
+ "time": 0,
+ "unit_time": "s",
+ "status": "SUCCESS"
+ }
+ """, true));
+ }
+
+ @Test
+ public void getSelection() throws Exception {
+ var post = post("/serialisation").contentType(MediaType.APPLICATION_JSON)
+ // language=JSON
+ .content("""
+ {
+ "cmd": "get_selection",
+ "nr_of_arguments": 4,
+ "attacks": [[1, 2],[2,3],[3,4],[4,3]],
+ "selectionFunction": "UC",
+ "timeout": 10,
+ "unit_timeout": "s"
+ }
+ """);
+
+ mvc.perform(post).andExpect(status().isOk())
+ // language=JSON
+ .andExpect(content().json("""
+ {
+ "reply": "get_selection",
+ "email": null,
+ "nr_of_arguments": 4,
+ "attacks": [
+ [
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 3
+ ],
+ [
+ 3,
+ 4
+ ],
+ [
+ 4,
+ 3
+ ]
+ ],
+ "extension": null,
+ "selectionFunction": "UC",
+ "terminationFunction": null,
+ "answer": "[{1}, {4}]",
+ "time": 0,
+ "unit_time": "s",
+ "status": "SUCCESS"
+ }
+ """, true));
+ }
+
+ @Test
+ public void isTerminal() throws Exception {
+ var post = post("/serialisation").contentType(MediaType.APPLICATION_JSON)
+ // language=JSON
+ .content("""
+ {
+ "cmd": "is_terminal",
+ "nr_of_arguments": 4,
+ "attacks": [[1, 2],[2,3],[3,4],[4,3]],
+ "terminationFunction": "UC",
+ "timeout": 10,
+ "unit_timeout": "s"
+ }
+ """);
+
+ mvc.perform(post).andExpect(status().isOk())
+ // language=JSON
+ .andExpect(content().json("""
+ {
+ "reply": "is_terminal",
+ "email": null,
+ "nr_of_arguments": 4,
+ "attacks": [
+ [
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 3
+ ],
+ [
+ 3,
+ 4
+ ],
+ [
+ 4,
+ 3
+ ]
+ ],
+ "extension": null,
+ "selectionFunction": null,
+ "terminationFunction": "UC",
+ "answer": "false",
+ "time": 0,
+ "unit_time": "s",
+ "status": "SUCCESS"
+ }
+ """, true));
+ }
+
+ @Test
+ public void getModels() throws Exception {
+ var post = post("/serialisation").contentType(MediaType.APPLICATION_JSON)
+ // language=JSON
+ .content("""
+ {
+ "cmd": "get_models",
+ "nr_of_arguments": 4,
+ "attacks": [[1, 2],[2,3],[3,4],[4,3]],
+ "selectionFunction": "ADM",
+ "terminationFunction": "PR",
+ "timeout": 10,
+ "unit_timeout": "s"
+ }
+ """);
+
+ mvc.perform(post).andExpect(status().isOk())
+ // language=JSON
+ .andExpect(content().json("""
+ {
+ "reply": "get_models",
+ "email": null,
+ "nr_of_arguments": 4,
+ "attacks": [
+ [
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 3
+ ],
+ [
+ 3,
+ 4
+ ],
+ [
+ 4,
+ 3
+ ]
+ ],
+ "extension": null,
+ "selectionFunction": "ADM",
+ "terminationFunction": "PR",
+ "answer": "[{1,3}, {1,4}]",
+ "time": 0,
+ "unit_time": "s",
+ "status": "SUCCESS"
+ }
+ """, true));
+ }
+
+ @Test
+ public void getSequences() throws Exception {
+ var post = post("/serialisation").contentType(MediaType.APPLICATION_JSON)
+ // language=JSON
+ .content("""
+ {
+ "cmd": "get_sequences",
+ "nr_of_arguments": 4,
+ "attacks": [[1, 2],[2,3],[3,4],[4,3]],
+ "selectionFunction": "UC",
+ "terminationFunction": "UC",
+ "timeout": 10,
+ "unit_timeout": "s"
+ }
+ """);
+
+ mvc.perform(post).andExpect(status().isOk())
+ // language=JSON
+ .andExpect(content().json("""
+ {
+ "reply": "get_sequences",
+ "email": null,
+ "nr_of_arguments": 4,
+ "attacks": [
+ [
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 3
+ ],
+ [
+ 3,
+ 4
+ ],
+ [
+ 4,
+ 3
+ ]
+ ],
+ "extension": null,
+ "selectionFunction": "UC",
+ "terminationFunction": "UC",
+ "answer": "[({4},{1}), ({1})]",
+ "time": 0,
+ "unit_time": "s",
+ "status": "SUCCESS"
+ }
+ """, true));
+ }
+}
\ No newline at end of file
From 4c44c47880d568b4ef3e9c22424530821c3f5dae Mon Sep 17 00:00:00 2001
From: larsbengel <77848869+larsbengel@users.noreply.github.com>
Date: Mon, 15 Jun 2026 00:28:32 +0200
Subject: [PATCH 03/14] minor bugfix
---
.../web/services/RequestController.java | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
index c1a48e8b0..ca609d60b 100644
--- a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
@@ -1499,36 +1499,33 @@ public Response handleRequest(@RequestBody SerialisationPost serPost) {
int user_timeout = Utils.checkUserTimeout(serPost.getTimeout(), SERVICES_TIMEOUT_DUNG, unit);
try {
String result_str;
+ Long result_time;
switch (cmd) {
case GET_SEQUENCES -> {
Future> future = executor.submit(callee);
Pair, Long> result = Utils.runServicesWithTimeout(future, user_timeout, unit);
result_str = result.getKey().toString();
+ result_time = result.getValue();
} case GET_REDUCT -> {
Future future = executor.submit(callee);
Pair result = Utils.runServicesWithTimeout(future, user_timeout, unit);
result_str = result.getKey().toString();
+ result_time = result.getValue();
} case IS_TERMINAL -> {
Future future = executor.submit(callee);
Pair result = Utils.runServicesWithTimeout(future, user_timeout, unit);
result_str = result.getKey().toString();
+ result_time = result.getValue();
} case GET_SELECTION,GET_MODELS -> {
Future>> future = executor.submit(callee);
Pair>, Long> result = Utils.runServicesWithTimeout(future, user_timeout, unit);
result_str = result.getKey().toString();
+ result_time = result.getValue();
} default -> throw new IllegalArgumentException("unknown command " + cmd);
-
- /*
-
- */
-
}
- // TODO update result type; need to make distinction here i guess
- Future future = executor.submit(callee);
- Pair result = Utils.runServicesWithTimeout(future, user_timeout, unit);
executor.shutdownNow();
reasonerResponse.setAnswer(result_str);
- reasonerResponse.setTime(result.getValue());
+ reasonerResponse.setTime(result_time);
reasonerResponse.setStatus("SUCCESS");
} catch (TimeoutException e) {
reasonerResponse.setTime(serPost.getTimeout());
From 8ea7d5219760de6964f7edee69992b3476796ca7 Mon Sep 17 00:00:00 2001
From: Lars Bengel
Date: Mon, 15 Jun 2026 02:21:40 +0200
Subject: [PATCH 04/14] Experimental refactoring of RequestController
---
.../web/services/RequestController.java | 1536 +++++------------
.../web/services/causal/CausalController.java | 186 ++
2 files changed, 577 insertions(+), 1145 deletions(-)
create mode 100644 org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/causal/CausalController.java
diff --git a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
index ca609d60b..935b9bb9b 100644
--- a/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
+++ b/org-tweetyproject-web/src/main/java/org/tweetyproject/web/services/RequestController.java
@@ -18,14 +18,12 @@
*/
package org.tweetyproject.web.services;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -34,24 +32,34 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import java.util.logging.Level;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.server.ResponseStatusException;
+import org.tweetyproject.arg.aba.parser.AbaParser;
+import org.tweetyproject.arg.aba.reasoner.GeneralAbaReasoner;
+import org.tweetyproject.arg.aba.semantics.AbaExtension;
+import org.tweetyproject.arg.aba.syntax.AbaTheory;
+import org.tweetyproject.arg.aba.syntax.Assumption;
import org.tweetyproject.arg.adf.reasoner.AbstractADFReasoner;
-import org.tweetyproject.arg.adf.semantics.interpretation.Interpretation;
import org.tweetyproject.arg.adf.syntax.adf.AbstractDialecticalFramework;
import org.tweetyproject.arg.bipolar.reasoner.AbstractBipolarExtensionReasoner;
import org.tweetyproject.arg.bipolar.syntax.BipolarArgumentationFramework;
+import org.tweetyproject.arg.delp.parser.DelpParser;
+import org.tweetyproject.arg.delp.reasoner.DelpReasoner;
+import org.tweetyproject.arg.delp.semantics.ComparisonCriterion;
+import org.tweetyproject.arg.delp.semantics.DelpAnswer;
+import org.tweetyproject.arg.delp.semantics.EmptyCriterion;
+import org.tweetyproject.arg.delp.semantics.GeneralizedSpecificity;
+import org.tweetyproject.arg.delp.syntax.DefeasibleLogicProgram;
+import org.tweetyproject.arg.dung.reasoner.AbstractExtensionReasoner;
import org.tweetyproject.arg.dung.reasoner.IncompleteReasoner;
+import org.tweetyproject.arg.dung.semantics.Extension;
import org.tweetyproject.arg.dung.semantics.Semantics;
-import org.tweetyproject.arg.dung.serialisability.semantics.SerialisationSequence;
import org.tweetyproject.arg.dung.serialisability.syntax.SelectionFunction;
import org.tweetyproject.arg.dung.serialisability.syntax.TerminationFunction;
import org.tweetyproject.arg.dung.syntax.Argument;
@@ -62,13 +70,10 @@
import org.tweetyproject.arg.prob.syntax.ProbabilisticArgumentationFramework;
import org.tweetyproject.arg.rankings.reasoner.AbstractRankingReasoner;
import org.tweetyproject.arg.rankings.semantics.RankingSemantics;
-import org.tweetyproject.causal.parser.CausalParser;
-import org.tweetyproject.causal.syntax.CausalKnowledgeBase;
import org.tweetyproject.commons.BeliefSet;
import org.tweetyproject.commons.Formula;
import org.tweetyproject.commons.Parser;
import org.tweetyproject.commons.ParserException;
-import org.tweetyproject.comparator.GeneralComparator;
import org.tweetyproject.logics.commons.analysis.InconsistencyMeasure;
import org.tweetyproject.logics.commons.analysis.NaiveMusEnumerator;
import org.tweetyproject.logics.fol.parser.FolParser;
@@ -97,7 +102,6 @@
import org.tweetyproject.web.services.aba.GeneralAbaReasonerFactory;
import org.tweetyproject.web.services.adf.*;
import org.tweetyproject.web.services.bipolar.*;
-import org.tweetyproject.web.services.causal.*;
import org.tweetyproject.web.services.delp.DeLPCallee;
import org.tweetyproject.web.services.delp.DeLPPost;
import org.tweetyproject.web.services.delp.DeLPResponse;
@@ -107,42 +111,22 @@
import org.tweetyproject.web.services.incmes.InconsistencyGetMeasuresResponse;
import org.tweetyproject.web.services.incmes.InconsistencyPost;
import org.tweetyproject.web.services.incmes.InconsistencyValueResponse;
-import org.tweetyproject.web.services.rankings.*;
import org.tweetyproject.web.services.paf.*;
+import org.tweetyproject.web.services.rankings.*;
import org.tweetyproject.web.services.sequenceexplanation.*;
import org.tweetyproject.web.services.sequenceexplanation.SequenceExplanationPost.GetSequenceExplanationsCmd;
import org.tweetyproject.web.services.sequenceexplanation.SequenceExplanationPost.SequenceExplanationCmd;
import org.tweetyproject.web.services.sequenceexplanation.SequenceExplanationResponse.GetSequenceExplanationsResult;
import org.tweetyproject.web.services.sequenceexplanation.SequenceExplanationResponse.SequenceExplanationResult;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.tweetyproject.arg.aba.parser.AbaParser;
-import org.tweetyproject.arg.aba.reasoner.GeneralAbaReasoner;
-import org.tweetyproject.arg.aba.semantics.AbaExtension;
-import org.tweetyproject.arg.aba.syntax.AbaTheory;
-import org.tweetyproject.arg.aba.syntax.Assumption;
-import org.tweetyproject.arg.delp.parser.DelpParser;
-import org.tweetyproject.arg.delp.reasoner.DelpReasoner;
-import org.tweetyproject.arg.delp.semantics.ComparisonCriterion;
-import org.tweetyproject.arg.delp.semantics.DelpAnswer;
-import org.tweetyproject.arg.delp.semantics.EmptyCriterion;
-import org.tweetyproject.arg.delp.semantics.GeneralizedSpecificity;
-import org.tweetyproject.arg.delp.syntax.DefeasibleLogicProgram;
-import org.tweetyproject.arg.dung.reasoner.AbstractExtensionReasoner;
-import org.tweetyproject.arg.dung.semantics.Extension;
+import org.tweetyproject.web.services.serialisation.*;
import javafx.util.Pair;
-import org.tweetyproject.web.services.serialisation.*;
import javax.validation.Valid;
-import java.util.logging.Level;
-
-import static org.tweetyproject.web.services.causal.CausalReasonerResponse.Status.SUCCESS;
-import static org.tweetyproject.web.services.causal.CausalReasonerResponse.Status.TIMEOUT;
/**
- * handles HTTP POST requests at the provided endpoints
+ * Handles HTTP POST requests for all TweetyProject web service endpoints.
*/
@RestController
public class RequestController {
@@ -151,316 +135,197 @@ public class RequestController {
private final int SERVICES_TIMEOUT_DELP = 600;
private final int SERVICES_TIMEOUT_INCMES = 300;
private final int SERVICES_TIMEOUT_SEQUENCE_EXPLANATION = 300;
- private final int SERVICES_TIMEOUT_CAUSAL = 300;
private final SequenceExplanationService sequenceExplanationService;
- private final ObjectMapper objectMapper;
- private final CausalReasonerService causalReasonerService;
- /**
- * Constructor for causal reasoner service
- * @param sequenceExplanationService the sequence explanation service
- * @param objectMapper the object mapper
- * @param causalReasonerService the causal reasoner service
- */
@Autowired
- public RequestController(SequenceExplanationService sequenceExplanationService,
- ObjectMapper objectMapper,
- CausalReasonerService causalReasonerService) {
+ public RequestController(SequenceExplanationService sequenceExplanationService) {
this.sequenceExplanationService = sequenceExplanationService;
- this.objectMapper = objectMapper;
- this.causalReasonerService = causalReasonerService;
}
+ /** Holds the outcome of a timed callee execution. */
+ private static final class ExecutionResult {
+ final String answer;
+ final double time;
+ final String status;
+
+ ExecutionResult(String answer, double time, String status) {
+ this.answer = answer;
+ this.time = time;
+ this.status = status;
+ }
+ }
+
+ /**
+ * Submits {@code callee} to a single-threaded executor, waits up to {@code userTimeout},
+ * and returns an {@link ExecutionResult} with answer/time/status filled in.
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private static ExecutionResult runCallee(Callee callee, int userTimeout, double requestTimeout, TimeUnit unit) {
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ try {
+ Future