Skip to content

Commit

Permalink
Fix #13214: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
marob committed Oct 24, 2024
1 parent cbc67bb commit 92587dc
Show file tree
Hide file tree
Showing 68 changed files with 210 additions and 469 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import java.time.OffsetDateTime;
import java.time.Instant;

/**
* The DTO v1 for a subrogation.
Expand All @@ -65,7 +65,7 @@ public class SubrogationDto extends IdDto {
@NotNull
private SubrogationStatusEnum status;

private OffsetDateTime date;
private Instant date;

@NotNull
@Length(min = 4, max = 100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import fr.gouv.vitamui.iam.common.enums.OtpEnum;
import fr.gouv.vitamui.iam.common.enums.SubrogationStatusEnum;

import java.time.Instant;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -201,7 +202,7 @@ public static SubrogationDto buildSubrogationDto(
) {
final SubrogationDto subrogation = new SubrogationDto();
subrogation.setId(id);
subrogation.setDate(OffsetDateTime.now());
subrogation.setDate(Instant.now());
subrogation.setStatus(SubrogationStatusEnum.CREATED);
subrogation.setSurrogate(surrogate);
subrogation.setSurrogateCustomerId(surrogateCustomerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@
import fr.gouv.vitamui.iam.internal.server.user.dao.UserRepository;
import fr.gouv.vitamui.iam.internal.server.user.domain.User;

import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public class SubrogationConverter implements Converter<SubrogationDto, Subrogation> {

Expand Down Expand Up @@ -79,19 +78,15 @@ private String getUserId(final String email, final String customerId) {
public Subrogation convertDtoToEntity(final SubrogationDto dto) {
final Subrogation entity = new Subrogation();
VitamUIUtils.copyProperties(dto, entity);
if (dto != null && dto.getDate() != null) {
entity.setDate(Date.from(dto.getDate().toInstant()));
}
Optional.ofNullable(dto).map(SubrogationDto::getDate).map(Date::from).ifPresent(entity::setDate);
return entity;
}

@Override
public SubrogationDto convertEntityToDto(final Subrogation entity) {
final SubrogationDto dto = new SubrogationDto();
VitamUIUtils.copyProperties(entity, dto);
if (entity != null && entity.getDate() != null) {
dto.setDate(OffsetDateTime.ofInstant(entity.getDate().toInstant(), ZoneOffset.UTC));
}
Optional.ofNullable(entity).map(Subrogation::getDate).map(Date::toInstant).ifPresent(dto::setDate);
return dto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
import org.springframework.util.Assert;

import javax.validation.constraints.NotNull;
import java.time.OffsetDateTime;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.Optional;

Expand Down Expand Up @@ -193,7 +194,7 @@ protected void beforeCreate(final SubrogationDto dto) {
} else {
ttlInMinutes = subrogationTtl;
}
final OffsetDateTime nowPlusXMinutes = OffsetDateTime.now().plusMinutes(ttlInMinutes);
final Instant nowPlusXMinutes = Instant.now().plus(ttlInMinutes, ChronoUnit.MINUTES);
dto.setDate(nowPlusXMinutes);

checkSubrogationAlreadyExist(dto.getSurrogate(), dto.getSurrogateCustomerId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public void testFindSubrogationsBySuperUserId() {
assertEquals(1, subrogations.size());
final SubrogationDto dto = subrogations.get(0);
assertEquals(subrogation.getId(), dto.getId());
assertEquals(subrogation.getDate(), Date.from(dto.getDate().toInstant()));
assertEquals(subrogation.getDate(), Date.from(dto.getDate()));
assertEquals(subrogation.getSuperUser(), dto.getSuperUser());
assertEquals(subrogation.getSurrogate(), dto.getSurrogate());
assertEquals(subrogation.getStatus(), dto.getStatus());
Expand All @@ -330,7 +330,7 @@ public void testFindSubrogationsBySuperUserEmail() {
assertEquals(1, subrogations.size());
final SubrogationDto dto = subrogations.get(0);
assertEquals(subrogation.getId(), dto.getId());
assertEquals(subrogation.getDate(), Date.from(dto.getDate().toInstant()));
assertEquals(subrogation.getDate(), Date.from(dto.getDate()));
assertEquals(subrogation.getSuperUser(), dto.getSuperUser());
assertEquals(subrogation.getSurrogate(), dto.getSurrogate());
assertEquals(subrogation.getStatus(), dto.getStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.time.OffsetDateTime;
import java.time.Instant;

import static org.mockito.Mockito.when;

Expand All @@ -47,7 +47,7 @@ public final class SubrogationCrudControllerTest extends AbstractCrudControllerT
private static final String SUPER_USER_CUSTOMER_ID = "systemCustomerId";
private static final String SURROGATE_CREATE_EMAIL = "surrogate@test.fr";
private static final String SURROGATE_CUSTOMER_ID = "customerId";
private static final OffsetDateTime NOW = OffsetDateTime.now();
private static final Instant NOW = Instant.now();
private static final User SURROGATE;
private static final User SURROGATE_CREATE;
private static final User SUPERUSER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@
<div class="read-only-field">
<label>{{ 'ARCHIVE_SEARCH.ARCHIVE_UNIT_PREVIEW.FIELDS.START_DATE' | translate }} :</label>
<div>
{{ archiveUnit?.StartDate | dateTime: 'dd/MM/yyyy' }}
{{ archiveUnit?.StartDate | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</div>
</div>
</div>
<div class="col-6">
<div class="read-only-field">
<label>{{ 'ARCHIVE_SEARCH.ARCHIVE_UNIT_PREVIEW.FIELDS.END_DATE' | translate }} :</label>
<div>
{{ archiveUnit?.EndDate | dateTime: 'dd/MM/yyyy' }}
{{ archiveUnit?.EndDate | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { TranslateModule } from '@ngx-translate/core';
import { environment } from 'projects/archive-search/src/environments/environment';
import { of } from 'rxjs';
import {
AppendZIfNoTimezonePipe,
BASE_URL,
DescriptionLevel,
ENVIRONMENT,
Expand All @@ -56,13 +57,6 @@ import {
import { ArchiveService } from '../../archive.service';
import { ArchiveUnitInformationTabComponent } from './archive-unit-information-tab.component';

@Pipe({ name: 'dateTime' })
export class MockDateTimePipe implements PipeTransform {
transform(value: string = ''): any {
return value;
}
}

@Pipe({ name: 'truncate' })
class MockTruncatePipe implements PipeTransform {
transform(value: number): number {
Expand Down Expand Up @@ -122,7 +116,7 @@ describe('ArchiveUnitInformationTabComponent', () => {
BrowserAnimationsModule,
TranslateModule.forRoot(),
],
declarations: [ArchiveUnitInformationTabComponent, MockTruncatePipe, MockDateTimePipe, MockUnitI18nPipe],
declarations: [ArchiveUnitInformationTabComponent, MockTruncatePipe, AppendZIfNoTimezonePipe, MockUnitI18nPipe],
providers: [
FormBuilder,
{ provide: ArchiveService, useValue: archiveServiceMock },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</i>
{{ getRuleCategoryName(ruleCategory) }}
</div>
<div class="col" *ngIf="!isPreventInheritance">{{ getMaxEndDate(unitRuleDTO) | dateTime: 'dd/MM/yyyy' }}</div>
<div class="col" *ngIf="!isPreventInheritance">{{ getMaxEndDate(unitRuleDTO) | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}</div>
<div class="col" *ngIf="!isPreventInheritance">{{ getFinalActionValue(propertiesList) }}</div>
</div>
<div class="collapsible" [@collapse]="listOfRulesCollapsed">
Expand Down Expand Up @@ -131,8 +131,8 @@
(click)="getHoldRuleInformations(rule)"
>
<div class="col-4 text">{{ rule.Rule }}</div>
<div class="col-3 text">{{ rule.StartDate | dateTime: 'dd/MM/yyyy' }}</div>
<div class="col-3 text">{{ rule.EndDate | dateTime: 'dd/MM/yyyy' }}</div>
<div class="col-3 text">{{ rule.StartDate | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}</div>
<div class="col-3 text">{{ rule.EndDate | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}</div>
<div class="col-2 text">{{ getRuleStatus(rule) }}</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
>

<ng-template #showStartDate
><span (click)="pickerSatrDate.open()">{{ ruleDetailsForm.get('startDate').value | dateTime: 'dd/MM/yyyy' }} </span>
><span (click)="pickerSatrDate.open()"
>{{ ruleDetailsForm.get('startDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input class="hidden" size="0" [matDatepicker]="pickerSatrDate" formControlName="startDate" />
<mat-datepicker #pickerSatrDate></mat-datepicker>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

<ng-template #showStartDate
><span (click)="isStartDateDisabled ? null : pickerSatrDate.open()"
>{{ ruleDetailsForm.get('startDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ ruleDetailsForm.get('startDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input class="hidden" size="0" [matDatepicker]="pickerSatrDate" formControlName="startDate" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
>
<ng-template #showBeginDtAccessRule
><span (click)="pickerBeginAccessRule.open()"
>{{ accessRuleCriteriaForm.get('accessRuleStartDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ accessRuleCriteriaForm.get('accessRuleStartDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down Expand Up @@ -98,7 +98,7 @@
>
<ng-template #showEndDtAccessRule
><span (click)="pickerEndAccessRule.open()"
>{{ accessRuleCriteriaForm.get('accessRuleEndDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ accessRuleCriteriaForm.get('accessRuleEndDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
>
<ng-template #showBeginDtDua
><span (click)="pickerBeginDua.open()"
>{{ appraisalRuleCriteriaForm.get('appraisalRuleStartDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ appraisalRuleCriteriaForm.get('appraisalRuleStartDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down Expand Up @@ -98,7 +98,7 @@
>
<ng-template #showEndDtDua
><span (click)="pickerEndDua.open()"
>{{ appraisalRuleCriteriaForm.get('appraisalRuleEndDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ appraisalRuleCriteriaForm.get('appraisalRuleEndDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
>
<ng-template #showBeginDtDisseminationRule
><span (click)="pickerBeginDisseminationRule.open()"
>{{ disseminationRuleCriteriaForm.get('disseminationRuleStartDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ disseminationRuleCriteriaForm.get('disseminationRuleStartDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down Expand Up @@ -98,7 +98,7 @@
>
<ng-template #showEndDtDisseminationRule
><span (click)="pickerEndDisseminationRule.open()"
>{{ disseminationRuleCriteriaForm.get('disseminationRuleEndDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ disseminationRuleCriteriaForm.get('disseminationRuleEndDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
>
<ng-template #showBeginDtReuseRule
><span (click)="pickerBeginReuseRule.open()"
>{{ reuseRuleCriteriaForm.get('reuseRuleStartDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ reuseRuleCriteriaForm.get('reuseRuleStartDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down Expand Up @@ -98,7 +98,7 @@
>
<ng-template #showEndDtReuseRule
><span (click)="pickerEndReuseRule.open()"
>{{ reuseRuleCriteriaForm.get('reuseRuleEndDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ reuseRuleCriteriaForm.get('reuseRuleEndDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
>
<ng-template #showBeginDtDua
><span (click)="pickerBeginDua.open()"
>{{ storageRuleCriteriaForm.get('storageRuleStartDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ storageRuleCriteriaForm.get('storageRuleStartDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down Expand Up @@ -98,7 +98,7 @@
>
<ng-template #showEndDtDua
><span (click)="pickerEndDua.open()"
>{{ storageRuleCriteriaForm.get('storageRuleEndDate').value | dateTime: 'dd/MM/yyyy' }}
>{{ storageRuleCriteriaForm.get('storageRuleEndDate').value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</span>
</ng-template>
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,10 @@ <h5>{{ 'ARCHIVE_SEARCH.TITLE_SEARCH' | translate }}</h5>
</span>
</div>
<div class="col-2 d-flex align-items-center">
{{ archiveUnit?.StartDate | dateTime: 'dd/MM/yyyy' }}
{{ archiveUnit?.StartDate | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</div>
<div class="col-2 d-flex align-items-center" (click)="archiveUnitClick.emit(archiveUnit)">
{{ archiveUnit?.EndDate | dateTime: 'dd/MM/yyyy' }}
{{ archiveUnit?.EndDate | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}
</div>
<div class="col-2 d-flex align-items-center" (click)="archiveUnitClick.emit(archiveUnit)">
<p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
cancelLabel="ANNULER"
>
<h5>{{ 'ARCHIVE_SEARCH.SEARCH_CRITERIA_SAVER.SAVE_DELETE_CRITERIA_MESSGE' | translate }}</h5>
<strong> {{ objectName }} - {{ objectDate | dateTime: 'dd/MM/yyyy' }}</strong>
<strong> {{ objectName }} - {{ objectDate | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}</strong>
</vitamui-common-confirm-dialog>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="grid-container">
<div class="criteria-name-date">
<span class="criteria-name">{{ criteria.name | truncate: 30 }}</span> -
<span class="criteria-date">{{ criteria.savingDate | dateTime: 'dd/MM/yyyy' }}</span>
<span class="criteria-date">{{ criteria.savingDate | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}</span>
</div>
<div>
<i class="material-icons btn-delete" (click)="deleteSearchCriteriaHistory(criteria)">delete</i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
'ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.FIELDS.START_DATE_SEARCH' | translate
}}</span>
<ng-template #showBeginDt
><span (click)="pickerBegin.open()">{{ beginDt.value | dateTime: 'dd/MM/yyyy' }} </span>
><span (click)="pickerBegin.open()">{{ beginDt.value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }} </span>
</ng-template>
<input class="hidden" size="0" [matDatepicker]="pickerBegin" formControlName="beginDt" />
<mat-datepicker #pickerBegin></mat-datepicker>
Expand All @@ -101,7 +101,7 @@
'ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.FIELDS.END_DATE_SEARCH' | translate
}}</span>
<ng-template #showEndDt
><span (click)="pickerEnd.open()">{{ endDt.value | dateTime: 'dd/MM/yyyy' }} </span>
><span (click)="pickerEnd.open()">{{ endDt.value | appendZIfNoTimezone | date: 'dd/MM/yyyy' }} </span>
</ng-template>
<input class="hidden" size="0" [matDatepicker]="pickerEnd" formControlName="endDt" />
<mat-datepicker #pickerEnd></mat-datepicker>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h2>{{ 'ARCHIVE_SEARCH.TRANSFER_ACKNOWLEDGMENT.TRANSFER_REPLY_OPERATION' | trans
<p class="detail-text">
{{ 'ARCHIVE_SEARCH.TRANSFER_ACKNOWLEDGMENT.TRANSFER_REALISATION_DATE' | translate }}
</p>
<p>{{ transfertDetails.date | dateTime: 'dd/MM/yyyy' }}</p>
<p>{{ transfertDetails.date | appendZIfNoTimezone | date: 'dd/MM/yyyy' }}</p>
</div>

<div>
Expand Down
Loading

0 comments on commit 92587dc

Please sign in to comment.