migration fixes

This commit is contained in:
Efstratios Giannopoulos 2024-03-13 17:04:42 +02:00
parent cbfe4ec4f2
commit db68cd32e1
4 changed files with 14 additions and 13 deletions

View File

@ -56,7 +56,7 @@ public class FunderMigrationService {
ReferenceEntity data = new ReferenceEntity();
data.setId(item.getId());
data.setLabel(item.getLabel());
data.setIsActive(Funder.Status.fromInteger(item.getStatus()).equals(Funder.Status.ACTIVE) ? IsActive.Active : IsActive.Inactive);
data.setIsActive(IsActive.Active);
data.setTypeId(ReferenceTypeIds.Funder);
data.setCreatedAt(item.getCreated().toInstant());
data.setUpdatedAt(item.getModified().toInstant());

View File

@ -21,7 +21,8 @@ import java.util.List;
import java.util.Locale;
@Service
public class GrantMigrationService {
public class
GrantMigrationService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(GrantMigrationService.class));
private static final int PageSize = 500;
@ -63,7 +64,7 @@ public class GrantMigrationService {
data.setLabel(item.getLabel());
data.setDescription(item.getDescription());
data.setAbbreviation(item.getAbbreviation());
data.setIsActive(Grant.Status.fromInteger(item.getStatus()).equals(Grant.Status.ACTIVE) ? IsActive.Active : IsActive.Inactive);
data.setIsActive(IsActive.Active);
data.setTypeId(ReferenceTypeIds.Grants);
data.setCreatedAt(item.getCreated().toInstant());
data.setUpdatedAt(item.getModified().toInstant());

View File

@ -64,8 +64,8 @@ public class ProjectMigrationService {
data.setLabel(item.getLabel());
data.setAbbreviation(item.getAbbreviation());
data.setDescription(item.getDescription());
data.setIsActive(Project.Status.ACTIVE.equals(Project.Status.fromInteger(item.getStatus())) ? IsActive.Active : IsActive.Inactive);
data.setTypeId(ReferenceTypeIds.DataRepositories);
data.setIsActive(IsActive.Active);
data.setTypeId(ReferenceTypeIds.Project);
data.setCreatedAt(item.getCreated().toInstant());
data.setUpdatedAt(item.getModified().toInstant());
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());

View File

@ -63,9 +63,9 @@ public class StorageFileMigrationService {
logger.debug("Migrate FileUpload " + page * PageSize + " of " + total);
for (FileUpload item : items) {
entityManager.detach(item);
File file = new File(this.environment.getProperty("file.storage") + item.getId().toString());
if (!file.exists()) file = new File(this.environment.getProperty("temp.temp") + item.getId().toString());
if (!file.exists()) throw new MyApplicationException("Storage file not exist " + item.getId().toString());
// File file = new File(this.environment.getProperty("file.storage") + item.getId().toString());
// if (!file.exists()) file = new File(this.environment.getProperty("temp.temp") + item.getId().toString());
// if (!file.exists()) throw new MyApplicationException("Storage file not exist " + item.getId().toString());
StorageFileEntity data = new StorageFileEntity();
data.setId(item.getId());
@ -80,11 +80,11 @@ public class StorageFileMigrationService {
data.setPurgedAt(null);
if (item.getCreator() == null) data.setOwnerId(item.getCreator().getId());
File destinationFile = new File(Paths.get(this.environment.getProperty("file.mainstorage"), data.getFileRef()).toString());
boolean fileCopied = FileCopyUtils.copy(file, destinationFile) > 0;
if (!fileCopied) throw new MyApplicationException("Storage file not copied " + data.getId().toString());
filesToDelete.add(file);
// File destinationFile = new File(Paths.get(this.environment.getProperty("file.mainstorage"), data.getFileRef()).toString());
// boolean fileCopied = FileCopyUtils.copy(file, destinationFile) > 0;
// if (!fileCopied) throw new MyApplicationException("Storage file not copied " + data.getId().toString());
//
// filesToDelete.add(file);
this.entityManager.persist(data);
}