diff --git a/src/main/java/fr/insee/trevas/lab/controller/TrevasLabController.java b/src/main/java/fr/insee/trevas/lab/controller/TrevasLabController.java index 820f04a..aea1e4b 100644 --- a/src/main/java/fr/insee/trevas/lab/controller/TrevasLabController.java +++ b/src/main/java/fr/insee/trevas/lab/controller/TrevasLabController.java @@ -5,6 +5,10 @@ import fr.insee.trevas.lab.model.*; import fr.insee.trevas.lab.service.InMemoryEngine; import fr.insee.trevas.lab.service.SparkEngine; +import fr.insee.vtl.prov.ProvenanceListener; +import fr.insee.vtl.prov.RDFUtils; +import fr.insee.vtl.prov.prov.Program; +import org.apache.jena.rdf.model.Model; import org.apache.spark.sql.SparkSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -59,6 +63,20 @@ else if (connectorType == ConnectorType.S3) } else throw new Exception("Unknow mode: " + mode); } + @PostMapping("/provenance") + public ResponseEntity postProvenance( + Authentication auth, + @RequestBody BodyProvenance body + ) { + String id = body.getId(); + String name = body.getName(); + String script = body.getScript(); + Program program = ProvenanceListener.run(script, id, name); + Model model = RDFUtils.buildModel(program); + return ResponseEntity.status(HttpStatus.OK) + .body(RDFUtils.serialize(model, "JSON-LD")); + } + @PostMapping("/execute") public ResponseEntity executeNew( Authentication auth, diff --git a/src/main/java/fr/insee/trevas/lab/model/BodyProvenance.java b/src/main/java/fr/insee/trevas/lab/model/BodyProvenance.java new file mode 100644 index 0000000..2fef974 --- /dev/null +++ b/src/main/java/fr/insee/trevas/lab/model/BodyProvenance.java @@ -0,0 +1,20 @@ +package fr.insee.trevas.lab.model; + +public class BodyProvenance { + + String id; + String name; + String script; + + public String getScript() { + return script; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } +}