Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • coscine/backend/scripts/kpi-generator
1 result
Select Git revision
Show changes
Commits on Source (4)
......@@ -7,7 +7,7 @@
<AssemblyName>Coscine.KpiGenerator</AssemblyName>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.1.7</Version>
<Version>0.1.8</Version>
</PropertyGroup>
<PropertyGroup>
......
......@@ -190,10 +190,6 @@ public abstract class Reporting<O> where O : class
foreach (var org in organizations)
{
var ror = org.RorUrl;
if (ror.Contains("www.rwth-aachen.de"))
{
ror = ConvertOldRwthOrganizationToRor(ror); // e.g. <https://www.rwth-aachen.de/22000> turns into <https://ror.org/04xfq0f34#ORG-42NHW>
}
result.Add(new Organization
{
RorUrl = ror.Contains('#') ? ror[..ror.IndexOf('#')] : ror, // e.g. <https://ror.org/04xfq0f34#ORG-42NHW> turns into <https://ror.org/04xfq0f34>
......@@ -250,54 +246,4 @@ public abstract class Reporting<O> where O : class
}
Console.WriteLine();
}
public string ConvertOldRwthOrganizationToRor(string organization)
{
// Converts values like https://www.rwth-aachen.de/22000 to its corresponding RoR (here: https://ror.org/04xfq0f34#ORG-42NHW)
var _queryString = new SparqlParameterizedString
{
CommandText = $@"
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org: <http://www.w3.org/ns/org#>
SELECT DISTINCT ?source ?inst
WHERE {{
# Define ?source URI
VALUES ?source
{{
<{organization}>
}} .
# Get Display Name of the institution
?source rdfs:label ?name .
# Get Institute Identifier in ?ikzid
?source org:identifier ?ikzid .
# IKZ ID is in the form 'ikz:<ID>' or 'ikz:0<ID>'
BIND(concat('ikz:', ?ikzid) AS ?ikz) .
BIND(concat('ikz:0', ?ikzid) AS ?ikz0) .
# Fetch all institutes from RWTH
<{RwthRor}> org:hasUnit ?inst .
# OR statement to search by ikz variations and name
{{ ?inst org:identifier ?ikz .}} UNION {{ ?inst org:identifier ?ikz0 .}} UNION {{ ?inst rdfs:label ?name .}}
}}
GROUP BY ?inst
"
};
using var results = RdfStoreConnector.QueryEndpoint.QueryWithResultSet(_queryString.ToString());
if (!results.IsEmpty)
{
var inst = results.Select(x => x.Value("inst").ToString()); // Get the value for ?inst
if (inst.Any())
{
Console.WriteLine($" Organization {organization} found to match {inst.ToList()[0]}");
organization = inst.ToList()[0];
}
}
Console.WriteLine($" Could not find match for {organization}");
return organization;
}
}
\ No newline at end of file
......@@ -62,7 +62,7 @@ public class ProjectReporting : Reporting<ProjectReportingOptions>
Organizations = GetOrganizations(projectReturnObject),
Disciplines = projectReturnObject.Disciplines.ToList(),
Deleted = projectReturnObject.Deleted,
ProjectVisibilityId = projectReturnObject.Visibility.Id,
ProjectVisibility = projectReturnObject.Visibility,
GrantId = projectReturnObject.GrantId,
Users = _projectRoleModel.GetAllWhere(x => x.ProjectId == projectReturnObject.Id).Count(),
ResourceTypeQuota = GetResourceTypeQuota(projectReturnObject.Id)
......@@ -86,11 +86,6 @@ public class ProjectReporting : Reporting<ProjectReportingOptions>
}
var returnObjectsForOrganization = returnObjects.Where(ro => ro.Organizations.Select(o => o.RorUrl).Any(e => e.Contains(entry.RorUrl))).ToList();
// Additional condition to process old RWTH Entries (Could be removed after entries in virtuoso are migrated to their correct RoRs)
if (entry.RorUrl.Equals(RwthRor))
{
returnObjectsForOrganization.AddRange(returnObjects.Where(ro => ro.Organizations.Select(o => o.RorUrl).Any(e => e.Contains("www.rwth-aachen.de"))).ToList());
}
reportingFilesPerOrganization.Add(new ReportingFileObject
{
......
......@@ -13,7 +13,7 @@ public class ReturnObject
public List<Organization> Organizations { get; set; } = new();
public List<DisciplineObject> Disciplines { get; set; } = new();
public bool Deleted { get; set; }
public Guid ProjectVisibilityId { get; set; }
public VisibilityObject ProjectVisibility { get; set; } = null!;
public string? GrantId { get; set; }
public int? Users { get; set; } = null;
public List<ResourceTypeQuotaReturnObject> ResourceTypeQuota { get; set; } = new();
......
......@@ -58,7 +58,7 @@ public class ResourceReporting : Reporting<ResourceReportingOptions>
DateCreated = resourceReturnObject.DateCreated,
Archived = resourceReturnObject.Archived,
Deleted = resourceReturnObject.Deleted,
MetadataVisibilityId = resourceReturnObject.Visibility.Id,
MetadataVisibility = resourceReturnObject.Visibility,
RelatedProjectId = GetRelatedProject(resource.Id),
Organizations = GetOrganizations(resourceReturnObject.Id),
Disciplines = resourceReturnObject.Disciplines.ToList(),
......@@ -84,11 +84,6 @@ public class ResourceReporting : Reporting<ResourceReportingOptions>
Console.WriteLine($" WARNING!: Organization \"{entry.RorUrl}\" could not be correctly identified. Will use \"{_otherOrganization.RorUrl}\".");
}
var returnObjectsForOrganization = returnObjects.Where(ro => ro.Organizations.Select(o => o.RorUrl).Any(e => e.Equals(entry.RorUrl))).ToList();
// Additional condition to process old RWTH Entries (Could be removed after entries in virtuoso are migrated to their correct RoRs)
if (entry.RorUrl.Equals(RwthRor))
{
returnObjectsForOrganization.AddRange(returnObjects.Where(ro => ro.Organizations.Select(o => o.RorUrl).Any(e => e.Contains("www.rwth-aachen.de"))).ToList());
}
reportingFilesPerOrganization.Add(new ReportingFileObject
{
......
......@@ -13,7 +13,7 @@ public class ReturnObject
public DateTime? DateCreated { get; set; } = null;
public bool Archived { get; set; }
public bool Deleted { get; set; }
public Guid MetadataVisibilityId { get; set; }
public VisibilityObject MetadataVisibility { get; set; } = null!;
public Guid? RelatedProjectId { get; set; }
public List<Organization> Organizations { get; set; } = new();
public List<DisciplineObject> Disciplines { get; set; } = new();
......