detach entities for migration
This commit is contained in:
parent
93bbde9623
commit
be4e723911
|
@ -29,17 +29,18 @@ public class DataRepositoryMigrationService {
|
|||
}
|
||||
|
||||
public void migrate(){
|
||||
DataRepositoryDao DataRepositoryDao = databaseRepository.getDataRepositoryDao();
|
||||
long total = DataRepositoryDao.asQueryable().count();
|
||||
DataRepositoryDao dataRepositoryDao = databaseRepository.getDataRepositoryDao();
|
||||
long total = dataRepositoryDao.asQueryable().count();
|
||||
logger.debug("Migrate DataRepository Total : " + total);
|
||||
int page = 0;
|
||||
|
||||
List<DataRepository> items;
|
||||
do {
|
||||
items = DataRepositoryDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
items = dataRepositoryDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
logger.debug("Migrate DataRepository " + page * PageSize + " of " + total);
|
||||
for (DataRepository item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is null DataRepository " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -58,7 +59,7 @@ public class DataRepositoryMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
|
@ -30,17 +30,18 @@ public class ExternalDatasetMigrationService {
|
|||
}
|
||||
|
||||
public void migrate(){
|
||||
ExternalDatasetDao ExternalDatasetDao = databaseRepository.getExternalDatasetDao();
|
||||
long total = ExternalDatasetDao.asQueryable().count();
|
||||
ExternalDatasetDao externalDatasetDao = databaseRepository.getExternalDatasetDao();
|
||||
long total = externalDatasetDao.asQueryable().count();
|
||||
logger.debug("Migrate ExternalDataset Total : " + total);
|
||||
int page = 0;
|
||||
|
||||
List<ExternalDataset> items;
|
||||
do {
|
||||
items = ExternalDatasetDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
items = externalDatasetDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
logger.debug("Migrate ExternalDataset " + page * PageSize + " of " + total);
|
||||
for (ExternalDataset item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is null ExternalDataset " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -59,7 +60,7 @@ public class ExternalDatasetMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
|
@ -30,17 +30,18 @@ public class FunderMigrationService {
|
|||
}
|
||||
|
||||
public void migrate(){
|
||||
FunderDao FunderDao = databaseRepository.getFunderDao();
|
||||
long total = FunderDao.asQueryable().count();
|
||||
FunderDao funderDao = databaseRepository.getFunderDao();
|
||||
long total = funderDao.asQueryable().count();
|
||||
logger.debug("Migrate Funder Total : " + total);
|
||||
int page = 0;
|
||||
|
||||
List<Funder> items;
|
||||
do {
|
||||
items = FunderDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
items = funderDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
logger.debug("Migrate Funder " + page * PageSize + " of " + total);
|
||||
for (Funder item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is null Funder " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -59,7 +60,7 @@ public class FunderMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(Funder.FunderType.INTERNAL.getValue().equals(item.getType())? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
|
@ -30,17 +30,18 @@ public class GrantMigrationService {
|
|||
}
|
||||
|
||||
public void migrate(){
|
||||
GrantDao GrantDao = databaseRepository.getGrantDao();
|
||||
long total = GrantDao.asQueryable().count();
|
||||
GrantDao grantDao = databaseRepository.getGrantDao();
|
||||
long total = grantDao.asQueryable().count();
|
||||
logger.debug("Migrate Grant Total : " + total);
|
||||
int page = 0;
|
||||
|
||||
List<Grant> items;
|
||||
do {
|
||||
items = GrantDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
items = grantDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
logger.debug("Migrate Grant " + page * PageSize + " of " + total);
|
||||
for (Grant item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is null Grant " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -59,7 +60,7 @@ public class GrantMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal ? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public class OrganizationMigrationService {
|
|||
if (items != null && !items.isEmpty()) {
|
||||
logger.debug("Migrate Organisation " + page * PageSize + " of " + total);
|
||||
for (Organisation item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is null Organisation " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -61,7 +62,7 @@ public class OrganizationMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setAbbreviation(item.getAbbreviation());
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
|
@ -30,17 +30,18 @@ public class ProjectMigrationService {
|
|||
}
|
||||
|
||||
public void migrate(){
|
||||
ProjectDao ProjectDao = databaseRepository.getProjectDao();
|
||||
long total = ProjectDao.asQueryable().count();
|
||||
ProjectDao projectDao = databaseRepository.getProjectDao();
|
||||
long total = projectDao.asQueryable().count();
|
||||
logger.debug("Migrate Project Total : " + total);
|
||||
int page = 0;
|
||||
|
||||
List<Project> items;
|
||||
do {
|
||||
items = ProjectDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
items = projectDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
logger.debug("Migrate Project " + page * PageSize + " of " + total);
|
||||
for (Project item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is null Project " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -60,7 +61,7 @@ public class ProjectMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(Project.ProjectType.INTERNAL.getValue().equals(item.getType())? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
|
@ -30,17 +30,18 @@ public class RegistryMigrationService {
|
|||
}
|
||||
|
||||
public void migrate(){
|
||||
RegistryDao RegistryDao = databaseRepository.getRegistryDao();
|
||||
long total = RegistryDao.asQueryable().count();
|
||||
RegistryDao registryDao = databaseRepository.getRegistryDao();
|
||||
long total = registryDao.asQueryable().count();
|
||||
logger.debug("Migrate Registry Total : " + total);
|
||||
int page = 0;
|
||||
|
||||
List<Registry> items;
|
||||
do {
|
||||
items = RegistryDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
items = registryDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
logger.debug("Migrate Registry " + page * PageSize + " of " + total);
|
||||
for (Registry item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is null Registry " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -59,7 +60,7 @@ public class RegistryMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public class ResearcherMigrationService {
|
|||
if (items != null && !items.isEmpty()) {
|
||||
logger.debug("Migrate Researcher " + page * PageSize + " of " + total);
|
||||
for (Researcher item : items) {
|
||||
entityManager.detach(item);
|
||||
if (item.getReference() == null || !item.getReference().contains(":")){
|
||||
logger.warn("Reference generated because is null Researcher " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -61,7 +62,7 @@ public class ResearcherMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
|
@ -29,17 +29,18 @@ public class ServiceMigrationService {
|
|||
}
|
||||
|
||||
public void migrate(){
|
||||
ServiceDao ServiceDao = databaseRepository.getServiceDao();
|
||||
long total = ServiceDao.asQueryable().count();
|
||||
ServiceDao serviceDao = databaseRepository.getServiceDao();
|
||||
long total = serviceDao.asQueryable().count();
|
||||
logger.debug("Migrate Service Total : " + total);
|
||||
int page = 0;
|
||||
|
||||
List<eu.old.eudat.data.entities.Service> items;
|
||||
do {
|
||||
items = ServiceDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
items = serviceDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
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(":")){
|
||||
logger.warn("Reference generated because is null Service " + item.getId());
|
||||
item.setReference(InternalReferenceSource + ":" + item.getId().toString().toLowerCase(Locale.ROOT));
|
||||
|
@ -59,7 +60,7 @@ public class ServiceMigrationService {
|
|||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
if (item.getCreationUser() != null) data.setCreatedById(item.getCreationUser().getId());
|
||||
data.setReference(referenceParts[1]);
|
||||
data.setSource(referenceParts[0]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue