Skip to content
Snippets Groups Projects

Chore: 1.1.1

Merged Petar Hristov requested to merge main into dev
3 files
+ 22
12
Compare changes
  • Side-by-side
  • Inline

Files

@@ -27,7 +27,7 @@ namespace AimsBackend.Controllers
_configuration = new Coscine.Configuration.EnvironmentConfiguration();
_logger = logger;
_graphPrefix = _configuration.GetString("GRAPH_PREFIX", "https://aims-projekt.de/metadata/");
_sparqlEndpoint = _configuration.GetString("SPARQL_ENDPOINT", "https://db.aims.otc.coscine.dev/sparql");
_sparqlEndpoint = _configuration.GetString("SPARQL_ENDPOINT", "http://vdb:8890/sparql");
UpdateEndpoint = new SparqlRemoteUpdateEndpoint(new Uri(string.Format(_sparqlEndpoint)));
QueryEndpoint = new SparqlRemoteEndpoint(new Uri(string.Format(_sparqlEndpoint)));
@@ -37,11 +37,13 @@ namespace AimsBackend.Controllers
/// <summary>
/// Gets metadata by a query and targetClass parameter and returns a list of text/turtle formatted metadata
/// </summary>
/// <param name="subject"></param>
/// <param name="predicate"></param>
/// <param name="query"></param>
/// <param name="targetClass"></param>
/// <returns></returns>
[HttpGet(Name = "GetMetadata")]
public IEnumerable<string> Get(string? query, Uri? targetClass)
public IEnumerable<string> Get(string? subject, string? predicate, string? query, Uri? targetClass)
{
var queryString = new SparqlParameterizedString
{
@@ -49,15 +51,25 @@ namespace AimsBackend.Controllers
GRAPH ?g {
?s ?p ?o .
" + (targetClass != null ? "?s a @targetClass ." : "") + @"
" + (subject != null ? "FILTER(REGEX(str(?s), @subject)) ." : "") + @"
" + (predicate != null ? "FILTER(REGEX(str(?p), @predicate)) ." : "") + @"
" + (query != null ? "FILTER(REGEX(str(?o), @query)) ." : "") + @"
} .
FILTER(REGEX(str(?g), @graphPrefix)) .
}"
};
if (targetClass != null)
if (targetClass != null)
{
queryString.SetUri("targetClass", targetClass);
}
if (subject != null)
{
queryString.SetLiteral("subject", subject);
}
if (predicate != null)
{
queryString.SetLiteral("predicate", predicate);
}
if (query != null)
{
queryString.SetLiteral("query", query);
@@ -97,7 +109,7 @@ namespace AimsBackend.Controllers
{
var contentType = Request.Headers.ContentType;
var mimeType = "application/n-triples";
if (string.IsNullOrWhiteSpace(contentType))
if (!string.IsNullOrWhiteSpace(contentType) && contentType != "application/json")
{
mimeType = contentType;
}
@@ -147,7 +159,7 @@ namespace AimsBackend.Controllers
{
var contentType = Request.Headers.ContentType;
var mimeType = "application/n-triples";
if (string.IsNullOrWhiteSpace(contentType))
if (!string.IsNullOrWhiteSpace(contentType) && contentType != "application/json")
{
mimeType = contentType;
}
@@ -170,4 +182,4 @@ namespace AimsBackend.Controllers
return Ok(await ValidationModel.ValidateMetadata(applicationProfile, graph));
}
}
}
\ No newline at end of file
}
Loading