Skip to content

Commit

Permalink
bugs #11962 fix: apply shortname for translation
Browse files Browse the repository at this point in the history
bugs #11978 fix: breaking changes in model and display algorithm
  • Loading branch information
Regzox committed Dec 1, 2023
1 parent 7452889 commit ba7e29c
Show file tree
Hide file tree
Showing 34 changed files with 11,228 additions and 8,537 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import fr.gouv.vitam.common.model.administration.OntologyOrigin;
import fr.gouv.vitam.common.model.administration.SchemaCategory;
import fr.gouv.vitam.common.model.administration.SchemaType;
import fr.gouv.vitamui.referential.common.model.Cardinality;
import fr.gouv.vitamui.referential.common.model.Collection;
Expand All @@ -42,12 +43,10 @@
public class ExtendedOntologyCreateDto {
@JsonProperty("Tenant") private Integer tenant;
@JsonProperty("Version") private Integer version;
@JsonProperty("Depth") private Integer depth; // TODO: Useless, easy to compute
@JsonProperty("path") private String path;
@JsonProperty("DataType") private String dataType;
@JsonProperty("DataSize") private String dataSize; // TODO: Useless, don't know how to use this
@JsonProperty("Path") private String path;
@JsonProperty("StringSize") private String stringSize;
@JsonProperty("Cardinality") private Cardinality cardinality;
@JsonProperty("Identifier") private String identifier;
@JsonProperty("FieldName") private String fieldName;
@JsonProperty("ShortName") private String shortName;
@JsonProperty("Description") private String description;
@JsonProperty("CreationDate") private String creationDate;
Expand All @@ -59,4 +58,6 @@ public class ExtendedOntologyCreateDto {
@JsonProperty("Collections") private List<Collection> collections;
@JsonProperty("SedaVersions") private List<String> sedaVersions;
@JsonProperty("RootPaths") private List<String> rootPaths;
@JsonProperty("Category") private SchemaCategory category;
@JsonProperty("ApiPath") private String apiPath;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public ExtendedOntologyDto convert(SchemaModel schemaModel) {
// setDepth(schemaModel.getDepth()) // Not precomputed
.setPath(schemaModel.getPath())
// setDataType(schemaModel.getDataType()) // Mapped by Type
.setDataSize(stringSize)
.setStringSize(stringSize)
.setCardinality(Cardinality.of(schemaModel.getCardinality().value()))
.setIdentifier(schemaModel.getIdentifier())
.setFieldName(schemaModel.getFieldName())
.setShortName(schemaModel.getShortName())
.setDescription(schemaModel.getDescription())
// setCreationDate(schemaModel.getCreationDate()) // No mapping
Expand All @@ -66,7 +66,9 @@ public ExtendedOntologyDto convert(SchemaModel schemaModel) {
.setOrigin(schemaModel.getOrigin())
.setCollections(mapCollections(schemaModel))
.setSedaVersions(schemaModel.getSedaVersions())
.setRootPaths(null);
.setRootPaths(null)
.setCategory(schemaModel.getCategory())
.setApiPath(schemaModel.getApiPath());
}

private List<Collection> mapCollections(final SchemaModel schemaModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
package fr.gouv.vitamui.commons.vitam.api.dto;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
Expand All @@ -45,7 +47,9 @@
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
@NoArgsConstructor
Expand Down Expand Up @@ -198,6 +202,19 @@ public class ResultsDto {
@JsonAlias({"_aud"})
private String approximateEndDate;

private Map<String, Object> additionalProperties = new HashMap<>();

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperties(String key, Object value) {
System.out.println("Setting additional property - Key: " + key + ", Value: " + value);
additionalProperties.put(key, value);
}

@JsonProperty("id")
private void setIdV2(final String id) {
if (this.id == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022)
*
* contact.vitam@culture.gouv.fr
*
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing
* high volumetry securely and efficiently.
*
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info".
*
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the
* successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or
* developing or reproducing the software by the user in light of its specific status of free software, that may mean
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data
* to be ensured and, more generally, to use and operate it in the same conditions as regards security.
*
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you
* accept its terms.
*/

package fr.gouv.vitamui.commons.vitam.api.dto;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

class ResultsDtoTest {

@Test
void testAdditionalProperties() throws Exception {
// Créer un objet JSON avec une propriété supplémentaire non définie dans ResultsDto
String json = "{\"id\":\"123\", \"Title\":\"Test\", \"unknownProperty\":\"Value\"}";

// Désérialiser le JSON en un objet ResultsDto
ObjectMapper objectMapper = new ObjectMapper();
ResultsDto resultsDto = objectMapper.readValue(json, ResultsDto.class);

// Vérifier les propriétés typées
assertEquals("123", resultsDto.getId());
assertEquals("Test", resultsDto.getTitle());

// Vérifier la propriété supplémentaire
Map<String, Object> additionalProperties = resultsDto.getAdditionalProperties();
assertEquals(1, additionalProperties.size());
assertEquals("Value", additionalProperties.get("unknownProperty"));
}

@Test
void testSerializationWithAdditionalProperties() throws Exception {
// Créer un objet ResultsDto avec des propriétés et des propriétés supplémentaires
ResultsDto resultsDto = new ResultsDto()
.setId("123")
.setTitle("Test");
resultsDto.setAdditionalProperties("additionalProp1", "value1");
resultsDto.setAdditionalProperties("additionalProp2", 42);

// Sérialiser l'objet ResultsDto en JSON
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(resultsDto);

// Vérifier la présence des propriétés typées dans le JSON
assertThat(json).contains("\"#id\":\"123\"");
assertThat(json).contains("\"Title\":\"Test\"");

// Vérifier la présence des propriétés supplémentaires dans le JSON
assertThat(json).contains("\"additionalProp1\":\"value1\"");
assertThat(json).contains("\"additionalProp2\":42");
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { map } from 'rxjs/operators';
import { BASE_URL } from '../../../injection-tokens';
import { LoggerModule } from '../../../logger';
import { ObjectViewerModule } from '../../../object-viewer/object-viewer.module';
import { MockExtendedOntologyService } from '../../../object-viewer/services/mock-extended-ontology.service';
import { OntologyService } from '../../../ontology';
import { MockSchemaService } from '../../../object-viewer/services/mock-schema.service';
import { Collection, Schema, SchemaService } from '../../../schema';
import { SchemaApiService } from '../../../schema/schema-api.service';
import { ArchiveUnitViewerComponent } from './archive-unit-viewer.component';
Expand Down Expand Up @@ -68,15 +67,15 @@ describe('ArchiveUnitViewerComponent', () => {
providers: [
SchemaService,
{ provide: BASE_URL, useValue: '/fake-api' },
{ provide: OntologyService, useClass: MockExtendedOntologyService },
{ provide: SchemaService, useClass: MockSchemaService },
{
provide: SchemaApiService,
use: () => ({
getSchemas: (collections: Collection[]): Observable<Schema[]> => {
return new MockExtendedOntologyService().getInternalOntologyFieldsList().pipe(map((schema) => [schema]));
return new MockSchemaService().getSchema(null).pipe(map((schema) => [schema]));
},
getSchema: (collection: Collection): Observable<Schema> => {
return new MockExtendedOntologyService().getInternalOntologyFieldsList();
return new MockSchemaService().getSchema(null);
},
}),
},
Expand Down
Loading

0 comments on commit ba7e29c

Please sign in to comment.