|
1 | 1 | package fr.insee.rmes.magma.gestion.old.services.datasets; |
2 | 2 |
|
3 | | -import tools.jackson.core.JacksonException; |
4 | | -import tools.jackson.databind.JsonNode; |
5 | 3 | import fr.insee.rmes.magma.gestion.old.datasets.PatchDatasetDTO; |
6 | 4 | import fr.insee.rmes.magma.gestion.old.model.CodeList.Code; |
7 | 5 | import fr.insee.rmes.magma.gestion.old.model.datasets.*; |
|
12 | 10 | import fr.insee.rmes.magma.gestion.old.utils.Constants; |
13 | 11 | import fr.insee.rmes.magma.gestion.old.utils.config.Config; |
14 | 12 | import fr.insee.rmes.magma.gestion.old.utils.exceptions.RmesException; |
15 | | -import fr.insee.rmes.magma.gestion.old.model.datasets.*; |
16 | | -import fr.insee.rmes.magma.gestion.old.modelSwagger.dataset.*; |
17 | 13 | import fr.insee.rmes.magma.gestion.security.User; |
18 | 14 | import org.json.JSONArray; |
19 | 15 | import org.json.JSONObject; |
|
25 | 21 | import org.springframework.http.ResponseEntity; |
26 | 22 | import org.springframework.stereotype.Service; |
27 | 23 | import org.springframework.web.client.RestClient; |
| 24 | +import tools.jackson.core.JacksonException; |
| 25 | +import tools.jackson.databind.JsonNode; |
28 | 26 | import tools.jackson.databind.json.JsonMapper; |
29 | 27 |
|
30 | 28 | import java.util.*; |
@@ -152,13 +150,22 @@ protected DataSetModelSwagger findDataSetModelSwagger(String id) throws RmesExce |
152 | 150 | List<LangContent> title = constructLangContent(catalogue_result.getString("titleLg1"), catalogue_result.getString("titleLg2")); |
153 | 151 | Id id1=new Id(catalogue_result.getString("id")); |
154 | 152 | Uri uri = new Uri(catalogue_result.getString("uri")); |
155 | | - DisseminationStatus disseminationStatus = new DisseminationStatus(ontologies_result.getString("labeldisseminationStatusLg1")); |
| 153 | + |
156 | 154 | CatalogRecordCreated catalogRecordCreated = new CatalogRecordCreated(catalogue_result.getString("catalogRecordCreated")); |
157 | 155 | CatalogRecordModified catalogRecordModified = new CatalogRecordModified(catalogue_result.getString("catalogRecordModified")); |
158 | 156 | CatalogRecordCreator catalogRecordCreator = new CatalogRecordCreator(catalogue_result.getString("catalogRecordCreator")); |
159 | 157 | CatalogRecordContributor catalogRecordContributor = new CatalogRecordContributor(catalogue_result.getString("catalogRecordContributor")); |
160 | 158 | String validationState = catalogue_result.getString("statutValidation"); |
161 | | - DataSetModelSwagger response = new DataSetModelSwagger(id1, title, uri, validationState, disseminationStatus, catalogRecordCreated,catalogRecordModified,catalogRecordCreator,catalogRecordContributor); |
| 159 | + |
| 160 | + DisseminationStatus disseminationStatus = null; |
| 161 | + DataSetModelSwagger response = null; |
| 162 | + if (ontologies_result.has("labeldisseminationStatusLg1")){ |
| 163 | + disseminationStatus = new DisseminationStatus(ontologies_result.getString("labeldisseminationStatusLg1")); |
| 164 | + response = new DataSetModelSwagger(id1, title, uri, validationState, disseminationStatus, catalogRecordCreated, catalogRecordModified, catalogRecordCreator, catalogRecordContributor); |
| 165 | + } else { |
| 166 | + response = new DataSetModelSwagger(id1, title, uri, validationState, catalogRecordCreated, catalogRecordModified, catalogRecordCreator, catalogRecordContributor); |
| 167 | + } |
| 168 | + |
162 | 169 | testPresenceVariablePuisAjout(response,catalogue_result,adms_result,codes_result,organisations_result,structures_result); |
163 | 170 | return response; |
164 | 171 | } else { |
@@ -524,10 +531,14 @@ private List<IdLabel> getWasGeneratedBy(List<String> operationStat) throws RmesE |
524 | 531 | params.put("URI", s.replace(" ", "")); |
525 | 532 |
|
526 | 533 | JSONObject wasGeneratedByQuery = repoGestion.getResponseAsObject(buildRequest(Constants.DATASETS_QUERIES_PATH+DATASET_BY_ID_PATH, "getDataSetByIdWasGeneratedBy.ftlh", params)); |
527 | | - List<LangContent> wasGeneratedByTitles = constructLangContent(wasGeneratedByQuery.getString("labelwasGeneratedByLg1"),wasGeneratedByQuery.getString("labelwasGeneratedByLg2")); |
528 | | - IdLabel wasGeneratedByIdLabel = new IdLabel(wasGeneratedByQuery.getString("wasGeneratedById"),wasGeneratedByTitles); |
529 | | - wasGeneratedByIdLabel.setType(wasGeneratedByQuery.getString("typeWasGeneratedBy")); |
530 | | - wasGeneratedBy.add(wasGeneratedByIdLabel); |
| 534 | + List<LangContent> wasGeneratedByTitles = null; |
| 535 | + IdLabel wasGeneratedByIdLabel = null; |
| 536 | + if (wasGeneratedByQuery.has("wasGeneratedById")) { |
| 537 | + wasGeneratedByTitles = constructLangContent(wasGeneratedByQuery.getString("labelwasGeneratedByLg1"), wasGeneratedByQuery.getString("labelwasGeneratedByLg2")); |
| 538 | + wasGeneratedByIdLabel = new IdLabel(wasGeneratedByQuery.getString("wasGeneratedById"), wasGeneratedByTitles); |
| 539 | + wasGeneratedByIdLabel.setType(wasGeneratedByQuery.getString("typeWasGeneratedBy")); |
| 540 | + wasGeneratedBy.add(wasGeneratedByIdLabel); |
| 541 | + } |
531 | 542 | } |
532 | 543 | return wasGeneratedBy; |
533 | 544 | } |
|
0 commit comments