Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_TopLab_PostIt");

entity.HasOne(d => d.Stamm).WithMany(p => p.TopLabs)
.HasForeignKey(d => d.StammGuid)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_TopLab_Stamm");

entity.HasOne(d => d.TopTopLab).WithMany(p => p.InverseTopTopLab)
.HasForeignKey(d => d.TopTopLabGuid)
.HasConstraintName("FK_TopLab_TopLab");
Expand Down
38 changes: 36 additions & 2 deletions NulllogiconeCore/NulllogiconeCore/Endpoints/StammEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,43 @@ private static async Task<IResult> HandleStammRequest(Guid id, ApplicationDbCont
return Results.Content(rdf, "text/xml");
}

// Default to JSON
var stammJson = await db.Stamms
.Include(s => s.Anglers)
.FirstOrDefaultAsync(s => s.StammGuid == id);
.Where(s => s.StammGuid == id)
.Select(s => new
{
s.StammGuid,
s.Stamm1,
s.Beschreibung,
s.KooK,
s.Datum,
s.Datei,
s.Link,

Anglers = s.Anglers.Select(a => new
{
a.AnglerGuid,
a.Angler1,
a.Beschreibung,
a.Datum
}).ToList(),

TopLabs = s.TopLabs.Select(t => new
{
t.TopLabGuid,
t.Titel,
t.TopLab1,
t.Datum,
t.Datei,
PostIt = new
{
t.PostIt.PostItGuid,
t.PostIt.Titel,
t.PostIt.Datum
}
}).ToList()
})
.FirstOrDefaultAsync();
return stammJson is not null
? Results.Ok(stammJson)
: Results.NotFound($"Stamm with ID {id} not found");
Expand Down
2 changes: 2 additions & 0 deletions NulllogiconeCore/NulllogiconeCore/Models/Stamm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public partial class Stamm

public virtual ICollection<Tolli> Tollis { get; set; } = new List<Tolli>();

public virtual ICollection<TopLab> TopLabs { get; set; } = new List<TopLab>();

public virtual ICollection<Wurzeln> Wurzelns { get; set; } = new List<Wurzeln>();
}

3 changes: 3 additions & 0 deletions NulllogiconeCore/NulllogiconeCore/Models/TopLab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public partial class TopLab

public virtual PostIt PostIt { get; set; } = null!;

public virtual Stamm Stamm { get; set; } = null!;

public virtual ICollection<Tolli> Tollis { get; set; } = new List<Tolli>();

public virtual TopLab? TopTopLab { get; set; }

}

51 changes: 20 additions & 31 deletions NulllogiconeCore/NulllogiconeCore/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
full class name from [SAPCT][NKBZ] with appended GUID. These can display further information
on a webpage as URLs.
</p>
<div class="beispiel">
Example: various URIrefs as hyperlinks
</div>
<h3>Html examples</h3>
<p>
<a
href="/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947">https://nulllogicone.net/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947</a>
Expand All @@ -74,6 +72,24 @@
<a
href="/Netz/76035f19-f4ae-4d58-a388-4bbc72c51cef">https://nulllogicone.net/Netz/76035f19-f4ae-4d58-a388-4bbc72c51cef</a>
</p>
<h3>Json Examples</h3>
<p>
<a href="/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947.json">https://nulllogicone.net/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947.json</a><br>
<a href="/Angler/be279cca-b934-45e6-85fd-96b1a6b1e6ed.json">https://nulllogicone.net/Angler/be279cca-b934-45e6-85fd-96b1a6b1e6ed.json</a><br>
<a href="/PostIt/176bae4e-05d7-4256-97a5-c98bfcbb2869.json">https://nulllogicone.net/PostIt/176bae4e-05d7-4256-97a5-c98bfcbb2869.json</a><br />
<a href="/TopLab/0c373672-6b2d-46bf-8962-9f697f6722d3.json">https://nulllogicone.net/TopLab/0c373672-6b2d-46bf-8962-9f697f6722d3.json</a><br />

</p>
<h3>RDF examples</h3>
<div class="beispiel">
Example: Links to complete RDF documents
</div>
<p>
<a href="/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947.rdf">https://nulllogicone.net/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947.rdf</a><br>
<a href="/Angler/be279cca-b934-45e6-85fd-96b1a6b1e6ed.rdf">https://nulllogicone.net/Angler/be279cca-b934-45e6-85fd-96b1a6b1e6ed.rdf</a><br>
<a href="/PostIt/176bae4e-05d7-4256-97a5-c98bfcbb2869.rdf">https://nulllogicone.net/PostIt/176bae4e-05d7-4256-97a5-c98bfcbb2869.rdf</a><br />
<a href="/TopLab/0c373672-6b2d-46bf-8962-9f697f6722d3.rdf">https://nulllogicone.net/TopLab/0c373672-6b2d-46bf-8962-9f697f6722d3.rdf</a><br />
</p>

<h2 id="schema">2. Schema</h2>
<p>
Expand Down Expand Up @@ -119,36 +135,9 @@
&lt;/nlo:Stamm&gt;
&lt;/rdf:RDF&gt;
</pre>
<div class="beispiel">
Example: Links to complete RDF documents
</div>
<p>
<a
href="/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947.rdf">https://nulllogicone.net/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947.rdf</a><br>
<a
href="/Angler/be279cca-b934-45e6-85fd-96b1a6b1e6ed.rdf">https://nulllogicone.net/Angler/be279cca-b934-45e6-85fd-96b1a6b1e6ed.rdf</a><br>
<a
href="/PostIt/176bae4e-05d7-4256-97a5-c98bfcbb2869.rdf">https://nulllogicone.net/PostIt/176bae4e-05d7-4256-97a5-c98bfcbb2869.rdf</a><br />
<a
href="/TopLab/0c373672-6b2d-46bf-8962-9f697f6722d3.rdf">https://nulllogicone.net/TopLab/0c373672-6b2d-46bf-8962-9f697f6722d3.rdf</a><br />
</p>
<p>
<strong>same with json</strong><br />
<a
href="/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947.json">https://nulllogicone.net/Stamm/b4111e0e-48d9-42c4-a6f6-ec4991264947.json</a><br>
<a
href="/Angler/be279cca-b934-45e6-85fd-96b1a6b1e6ed.json">https://nulllogicone.net/Angler/be279cca-b934-45e6-85fd-96b1a6b1e6ed.json</a><br>
<a
href="/PostIt/176bae4e-05d7-4256-97a5-c98bfcbb2869.json">https://nulllogicone.net/PostIt/176bae4e-05d7-4256-97a5-c98bfcbb2869.json</a><br />
<a
href="/TopLab/0c373672-6b2d-46bf-8962-9f697f6722d3.json">https://nulllogicone.net/TopLab/0c373672-6b2d-46bf-8962-9f697f6722d3.json</a><br />
</p>
<p>
For each further entity in an RDF document, a link is specified with the predicate <font face="Courier New">
&lt;nlo:resource&gt;
</font>, which can be followed.
</p>


<h2 id="importexport">4. Input / Output</h2>
<p>
Data can be exchanged and distributed in RDF format. For this purpose, functions are
Expand Down
18 changes: 0 additions & 18 deletions NulllogiconeCore/NulllogiconeCore/Pages/Ui/PostIt/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,5 @@
}
</div>
</div>

<div class="mt-4">
<h3>JSON Response</h3>
<pre class="bg-light p-3 border">@Model.JsonResponse</pre>
</div>
}
else
{
<div class="alert alert-warning">
@if (Model.Guid.HasValue)
{
<p>PostIt with ID @Model.Guid not found.</p>
}
else
{
<p>No PostIt ID provided.</p>
}
</div>
}
</div>
35 changes: 5 additions & 30 deletions NulllogiconeCore/NulllogiconeCore/Pages/Ui/PostIt/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,22 @@ public IndexModel(ApplicationDbContext db, IHttpClientFactory httpClientFactory)
}

[FromRoute]
public Guid? Guid { get; set; }
public Guid Guid { get; set; }

public Models.PostIt? Entity { get; set; }
public string? JsonResponse { get; set; }

public async Task OnGetAsync()
{
if (Guid.HasValue)
{

Entity = _db.PostIts
.Include(p => p.Codes)
.Include(p => p.TopLabs)
.Include(p => p.Provisions)
.Include(p => p.Wurzelns)
.FirstOrDefault(p => p.PostItGuid == Guid.Value);
.FirstOrDefault(p => p.PostItGuid == Guid);

var client = _api.CreateClient("BackendApi");
// Using the unified endpoint for JSON data
var response = await client.GetAsync($"/postit/{Guid.Value}.json");
if (response.IsSuccessStatusCode)
{
var jsonString = await response.Content.ReadAsStringAsync();
try
{
var jsonElement = System.Text.Json.JsonSerializer.Deserialize<object>(jsonString);
JsonResponse = System.Text.Json.JsonSerializer.Serialize(jsonElement, new System.Text.Json.JsonSerializerOptions { WriteIndented = true });
}
catch
{
JsonResponse = jsonString; // fallback if not valid JSON
}
}
else
{
JsonResponse = $"Error: {response.StatusCode}";
}
}
else
{
JsonResponse = "No GUID provided.";
}


}
}
}
4 changes: 0 additions & 4 deletions NulllogiconeCore/NulllogiconeCore/Pages/Ui/Stamm/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,4 @@ else
<p>No anglers found for this Stamm.</p>
}

<h2>Json response from HttpClient</h2>
<pre>
@Model.JsonResponse
</pre>

31 changes: 2 additions & 29 deletions NulllogiconeCore/NulllogiconeCore/Pages/Ui/Stamm/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@ namespace NulllogiconeCore.Pages.Ui.Stamm
public class IndexModel : PageModel
{
private readonly ApplicationDbContext _db;
private readonly IHttpClientFactory _api;

public IndexModel(ApplicationDbContext db, IHttpClientFactory httpClientFactory)
public IndexModel(ApplicationDbContext db)
{
_db = db;
_api = httpClientFactory;
}

[FromRoute]
public Guid? Guid { get; set; }

public Models.Stamm? Entity { get; set; }
public string? JsonResponse { get; set; }

public async Task OnGetAsync()
{
Expand All @@ -29,32 +26,8 @@ public async Task OnGetAsync()
Entity = _db.Stamms
.Include(s => s.Anglers)
.FirstOrDefault(s => s.StammGuid == Guid.Value);
var client = _api.CreateClient("BackendApi");
var response = await client.GetAsync($"/test/{Guid.Value}");
if (response.IsSuccessStatusCode)
{
var jsonString = await response.Content.ReadAsStringAsync();
try
{
var jsonElement = System.Text.Json.JsonSerializer.Deserialize<object>(jsonString);
JsonResponse = System.Text.Json.JsonSerializer.Serialize(jsonElement, new System.Text.Json.JsonSerializerOptions { WriteIndented = true });
}
catch
{
JsonResponse = jsonString; // fallback if not valid JSON
}
}
else
{
JsonResponse = $"Error: {response.StatusCode}";
}
}
else
{
// Handle case when guid is not provided
// Entity = null or default;
JsonResponse = "No GUID provided.";
}

}
}
}
Expand Down
31 changes: 31 additions & 0 deletions NulllogiconeCore/NulllogiconeCore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Null Logic One

The semantic API behind OLI-it, https://www.oli-it.com
All Entitites with endpoints for html, json, and RDF

> This repository is a fork from an old OLI-it project in Azure DevOps.


## Goal

The goal is to have a RDF API again for OLI-it deployed to https://nulllogicone.net/


## Visualize

https://issemantic.net/rdf-visualizer

## Approach

create a new dotnet Core Web + Api project for html, json and rdf output.

## ToDo

[x] Move legacy projects to archive folder, delete it soon.
[x] Deploy to real Azure App Service site, configure DNS.
[x] Create GitHub Actions for automated deployment
[ ] Add more OLI-it entities (SAPCT-NKBZ).
[ ] Improve RDF output with more ontologies.
[ ] Add SPARQL endpoint.


Loading