migration fixes
This commit is contained in:
parent
8719b56920
commit
2f283ae594
|
@ -2,6 +2,7 @@ package eu.eudat.model.deleter;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.*;
|
import eu.eudat.data.*;
|
||||||
|
import eu.eudat.model.Description;
|
||||||
import eu.eudat.model.DmpDescriptionTemplate;
|
import eu.eudat.model.DmpDescriptionTemplate;
|
||||||
import eu.eudat.model.DmpReference;
|
import eu.eudat.model.DmpReference;
|
||||||
import eu.eudat.query.*;
|
import eu.eudat.query.*;
|
||||||
|
@ -89,6 +90,12 @@ public class DmpDeleter implements Deleter {
|
||||||
DmpReferenceDeleter deleter = this.deleterFactory.deleter(DmpReferenceDeleter.class);
|
DmpReferenceDeleter deleter = this.deleterFactory.deleter(DmpReferenceDeleter.class);
|
||||||
deleter.delete(items);
|
deleter.delete(items);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
logger.debug("checking related - {}", Description.class.getSimpleName());
|
||||||
|
List<DescriptionEntity> items = this.queryFactory.query(DescriptionQuery.class).dmpIds(ids).collect();
|
||||||
|
DescriptionDeleter deleter = this.deleterFactory.deleter(DescriptionDeleter.class);
|
||||||
|
deleter.delete(items, false); //We delete elastic entities by bmp deleter
|
||||||
|
}
|
||||||
|
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,7 @@ import eu.eudat.commons.types.dmpreference.DmpReferenceDataEntity;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
import eu.eudat.commons.types.reference.FieldEntity;
|
import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.*;
|
||||||
import eu.eudat.data.DmpEntity;
|
|
||||||
import eu.eudat.data.DmpReferenceEntity;
|
|
||||||
import eu.eudat.data.ReferenceEntity;
|
|
||||||
import eu.eudat.model.DmpBlueprint;
|
import eu.eudat.model.DmpBlueprint;
|
||||||
import eu.eudat.query.DmpBlueprintQuery;
|
import eu.eudat.query.DmpBlueprintQuery;
|
||||||
import eu.old.eudat.data.dao.entities.DMPDao;
|
import eu.old.eudat.data.dao.entities.DMPDao;
|
||||||
|
@ -173,6 +170,19 @@ public class DmpMigrationService {
|
||||||
}
|
}
|
||||||
if (data.getCreatorId() == null){
|
if (data.getCreatorId() == null){
|
||||||
throw new MyApplicationException("Migration skipped creator not found " + item.getId());
|
throw new MyApplicationException("Migration skipped creator not found " + item.getId());
|
||||||
|
} else {
|
||||||
|
boolean shouldCreateOwner = item.getUsers() == null || item.getUsers().stream().noneMatch(x-> x.getUser() != null && data.getCreatorId().equals(x.getUser().getId()) && DmpUserRole.Owner.getValue().equals(x.getRole().shortValue()));
|
||||||
|
if (shouldCreateOwner) {
|
||||||
|
DmpUserEntity dmpUserEntity = new DmpUserEntity();
|
||||||
|
dmpUserEntity.setId(item.getId());
|
||||||
|
dmpUserEntity.setDmpId(item.getId());
|
||||||
|
dmpUserEntity.setUserId(data.getCreatorId());
|
||||||
|
dmpUserEntity.setRole(DmpUserRole.Owner);
|
||||||
|
dmpUserEntity.setCreatedAt(data.getCreatedAt());
|
||||||
|
dmpUserEntity.setUpdatedAt(data.getCreatedAt());
|
||||||
|
dmpUserEntity.setIsActive(IsActive.Active);
|
||||||
|
this.entityManager.persist(dmpUserEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
|
|
Loading…
Reference in New Issue