Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Sep 25, 2023
1 parent c807da8 commit bb96530
Show file tree
Hide file tree
Showing 69 changed files with 396 additions and 303 deletions.
15 changes: 12 additions & 3 deletions databox/api/config/packages/fos_elastica.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
parameters:
es_index_prefix: '%env(ELASTICSEARCH_INDEX_PREFIX)%'
elastica.use_alias: true

# Read the documentation: https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/doc/setup.md
fos_elastica:
clients:
default: { url: '%env(ELASTICSEARCH_URL)%/' }
indexes:
asset:
use_alias: true
use_alias: '%elastica.use_alias%'
index_name: "%es_index_prefix%asset_%kernel.environment%"
settings:
index:
Expand Down Expand Up @@ -85,7 +86,7 @@ fos_elastica:
listener: { enabled: false }

collection:
use_alias: true
use_alias: '%elastica.use_alias%'
index_name: "%es_index_prefix%collection_%kernel.environment%"
settings:
index:
Expand Down Expand Up @@ -129,7 +130,7 @@ fos_elastica:
listener: { enabled: false }

asset_data_template:
use_alias: true
use_alias: '%elastica.use_alias%'
index_name: "%es_index_prefix%asset_data_template_%kernel.environment%"
properties:
name:
Expand Down Expand Up @@ -159,3 +160,11 @@ fos_elastica:
driver: orm
model: App\Entity\Template\AssetDataTemplate
listener: { enabled: false }

when@dev:
parameters:
elastica.use_alias: false

when@test:
parameters:
elastica.use_alias: false
6 changes: 3 additions & 3 deletions databox/api/src/Api/Model/Output/Traits/CreatedAtDTOTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ trait CreatedAtDTOTrait
{
#[Groups(['dates'])]
#[ApiProperty]
protected \DateTimeInterface $createdAt;
protected \DateTimeImmutable $createdAt;

public function getCreatedAt(): \DateTimeInterface
public function getCreatedAt(): \DateTimeImmutable
{
return $this->createdAt;
}

public function setCreatedAt(\DateTimeInterface $createdAt): void
public function setCreatedAt(\DateTimeImmutable $createdAt): void
{
$this->createdAt = $createdAt;
}
Expand Down
6 changes: 3 additions & 3 deletions databox/api/src/Api/Model/Output/Traits/UpdatedAtDTOTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ trait UpdatedAtDTOTrait
{
#[Groups(['dates'])]
#[ApiProperty]
protected \DateTimeInterface $updatedAt;
protected \DateTimeImmutable $updatedAt;

public function getUpdatedAt(): \DateTimeInterface
public function getUpdatedAt(): \DateTimeImmutable
{
return $this->updatedAt;
}

public function setUpdatedAt(\DateTimeInterface $updatedAt): void
public function setUpdatedAt(\DateTimeImmutable $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
Expand Down
12 changes: 3 additions & 9 deletions databox/api/src/Attribute/Type/DateAttributeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ public static function getName(): string
public function getGroupValueLabel($value): ?string
{
if ($value instanceof \DateTimeInterface) {
if ($value instanceof \DateTimeImmutable) {
$date = \DateTime::createFromImmutable($value);
} else {
$date = clone $value;
}

$date->setTime(0, 0);

return $date->format(\DateTimeInterface::ATOM);
return \DateTimeImmutable::createFromInterface($value)
->setTime(0, 0)
->format(\DateTimeInterface::ATOM);
}

return parent::getGroupValueLabel($value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

interface SoftDeleteableInterface
{
public function getDeletedAt(): ?\DateTimeInterface;
public function getDeletedAt(): ?\DateTimeImmutable;
}
4 changes: 3 additions & 1 deletion databox/api/src/Entity/AbstractUuidEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace App\Entity;

use ApiPlatform\Metadata\ApiProperty;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Doctrine\UuidType;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Serializer\Annotation\Groups;

Expand All @@ -14,7 +16,7 @@ abstract class AbstractUuidEntity
{
#[Groups(['_'])]
#[ORM\Id]
#[ORM\Column(type: 'uuid', unique: true)]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ApiProperty(identifier: true)]
private string $id;

Expand Down
5 changes: 3 additions & 2 deletions databox/api/src/Entity/Admin/ESIndexState.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Entity\AbstractUuidEntity;
use App\Entity\Traits\CreatedAtTrait;
use App\Entity\Traits\UpdatedAtTrait;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Table]
Expand All @@ -17,10 +18,10 @@ class ESIndexState extends AbstractUuidEntity
use CreatedAtTrait;
use UpdatedAtTrait;

#[ORM\Column(type: 'string', length: 150, nullable: false)]
#[ORM\Column(type: Types::STRING, length: 150, nullable: false)]
private string $indexName;

#[ORM\Column(type: 'json', nullable: false)]
#[ORM\Column(type: Types::JSON, nullable: false)]
private array $mapping;

public function getIndexName(): string
Expand Down
19 changes: 10 additions & 9 deletions databox/api/src/Entity/Admin/PopulatePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Entity\AbstractUuidEntity;
use App\Entity\Traits\CreatedAtTrait;
use App\Util\Time;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Table]
Expand All @@ -15,22 +16,22 @@ class PopulatePass extends AbstractUuidEntity
{
use CreatedAtTrait;

#[ORM\Column(type: 'datetime', nullable: true)]
protected ?\DateTimeInterface $endedAt = null;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
protected ?\DateTimeImmutable $endedAt = null;

#[ORM\Column(type: 'bigint', nullable: false)]
#[ORM\Column(type: Types::BIGINT, nullable: false)]
private int $documentCount;

#[ORM\Column(type: 'bigint', nullable: true)]
#[ORM\Column(type: Types::BIGINT, nullable: true)]
private ?int $progress = null;

#[ORM\Column(type: 'string', length: 255, nullable: false)]
#[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
private string $indexName;

#[ORM\Column(type: 'json', nullable: false)]
#[ORM\Column(type: Types::JSON, nullable: false)]
private array $mapping;

#[ORM\Column(type: 'string', nullable: true)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $error = null;

public function getTimeTaken(): ?int
Expand Down Expand Up @@ -77,12 +78,12 @@ public function setMapping(array $mapping): void
$this->mapping = $mapping;
}

public function getEndedAt(): ?\DateTimeInterface
public function getEndedAt(): ?\DateTimeImmutable
{
return $this->endedAt;
}

public function setEndedAt(?\DateTimeInterface $endedAt): void
public function setEndedAt(?\DateTimeImmutable $endedAt): void
{
$this->endedAt = $endedAt;
}
Expand Down
1 change: 1 addition & 0 deletions databox/api/src/Entity/Basket/Basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Entity\AbstractUuidEntity;
use App\Entity\Core\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
Expand Down
11 changes: 6 additions & 5 deletions databox/api/src/Entity/Core/AbstractBaseAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Entity\AbstractUuidEntity;
use App\Entity\Traits\CreatedAtTrait;
use App\Entity\Traits\UpdatedAtTrait;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\MappedSuperclass]
Expand All @@ -15,13 +16,13 @@ abstract class AbstractBaseAttribute extends AbstractUuidEntity
use CreatedAtTrait;
use UpdatedAtTrait;

#[ORM\Column(type: 'string', length: 10, nullable: true)]
#[ORM\Column(type: Types::STRING, length: 10, nullable: true)]
private ?string $locale = null;

#[ORM\Column(type: 'integer', nullable: false)]
#[ORM\Column(type: Types::INTEGER, nullable: false)]
private int $position = 0;

#[ORM\Column(type: 'text', nullable: false)]
#[ORM\Column(type: Types::TEXT, nullable: false)]
private ?string $value = null;

/**
Expand Down Expand Up @@ -64,12 +65,12 @@ public function setPosition(int $position): void
$this->position = $position;
}

public function setCreatedAt(\DateTimeInterface $createdAt): void
public function setCreatedAt(\DateTimeImmutable $createdAt): void
{
$this->createdAt = $createdAt;
}

public function setUpdatedAt(\DateTimeInterface $updatedAt): void
public function setUpdatedAt(\DateTimeImmutable $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
Expand Down
5 changes: 3 additions & 2 deletions databox/api/src/Entity/Core/AlternateUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Entity\Traits\CreatedAtTrait;
use App\Entity\Traits\WorkspaceTrait;
use App\Repository\Core\AttributeRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: AttributeRepository::class)]
Expand All @@ -16,10 +17,10 @@ class AlternateUrl extends AbstractUuidEntity
use CreatedAtTrait;
use WorkspaceTrait;

#[ORM\Column(type: 'string', length: 50, nullable: false)]
#[ORM\Column(type: Types::STRING, length: 50, nullable: false)]
private ?string $type = null;

#[ORM\Column(type: 'string', length: 255, nullable: false)]
#[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
private ?string $label = null;

public function getType(): ?string
Expand Down
17 changes: 9 additions & 8 deletions databox/api/src/Entity/Core/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use App\Security\Voter\AssetVoter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection as DoctrineCollection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use FOS\ElasticaBundle\Transformer\HighlightableModelInterface;
use Symfony\Component\Serializer\Annotation\Groups;
Expand Down Expand Up @@ -121,28 +122,28 @@ class Asset extends AbstractUuidEntity implements HighlightableModelInterface, W
final public const GROUP_LIST = 'asset:index';
final public const GROUP_WRITE = 'asset:w';

#[ORM\Column(type: 'integer', nullable: false)]
#[ORM\Column(type: Types::INTEGER, nullable: false)]
private int $microseconds = 0;

#[ORM\Column(type: 'integer', nullable: false)]
#[ORM\Column(type: Types::INTEGER, nullable: false)]
private int $sequence = 0;

#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $title = null;

#[ORM\Column(type: 'string', length: 36)]
#[ORM\Column(type: Types::STRING, length: 36)]
private ?string $ownerId = null;

/**
* Unique key by workspace. Used to prevent duplicates.
*/
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $key = null;

/**
* Token sent to Uploader.
*/
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $pendingUploadToken = null;

#[ORM\OneToMany(mappedBy: 'asset', targetEntity: CollectionAsset::class, cascade: ['remove'])]
Expand Down Expand Up @@ -181,14 +182,14 @@ class Asset extends AbstractUuidEntity implements HighlightableModelInterface, W
* Last update time of attribute.
*/
#[Groups(['dates'])]
#[ORM\Column(type: 'datetime_immutable')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
protected ?\DateTimeImmutable $attributesEditedAt = null;

/**
* Last update time of tags.
*/
#[Groups(['dates'])]
#[ORM\Column(type: 'datetime_immutable')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
protected ?\DateTimeImmutable $tagsEditedAt = null;

/**
Expand Down
5 changes: 3 additions & 2 deletions databox/api/src/Entity/Core/AssetFileVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use App\Entity\AbstractUuidEntity;
use App\Entity\Traits\CreatedAtTrait;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

Expand All @@ -37,7 +38,7 @@ class AssetFileVersion extends AbstractUuidEntity
final public const GROUP_READ = 'afv:read';
final public const GROUP_LIST = 'afv:index';

#[ORM\Column(type: 'string', length: 50, nullable: true)]
#[ORM\Column(type: Types::STRING, length: 50, nullable: true)]
private ?string $versionName = null;

#[ORM\ManyToOne(targetEntity: Asset::class)]
Expand All @@ -50,7 +51,7 @@ class AssetFileVersion extends AbstractUuidEntity
#[Groups([AssetFileVersion::GROUP_LIST])]
private ?File $file = null;

#[ORM\Column(type: 'json')]
#[ORM\Column(type: Types::JSON)]
private array $context = [];

public function getVersionName(): ?string
Expand Down
5 changes: 3 additions & 2 deletions databox/api/src/Entity/Core/AssetRelationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Entity\Integration\WorkspaceIntegration;
use App\Entity\Traits\CreatedAtTrait;
use App\Entity\Traits\UpdatedAtTrait;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Table]
Expand All @@ -20,13 +21,13 @@ class AssetRelationship extends AbstractUuidEntity
/**
* The type of relationship.
*/
#[ORM\Column(type: 'string', length: 20)]
#[ORM\Column(type: Types::STRING, length: 20)]
private ?string $type = null;

/**
* Whether the two assets can't live alone (being deleted, moved to another collection...).
*/
#[ORM\Column(type: 'boolean')]
#[ORM\Column(type: Types::BOOLEAN)]
private bool $sticky = false;

#[ORM\ManyToOne(targetEntity: Asset::class)]
Expand Down
1 change: 1 addition & 0 deletions databox/api/src/Entity/Core/AssetRendition.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Entity\Traits\CreatedAtTrait;
use App\Entity\Traits\UpdatedAtTrait;
use App\Repository\Core\AssetRenditionRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

Expand Down
Loading

0 comments on commit bb96530

Please sign in to comment.