Class RequestController
-
Constructor Summary
ConstructorsConstructorDescriptionRequestController(SequenceExplanationService sequenceExplanationService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, CausalReasonerService causalReasonerService) Constructs a RequestController with the required services -
Method Summary
Modifier and TypeMethodDescriptiongetInfo(DungReasonerPost dungPost) Handles a POST request to retrieve information about the Dung reasoner services.handleRequest(@Valid CausalReasonerPost request) Executes the causal reasoner as specified by the providedCausalReasonerPosthandleRequest(@Valid SequenceExplanationPost request) handler for the /sequence-explanation endpointhandleRequest(AbaReasonerPost AbaReasonerPost) Handles HTTP POST requests at the endpoint "/aba".handleRequest(AdfReasonerPost adfReasonerPost) Handles HTTP POST requests for ADF Reasoner operations.handleRequest(BipolarReasonerPost bipolarReasonerPost) Handles HTTP POST requests for bipolar extension reasoner operations.handleRequest(DeLPPost delpPost) Handles HTTP POST requests for Defeasible logic programming DeLP Reasoner operations.handleRequest(DungReasonerPost dungReasonerPost) Handles HTTP POST requests for Dung Reasoner operations.handleRequest(IafReasonerPost iafReasonerPost) Handles HTTP POST requests for Dung Reasoner operations.handleRequest(InconsistencyPost incmesPost) Handles HTTP POST requests for Inconsistency Measures operations.handleRequest(PafReasonerPost pafPost) Handles HTTP POST requests for Probabilistic Argumentation Framework (PAF) operations.handleRequest(RankingReasonerPost rankingReasonerPost) Handles HTTP POST requests for Ranking Reasoner operations.Handles HTTP POST requests for ping operations.
-
Constructor Details
-
RequestController
@Autowired public RequestController(SequenceExplanationService sequenceExplanationService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, CausalReasonerService causalReasonerService) Constructs a RequestController with the required services- Parameters:
sequenceExplanationService- the sequence explanation serviceobjectMapper- the object mappercausalReasonerService- the causal reasoner service
-
-
Method Details
-
handleRequest
@PostMapping(value="/aba", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody AbaReasonerPost AbaReasonerPost) throws ParserException, IOException, org.json.JSONException, org.codehaus.jettison.json.JSONException Handles HTTP POST requests at the endpoint "/aba". Parses and processes the incoming JSON payload to perform various ABA reasoning commands. Supported commands are: - get_models: Return all models for a given semantics and beliefbase - get_model: Return some model for a given semantics and beliefbase - query: Query an assumption - semantics: Return supported semantics- Parameters:
AbaReasonerPost- The request payload containing information for ABA reasoning.- Returns:
- A Response object containing the result of the ABA reasoning operation.
- Throws:
ParserException- If there is an error while parsing the input data.IOException- If there is an error reading or writing data.org.json.JSONException- If there is an error with JSON processing.org.codehaus.jettison.json.JSONException- If there is an error with Jettison JSON processing.
-
handleRequest
@PostMapping(value="/dung", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody DungReasonerPost dungReasonerPost) Handles HTTP POST requests for Dung Reasoner operations.This method processes requests with the endpoint "/dung" that have the specified content types for both request and response. It takes a DungReasonerPost object as the request body and returns a Response object as the response body.
The method checks the command (cmd) from the DungReasonerPost object and performs different operations based on the command. If the command is "info," it delegates the request to the getInfo method. If the command is "get_models" or "get_model," it processes the request using the DungTheory, AbstractExtensionReasoner, and other components. The result includes information about the execution time, answer, and status, which is encapsulated in a DungReasonerResponse object.
In case of a timeout during execution, the method sets the response status to "TIMEOUT" and includes the specified timeout duration. If any other exception occurs, the response status is set to "Error," and the method provides a generic response with a time of 0.0 and a null answer.
If the command is not recognized or not applicable, the method returns a default DungReasonerResponse.
- Parameters:
dungReasonerPost- The DungReasonerPost object representing the request payload.- Returns:
- A Response object representing the response payload.
-
handleRequest
@PostMapping(value="/iaf", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody IafReasonerPost iafReasonerPost) Handles HTTP POST requests for Dung Reasoner operations.This method processes requests with the endpoint "/dung" that have the specified content types for both request and response. It takes a DungReasonerPost object as the request body and returns a Response object as the response body.
The method checks the command (cmd) from the DungReasonerPost object and performs different operations based on the command. If the command is "info," it delegates the request to the getInfo method. If the command is "get_models" or "get_model," it processes the request using the DungTheory, AbstractExtensionReasoner, and other components. The result includes information about the execution time, answer, and status, which is encapsulated in a DungReasonerResponse object.
In case of a timeout during execution, the method sets the response status to "TIMEOUT" and includes the specified timeout duration. If any other exception occurs, the response status is set to "Error," and the method provides a generic response with a time of 0.0 and a null answer.
If the command is not recognized or not applicable, the method returns a default DungReasonerResponse.
- Parameters:
iafReasonerPost- The DungReasonerPost object representing the request payload.- Returns:
- A Response object representing the response payload.
-
handleRequest
@PostMapping(value="/rankings", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody RankingReasonerPost rankingReasonerPost) Handles HTTP POST requests for Ranking Reasoner operations.This method processes requests with the endpoint "/rankings" that have the specified content types for both request and response. It takes a DungReasonerPost object as the request body and returns a Response object as the response body.
The method checks the command (cmd) from the DungReasonerPost object and performs different operations based on the command. If the command is "info," it delegates the request to the getInfo method. If the command is "get_models" or "get_model," it processes the request using the DungTheory, AbstractRankingReasoner, and other components. The result includes information about the execution time, answer, and status, which is encapsulated in a DungReasonerResponse object.
In case of a timeout during execution, the method sets the response status to "TIMEOUT" and includes the specified timeout duration. If any other exception occurs, the response status is set to "Error," and the method provides a generic response with a time of 0.0 and a null answer.
If the command is not recognized or not applicable, the method returns a default DungReasonerResponse.
- Parameters:
rankingReasonerPost- The DungReasonerPost object representing the request payload.- Returns:
- A Response object representing the response payload.
-
handleRequest
@PostMapping(value="/adf", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody AdfReasonerPost adfReasonerPost) Handles HTTP POST requests for ADF Reasoner operations.This method processes requests with the endpoint "/dung" that have the specified content types for both request and response. It takes a AdfReasonerPost object as the request body and returns a Response object as the response body.
The method checks the command (cmd) from the AdfReasonerPost object and performs different operations based on the command. If the command is "info," it delegates the request to the getInfo method. If the command is "get_models" or "get_model," it processes the request using the ADF, AbstractExtensionReasoner, and other components. The result includes information about the execution time, answer, and status, which is encapsulated in a DungReasonerResponse object.
In case of a timeout during execution, the method sets the response status to "TIMEOUT" and includes the specified timeout duration. If any other exception occurs, the response status is set to "Error," and the method provides a generic response with a time of 0.0 and a null answer.
If the command is not recognized or not applicable, the method returns a default DungReasonerResponse.
- Parameters:
adfReasonerPost- The DungReasonerPost object representing the request payload.- Returns:
- A Response object representing the response payload.
-
ping
@PostMapping(value="/ping", produces="application/json") @ResponseBody public Ping ping(@RequestBody Ping ping_Greeting) Handles HTTP POST requests for ping operations.This method processes requests with the endpoint "/ping" that have the specified content type for the request and response. It takes a Ping object as the request body and returns the same Ping object as the response body.
The method echoes the received Ping object, providing a simple way to test the connectivity or response of the service. The response contains the same information as the request, including the identifier (id) and content of the Ping object.
- Parameters:
ping_Greeting- The Ping object representing the request payload.- Returns:
- A Ping object representing the response payload.
-
getInfo
@PostMapping(value="/info", produces="application/json") @ResponseBody public DungServicesInfoResponse getInfo(@RequestBody DungReasonerPost dungPost) Handles a POST request to retrieve information about the Dung reasoner services. This method constructs a response with general information about the services available, such as available semantics and commands. The input data includes email and other user-specific details, which are used to tailor the response.- Parameters:
dungPost- ADungReasonerPostobject containing the data sent by the client in the POST request body. This typically includes identifiers like email that can be used to personalize or secure the response.- Returns:
- A
DungServicesInfoResponseobject containing a variety of information about the services, including available semantics and commands supported by the Dung reasoner. The response is structured for JSON representation suitable for client-side consumption.
-
handleRequest
@PostMapping(value="/bipolar", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody BipolarReasonerPost bipolarReasonerPost) Handles HTTP POST requests for bipolar extension reasoner operations.This method processes requests with the endpoint "/bipolar" that have the specified content types for both request and response. It takes a BipolarReasonerPost object as the request body and returns a Response object as the response body.
The method checks the command (cmd) from the BipolarReasonerPost object and performs different operations based on the command. If the command is "info," it delegates the request to the getInfo method. If the command is "get_models" or "get_model," it processes the request using the DungTheory, AbstractExtensionReasoner, and other components. The result includes information about the execution time, answer, and status, which is encapsulated in a BipolarReasonerResponse object.
In case of a timeout during execution, the method sets the response status to "TIMEOUT" and includes the specified timeout duration. If any other exception occurs, the response status is set to "Error," and the method provides a generic response with a time of 0.0 and a null answer.
If the command is not recognized or not applicable, the method returns a default BipolarReasonerResponse.
- Parameters:
bipolarReasonerPost- The BipolarReasonerPost object representing the request payload.- Returns:
- A Response object representing the response payload.
-
handleRequest
@PostMapping(value="/delp", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody DeLPPost delpPost) Handles HTTP POST requests for Defeasible logic programming DeLP Reasoner operations. This method processes requests with the endpoint "/delp" that have the specified content types for both request and response. It takes a DeLPPost object as the request body and returns a DelpResponse object as the response body. The method prints the received DelpPost object to the console for debugging purposes. It then constructs a DeLPResponse object with default values, prepares the DelpReasoner, and executes it asynchronously using a separate thread. The result includes information about the execution time, answer, and status, encapsulated in a DelpResponse object. If the execution times out, the method sets the response status to "TIMEOUT" and includes the specified timeout duration. If a parsing exception occurs during knowledge base or query parsing, the method throws a JSONException with an appropriate error message. If any other unexpected exception occurs, the method prints the stack trace and throws a JSONException with a generic error message.- Parameters:
delpPost- The DelpPost object representing the request payload.- Returns:
- A Response object representing the response payload.
- Throws:
org.json.JSONException- If there is a parsing error or an unexpected error occurs during processing.
-
handleRequest
@PostMapping(value="/incmes", produces="application/json") @ResponseBody public Response handleRequest(@RequestBody InconsistencyPost incmesPost) Handles HTTP POST requests for Inconsistency Measures operations. This method processes requests with the endpoint "/incmes" that have the specified content type for the request and response. It takes an InconsistencyPost object as the request body and returns a Response object as the response body. The method initializes an InconsistencyValueResponse object for the response. It then checks the command (cmd) from the InconsistencyPost object and delegates the request to specific methods based on the command. If the command is "value," it calls the handleGetICMESValue method. If the command is "measures," it calls the handleGetMeasures method. Any exceptions that occur during the processing are caught, and a generic error message is printed to the console. If the command is not recognized or not applicable, the method returns a default InconsistencyValueResponse.- Parameters:
incmesPost- The InconsistencyPost object representing the request payload.- Returns:
- A Response object representing the response payload.
-
handleRequest
@PostMapping(value="/sequence-explanation", produces="application/json") @ResponseBody public SequenceExplanationResponse handleRequest(@Valid @RequestBody @Valid SequenceExplanationPost request) handler for the /sequence-explanation endpoint- Parameters:
request- the sequence explanation request- Returns:
- the server response
-
handleRequest
@PostMapping(value="/causal", produces="application/json") @ResponseBody public CausalReasonerResponse handleRequest(@Valid @RequestBody @Valid CausalReasonerPost request) Executes the causal reasoner as specified by the providedCausalReasonerPost- Parameters:
request- The request payload containing information for causal reasoning- Returns:
- A Response object containing the result of the ABA reasoning operation.
-
handleRequest
@PostMapping(value="/paf", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody PafReasonerPost pafPost) Handles HTTP POST requests for Probabilistic Argumentation Framework (PAF) operations.Supported commands:
info– return supported semantics, commands, and solversget_credulous– probability that the queried argument is credulously acceptedget_skeptical– probability that the queried argument is skeptically accepted
Two solvers are available:
simple(exact, enumerates all subgraphs) andmontecarlo(approximate sampling, configurable vianr_of_trials).- Parameters:
pafPost- the request payload- Returns:
- a
Responsecontaining the computed probability or service info
-