migration changes

This commit is contained in:
Efstratios Giannopoulos 2024-05-30 17:56:38 +03:00
parent 90a2737321
commit 1a26327fd3
1 changed files with 16 additions and 4 deletions

View File

@ -194,6 +194,8 @@ public class DescriptionTemplateXmlMigrationService {
data.setId(persist.getId().trim()); data.setId(persist.getId().trim());
data.setOrdinal(persist.getOrdinal()); data.setOrdinal(persist.getOrdinal());
data.setSemantics(persist.getSchematics()); data.setSemantics(persist.getSchematics());
// if (persist.getSchematics() != null && persist.getSchematics().stream().anyMatch("rda.dmp.cost"::equalsIgnoreCase)) throw new MyApplicationException("rda.dmp.cost not implemented");
// if (persist.getSchematics() != null && persist.getSchematics().stream().anyMatch("rda.dataset.data_quality_assurance"::equalsIgnoreCase)) throw new MyApplicationException("rda.dataset.data_quality_assurance not implemented");
if (persist.getValidations() != null) data.setValidations(persist.getValidations().stream().map(x-> { if (persist.getValidations() != null) data.setValidations(persist.getValidations().stream().map(x-> {
switch (x){ switch (x){
case NONE -> { case NONE -> {
@ -584,8 +586,18 @@ public class DescriptionTemplateXmlMigrationService {
} }
private ReferenceTypeEntity getReferenceTypeEntityByUrl(ReferenceTypeDefinitionEntity definitionEntity, Map<UUID, ReferenceTypeEntity> knownReferenceEntities){ private ReferenceTypeEntity getReferenceTypeEntityByUrl(ReferenceTypeDefinitionEntity definitionEntity, Map<UUID, ReferenceTypeEntity> knownReferenceEntities){
if (definitionEntity == null || this.conventionService.isListNullOrEmpty(definitionEntity.getSources()) || definitionEntity.getSources().size() != 1) return null; if (definitionEntity == null || this.conventionService.isListNullOrEmpty(definitionEntity.getSources()) || definitionEntity.getSources().isEmpty()) return null;
ExternalFetcherApiSourceConfigurationEntity externalFetcherApiSourceConfigurationEntity = (ExternalFetcherApiSourceConfigurationEntity)definitionEntity.getSources().getFirst(); List<ReferenceTypeEntity> referenceTypeEntities = new ArrayList<>();
for (ExternalFetcherBaseSourceConfigurationEntity externalFetcherApiSourceConfigurationEntity : definitionEntity.getSources()){
ReferenceTypeEntity referenceTypeEntity = getReferenceTypeEntityForSourceByUrl((ExternalFetcherApiSourceConfigurationEntity)externalFetcherApiSourceConfigurationEntity, knownReferenceEntities);
if (referenceTypeEntity == null) return null;
if (referenceTypeEntities.stream().noneMatch(x-> x.getId().equals(referenceTypeEntity.getId()))) referenceTypeEntities.add(referenceTypeEntity);
}
if (referenceTypeEntities.size() == 1) return referenceTypeEntities.getFirst();
return null;
}
private ReferenceTypeEntity getReferenceTypeEntityForSourceByUrl(ExternalFetcherApiSourceConfigurationEntity externalFetcherApiSourceConfigurationEntity, Map<UUID, ReferenceTypeEntity> knownReferenceEntities){
if (externalFetcherApiSourceConfigurationEntity == null || this.conventionService.isNullOrEmpty(externalFetcherApiSourceConfigurationEntity.getUrl())) return null; if (externalFetcherApiSourceConfigurationEntity == null || this.conventionService.isNullOrEmpty(externalFetcherApiSourceConfigurationEntity.getUrl())) return null;
String url = StringUtils.stripEnd(externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).replace(" ", ""), "/"); String url = StringUtils.stripEnd(externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).replace(" ", ""), "/");