repository = new SemanticExplorerRepository(); } /** * GET /semantic-explorer/entitaeten * Liste aller Entitaeten */ public function index(): void { $type = $this->getString('type'); $search = $this->getString('search'); $entities = $this->repository->getEntitiesFiltered($type, $search); $stats = $this->repository->getEntityStats(); $this->view('semantic-explorer.entitaeten.index', [ 'title' => 'Entitaeten', 'entities' => $entities, 'stats' => $stats, 'currentType' => $type, 'currentSearch' => $search, ]); } /** * GET /semantic-explorer/entitaeten/{id} * Entitaet-Details */ public function show(int $id): void { $entity = $this->repository->getEntity($id); if ($entity === null) { $this->notFound('Entitaet nicht gefunden'); } $synonyms = $this->repository->getEntitySynonyms($id); $outgoingRelations = $this->repository->getOutgoingRelations($id); $incomingRelations = $this->repository->getIncomingRelations($id); $chunks = $this->repository->getChunksForEntity($id); $classifications = $this->repository->getEntityClassifications($id); $this->view('semantic-explorer.entitaeten.show', [ 'title' => $entity['name'], 'entity' => $entity, 'synonyms' => $synonyms, 'outgoingRelations' => $outgoingRelations, 'incomingRelations' => $incomingRelations, 'chunks' => $chunks, 'classifications' => $classifications, ]); } /** * GET /semantic-explorer/entitaeten/new */ public function create(): void { $this->view('semantic-explorer.entitaeten.new', [ 'title' => 'Neue Entitaet', 'types' => $this->repository->getEntityTypes(), ]); } /** * POST /semantic-explorer/entitaeten */ public function store(): void { $input = $this->getJsonInput(); $name = trim($input['name'] ?? ''); $type = trim($input['type'] ?? ''); $description = trim($input['description'] ?? '') ?: null; if ($name === '' || $type === '') { $this->json(['success' => false, 'error' => 'Name und Typ sind erforderlich'], 400); return; } try { $id = $this->repository->createEntity($name, $type, $description); $this->json(['success' => true, 'id' => $id]); } catch (\Exception $e) { $this->json(['success' => false, 'error' => $e->getMessage()], 500); } } /** * GET /semantic-explorer/entitaeten/{id}/edit */ public function edit(int $id): void { $entity = $this->repository->getEntity($id); if ($entity === null) { $this->notFound('Entitaet nicht gefunden'); } $this->view('semantic-explorer.entitaeten.edit', [ 'title' => 'Entitaet bearbeiten', 'entity' => $entity, 'types' => $this->repository->getEntityTypes(), ]); } /** * POST /semantic-explorer/entitaeten/{id} */ public function update(int $id): void { $input = $this->getJsonInput(); $name = trim($input['name'] ?? ''); $type = trim($input['type'] ?? ''); $description = trim($input['description'] ?? '') ?: null; if ($name === '' || $type === '') { $this->json(['success' => false, 'error' => 'Name und Typ sind erforderlich'], 400); return; } try { $this->repository->updateEntity($id, $name, $type, $description); $this->json(['success' => true]); } catch (\Exception $e) { $this->json(['success' => false, 'error' => $e->getMessage()], 500); } } /** * POST /semantic-explorer/entitaeten/{id}/delete */ public function delete(int $id): void { try { $success = $this->repository->deleteEntity($id); if ($success) { $this->json(['success' => true]); } else { $this->json(['success' => false, 'error' => 'Entitaet hat noch Relationen'], 400); } } catch (\Exception $e) { $this->json(['success' => false, 'error' => $e->getMessage()], 500); } } }