Skip to content

Commit

Permalink
activate context chat manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Rello committed Aug 5, 2024
1 parent 42cc8f1 commit 094e4b2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 36 deletions.
55 changes: 27 additions & 28 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace OCA\Analytics\AppInfo;

use OCA\Analytics\ContextChat\ContentProvider;
use OCA\Analytics\Dashboard\Widget;
use OCA\Analytics\Flow\FlowOperation;
use OCA\Analytics\Listener\LoadAdditionalScripts;
Expand All @@ -26,40 +27,38 @@
use OCP\Collaboration\Reference\RenderReferenceEvent;
use Psr\Container\ContainerInterface;
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;
use OCA\ContextChat\Event\ContentProviderRegisterEvent;

class Application extends App implements IBootstrap
{
public const APP_ID = 'analytics';
class Application extends App implements IBootstrap {
public const APP_ID = 'analytics';

public function __construct(array $urlParams = [])
{
parent::__construct(self::APP_ID, $urlParams);
}
public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);
}

public function register(IRegistrationContext $context): void
{
$context->registerDashboardWidget(Widget::class);
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
$context->registerSearchProvider(SearchProvider::class);
public function register(IRegistrationContext $context): void {
$context->registerDashboardWidget(Widget::class);

if (method_exists($context, 'registerReferenceProvider')) {
$context->registerReferenceProvider(ReferenceProvider::class);
$context->registerEventListener(RenderReferenceEvent::class, ReferenceListener::class);
}
$context->registerSearchProvider(SearchProvider::class);

$this->registerNotifications();
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
$context->registerEventListener(RegisterOperationsEvent::class, FlowOperation::class);
$context->registerEventListener(ContentProviderRegisterEvent::class, ContentProvider::class);

$context->registerEventListener(RegisterOperationsEvent::class, FlowOperation::class);
}
if (method_exists($context, 'registerReferenceProvider')) {
$context->registerReferenceProvider(ReferenceProvider::class);
$context->registerEventListener(RenderReferenceEvent::class, ReferenceListener::class);
}

public function boot(IBootContext $context): void
{
}
$this->registerNotifications();
}

protected function registerNotifications(): void
{
$notificationManager = \OC::$server->getNotificationManager();
$notificationManager->registerNotifierService(Notifier::class);
}
public function boot(IBootContext $context): void {
}

protected function registerNotifications(): void {
$notificationManager = \OC::$server->getNotificationManager();
$notificationManager->registerNotifierService(Notifier::class);
}
}
1 change: 1 addition & 0 deletions lib/ContextChat/ContentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function handle(Event $event): void {
if (!$event instanceof ContentProviderRegisterEvent) {
return;
}
$this->logger->info('registering analytics content provider');
$event->registerContentProvider('analytics', 'report', ContentProvider::class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,32 @@
use OCP\IL10N;
use Psr\Log\LoggerInterface;
use OCA\ContextChat\Public\ContentItem;
use OCA\ContextChat\Public\ContentManager;
use OCA\Analytics\Service\StorageService;
use OCA\Analytics\Service\DatasetService;

class ContentManager {
class ContextChatManager {
private $userId;
private $logger;
private $l10n;
private $StorageService;
private $DatasetService;
private $ContentManager;

public function __construct(
$userId,
IL10N $l10n,
LoggerInterface $logger,
StorageService $StorageService,
DatasetService $DatasetService
DatasetService $DatasetService,
ContentManager $ContentManager
) {
$this->userId = $userId;
$this->l10n = $l10n;
$this->logger = $logger;
$this->StorageService = $StorageService;
$this->DatasetService = $DatasetService;
$this->ContentManager = $ContentManager;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/Controller/DatasetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@
use OCP\DB\Exception;
use OCP\IRequest;
use Psr\Log\LoggerInterface;
use OCA\Analytics\ContextChat\ContentManager;
use OCA\Analytics\ContextChat\ContextChatManager;

class DatasetController extends Controller {
private $logger;
private $DatasetService;
private $ReportService;
private $ContentManager;
private $ContextChatManager;

public function __construct(
$appName,
IRequest $request,
LoggerInterface $logger,
DatasetService $DatasetService,
ReportService $ReportService,
ContentManager $ContentManager
ContextChatManager $ContextChatManager
) {
parent::__construct($appName, $request);
$this->logger = $logger;
$this->DatasetService = $DatasetService;
$this->ReportService = $ReportService;
$this->ContentManager = $ContentManager;
$this->ContextChatManager = $ContextChatManager;
}

/**
Expand Down Expand Up @@ -141,7 +141,7 @@ public function status(int $datasetId) {
*/
public function provider(int $datasetId) {
if ($this->DatasetService->isOwn($datasetId)) {
$this->ContentManager->submitContent($datasetId);
$this->ContextChatManager->submitContent($datasetId);
return new DataResponse('true');
} else {
return new DataResponse('false');
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/StorageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function read($datasetId, $reportMetadata) {
$availableDimensions = array();
$header = array();
$datasetMetadata = $this->DatasetService->read($datasetId);
if ($reportMetadata['filteroptions'] !== null) {
if ($reportMetadata && $reportMetadata['filteroptions'] !== null) {
$options = json_decode($reportMetadata['filteroptions'], true);
} else {
$options = null;
Expand Down

0 comments on commit 094e4b2

Please sign in to comment.