Skip to content
Snippets Groups Projects
Commit ed94c7cd authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Simplify Query

parent 17f11a62
No related branches found
No related tags found
1 merge request!59Fix: Deal with other organizations
...@@ -420,44 +420,36 @@ namespace Coscine.Metadata ...@@ -420,44 +420,36 @@ namespace Coscine.Metadata
return triples; return triples;
} }
public IEnumerable<Triple> GetOrganizationByExternalOrEntityId(string externalOrEntityId) public IEnumerable<Triple> GetOrganizationByEntityId(string entityId)
{ {
var _queryString = new SparqlParameterizedString() var cmdString = new SparqlParameterizedString()
{ {
CommandText = $@" CommandText = $@"
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org: <http://www.w3.org/ns/org#> PREFIX org: <http://www.w3.org/ns/org#>
SELECT DISTINCT ?ror SELECT DISTINCT ?ror (rdfs:label AS ?p) ?name
WHERE {{ WHERE {{
?ror rdfs:label ?name . ?ror rdfs:label ?name .
{{ {{
SELECT DISTINCT ?ror SELECT DISTINCT ?ror
WHERE {{ WHERE {{
?class ?p ?memberUrl ; ?ror ?p ?value .
org:organization ?ror . FILTER( ?value IN ( @entityId ))
{{
SELECT DISTINCT ?memberUrl
WHERE {{
?memberUrl ?p ?value .
FILTER( ?value IN ( '{externalOrEntityId}' ))
}}
}}
}} }}
}} }}
}} }}
" "
}; };
using var results = QueryEndpoint.QueryWithResultSet(_queryString.ToString()); cmdString.SetLiteral("entityId", entityId);
if (!results.IsEmpty)
{ using var resultSet = QueryEndpoint.QueryWithResultSet(cmdString.ToString());
var ror = results.Select(x => x.Value("ror").ToString()); // Get the value for ?ror var triples = new List<Triple>();
if (ror.Any()) foreach (SparqlResult r in resultSet)
{ {
return GetLabelForSubject(new Uri(ror.ToList()[0])); triples.Add(new Triple(r.Value("ror"), r.Value("p"), r.Value("name")));
} }
} return triples;
return new List<Triple>();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment