Skip to content

Commit

Permalink
Fix/solve issue validation distribution (#671)
Browse files Browse the repository at this point in the history
* feat: return validation status for a distribution

* fix: solve issue when publishing distribution
  • Loading branch information
EmmanuelDemey authored Jun 27, 2024
1 parent 0a73ebe commit cffdea9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public String publishDataset(String id) throws RmesException {
publicationUtils.publishResource(iri, Set.of("processStep", "archiveUnit", "validationState"));
publicationUtils.publishResource(catalogRecordIri, Set.of(CREATOR, "contributor"));
model.add(iri, INSEE.VALIDATION_STATE, RdfUtils.setLiteralString(ValidationStatus.VALIDATED), RdfUtils.createIRI(getDatasetsGraph()));
model.remove(iri, INSEE.VALIDATION_STATE, RdfUtils.setLiteralString(ValidationStatus.UNPUBLISHED), RdfUtils.createIRI(getDatasetsGraph()));
model.remove(iri, INSEE.VALIDATION_STATE, RdfUtils.setLiteralString(ValidationStatus.MODIFIED), RdfUtils.createIRI(getDatasetsGraph()));

repoGestion.objectValidation(iri, model);

return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public String create(String body) throws RmesException {
Distribution distribution = Deserializer.deserializeBody(body, Distribution.class);
String idnewt = IdGenerator.generateNextId(repoGestion.getResponseAsObject(DistributionQueries.lastDatasetId(getDistributionGraph())), "d");
distribution.setId(idnewt);
distribution.setValidationState(ValidationStatus.UNPUBLISHED.toString());

this.validate(distribution);

Expand All @@ -92,6 +93,7 @@ public String create(String body) throws RmesException {
public String update(String id, String body) throws RmesException {
Distribution distribution = Deserializer.deserializeBody(body, Distribution.class);
distribution.setId(id);
distribution.setValidationState(ValidationStatus.MODIFIED.toString());

this.validate(distribution);

Expand All @@ -113,6 +115,9 @@ public String publishDistribution(String id) throws RmesException {

publicationUtils.publishResource(iri, Set.of());
model.add(iri, INSEE.VALIDATION_STATE, RdfUtils.setLiteralString(ValidationStatus.VALIDATED), RdfUtils.createIRI(getDistributionGraph()));
model.remove(iri, INSEE.VALIDATION_STATE, RdfUtils.setLiteralString(ValidationStatus.UNPUBLISHED), RdfUtils.createIRI(getDistributionGraph()));
model.remove(iri, INSEE.VALIDATION_STATE, RdfUtils.setLiteralString(ValidationStatus.MODIFIED), RdfUtils.createIRI(getDistributionGraph()));

repoGestion.objectValidation(iri, model);

return id;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/fr/insee/rmes/model/dataset/Distribution.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Distribution {
String format;
String byteSize;
String url;
String validationState;

public String getId() {
return id;
Expand Down Expand Up @@ -100,4 +101,12 @@ public String getUrl() {
public void setUrl(String url) {
this.url = url;
}

public String getValidationState() {
return validationState;
}

public void setValidationState(String validationState) {
this.validationState = validationState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ WHERE {
}

OPTIONAL {
?uriDataset insee:validationState ?validationState .
?uri insee:validationState ?validationState .
}
}

0 comments on commit cffdea9

Please sign in to comment.