migration fixes
This commit is contained in:
parent
996f0de054
commit
f2165c83a3
|
@ -51,10 +51,14 @@ public class DataRepositoryMigrationService {
|
|||
logger.debug("Migrate DataRepository " + page * PageSize + " of " + total);
|
||||
for (DataRepository item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null DataRepository " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' DataRepository " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
eu.old.eudat.models.data.datarepository.DataRepositoryModel model = new eu.old.eudat.models.data.datarepository.DataRepositoryModel().fromDataModel(item);
|
||||
|
||||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.old.eudat.migration;
|
||||
|
||||
import eu.old.eudat.data.entities.DMP;
|
||||
import org.opencdmp.commons.JsonHandlingService;
|
||||
import org.opencdmp.commons.XmlHandlingService;
|
||||
import org.opencdmp.commons.enums.*;
|
||||
|
@ -194,7 +195,8 @@ public class DatasetMigrationService {
|
|||
private List<DmpDescriptionTemplateEntity> getOrCreateDmpDescriptionTemplateEntity(Dataset item, UUID sectionId, UUID groupId, List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities){
|
||||
List<DmpDescriptionTemplateEntity> itemDescriptionTemplates = dmpDescriptionTemplateEntities.stream().filter(x-> x.getDescriptionTemplateGroupId().equals(groupId) && x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId)).toList();
|
||||
if (itemDescriptionTemplates.isEmpty()) {
|
||||
if (!item.getStatus().equals(Dataset.Status.DELETED.getValue())) logger.warn("Migrate Dataset " + item.getId() + " cannot found DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
|
||||
boolean isDeleted = item.getStatus().equals(Dataset.Status.CANCELED.getValue()) ||item.getStatus().equals(Dataset.Status.DELETED.getValue()) || item.getDmp().getStatus().equals(DMP.DMPStatus.DELETED.getValue());
|
||||
if (!isDeleted) logger.warn("Migrate Dataset " + item.getId() + " cannot found DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
|
||||
if (dmpDescriptionTemplateEntities.stream().anyMatch(x -> x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId))) {
|
||||
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = new DmpDescriptionTemplateEntity();
|
||||
dmpDescriptionTemplateEntity.setId(UUID.randomUUID());
|
||||
|
@ -203,7 +205,7 @@ public class DatasetMigrationService {
|
|||
dmpDescriptionTemplateEntity.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
||||
dmpDescriptionTemplateEntity.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
||||
dmpDescriptionTemplateEntity.setSectionId(sectionId);
|
||||
dmpDescriptionTemplateEntity.setIsActive(!item.getStatus().equals(Dataset.Status.DELETED.getValue()) ? IsActive.Active : IsActive.Inactive);
|
||||
dmpDescriptionTemplateEntity.setIsActive(!isDeleted ? IsActive.Active : IsActive.Inactive);
|
||||
this.entityManager.persist(dmpDescriptionTemplateEntity);
|
||||
this.entityManager.flush();
|
||||
itemDescriptionTemplates = List.of(dmpDescriptionTemplateEntity);
|
||||
|
|
|
@ -40,10 +40,14 @@ public class ExternalDatasetMigrationService {
|
|||
logger.debug("Migrate ExternalDataset " + page * PageSize + " of " + total);
|
||||
for (ExternalDataset item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null ExternalDataset " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' ExternalDataset " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
eu.old.eudat.models.data.externaldataset.ExternalDatasetModel model = new eu.old.eudat.models.data.externaldataset.ExternalDatasetModel().fromDataModel(item);
|
||||
|
||||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
|
|
|
@ -44,10 +44,14 @@ public class FunderMigrationService {
|
|||
logger.debug("Migrate Funder " + page * PageSize + " of " + total);
|
||||
for (Funder item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null Funder " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' Funder " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
eu.old.eudat.models.data.funder.Funder model = new eu.old.eudat.models.data.funder.Funder().fromDataModel(item);
|
||||
|
||||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
|
|
|
@ -51,10 +51,14 @@ GrantMigrationService {
|
|||
logger.debug("Migrate Grant " + page * PageSize + " of " + total);
|
||||
for (Grant item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null Grant " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' Grant " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
boolean isInternal = referenceParts[0].equals(InternalReferenceSource);
|
||||
|
|
|
@ -49,10 +49,14 @@ public class OrganizationMigrationService {
|
|||
logger.debug("Migrate Organisation " + page * PageSize + " of " + total);
|
||||
for (Organisation item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null Organisation " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' Organisation " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
eu.old.eudat.models.data.dmp.Organisation model = new eu.old.eudat.models.data.dmp.Organisation().fromDataModel(item);
|
||||
|
||||
|
|
|
@ -50,10 +50,14 @@ public class ProjectMigrationService {
|
|||
logger.debug("Migrate Project " + page * PageSize + " of " + total);
|
||||
for (Project item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null Project " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' Project " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
eu.old.eudat.models.data.project.Project model = new eu.old.eudat.models.data.project.Project().fromDataModel(item);
|
||||
|
||||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
|
|
|
@ -49,10 +49,14 @@ public class RegistryMigrationService {
|
|||
logger.debug("Migrate Registry " + page * PageSize + " of " + total);
|
||||
for (Registry item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null Registry " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' Registry " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
eu.old.eudat.models.data.registries.RegistryModel model = new eu.old.eudat.models.data.registries.RegistryModel().fromDataModel(item);
|
||||
|
||||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
|
|
|
@ -50,10 +50,14 @@ public class ResearcherMigrationService {
|
|||
logger.debug("Migrate Researcher " + page * PageSize + " of " + total);
|
||||
for (Researcher item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null Researcher " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' Researcher " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
eu.old.eudat.models.data.dmp.Researcher model = new eu.old.eudat.models.data.dmp.Researcher().fromDataModel(item);
|
||||
|
||||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
|
|
|
@ -48,10 +48,14 @@ public class ServiceMigrationService {
|
|||
logger.debug("Migrate Service " + page * PageSize + " of " + total);
|
||||
for (eu.old.eudat.data.entities.Service item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
if (item.getReference() == null || item.getReference().isBlank()){
|
||||
logger.warn("Reference generated because is null Service " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is not contains ':' Service " + item.getId() + " reference " + item.getReference());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
eu.old.eudat.models.data.services.ServiceModel model = new eu.old.eudat.models.data.services.ServiceModel().fromDataModel(item);
|
||||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
|
|
|
@ -175,6 +175,7 @@ public class MigrationController {
|
|||
public boolean step3() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException {
|
||||
//Description
|
||||
this.datasetMigrationService.migrate();
|
||||
// throw new InvalidApplicationException("");
|
||||
this.datasetReferenceMigrationService.migrateDatasetReferences();
|
||||
this.tagMigrationService.migrate();
|
||||
|
||||
|
|
Loading…
Reference in New Issue