RED-10027 - Fix time zone issues
This commit is contained in:
parent
20e55817e9
commit
9a7778fc7f
@ -1,6 +1,8 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.migration;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -145,7 +147,9 @@ public class StorageToMongoCopyService {
|
||||
});
|
||||
|
||||
if (file.softDeleted != null) {
|
||||
componentLogService.softDeleteAllOverrides(file.dossierId(), file.fileId(), file.softDeleted);
|
||||
ZonedDateTime zonedDeletedTime = file.softDeleted.atZoneSameInstant(ZoneId.systemDefault());
|
||||
OffsetDateTime adjustedSoftDeletedTime = zonedDeletedTime.toOffsetDateTime();
|
||||
componentLogService.softDeleteAllOverrides(file.dossierId(), file.fileId(), adjustedSoftDeletedTime);
|
||||
}
|
||||
|
||||
fileManagementStorageService.deleteObject(file.dossierId(), file.fileId(), FileType.COMPONENTS);
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.shared.mongo.service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
@ -21,18 +23,22 @@ public class ComponentDocumentUpdateService {
|
||||
|
||||
public void setSoftDeletedTime(String componentLogId, OffsetDateTime softDeletedTime) {
|
||||
|
||||
ZonedDateTime zonedDeletedTime = softDeletedTime.atZoneSameInstant(ZoneId.systemDefault());
|
||||
OffsetDateTime adjustedSoftDeletedTime = zonedDeletedTime.toOffsetDateTime();
|
||||
Query query = new Query(Criteria.where("componentLogId").is(componentLogId)
|
||||
.and("softDeletedTime").is(null));
|
||||
|
||||
Update update = new Update().set("softDeletedTime", softDeletedTime);
|
||||
Update update = new Update().set("softDeletedTime", adjustedSoftDeletedTime);
|
||||
mongoTemplate.updateMulti(query, update, ComponentDocument.class);
|
||||
|
||||
}
|
||||
|
||||
public void unsetSoftDeletedTimeWhereGreaterThanEquals(String componentLogId, OffsetDateTime softDeletedTime) {
|
||||
|
||||
ZonedDateTime zonedDeletedTime = softDeletedTime.atZoneSameInstant(ZoneId.systemDefault());
|
||||
OffsetDateTime adjustedSoftDeletedTime = zonedDeletedTime.toOffsetDateTime();
|
||||
Query query = new Query(Criteria.where("componentLogId").is(componentLogId)
|
||||
.and("softDeletedTime").gte(softDeletedTime));
|
||||
.and("softDeletedTime").gte(adjustedSoftDeletedTime));
|
||||
|
||||
Update update = new Update().unset("softDeletedTime");
|
||||
mongoTemplate.updateMulti(query, update, ComponentDocument.class);
|
||||
@ -40,4 +46,4 @@ public class ComponentDocumentUpdateService {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user