Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend functionality on non get requests #116

Merged
merged 35 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
87216f3
Reinstate validation, add resolve for internal schema entities
rjzondervan Dec 10, 2024
8088979
validation of files, oneof etc. first draft
rjzondervan Dec 11, 2024
03a4bb7
Major cleanup on subobjects
rjzondervan Dec 12, 2024
6f06d31
Add docblocks to new functions
rjzondervan Dec 12, 2024
3e2a0a1
Code style fixes
WilcoLouwerse Dec 12, 2024
3167fae
Added docblocks
WilcoLouwerse Dec 12, 2024
d00ce52
Some more small docblock updates
WilcoLouwerse Dec 12, 2024
a5751d7
Big docblock update for ObjectService
WilcoLouwerse Dec 12, 2024
75678f5
added cascade delete in frontend
bbrands02 Dec 12, 2024
f6cc6c8
Added cascade delete
bbrands02 Dec 12, 2024
addef18
Refactor on file synchronization
rjzondervan Dec 12, 2024
c9c6af5
Merge remote-tracking branch 'origin/feature/REGISTERS-75/validate-re…
bbrands02 Dec 13, 2024
64c1f2c
Merge branch 'feature/CONNECTOR-61/cascade-delete' into test-last-bra…
bbrands02 Dec 13, 2024
6957ef5
Fixes from testing
rjzondervan Dec 16, 2024
d6930f2
add oneOf in frontend
bbrands02 Dec 18, 2024
18967c8
Merge branch 'feature/REGISTERS-76/file-refactor' into test-last-bran…
WilcoLouwerse Dec 18, 2024
0decd9b
Start doing some merge fixes...
WilcoLouwerse Dec 18, 2024
9a90e7a
Some style fixes
WilcoLouwerse Dec 18, 2024
fc91258
Merge remote-tracking branch 'origin/development' into test-last-bran…
bbrands02 Dec 20, 2024
b7ca858
pass format
bbrands02 Dec 20, 2024
011ac62
added file formats
bbrands02 Dec 20, 2024
56e404c
fix File defaults
bbrands02 Dec 20, 2024
3ed6e00
Merge remote-tracking branch 'origin/main' into development
rubenvdlinde Dec 28, 2024
7627679
Merge branch 'development' into feature/REGISTERS-85/improved-develop…
rubenvdlinde Dec 28, 2024
227a84f
Fix small bug in format detection for files
rjzondervan Dec 30, 2024
a5ed542
Allow extending on creation and update
rubenvdlinde Dec 31, 2024
e1ffe80
Merge remote-tracking branch 'origin/development' into test-last-bran…
rjzondervan Dec 31, 2024
073eb03
Fix merge conflicts
rjzondervan Dec 31, 2024
4c25bdb
lint fix
bbrands02 Dec 31, 2024
67381b7
Merge pull request #115 from ConductionNL/test-last-branches-merged
bbrands02 Dec 31, 2024
32bc4e0
Small refactor
rubenvdlinde Jan 1, 2025
7dd702d
Better code for extending from external applicaitons
rubenvdlinde Jan 1, 2025
394b661
Update from dev
rubenvdlinde Jan 2, 2025
b8aefee
Extend registers withs schema's
rubenvdlinde Jan 2, 2025
6c29e77
Merge pull request #114 from ConductionNL/feature/REGISTERS-85/improv…
rubenvdlinde Jan 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .babelrc
100755 → 100644
Empty file.
Empty file modified .eslintrc.js
100755 → 100644
Empty file.
Empty file modified .gitattributes
100755 → 100644
Empty file.
Empty file modified .gitignore
100755 → 100644
Empty file.
Empty file modified .nvmrc
100755 → 100644
Empty file.
Empty file modified .php-cs-fixer.dist.php
100755 → 100644
Empty file.
Empty file modified .prettierrc
100755 → 100644
Empty file.
Empty file modified LICENSE
100755 → 100644
Empty file.
Empty file modified README.md
100755 → 100644
Empty file.
Empty file modified appinfo/info.xml
100755 → 100644
Empty file.
Empty file modified appinfo/routes.php
100755 → 100644
Empty file.
Empty file modified composer-setup.php
100755 → 100644
Empty file.
Empty file modified composer.json
100755 → 100644
Empty file.
Empty file modified composer.lock
100755 → 100644
Empty file.
Empty file modified css/main.css
100755 → 100644
Empty file.
Empty file modified docs/styleguide.md
100755 → 100644
Empty file.
Empty file modified img/app-dark.svg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified img/app.svg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified jest.config.js
100755 → 100644
Empty file.
Empty file modified lib/AppInfo/Application.php
100755 → 100644
Empty file.
Empty file modified lib/Controller/DashboardController.php
100755 → 100644
Empty file.
217 changes: 217 additions & 0 deletions lib/Db/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<?php

namespace OCA\OpenRegister\Db;

use DateTime;
use Exception;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
use OCP\IURLGenerator;

class File extends Entity implements JsonSerializable
{
/**
* @var string|null The unique identifier for the file.
*/
protected ?string $uuid = null;

/**
* @var string The name of the file.
*/
protected ?string $filename = null;

/**
* @var string The URL to download the file.
*/
protected ?string $downloadUrl = null;

/**
* @var string The URL to share the file.
*/
protected ?string $shareUrl = null;

/**
* @var string The URL to access the file.
*/
protected ?string $accessUrl = null;

/**
* @var string The file extension (e.g., .txt, .jpg).
*/
protected ?string $extension = null;

/**
* @var string The checksum of the file for integrity verification.
*/
protected ?string $checksum = null;

/**
* @var int|null The source of the file.
*/
protected ?int $source = null;

/**
* @var string The ID of the user associated with the file.
*/
protected ?string $userId = null;

/**
* @var string|null The base64 string for this file.
*/
protected ?string $base64 = null;

/**
* @var string|null The path to this file.
*/
protected ?string $filePath = null;

/**
* @var DateTime|null The date and time when the file was created.
*/
protected ?DateTime $created = null;

/**
* @var DateTime|null The date and time when the file was last updated.
*/
protected ?DateTime $updated = null;

/**
* Constructor for the File entity.
*/
public function __construct()
{
$this->addType('uuid', 'string');
$this->addType('filename', 'string');
$this->addType('downloadUrl', 'string');
$this->addType('shareUrl', 'string');
$this->addType('accessUrl', 'string');
$this->addType('extension', 'string');
$this->addType('checksum', 'string');
$this->addType('source', 'int');
$this->addType('userId', 'string');
$this->addType('base64', 'string');
$this->addType('filePath', 'string');
$this->addType('created', 'datetime');
$this->addType('updated', 'datetime');
}

/**
* Retrieves the fields that should be treated as JSON.
*
* @return array List of JSON field names.
*/
public function getJsonFields(): array
{
return array_keys(
array_filter($this->getFieldTypes(), function ($field) {
return $field === 'json';
})
);
}

/**
* Populates the entity with data from an array.
*
* @param array $object Data to populate the entity.
*
* @return self The hydrated entity.
*/
public function hydrate(array $object): self
{
$jsonFields = $this->getJsonFields();

foreach ($object as $key => $value) {
if (in_array($key, $jsonFields) === true && $value === []) {
$value = [];
}

$method = 'set' . ucfirst($key);

try {
$this->$method($value);
} catch (Exception $exception) {
// Log or handle the exception.
}
}

return $this;
}

/**
* Serializes the entity to a JSON-compatible array.
*
* @return array The serialized entity data.
*/
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'uuid' => $this->uuid,
'filename' => $this->filename,
'downloadUrl' => $this->downloadUrl,
'shareUrl' => $this->shareUrl,
'accessUrl' => $this->accessUrl,
'extension' => $this->extension,
'checksum' => $this->checksum,
'source' => $this->source,
'userId' => $this->userId,
'base64' => $this->base64,
'filePath' => $this->filePath,
'created' => isset($this->created) === true ? $this->created->format('c') : null,
'updated' => isset($this->updated) === true ? $this->updated->format('c') : null,
];
}

/**
* Generates a JSON schema for the File entity.
*
* @param IURLGenerator $IURLGenerator The URL generator instance.
*
* @return string The JSON schema as a string.
*/
public static function getSchema(IURLGenerator $IURLGenerator): string
{
return json_encode([
'$id' => $IURLGenerator->getBaseUrl().'/apps/openconnector/api/files/schema',
'$schema' => 'https://json-schema.org/draft/2020-12/schema',
'type' => 'object',
'required' => [
],
'properties' => [
'filename' => [
'type' => 'string',
'minLength' => 1,
'maxLength' => 255
],
'downloadUrl' => [
'type' => 'string',
'format' => 'uri',
],
'shareUrl' => [
'type' => 'string',
'format' => 'uri',
],
'accessUrl' => [
'type' => 'string',
'format' => 'uri',
],
'extension' => [
'type' => 'string',
'maxLength' => 10,
],
'checksum' => [
'type' => 'string',
],
'source' => [
'type' => 'number',
],
'userId' => [
'type' => 'string',
],
'base64' => [
'type' => 'string'
]
]
]);
}
}
Loading
Loading