Allignment with core changes

This commit is contained in:
Thomas Georgios Giannos 2023-11-21 10:00:18 +02:00
parent 4d01463c72
commit eb9ae3af48
3 changed files with 2 additions and 30 deletions

View File

@ -4,8 +4,6 @@ import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus; import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus; import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.InstantToUTCConverter;
import eu.eudat.data.converters.enums.DmpAccessTypeConverter; import eu.eudat.data.converters.enums.DmpAccessTypeConverter;
import eu.eudat.data.converters.enums.DmpStatusConverter; import eu.eudat.data.converters.enums.DmpStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
@ -64,13 +62,11 @@ public class DmpEntity implements DataEntity<DmpEntity, UUID> {
public static final String _description = "description"; public static final String _description = "description";
@Column(name = "created_at") @Column(name = "created_at")
@Convert(converter = InstantToUTCConverter.class)
private Instant createdAt; private Instant createdAt;
public static final String _createdAt = "createdAt"; public static final String _createdAt = "createdAt";
@Column(name = "updated_at") @Column(name = "updated_at")
@Convert(converter = InstantToUTCConverter.class)
private Instant updatedAt; private Instant updatedAt;
public static final String _updatedAt = "updatedAt"; public static final String _updatedAt = "updatedAt";
@ -82,7 +78,6 @@ public class DmpEntity implements DataEntity<DmpEntity, UUID> {
public static final String _isActive = "isActive"; public static final String _isActive = "isActive";
@Column(name = "finalized_at") @Column(name = "finalized_at")
@Convert(converter = InstantToUTCConverter.class)
private Instant finalizedAt; private Instant finalizedAt;
public static final String _finalizedAt = "finalizedAt"; public static final String _finalizedAt = "finalizedAt";

View File

@ -1,23 +0,0 @@
package eu.eudat.data.converters;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import java.time.Instant;
import java.util.Date;
@Converter
public class InstantToUTCConverter implements AttributeConverter<Instant, Date> {
@Override
public Date convertToDatabaseColumn(Instant attribute) {
if(attribute == null) return null;
return Date.from(attribute);
}
@Override
public Instant convertToEntityAttribute(Date dbData) {
if (dbData == null) return null;
return dbData.toInstant();
}
}

View File

@ -68,7 +68,7 @@ public class MigrationController {
dmpEntity.setDescription(dataManagementPlan.getDescription()); dmpEntity.setDescription(dataManagementPlan.getDescription());
dmpEntity.setAccessType(dataManagementPlan.getPublic() ? DmpAccessType.Public : DmpAccessType.Restricted); dmpEntity.setAccessType(dataManagementPlan.getPublic() ? DmpAccessType.Public : DmpAccessType.Restricted);
if (dataManagementPlan.getCreator() != null) if (dataManagementPlan.getCreator() != null)
dmpEntity.setCreator(dataManagementPlan.getCreator().getId()); dmpEntity.setCreatorId(dataManagementPlan.getCreator().getId());
dmpEntity.setGroupId(dataManagementPlan.getGroupId()); dmpEntity.setGroupId(dataManagementPlan.getGroupId());
dmpEntity.setVersion((short) dataManagementPlan.getVersion()); dmpEntity.setVersion((short) dataManagementPlan.getVersion());
dmpEntity.setVersionStatus(DmpVersionStatus.of((short) dataManagementPlan.getVersionStatus())); dmpEntity.setVersionStatus(DmpVersionStatus.of((short) dataManagementPlan.getVersionStatus()));
@ -78,7 +78,7 @@ public class MigrationController {
dmpEntity.setUpdatedAt(dataManagementPlan.getModified().toInstant()); dmpEntity.setUpdatedAt(dataManagementPlan.getModified().toInstant());
if (dataManagementPlan.getFinalized() != null) if (dataManagementPlan.getFinalized() != null)
dmpEntity.setFinalizedAt(dataManagementPlan.getFinalized().toInstant()); dmpEntity.setFinalizedAt(dataManagementPlan.getFinalized().toInstant());
dmpEntity.setBlueprint(dataManagementPlan.getProfile().getId()); dmpEntity.setBlueprintId(dataManagementPlan.getProfile().getId());
if (dataManagementPlan.getExtraProperties().containsKey("language") && dataManagementPlan.getExtraProperties().get("language") != null) if (dataManagementPlan.getExtraProperties().containsKey("language") && dataManagementPlan.getExtraProperties().get("language") != null)
dmpEntity.setLanguage((String) dataManagementPlan.getExtraProperties().get("language")); dmpEntity.setLanguage((String) dataManagementPlan.getExtraProperties().get("language"));
if (dataManagementPlan.getStatus() == 99) { if (dataManagementPlan.getStatus() == 99) {