Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-04-25 14:08:11 +03:00
commit 5ff5825f00
1 changed files with 25 additions and 22 deletions

View File

@ -29,6 +29,7 @@ import gr.cite.tools.logging.LoggerService;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.ws.rs.NotSupportedException; import jakarta.ws.rs.NotSupportedException;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.inject.Guice; import org.elasticsearch.common.inject.Guice;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -539,18 +540,20 @@ public class DescriptionTemplateXmlMigrationService {
if (definitionEntity == null || this.conventionService.isListNullOrEmpty(definitionEntity.getSources()) || definitionEntity.getSources().size() != 1) return null; if (definitionEntity == null || this.conventionService.isListNullOrEmpty(definitionEntity.getSources()) || definitionEntity.getSources().size() != 1) return null;
ExternalFetcherApiSourceConfigurationEntity externalFetcherApiSourceConfigurationEntity = (ExternalFetcherApiSourceConfigurationEntity)definitionEntity.getSources().getFirst(); ExternalFetcherApiSourceConfigurationEntity externalFetcherApiSourceConfigurationEntity = (ExternalFetcherApiSourceConfigurationEntity)definitionEntity.getSources().getFirst();
if (externalFetcherApiSourceConfigurationEntity == null || this.conventionService.isNullOrEmpty(externalFetcherApiSourceConfigurationEntity.getUrl())) return null; if (externalFetcherApiSourceConfigurationEntity == null || this.conventionService.isNullOrEmpty(externalFetcherApiSourceConfigurationEntity.getUrl())) return null;
if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://eestore.paas2.uninett.no/api/license/".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.License); String url = StringUtils.stripEnd(externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).replace(" ", ""), "/");
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://zenodo.org/api/licenses".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.License); if (url.equals("https://eestore.paas2.uninett.no/api/license".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.License);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://zenodo.org/api/licenses?q={like}".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.License); else if (url.equals("https://zenodo.org/api/licenses".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.License);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("http://api.openaire.eu/search/publications".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.Publication); else if (url.equals("https://zenodo.org/api/licenses?q={like}".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.License);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("http://api.openaire.eu/search/publications?format=json&title={like}".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.Publication); else if (url.equals("http://api.openaire.eu/search/publications".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.Publication);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://services.openaire.eu/openaire/ds/searchdetails/{page}/{pageSize}?requestSortBy=id&order=ASCENDING".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.Publication); else if (url.equals("http://api.openaire.eu/search/publications?format=json&title={like}".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.Publication);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://eestore.paas2.uninett.no/api/datarepo/".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.DataRepositories); else if (url.equals("https://services.openaire.eu/openaire/ds/searchdetails/{page}/{pageSize}?requestSortBy=id&order=ASCENDING".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.Publication);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://services.openaire.eu/search/v2/api/datasources?q={like}&fq=datasourcetypeuiname".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.DataRepositories); else if (url.equals("https://eestore.paas2.uninett.no/api/datarepo".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.DataRepositories);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://services.openaire.eu/search/v2/api/resources?query=oaftype exact datasource and {like} and ( datasourcetypeuiid = \"pubsrepository::journal\" or datasourcetypeuiid = \"aggregator::pubsrepository::journals\")&page=0&size=60&format=json".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.Journal); else if (url.equals("https://services.openaire.eu/search/v2/api/datasources?q={like}&fq=datasourcetypeuiname exact \"Data Repository\"&format=json".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.DataRepositories);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://eestore.paas2.uninett.no/api/metadataschema/".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.Registries); else if (url.equals("https://services.openaire.eu/search/v2/api/datasources?q={like}&fq=datasourcetypeuiname".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.DataRepositories);
else if (externalFetcherApiSourceConfigurationEntity.getUrl().trim().toLowerCase(Locale.ROOT).equals("https://eestore.paas2.uninett.no/api/taxonomy/".trim().toLowerCase(Locale.ROOT))) return knownReferenceEntities.get(ReferenceTypeIds.Taxonomy); else if (url.equals("https://services.openaire.eu/search/v2/api/resources?query=oaftype exact datasource and {like} and ( datasourcetypeuiid = \"pubsrepository::journal\" or datasourcetypeuiid = \"aggregator::pubsrepository::journals\")&page=0&size=60&format=json".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.Journal);
else if (url.equals("https://eestore.paas2.uninett.no/api/metadataschema".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.Registries);
else if (url.equals("https://eestore.paas2.uninett.no/api/taxonomy".trim().toLowerCase(Locale.ROOT).replace(" ", ""))) return knownReferenceEntities.get(ReferenceTypeIds.Taxonomy);
return null; return null;
} }
@ -560,16 +563,16 @@ public class DescriptionTemplateXmlMigrationService {
if (definitionEntity.getSources() != null){ if (definitionEntity.getSources() != null){
for (ExternalFetcherApiSourceConfigurationEntity source : definitionEntity.getSources().stream().map(x-> (ExternalFetcherApiSourceConfigurationEntity)x).toList()){ for (ExternalFetcherApiSourceConfigurationEntity source : definitionEntity.getSources().stream().map(x-> (ExternalFetcherApiSourceConfigurationEntity)x).toList()){
StringBuilder sourceStringBuilder = new StringBuilder(); StringBuilder sourceStringBuilder = new StringBuilder();
sourceStringBuilder.append(source.getUrl()); sourceStringBuilder.append(StringUtils.stripEnd(source.getUrl().trim().toLowerCase(Locale.ROOT), "/"));
sourceStringBuilder.append(source.getHttpMethod().getValue().toString()); sourceStringBuilder.append(source.getHttpMethod().getValue().toString().trim().toLowerCase(Locale.ROOT));
sourceStringBuilder.append(source.getKey()); // sourceStringBuilder.append(source.getKey());
if (source.getResults() != null){ // if (source.getResults() != null){
sourceStringBuilder.append(source.getResults().getResultsArrayPath()); // sourceStringBuilder.append(source.getResults().getResultsArrayPath());
if (source.getResults().getFieldsMapping() != null) { // if (source.getResults().getFieldsMapping() != null) {
sourceStringBuilder.append(source.getResults().getFieldsMapping().stream().filter(x-> x.getCode().equals(ReferenceEntity.KnownFields.ReferenceId)).map(ResultFieldsMappingConfigurationEntity::getResponsePath).findFirst().orElse("")); // sourceStringBuilder.append(source.getResults().getFieldsMapping().stream().filter(x-> x.getCode().equals(ReferenceEntity.KnownFields.ReferenceId)).map(ResultFieldsMappingConfigurationEntity::getResponsePath).findFirst().orElse(""));
sourceStringBuilder.append(source.getResults().getFieldsMapping().stream().filter(x-> x.getCode().equals(ReferenceEntity.KnownFields.Label)).map(ResultFieldsMappingConfigurationEntity::getResponsePath).findFirst().orElse("")); // sourceStringBuilder.append(source.getResults().getFieldsMapping().stream().filter(x-> x.getCode().equals(ReferenceEntity.KnownFields.Label)).map(ResultFieldsMappingConfigurationEntity::getResponsePath).findFirst().orElse(""));
} // }
} // }
sourceKeys.add(sourceStringBuilder.toString().toLowerCase(Locale.ROOT)); sourceKeys.add(sourceStringBuilder.toString().toLowerCase(Locale.ROOT));
} }
} }