Skip to content
Snippets Groups Projects

Fix: Organizations

Merged Petar Hristov requested to merge dev into main
Files
2
@@ -158,7 +158,8 @@ public class UserReporting : Reporting<UserReportingOptions>
result.Add(orgOrcid);
break;
case "shibboleth":
var orgShibboleth = GetOrganizationByUserExternalId(externalId.ExternalId1);
// Find the RoR first based on the Organization Entity Id, then try based on the user's External Id.
var orgShibboleth = GetOrganizationByExternalOrEntityId(externalId.Organization) ?? GetOrganizationByExternalOrEntityId(externalId.ExternalId1);
if (orgShibboleth is null)
{
Console.WriteLine($" No {searchedEntityType} found for user with ID \"{id}\" and login provider {loginProvider.DisplayName}");
@@ -197,7 +198,7 @@ public class UserReporting : Reporting<UserReportingOptions>
return result.DistinctBy(e => e.RorUrl).ToList();
}
private Organization? GetOrganizationByUserExternalId(string userExternalId)
private Organization? GetOrganizationByExternalOrEntityId(string externalOrEntityId)
{
var _queryString = new SparqlParameterizedString()
{
@@ -217,7 +218,7 @@ public class UserReporting : Reporting<UserReportingOptions>
SELECT DISTINCT ?memberUrl
WHERE {{
?memberUrl ?p ?value .
FILTER( ?value IN ( '{userExternalId}' ))
FILTER( ?value IN ( '{externalOrEntityId}' ))
}}
}}
}}
@@ -226,12 +227,15 @@ public class UserReporting : Reporting<UserReportingOptions>
"
};
using var results = RdfStoreConnector.QueryEndpoint.QueryWithResultSet(_queryString.ToString());
if (results.IsEmpty)
if (!results.IsEmpty)
{
return null;
var ror = results.Select(x => x.Value("ror").ToString()); // Get the value for ?ror
if (ror.Any())
{
return FetchOrganizationByRor(ror.ToList()[0]);
}
}
var rors = results.Select(x => x.Value("ror").ToString()).ToList(); // Get the value for ?ror
return FetchOrganizationByRor(rors[0]);
return null;
}
private Organization? TryGetOrganizationByLabel(string rdfsLabel)
@@ -257,12 +261,15 @@ public class UserReporting : Reporting<UserReportingOptions>
"
};
using var results = RdfStoreConnector.QueryEndpoint.QueryWithResultSet(_queryString.ToString());
if (results.IsEmpty)
if (!results.IsEmpty)
{
return null;
var ror = results.Select(x => x.Value("ror").ToString()); // Get the value for ?ror
if (ror.Any())
{
return FetchOrganizationByRor(ror.ToList()[0]);
}
}
var ror = results.Select(x => x.Value("ror").ToString()).ToList()[0]; // Get the value for ?ror
return FetchOrganizationByRor(ror);
return null;
}
private DateTime? GetLatestActivity(Guid id)
Loading