Skip to content

Commit

Permalink
Revert "Merge pull request #133 from ConductionNL/feature/DIMOC-274/v…
Browse files Browse the repository at this point in the history
…alidate-publication"

This reverts commit d673b25, reversing
changes made to 0d52bef.
  • Loading branch information
rjzondervan committed Nov 8, 2024
1 parent 90d5291 commit 85b7cf0
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 263 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
"adbario/php-dot-notation": "^3.3.0",
"bamarni/composer-bin-plugin": "^1.8",
"elasticsearch/elasticsearch": "^v8.14.0",
"guzzlehttp/guzzle": "^7.0",
"guzzlehttp/guzzle": "^7.0",
"mpdf/mpdf": "^8.2",
"opis/json-schema": "^2.3",
"symfony/twig-bundle": "^6.4",
"symfony/uid": "^6.4"
},
Expand Down
192 changes: 1 addition & 191 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions lib/Db/PublicationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use DateTime;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
use OCP\IURLGenerator;

class PublicationType extends Entity implements JsonSerializable
{
Expand Down Expand Up @@ -123,33 +122,4 @@ public function jsonSerialize(): array

return $array;
}

/**
* Generate a JSON-Schema definition for the data field of a publication.
*
* @param IURLGenerator $urlGenerator An URL generator to generate the identifier of the schema.
*
* @return object The JSON-Schema object defining the data field of a publication.
*/
public function getSchema(IURLGenerator $urlGenerator): object
{
$schema = [];
$schema['$schema'] = 'https://json-schema.org/draft/2020-12/schema';
$schema['$id'] = $urlGenerator->getAbsoluteURL($urlGenerator->linkToRoute('opencatalogi.publication_types.show', ['id' => $this->getUuid()]));
$schema['type'] = 'object';
$schema['required'] = [];
$schema['properties'] = [];

foreach ($this->getProperties() as $name => $property) {
if ($property['required'] === true) {
$schema['required'][] = $name;
}
unset($property['title'], $property['required']);

// Remove empty fields with array_filter(), and add it to the properties of the schema.
$schema['properties'][$name] = array_filter($property);
}

return json_decode(json_encode($schema));
}
}
11 changes: 0 additions & 11 deletions lib/Service/ObjectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use OCP\App\IAppManager;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\IURLGenerator;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Uid\Uuid;
Expand All @@ -35,8 +34,6 @@ class ObjectService
/** @var string $appName The name of the app */
private string $appName;

private ValidationService $validationService;

/**
* Constructor for ObjectService.
*
Expand All @@ -62,11 +59,8 @@ public function __construct(
private ContainerInterface $container,
private readonly IAppManager $appManager,
private readonly IAppConfig $config,
IURLGenerator $urlGenerator,
) {
$this->appName = 'opencatalogi';

$this->validationService = new ValidationService(objectService: $this, urlGenerator: $urlGenerator);
}

/**
Expand Down Expand Up @@ -306,11 +300,6 @@ public function saveObject(string $objectType, array $object, bool $updateVersio
{
// Get the appropriate mapper for the object type
$mapper = $this->getMapper($objectType);

if ($objectType === 'publication') {
$object = $this->validationService->validatePublication($object);
}

// If the object has an id, update it; otherwise, create a new object
if (isset($object['id']) === true) {
return $mapper->updateFromArray($object['id'], $object, $updateVersion);
Expand Down
Loading

0 comments on commit 85b7cf0

Please sign in to comment.