Skip to content
Snippets Groups Projects

Fix: Handle empty AP (coscine/issues#1931)

Merged Benedikt Heinrichs requested to merge Hotfix/1931-indexingOfBrokenDocs into master
2 files
+ 42
18
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -13,7 +13,7 @@ namespace Coscine.SemanticSearch
/// <summary>
/// Provides all necessary queries to the RDF database to create a mapping of metadata graphs into a document.
/// </summary>
public class RdfClient
public class RdfClient
{
public const string LABEL_LITERAL_RULE = "instance";
public const string LABEL_ADDITIONAL_RULE = "graph";
@@ -62,6 +62,10 @@ namespace Coscine.SemanticSearch
}} LIMIT 1";
_queryString.SetUri("uri", new Uri(graphName));
var results = _connector.QueryWithResultSet(_queryString);
if (results.Count == 0)
{
return null;
}
return results.First().Value("applicationProfile").ToString();
}
@@ -192,7 +196,7 @@ namespace Coscine.SemanticSearch
// Expected correct URI format for Projects: https://purl.org/coscine/projects/{ProjectGUID}
var projectRoleModel = new ProjectRoleModel();
return projectRoleModel.GetAllWhere(p => p.UserId.Equals(Guid.Parse(user)) && p.Project.Deleted == false).Select(p => $"https://purl.org/coscine/projects/{p.ProjectId}").ToList();
return projectRoleModel.GetAllWhere(p => p.UserId.Equals(Guid.Parse(user)) && p.Project.Deleted == false).Select(p => $"https://purl.org/coscine/projects/{p.ProjectId}").ToList();
}
/// <summary>
@@ -329,7 +333,7 @@ namespace Coscine.SemanticSearch
}} ORDER BY ?order";
_queryString.SetUri("uri", new Uri(graphName));
var results = _connector.QueryWithResultSet(_queryString);
return results.ToDictionary(
x => x.Value("class").ToString(),
x =>
@@ -466,13 +470,13 @@ namespace Coscine.SemanticSearch
foreach (var graph in documents.Keys)
{
jObjects.Add(graph, CreateFields(documents[graph], profile, indexMapper));
}
}
}
}
else if (documents.Count() > 0)
{
jObjects.Add(graphName, CreateFields(documents[graphName], profile, indexMapper));
}
return jObjects;
}
@@ -503,11 +507,17 @@ namespace Coscine.SemanticSearch
try
{
jObject.Merge(_dataTypeParser.Parse(label, triple.Object, indexMapper, profile));
} catch (NotIndexableException e)
}
catch (NotIndexableException e)
{
Console.WriteLine($"Property {property} could not be indexed. Reason: {e.Reason}");
continue;
}
catch (FormatException e)
{
Console.WriteLine($"Property {property} could not be indexed. Reason: {e.Message}");
continue;
}
}
return jObject;
}
Loading