Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing validationState when fetching operation #781

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import fr.insee.rmes.persistance.sparql_queries.operations.operations.OperationsQueries;
import fr.insee.rmes.persistance.sparql_queries.operations.series.OpSeriesQueries;
import fr.insee.rmes.utils.DateUtils;
import fr.insee.rmes.utils.Deserializer;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.impl.LinkedHashModel;
Expand Down Expand Up @@ -77,32 +78,10 @@ private void getOperationSeries(String id, JSONObject operation) throws RmesExce
}


private Operation buildOperationFromJson(JSONObject operationJson) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);

Operation operation = new Operation();

private Operation buildOperationFromJson(JSONObject operationJson) throws RmesException {
Operation operation = Deserializer.deserializeJsonString(operationJson.toString(), Operation.class);
IdLabelTwoLangs series = famOpeSerIndUtils.buildIdLabelTwoLangsFromJson(operationJson.getJSONObject("series"));

operation.setId(operationJson.getString(Constants.ID));
if(operationJson.has(Constants.PREF_LABEL_LG1)) {
operation.setPrefLabelLg1(operationJson.getString(Constants.PREF_LABEL_LG1));
}
if(operationJson.has(Constants.PREF_LABEL_LG2)) {
operation.setPrefLabelLg2(operationJson.getString(Constants.PREF_LABEL_LG2));
}
if(operationJson.has(Constants.ALT_LABEL_LG1)) {
operation.setAltLabelLg1(operationJson.getString(Constants.ALT_LABEL_LG1));
}
if(operationJson.has(Constants.ALT_LABEL_LG2)) {
operation.setAltLabelLg2(operationJson.getString(Constants.ALT_LABEL_LG2));
}
operation.setSeries(series);
if(operationJson.has(Constants.ID_SIMS)) {
operation.setIdSims(operationJson.getString(Constants.ID_SIMS));
}
return operation;
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/fr/insee/rmes/model/operations/Operation.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public class Operation {
@Schema(description = "Update date")
private String updated;

@Schema(description = "Validation State")
private String validationState;

public Operation(String id, String prefLabelLg1, String prefLabelLg2, String altLabelLg1, String altLabelLg2,
IdLabelTwoLangs series, String idSims) {
IdLabelTwoLangs series, String idSims, String validationState) {
super();
this.id = id;
this.prefLabelLg1 = prefLabelLg1;
Expand All @@ -43,6 +46,7 @@ public Operation(String id, String prefLabelLg1, String prefLabelLg2, String alt
this.altLabelLg2 = altLabelLg2;
this.series = series;
this.idSims = idSims;
this.validationState = validationState;
}

public Operation() {
Expand Down Expand Up @@ -133,4 +137,12 @@ public String getUpdated() {
public void setUpdated(String updated) {
this.updated = updated;
}

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 @@ -40,7 +40,7 @@ class OperationsResourcesTest {

@CsvSource({
"1, '"+MediaType.APPLICATION_JSON_VALUE+"', '{\"id\":\"1\"}'",
"1, '"+MediaType.APPLICATION_XML_VALUE+"', '<Operation><id>1</id><prefLabelLg1/><prefLabelLg2/><altLabelLg1/><altLabelLg2/><series/><idSims/><created/><updated/></Operation>'",
"1, '"+MediaType.APPLICATION_XML_VALUE+"', '<Operation><id>1</id><prefLabelLg1/><prefLabelLg2/><altLabelLg1/><altLabelLg2/><series/><idSims/><created/><updated/><validationState/></Operation>'",
})
@ParameterizedTest
void getOperationByID_resultFormatFitAccessHeader(String id, String mediaType, String expected) throws Exception {
Expand Down