migration fixes
This commit is contained in:
parent
ae7366c3ff
commit
c243da1b9e
|
@ -35,7 +35,7 @@ public class ReferenceEntity extends TenantScopedBaseEntity {
|
|||
|
||||
public static final String _label = "label";
|
||||
|
||||
public static final int _labelLength = 500;
|
||||
public static final int _labelLength = 1024;
|
||||
|
||||
@Column(name = "type", nullable = false)
|
||||
private UUID typeId;
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.commons.JsonHandlingService;
|
|||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.*;
|
||||
import eu.eudat.commons.types.description.*;
|
||||
import eu.eudat.commons.types.descriptionreference.DescriptionReferenceDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
||||
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
||||
|
@ -14,6 +15,7 @@ import eu.eudat.data.*;
|
|||
import eu.eudat.model.Dmp;
|
||||
import eu.eudat.model.Reference;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.persist.descriptionreference.DescriptionReferenceDataPersist;
|
||||
import eu.eudat.query.*;
|
||||
import eu.old.eudat.data.dao.entities.DatasetDao;
|
||||
import eu.old.eudat.data.entities.Dataset;
|
||||
|
@ -24,6 +26,7 @@ import gr.cite.tools.fieldset.BaseFieldSet;
|
|||
import gr.cite.tools.logging.LoggerService;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -143,16 +146,17 @@ public class DatasetMigrationService {
|
|||
data.setIsActive(IsActive.Active);
|
||||
data.setStatus(DescriptionStatus.of(item.getStatus()));
|
||||
}
|
||||
|
||||
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinitionEntity = descriptionTemplateDefinitionMap.getOrDefault(item.getProfile().getId(), null);
|
||||
data.setProperties(this.jsonHandlingService.toJson(this.buildPropertyDefinitionEntity(item, descriptionTemplateDefinitionEntity, referenceTypeDefinitionEntityMap, referenceMap)));
|
||||
|
||||
if (data.getCreatedById() == null){
|
||||
throw new MyApplicationException("Migration skipped creator not found " + item.getId());
|
||||
}
|
||||
|
||||
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinitionEntity = descriptionTemplateDefinitionMap.getOrDefault(item.getProfile().getId(), null);
|
||||
this.entityManager.persist(data);
|
||||
this.entityManager.flush();
|
||||
|
||||
data.setProperties(this.jsonHandlingService.toJson(this.buildPropertyDefinitionEntity(item, descriptionTemplateDefinitionEntity, referenceTypeDefinitionEntityMap, referenceMap)));
|
||||
|
||||
this.entityManager.merge(data);
|
||||
this.entityManager.flush();
|
||||
}
|
||||
|
||||
page++;
|
||||
|
@ -635,7 +639,10 @@ public class DatasetMigrationService {
|
|||
fieldEntity.setTextListValue(new ArrayList<>());
|
||||
for (Map<String, Object> reference : references){
|
||||
ReferenceEntity referenceEntity = this.geReferenceEntity(item, reference, referenceTypeDefinitionEntityMap, referenceTypeDataEntity, referenceMap);
|
||||
if (referenceEntity != null) fieldEntity.getTextListValue().add(referenceEntity.getId().toString());
|
||||
if (referenceEntity != null) {
|
||||
this.createDescriptionReferenceEntity(referenceEntity.getId(), item.getId(), currentField);
|
||||
fieldEntity.getTextListValue().add(referenceEntity.getId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -981,6 +988,8 @@ public class DatasetMigrationService {
|
|||
if(existingEntity == null){
|
||||
if (data.getCreatedById() == null) referenceMap.put(new ReferenceKey(data), data);
|
||||
this.entityManager.persist(data);
|
||||
this.entityManager.flush();
|
||||
|
||||
return data;
|
||||
} else {
|
||||
return existingEntity;
|
||||
|
@ -988,6 +997,24 @@ public class DatasetMigrationService {
|
|||
|
||||
}
|
||||
|
||||
private void createDescriptionReferenceEntity(UUID referenceId, UUID descriptionId, eu.eudat.commons.types.descriptiontemplate.FieldEntity currentField ){
|
||||
DescriptionReferenceEntity data = new DescriptionReferenceEntity();
|
||||
data.setId(UUID.randomUUID());
|
||||
data.setReferenceId(referenceId);
|
||||
data.setDescriptionId(descriptionId);
|
||||
data.setCreatedAt(Instant.now());
|
||||
data.setUpdatedAt(Instant.now());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setData(this.jsonHandlingService.toJsonSafe(this.buildDescriptionReferenceDataEntity(currentField)));
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
||||
private @NotNull DescriptionReferenceDataEntity buildDescriptionReferenceDataEntity(eu.eudat.commons.types.descriptiontemplate.FieldEntity currentField){
|
||||
DescriptionReferenceDataEntity data = new DescriptionReferenceDataEntity();
|
||||
data.setFieldId(currentField.getId());
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public static class Currency{
|
||||
private String name;
|
||||
|
|
|
@ -78,7 +78,13 @@ public class DmpDatasetProfileMigrationService {
|
|||
DmpDatasetProfileData profileData = jsonHandlingService.fromJson(DmpDatasetProfileData.class, item.getData());
|
||||
|
||||
if (profileData == null || profileData.dmpSectionIndex == null || profileData.dmpSectionIndex.isEmpty()){
|
||||
throw new MyApplicationException("Migrate DmpDatasetProfile " + item.getId() + " failed no section info ");
|
||||
if (profileData != null && item.getDmp() != null && item.getDmp().getProfile() != null && item.getDmp().getProfile().getId() != null && item.getDmp().getProfile().getId().equals(UUID.fromString("86635178-36a6-484f-9057-a934e4eeecd5"))){
|
||||
profileData.dmpSectionIndex = new ArrayList<>();
|
||||
profileData.dmpSectionIndex.add(3);
|
||||
logger.warn("Migrate DmpDatasetProfile " + item.getId() + " failed no section info set to 3");
|
||||
} else {
|
||||
throw new MyApplicationException("Migrate DmpDatasetProfile " + item.getId() + " failed no section info ");
|
||||
}
|
||||
}
|
||||
DefinitionEntity definition = dmpBlueprintsMap.getOrDefault(item.getDmp().getProfile().getId(), null);
|
||||
if (definition == null){
|
||||
|
|
|
@ -90,38 +90,38 @@ public class MigrationController {
|
|||
@GetMapping("all")
|
||||
@Transactional
|
||||
public boolean migrateAll() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException {
|
||||
// //Reference
|
||||
// this.dataRepositoryMigrationService.migrate();
|
||||
// this.externalDatasetMigrationService.migrate();
|
||||
// this.funderMigrationService.migrate();
|
||||
// this.grantMigrationService.migrate();
|
||||
// this.organizationMigrationService.migrate();
|
||||
// this.projectMigrationService.migrate();
|
||||
// this.registryMigrationService.migrate();
|
||||
// this.researcherMigrationService.migrate();
|
||||
// this.serviceMigrationService.migrate();
|
||||
//
|
||||
// //User
|
||||
// this.userContactInfoMigrationService.migrate();
|
||||
// this.userMigrationService.migrate();
|
||||
//Reference
|
||||
this.dataRepositoryMigrationService.migrate();
|
||||
this.externalDatasetMigrationService.migrate();
|
||||
this.funderMigrationService.migrate();
|
||||
this.grantMigrationService.migrate();
|
||||
this.organizationMigrationService.migrate();
|
||||
this.projectMigrationService.migrate();
|
||||
this.registryMigrationService.migrate();
|
||||
this.researcherMigrationService.migrate();
|
||||
this.serviceMigrationService.migrate();
|
||||
|
||||
//User
|
||||
this.userContactInfoMigrationService.migrate();
|
||||
this.userMigrationService.migrate();
|
||||
|
||||
//XML recreate
|
||||
this.dmpBlueprintXmlMigrationService.migrate();
|
||||
this.descriptionTemplateXmlMigrationService.migrate();
|
||||
|
||||
// //XML recreate
|
||||
// this.dmpBlueprintXmlMigrationService.migrate();
|
||||
// this.descriptionTemplateXmlMigrationService.migrate();
|
||||
//
|
||||
//Dmp
|
||||
this.dmpMigrationService.migrate();
|
||||
this.dmpDatasetProfileMigrationService.migrate();
|
||||
this.dmpUserMigrationService.migrate();
|
||||
|
||||
// //Description
|
||||
// this.datasetMigrationService.migrate();
|
||||
// this.datasetReferenceMigrationService.migrateDatasetReferences();
|
||||
// this.tagMigrationService.migrate();
|
||||
//
|
||||
// this.storageFileMigrationService.migrate();
|
||||
//Description
|
||||
this.datasetMigrationService.migrate();
|
||||
this.datasetReferenceMigrationService.migrateDatasetReferences();
|
||||
this.tagMigrationService.migrate();
|
||||
|
||||
//throw new RuntimeException("");
|
||||
this.storageFileMigrationService.migrate();
|
||||
|
||||
// throw new RuntimeException("");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue