feat: add docmdp_level column to libresign_file table

- Add migration to create docmdp_level column (SMALLINT, default 0)
- Add docmdpLevel property to File entity with getters/setters
- Add getDocmdpLevelEnum() and setDocmdpLevelEnum() methods
- DocMDP levels: 0=not certified, 1=no changes, 2=form fill, 3=annotations

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This commit is contained in:
Vitor Mattos 2025-12-14 16:11:44 -03:00
parent 7a542b3a88
commit 3a026f5c10
No known key found for this signature in database
GPG key ID: 6FECE2AD4809003A
2 changed files with 58 additions and 0 deletions

View file

@ -41,6 +41,8 @@ use OCP\DB\Types;
* @method int getModificationStatus()
* @method void setSignatureFlow(int $signatureFlow)
* @method int getSignatureFlow()
* @method void setDocmdpLevel(int $docmdpLevel)
* @method int getDocmdpLevel()
*/
class File extends Entity {
protected int $nodeId = 0;
@ -56,6 +58,7 @@ class File extends Entity {
protected ?array $metadata = null;
protected int $modificationStatus = 0;
protected int $signatureFlow = SignatureFlow::NUMERIC_PARALLEL;
protected int $docmdpLevel = 0;
public const STATUS_NOT_LIBRESIGN_FILE = -1;
public const STATUS_DRAFT = 0;
public const STATUS_ABLE_TO_SIGN = 1;
@ -83,6 +86,7 @@ class File extends Entity {
$this->addType('metadata', Types::JSON);
$this->addType('modificationStatus', Types::SMALLINT);
$this->addType('signatureFlow', Types::SMALLINT);
$this->addType('docmdpLevel', Types::SMALLINT);
}
public function isDeletedAccount(): bool {
@ -102,4 +106,12 @@ class File extends Entity {
public function setSignatureFlowEnum(\OCA\Libresign\Enum\SignatureFlow $flow): void {
$this->setSignatureFlow($flow->toNumeric());
}
public function getDocmdpLevelEnum(): \OCA\Libresign\Enum\DocMdpLevel {
return \OCA\Libresign\Enum\DocMdpLevel::tryFrom($this->docmdpLevel) ?? \OCA\Libresign\Enum\DocMdpLevel::NOT_CERTIFIED;
}
public function setDocmdpLevelEnum(\OCA\Libresign\Enum\DocMdpLevel $level): void {
$this->setDocmdpLevel($level->value);
}
}

View file

@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Add DocMDP level support per file
* - Adds 'docmdp_level' column to libresign_file table to store DocMDP certification level per file
*/
class Version15001Date20251214000000 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
* @return null|ISchemaWrapper
*/
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('libresign_file')) {
$tableFile = $schema->getTable('libresign_file');
if (!$tableFile->hasColumn('docmdp_level')) {
$tableFile->addColumn('docmdp_level', Types::SMALLINT, [
'notnull' => true,
'default' => 0,
'comment' => 'DocMDP permission level for this file: 0=none, 1=no changes, 2=form fill, 3=form fill + annotations',
]);
}
}
return $schema;
}
}