migration fixes
This commit is contained in:
parent
cbfe4ec4f2
commit
db68cd32e1
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue