Skip to content

Commit

Permalink
Merge pull request #2002 from ProgrammeVitam/story_13004
Browse files Browse the repository at this point in the history
Story #13004
  • Loading branch information
Regzox authored Aug 29, 2024
2 parents abf181c + 4377ff2 commit 3aeb4cd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,29 @@
import fr.gouv.vitamui.referential.common.model.ControlType;
import fr.gouv.vitamui.referential.common.model.DataType;
import fr.gouv.vitamui.referential.common.model.EffectiveCardinality;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;
import java.util.Optional;

import static java.util.Objects.isNull;

@Slf4j
public class CombinedSchemaModelToSchemaElementDtoConverter
extends StdConverter<CombinedSchemaModel, SchemaElementDto> {

@Override
public SchemaElementDto convert(CombinedSchemaModel schemaModel) {
final SchemaStringSizeType stringTypeSize = SchemaStringSizeType.fromValue(schemaModel.getStringSize().name());
SchemaStringSizeType stringTypeSize = null;

if (schemaModel.getStringSize() != null) {
stringTypeSize = SchemaStringSizeType.fromValue(schemaModel.getStringSize().name());
}

final SchemaElementDto schemaElementDto = (SchemaElementDto) new SchemaElementDto()
.setPath(schemaModel.getPath())
.setStringSize(Optional.ofNullable(stringTypeSize).map(SchemaStringSizeType::value).orElse(null))
.setCardinality(Cardinality.of(schemaModel.getCardinality().name()))
.setCardinality(Cardinality.valueOf(schemaModel.getCardinality().name()))
.setFieldName(schemaModel.getFieldName())
.setShortName(schemaModel.getShortName())
.setDescription(schemaModel.getDescription())
Expand All @@ -66,18 +73,19 @@ public SchemaElementDto convert(CombinedSchemaModel schemaModel) {
.setApiPath(Optional.ofNullable(schemaModel.getApiPath()).orElse(schemaModel.getPath()))
.setDataType(convertFromIndexationType(schemaModel.getType().name()));

if (schemaModel.getControl() != null) {
final ControlDto controlDto = new ControlDto();
schemaElementDto.setEffectiveCardinality(EffectiveCardinality.valueOf(schemaModel.getEffectiveCardinality()));

controlDto.setType(ControlType.valueOf(schemaModel.getControl().getType()));
controlDto.setValue(schemaModel.getControl().getValue());
controlDto.setValues(schemaModel.getControl().getValues());
controlDto.setComment(schemaModel.getControl().getComment());
if (schemaModel.getControl() == null) return schemaElementDto;

schemaElementDto.setControl(controlDto);
final ControlDto controlDto = new ControlDto();
if (schemaModel.getControl().getType() != null) {
controlDto.setType(ControlType.valueOf(schemaModel.getControl().getType()));
}
controlDto.setValue(schemaModel.getControl().getValue());
controlDto.setValues(schemaModel.getControl().getValues());
controlDto.setComment(schemaModel.getControl().getComment());

schemaElementDto.setEffectiveCardinality(EffectiveCardinality.valueOf(schemaModel.getEffectiveCardinality()));
schemaElementDto.setControl(controlDto);

return schemaElementDto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
import fr.gouv.vitamui.iam.security.service.InternalSecurityService;
import fr.gouv.vitamui.referential.common.dto.SchemaDto;
import fr.gouv.vitamui.referential.common.model.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand All @@ -51,7 +49,6 @@
@Service
public class SchemaService {

private static final Logger log = LoggerFactory.getLogger(SchemaService.class);
private final InternalSecurityService internalSecurityService;
private final AdminExternalClient adminExternalClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ export class ArchiveUnitEditObjectService {
}
}

public hideCardinalityZero(editObject: EditObject): void {
if (editObject.cardinality === 'ZERO') {
editObject.displayRule = { ...editObject.displayRule, ui: { ...editObject.displayRule.ui, display: false } };
}

editObject.children.forEach((child) => this.hideCardinalityZero(child));
}

public setMissingTypes(editObject: EditObject): void {
const { kind } = editObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class ArchiveUnitEditorService {
this.archiveUnitEditObjectService.expand('', editObject);
this.archiveUnitEditObjectService.expand('Generalities', editObject);
this.archiveUnitEditObjectService.hideSpsFieldWithOneValue(editObject);
this.archiveUnitEditObjectService.hideCardinalityZero(editObject);

return editObject;
}
Expand Down

0 comments on commit 3aeb4cd

Please sign in to comment.