Skip to content

Commit

Permalink
Merge pull request #24 from WSE-research/semanticsDemoImplementation
Browse files Browse the repository at this point in the history
Semantics demo implementation
  • Loading branch information
dschiese authored May 21, 2024
2 parents ff8ebc0 + 0335f25 commit 420b746
Show file tree
Hide file tree
Showing 155 changed files with 1,745 additions and 2,020 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "input-data-storage"]
path = input-data-storage
url = git@github.com:dschiese/input-data-storage.git
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions dockerfile_scripts/extract_commons_version.sh

This file was deleted.

4 changes: 0 additions & 4 deletions dockerfile_scripts/install_commons_dependency.sh

This file was deleted.

1 change: 0 additions & 1 deletion input-data-storage
Submodule input-data-storage deleted from 9d29f9
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.wse</groupId>
<artifactId>qanary-explanation-service</artifactId>
<version>2.3.2</version>
<version>3.0.0</version>
<name>Qanary explanation service</name>
<description>Webservice for rule-based explanation of QA-Systems as well as specific components</description>
<properties>
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/com/wse/qanaryexplanationservice/CacheConfig.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wse.qanaryexplanationservice.controller;

import com.wse.qanaryexplanationservice.pojos.AutomatedTests.automatedTestingObject.automatedTestingObject.AutomatedTestRequestBody;
import com.wse.qanaryexplanationservice.repositories.AutomatedTestingRepository;
import com.wse.qanaryexplanationservice.helper.pojos.AutomatedTests.automatedTestingObject.AutomatedTestRequestBody;
import com.wse.qanaryexplanationservice.services.AutomatedTestingService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -16,11 +15,9 @@
@RestController
public class AutomatedTestController {

private final String authToken = ""; // Provide via GitHub actions
private final String authToken = ""; // Todo
@Autowired
private AutomatedTestingService automatedTestingService;
@Autowired
private AutomatedTestingRepository automatedTestingRepository;

// Note: Optional to the Path Variable "authToken", other approaches are possible too (CrossOrigin, Auth, ...)
@PostMapping(value = "/automatedtesting/{doGptRequest}", consumes = {
Expand All @@ -46,7 +43,8 @@ public ResponseEntity<String> automatedExperiments(
@PathVariable boolean doGptRequest
) {
try {
return new ResponseEntity<>(automatedTestingService.createTestWorkflow(requestBody, doGptRequest), HttpStatus.OK);
//return new ResponseEntity<>(automatedTestingService.createTestWorkflow(requestBody, doGptRequest), HttpStatus.OK);
return new ResponseEntity<>(automatedTestingService.createTestWorkflow(requestBody, false), HttpStatus.OK); // deactivated for live deployment
} catch (IllegalArgumentException e) {
return new ResponseEntity<>("Invalid Annotation Type!", HttpStatus.BAD_REQUEST);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,81 +1,18 @@
package com.wse.qanaryexplanationservice.controller;

import com.wse.qanaryexplanationservice.pojos.ExperimentSelectionDTO;
import com.wse.qanaryexplanationservice.pojos.Score;
import com.wse.qanaryexplanationservice.services.ClientService;
import com.wse.qanaryexplanationservice.services.ExplanationDataService;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.io.IOException;

@Controller
@Lazy
public class ClientController {

private final Logger logger = LoggerFactory.getLogger(ClientController.class);
@Autowired
private ClientService clientService;

@Autowired
private ExplanationDataService explanationDataService;

// TODO: set CrossOrigin later

/**
* Endpoint to return all explanations for the experiments which are described by the passed JSON-String
*
* @param experimentSelectionDTO Class to mirror passed JSON
* @return Experiments explanations
* @throws IOException while reading file
*/
@CrossOrigin(origins = {"http://localhost:3000"})
@PostMapping("/experiments/explanations")
public ResponseEntity<String> getExperimentExplanations(@RequestBody ExperimentSelectionDTO experimentSelectionDTO) throws IOException {
return new ResponseEntity<>(clientService.getExperimentExplanations(experimentSelectionDTO), HttpStatus.OK);
}

/**
* Endpoint to pass a JSON-String following the AutomatedTest-Structure and insert it to the underlying triplestore
*
* @param automatedTest JSON-String following the AutomatedTest-Structure
* @return ResponseEntity with "Successful"-message
*/
@PostMapping(value = "/insertjson", consumes = "application/json")
public ResponseEntity<String> insertAutomatedTestJson(@RequestBody String automatedTest) {
try {
JSONObject jsonObject = new JSONObject(automatedTest);
clientService.insertJson(jsonObject);
return new ResponseEntity<>("Successful", HttpStatus.OK);
} catch (RuntimeException e) {
logger.error("{}", e.toString());
return new ResponseEntity<>(null, HttpStatusCode.valueOf(500));
}
}

/**
* Endpoint to return all experiments including all data
*
* @param experimentSelectionDTO Class to mirror passed JSON
* @return JSON-String with all experiments including all data
*/
@PostMapping("/experiments")
public ResponseEntity<String> test(@RequestBody ExperimentSelectionDTO experimentSelectionDTO) {
return new ResponseEntity<>(clientService.getExperiments(experimentSelectionDTO), HttpStatus.OK);
}

@CrossOrigin
@PostMapping("/updatedataset")
public ResponseEntity<String> updateDatasetWithScore(@RequestBody Score score) {
return new ResponseEntity<>(explanationDataService.updateDataset(score), HttpStatus.OK);
}

}
Loading

0 comments on commit 420b746

Please sign in to comment.