Skip to content

Commit

Permalink
Add provenance endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoLaval committed Oct 9, 2024
1 parent 7b27247 commit ee209dc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,6 +63,20 @@ else if (connectorType == ConnectorType.S3)
} else throw new Exception("Unknow mode: " + mode);
}

@PostMapping("/provenance")
public ResponseEntity<String> 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<UUID> executeNew(
Authentication auth,
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/fr/insee/trevas/lab/model/BodyProvenance.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit ee209dc

Please sign in to comment.