Skip to content

Commit

Permalink
dummy documents: update to match the new typesense schema
Browse files Browse the repository at this point in the history
  • Loading branch information
lazka committed Aug 20, 2024
1 parent afbac3d commit 23b785c
Showing 1 changed file with 47 additions and 86 deletions.
133 changes: 47 additions & 86 deletions src/TypesenseSync/TypesenseSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Psr\Log\LoggerAwareTrait;
use Psr\Log\NullLogger;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Uid\Uuid;

class TypesenseSync implements LoggerAwareInterface
{
Expand Down Expand Up @@ -153,11 +154,39 @@ public function addDummyDocuments(string $collectionName, array $personDocuments
$phases = ['Application phase', 'Study phase', 'Graduation phase', 'General documents'];
$comment = ['Some comment', 'Some other comment'];
$subjectOf = ['GZ 2021-0.123.456', 'AZ 10 C 1234/23', 'VR 2023/789-B', '567/2022-XYZ', '987654-AB/2023'];
$countryOfOrigin = ['Österreich', 'Deutschland', 'France', 'Italia', 'Schweiz'];
$studyField = ['234', '456', '890'];
$fileSource = 'blob-cabinetBucket';
$atType = 'DocumentFile';
$fileNames = self::generateRandomPDFNames();

// admissionNotice
for ($i = 0; $i < 50; ++$i) {
$documents[] = [
'id' => "file-cabinet-admissionNotice.$i",
'@type' => $atType,
'objectType' => 'file-cabinet-admissionNotice',
'base' => $getRandom($personDocuments)['base'],
'file' => [
'base' => [
'fileSource' => $fileSource,
'groupId' => Uuid::v7()->toRfc4122(),
'fileId' => Uuid::v7()->toRfc4122(),
'fileName' => $getRandom($fileNames),
'comment' => $getRandom($comment),
'studentLifeCyclePhase' => $getRandom($phases),
'subjectOf' => $getRandom($subjectOf),
'studyField' => $getRandom($studyField),
'additionalType' => 'AdmissionNotice',
],
'admissionNotice' => [
'dateCreated' => $getRandom(['2024-12-24', '1970-01-01', '1978-01-03']),
'previousStudy' => $getRandom(['Something', 'Completely', 'Different']),
'decision' => $getRandom(['rejected', 'refused', 'granted']),
],
],
];
}

// citizenshipCertificate
for ($i = 0; $i < 50; ++$i) {
$documents[] = [
Expand All @@ -168,14 +197,18 @@ public function addDummyDocuments(string $collectionName, array $personDocuments
'file' => [
'base' => [
'fileSource' => $fileSource,
'groupId' => Uuid::v7()->toRfc4122(),
'fileId' => Uuid::v7()->toRfc4122(),
'fileName' => $getRandom($fileNames),
'comment' => $getRandom($comment),
'studentLifeCyclePhase' => $getRandom($phases),
'subjectOf' => $getRandom($subjectOf),
'studyField' => $getRandom($studyField),
'additionalType' => 'CitizenshipCertificate',
],
'citizenshipCertificate' => [
'countryOfOrigin' => $getRandom($countryOfOrigin),
'nationality' => $getRandom(['MNE', 'AUT', 'HRV']),
'dateCreated' => $getRandom(['2024-11-24', '1970-01-02', '1978-01-03']),
],
],
];
Expand All @@ -191,16 +224,19 @@ public function addDummyDocuments(string $collectionName, array $personDocuments
'file' => [
'base' => [
'fileSource' => $fileSource,
'groupId' => Uuid::v7()->toRfc4122(),
'fileId' => Uuid::v7()->toRfc4122(),
'fileName' => $getRandom($fileNames),
'comment' => $getRandom($comment),
'studentLifeCyclePhase' => $getRandom($phases),
'subjectOf' => $getRandom($subjectOf),
'studyField' => $getRandom($studyField),
'additionalType' => $getRandom(['PersonalLicence', 'Passport', 'DriversLicence']),
],
'identityDocument' => [
'countryOfOrigin' => $getRandom($countryOfOrigin),
'nationality' => $getRandom(['MNE', 'AUT', 'HRV']),
'identifier' => $getRandom(['AT-L-123456', 'P7890123', '23456789']),
'dateCreated' => $getRandom(['2021-02-11 11:30', '2021-02-12 19:40']),
'dateCreated' => $getRandom(['2024-11-26', '1970-01-03', '1978-01-03']),
],
],
];
Expand All @@ -216,10 +252,13 @@ public function addDummyDocuments(string $collectionName, array $personDocuments
'file' => [
'base' => [
'fileSource' => $fileSource,
'groupId' => Uuid::v7()->toRfc4122(),
'fileId' => Uuid::v7()->toRfc4122(),
'fileName' => $getRandom($fileNames),
'comment' => $getRandom($comment),
'studentLifeCyclePhase' => $getRandom($phases),
'subjectOf' => $getRandom($subjectOf),
'studyField' => $getRandom($studyField),
'additionalType' => $getRandom(['BirthCertificate', 'MaritalStatusCertificate', 'SupervisionAcceptance']),
],
'minimalSchema' => [
Expand All @@ -238,10 +277,13 @@ public function addDummyDocuments(string $collectionName, array $personDocuments
'file' => [
'base' => [
'fileSource' => $fileSource,
'groupId' => Uuid::v7()->toRfc4122(),
'fileId' => Uuid::v7()->toRfc4122(),
'fileName' => $getRandom($fileNames),
'comment' => $getRandom($comment),
'studentLifeCyclePhase' => $getRandom($phases),
'subjectOf' => $getRandom($subjectOf),
'studyField' => $getRandom($studyField),
'additionalType' => $getRandom(['PhoneCall', 'InPersonCommunication']),
],
'communication' => [
Expand All @@ -250,88 +292,7 @@ public function addDummyDocuments(string $collectionName, array $personDocuments
'givenName' => 'James',
'familyName' => 'Bond',
],
'dateCreated' => $getRandom(['2021-02-11 11:30', '2021-02-12 19:40']),
],
],
];
}

// email
for ($i = 0; $i < 50; ++$i) {
$documents[] = [
'id' => "file-cabinet-email.$i",
'@type' => $atType,
'objectType' => 'file-cabinet-email',
'base' => $getRandom($personDocuments)['base'],
'file' => [
'base' => [
'fileSource' => $fileSource,
'fileName' => $getRandom($fileNames),
'comment' => $getRandom($comment),
'studentLifeCyclePhase' => $getRandom($phases),
'subjectOf' => $getRandom($subjectOf),
'additionalType' => $getRandom(['Email']),
],
'email' => [
'abstract' => 'Short description or summarization of the email. Can also be a plain text copy.',
'dateCreated' => $getRandom(['2021-02-11 11:30', '2021-02-12 19:40']),
'sender' => [
'givenName' => 'Elim',
'familyName' => 'Garak',
'email' => '[email protected]',
],
'recipient' => [
'givenName' => 'Enabran',
'familyName' => 'Tain',
'email' => '[email protected]',
],
'ccRecipient' => '[email protected]',
'bccRecipient' => '[email protected]',
],
],
];
}

// letter
for ($i = 0; $i < 50; ++$i) {
$documents[] = [
'id' => "file-cabinet-letter.$i",
'@type' => $atType,
'objectType' => 'file-cabinet-letter',
'base' => $getRandom($personDocuments)['base'],
'file' => [
'base' => [
'fileSource' => $fileSource,
'fileName' => $getRandom($fileNames),
'comment' => $getRandom($comment),
'studentLifeCyclePhase' => $getRandom($phases),
'subjectOf' => $getRandom($subjectOf),
'additionalType' => $getRandom(['PostalLetter']),
],
'letter' => [
'abstract' => 'Short description or summarization of the email. Can also be a plain text copy.',
'dateSent' => $getRandom(['2021-02-11', '2021-02-12']),
'dateReceived' => $getRandom(['2021-02-13', '2021-02-14']),
'sender' => [
'givenName' => 'Elim',
'familyName' => 'Garak',
'worksFor' => [
'legalName' => 'Legal',
'department' => 'Department',
],
'legalName' => 'Legal',
'department' => 'Department',
],
'recipient' => [
'givenName' => 'Enabran',
'familyName' => 'Tain',
'worksFor' => [
'legalName' => 'Legal',
'department' => 'Department',
],
'legalName' => 'Legal',
'department' => 'Department',
],
'dateCreated' => $getRandom(['2023-05-15T09:30:45+05:00', '2021-12-31T23:59:59+02:00', '2024-02-29T00:00:00+00:00']),
],
],
];
Expand Down

0 comments on commit 23b785c

Please sign in to comment.