summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/Migrations/Version28000Date20230616104802.php5
-rw-r--r--lib/private/LanguageModel/Db/Task.php9
-rw-r--r--lib/public/LanguageModel/AbstractLanguageModelTask.php18
-rw-r--r--lib/public/LanguageModel/ILanguageModelTask.php6
4 files changed, 33 insertions, 5 deletions
diff --git a/core/Migrations/Version28000Date20230616104802.php b/core/Migrations/Version28000Date20230616104802.php
index ab7347608e2..f13f2ef03a6 100644
--- a/core/Migrations/Version28000Date20230616104802.php
+++ b/core/Migrations/Version28000Date20230616104802.php
@@ -78,6 +78,11 @@ class Version28000Date20230616104802 extends SimpleMigrationStep {
'length' => 32,
'default' => '',
]);
+ $table->addColumn('identifier', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 255,
+ 'default' => '',
+ ]);
$table->addColumn('last_updated', 'integer', [
'notnull' => false,
'length' => 4,
diff --git a/lib/private/LanguageModel/Db/Task.php b/lib/private/LanguageModel/Db/Task.php
index bbafd7583c8..1e8d57d39e8 100644
--- a/lib/private/LanguageModel/Db/Task.php
+++ b/lib/private/LanguageModel/Db/Task.php
@@ -20,6 +20,8 @@ use OCP\LanguageModel\ILanguageModelTask;
* @method string getuserId()
* @method setAppId(string $type)
* @method string getAppId()
+ * @method setIdentifier(string $type)
+ * @method string getIdentifier()
*/
class Task extends Entity {
protected $lastUpdated;
@@ -29,16 +31,17 @@ class Task extends Entity {
protected $status;
protected $userId;
protected $appId;
+ protected $identifier;
/**
* @var string[]
*/
- public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id'];
+ public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'identifier'];
/**
* @var string[]
*/
- public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId'];
+ public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'identifier'];
public function __construct() {
@@ -51,6 +54,7 @@ class Task extends Entity {
$this->addType('status', 'integer');
$this->addType('userId', 'string');
$this->addType('appId', 'string');
+ $this->addType('identifier', 'string');
}
public function toRow(): array {
@@ -69,6 +73,7 @@ class Task extends Entity {
'output' => $task->getOutput(),
'userId' => $task->getUserId(),
'appId' => $task->getAppId(),
+ 'identifier' => $task->getIdentifier(),
]);
}
}
diff --git a/lib/public/LanguageModel/AbstractLanguageModelTask.php b/lib/public/LanguageModel/AbstractLanguageModelTask.php
index a6b091dc14f..afa23dd36c8 100644
--- a/lib/public/LanguageModel/AbstractLanguageModelTask.php
+++ b/lib/public/LanguageModel/AbstractLanguageModelTask.php
@@ -43,12 +43,14 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
* @param string $input
* @param string $appId
* @param string|null $userId
+ * @param string $identifier An arbitrary identifier for this task. max length: 255 chars
* @since 28.0.0
*/
final public function __construct(
protected string $input,
protected string $appId,
protected ?string $userId,
+ protected string $identifier = '',
) {
}
@@ -123,6 +125,14 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
}
/**
+ * @return string
+ * @since 28.0.0
+ */
+ final public function getIdentifier(): string {
+ return $this->identifier;
+ }
+
+ /**
* @return string|null
* @since 28.0.0
*/
@@ -143,6 +153,7 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
'appId' => $this->getAppId(),
'input' => $this->getInput(),
'output' => $this->getOutput(),
+ 'identifier' => $this->getIdentifier(),
];
}
@@ -153,7 +164,7 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
* @since 28.0.0
*/
final public static function fromTaskEntity(Task $taskEntity): ILanguageModelTask {
- $task = self::factory($taskEntity->getType(), $taskEntity->getInput(), $taskEntity->getuserId(), $taskEntity->getAppId());
+ $task = self::factory($taskEntity->getType(), $taskEntity->getInput(), $taskEntity->getuserId(), $taskEntity->getAppId(), $taskEntity->getIdentifier());
$task->setId($taskEntity->getId());
$task->setStatus($taskEntity->getStatus());
$task->setOutput($taskEntity->getOutput());
@@ -165,14 +176,15 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
* @param string $input
* @param string|null $userId
* @param string $appId
+ * @param string $identifier
* @return ILanguageModelTask
* @throws \InvalidArgumentException
* @since 28.0.0
*/
- final public static function factory(string $type, string $input, ?string $userId, string $appId): ILanguageModelTask {
+ final public static function factory(string $type, string $input, ?string $userId, string $appId, string $identifier): ILanguageModelTask {
if (!in_array($type, array_keys(self::TYPES))) {
throw new \InvalidArgumentException('Unknown task type');
}
- return new (ILanguageModelTask::TYPES[$type])($input, $appId, $userId);
+ return new (ILanguageModelTask::TYPES[$type])($input, $appId, $userId, $identifier);
}
}
diff --git a/lib/public/LanguageModel/ILanguageModelTask.php b/lib/public/LanguageModel/ILanguageModelTask.php
index 356cb53914e..b8f0f96695d 100644
--- a/lib/public/LanguageModel/ILanguageModelTask.php
+++ b/lib/public/LanguageModel/ILanguageModelTask.php
@@ -133,6 +133,12 @@ interface ILanguageModelTask extends \JsonSerializable {
public function getAppId(): string;
/**
+ * @return string
+ * @since 28.0.0
+ */
+ public function getIdentifier(): string;
+
+ /**
* @return string|null
* @since 28.0.0
*/