Backup #292
| ID | 292 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Controller/OntologyController.php |
| Version | 1 |
| Typ |
modified |
| Größe | 4.1 KB |
| Hash | e2632a91bc3116c069b597bdf0b48d2502d7d4c218124b60f1b389e1c686b558 |
| Datum | 2025-12-22 08:03:01 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace Controller;
use Framework\Controller;
use Infrastructure\SemanticExplorerRepository;
/**
* OntologyController - CRUD for Semantic Explorer Ontology
*
* Extracted from SemanticExplorerController for SRP compliance.
*/
class OntologyController extends Controller
{
private SemanticExplorerRepository $repository;
public function __construct()
{
$this->repository = new SemanticExplorerRepository();
}
/**
* GET /semantic-explorer/ontologie
* Konzept-Klassen
*/
public function index(): void
{
$classes = $this->repository->getOntologyClasses();
// Properties dekodieren
foreach ($classes as &$class) {
$class['properties_decoded'] = json_decode($class['properties'] ?? '{}', true) ?: [];
}
$stats = $this->repository->getOntologyStats();
$this->view('semantic-explorer.ontologie', [
'title' => 'Ontologie',
'classes' => $classes,
'stats' => $stats,
]);
}
/**
* GET /semantic-explorer/ontologie/new
*/
public function create(): void
{
$this->view('semantic-explorer.ontologie.new', [
'title' => 'Neue Ontologie-Klasse',
'classes' => $this->repository->getOntologyClassesForSelect(),
]);
}
/**
* POST /semantic-explorer/ontologie
*/
public function store(): void
{
$input = json_decode(file_get_contents('php://input'), true);
$name = trim($input['name'] ?? '');
$parentId = isset($input['parent_class_id']) && $input['parent_class_id'] !== '' ? (int) $input['parent_class_id'] : null;
$description = trim($input['description'] ?? '') ?: null;
$properties = $input['properties'] ?? [];
if ($name === '') {
$this->json(['success' => false, 'error' => 'Name ist erforderlich'], 400);
return;
}
try {
$id = $this->repository->createOntologyClass($name, $parentId, $description, $properties);
$this->json(['success' => true, 'id' => $id]);
} catch (\Exception $e) {
$this->json(['success' => false, 'error' => $e->getMessage()], 500);
}
}
/**
* GET /semantic-explorer/ontologie/{id}/edit
*/
public function edit(int $id): void
{
$class = $this->repository->getOntologyClass($id);
if ($class === null) {
$this->notFound('Klasse nicht gefunden');
}
$this->view('semantic-explorer.ontologie.edit', [
'title' => 'Klasse bearbeiten',
'class' => $class,
'classes' => $this->repository->getOntologyClassesForSelect(),
]);
}
/**
* POST /semantic-explorer/ontologie/{id}
*/
public function update(int $id): void
{
$input = json_decode(file_get_contents('php://input'), true);
$name = trim($input['name'] ?? '');
$parentId = isset($input['parent_class_id']) && $input['parent_class_id'] !== '' ? (int) $input['parent_class_id'] : null;
$description = trim($input['description'] ?? '') ?: null;
$properties = $input['properties'] ?? [];
if ($name === '') {
$this->json(['success' => false, 'error' => 'Name ist erforderlich'], 400);
return;
}
try {
$this->repository->updateOntologyClass($id, $name, $parentId, $description, $properties);
$this->json(['success' => true]);
} catch (\Exception $e) {
$this->json(['success' => false, 'error' => $e->getMessage()], 500);
}
}
/**
* POST /semantic-explorer/ontologie/{id}/delete
*/
public function delete(int $id): void
{
try {
$success = $this->repository->deleteOntologyClass($id);
if ($success) {
$this->json(['success' => true]);
} else {
$this->json(['success' => false, 'error' => 'Klasse hat noch Unterklassen'], 400);
}
} catch (\Exception $e) {
$this->json(['success' => false, 'error' => $e->getMessage()], 500);
}
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1724 |
22 |
modified |
7.6 KB |
2025-12-27 12:33 |
| 1723 |
21 |
modified |
7.4 KB |
2025-12-27 12:33 |
| 1722 |
20 |
modified |
7.1 KB |
2025-12-27 12:32 |
| 1721 |
19 |
modified |
6.6 KB |
2025-12-27 12:31 |
| 1528 |
18 |
modified |
5.8 KB |
2025-12-26 07:01 |
| 1058 |
17 |
modified |
5.8 KB |
2025-12-25 02:22 |
| 1057 |
16 |
modified |
5.9 KB |
2025-12-25 02:22 |
| 1056 |
15 |
modified |
5.9 KB |
2025-12-25 02:22 |
| 1055 |
14 |
modified |
5.9 KB |
2025-12-25 02:22 |
| 1054 |
13 |
modified |
5.9 KB |
2025-12-25 02:22 |
| 1053 |
12 |
modified |
5.9 KB |
2025-12-25 02:22 |
| 1052 |
11 |
modified |
5.9 KB |
2025-12-25 02:22 |
| 1025 |
10 |
modified |
4.9 KB |
2025-12-24 20:20 |
| 1024 |
9 |
modified |
4.6 KB |
2025-12-24 20:20 |
| 1023 |
8 |
modified |
4.4 KB |
2025-12-24 20:19 |
| 694 |
7 |
modified |
4.5 KB |
2025-12-23 07:52 |
| 616 |
6 |
modified |
4.5 KB |
2025-12-23 04:42 |
| 512 |
5 |
modified |
4.4 KB |
2025-12-22 15:47 |
| 511 |
4 |
modified |
4.3 KB |
2025-12-22 15:47 |
| 510 |
3 |
modified |
4.0 KB |
2025-12-22 15:47 |
| 298 |
2 |
modified |
4.1 KB |
2025-12-22 08:04 |
| 292 |
1 |
modified |
4.1 KB |
2025-12-22 08:03 |
← Zurück zur Übersicht