<?php
declare(strict_types=1);
namespace JanusHercules\IndeedCampaignManagement\Domain\Entity;
use App\Utility\DatabaseIdGenerator;
use App\Utility\DateTimeUtility;
use DateTime;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use JanusHercules\IndeedCampaignManagement\Domain\Enum\EmplifyFeedItemCategoryVariant;
use JanusHercules\IndeedCampaignManagement\Domain\Enum\FeedItemGenerationStatus;
use JanusHercules\IndeedCampaignManagement\Domain\Enum\NotPublishableReason;
#[ORM\Entity]
#[ORM\Table(name: 'icm_feed_item_generation_results')]
#[ORM\Index(columns: ['recurrent_job_id', 'published_at'], name: 'recurrent_job_id_published_at_idx')]
class FeedItemGenerationResult
{
/**
* @throws Exception
*/
public function __construct(
FeedGenerationRun $feedGenerationRun,
FeedItemGenerationStatus $status,
?string $campaignDefinitionId,
?string $contentSnapshotId,
?string $publishedContentSnapshotId,
?string $recurrentJobId,
?bool $canBePublished,
?NotPublishableReason $notPublishableReason,
?EmplifyFeedItemCategoryVariant $categoryVariant,
?string $errorMessage = null,
?string $movedToCampaignId = null,
?string $movedToCampaignName = null
) {
$this->feedGenerationRun = $feedGenerationRun;
$this->status = $status;
$this->publishing_plan_entry_campaign_definition_id = $campaignDefinitionId;
$this->publishing_plan_entry_content_snapshot_id = $contentSnapshotId;
$this->publishing_plan_entry_published_content_snapshot_id = $publishedContentSnapshotId;
$this->recurrentJobId = $recurrentJobId;
$this->publishing_plan_entry_can_be_published = $canBePublished;
$this->publishing_plan_entry_not_publishable_reason = $notPublishableReason;
$this->publishing_plan_entry_emplify_feed_item_category_variant = $categoryVariant;
$this->errorMessage = $errorMessage;
$this->publishedAt = DateTimeUtility::createDateTimeUtc();
$this->publishingPlanEntryMovedToCampaignId = $movedToCampaignId;
$this->publishingPlanEntryMovedToCampaignName = $movedToCampaignName;
}
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
#[ORM\Column(type: Types::GUID, unique: true)]
private ?string $id = null;
public function getId(): ?string
{
return $this->id;
}
#[ORM\ManyToOne(targetEntity: CampaignItem::class, inversedBy: 'feedItemGenerationResults')]
#[ORM\JoinColumn(name: 'icm_campaign_items_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?CampaignItem $campaignItem = null;
public function getCampaignItem(): ?CampaignItem
{
return $this->campaignItem;
}
public function setCampaignItem(?CampaignItem $campaignItem): void
{
$this->campaignItem = $campaignItem;
}
#[ORM\ManyToOne(targetEntity: FeedGenerationRun::class)]
#[ORM\JoinColumn(name: 'icm_feed_generation_runs_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
private FeedGenerationRun $feedGenerationRun;
public function getFeedGenerationRun(): FeedGenerationRun
{
return $this->feedGenerationRun;
}
#[ORM\Column(type: Types::STRING, enumType: FeedItemGenerationStatus::class)]
private FeedItemGenerationStatus $status;
public function getStatus(): FeedItemGenerationStatus
{
return $this->status;
}
#[ORM\Column(name: 'error_message', type: Types::TEXT, nullable: true)]
private ?string $errorMessage;
public function getErrorMessage(): ?string
{
return $this->errorMessage;
}
#[ORM\Column(name: 'published_at', type: Types::DATETIME_MUTABLE)]
private DateTime $publishedAt;
public function getPublishedAt(): DateTime
{
return $this->publishedAt;
}
#[ORM\Column(name: 'publishing_plan_entry_campaign_definition_id', type: Types::GUID, nullable: true)]
private ?string $publishing_plan_entry_campaign_definition_id;
public function getPublishingPlanEntryCampaignDefinitionId(): ?string
{
return $this->publishing_plan_entry_campaign_definition_id;
}
#[ORM\Column(name: 'publishing_plan_entry_content_snapshot_id', type: Types::GUID, nullable: true)]
private ?string $publishing_plan_entry_content_snapshot_id;
public function getPublishingPlanEntryContentSnapshotId(): ?string
{
return $this->publishing_plan_entry_content_snapshot_id;
}
#[ORM\Column(name: 'publishing_plan_entry_published_content_snapshot_id', type: Types::GUID, nullable: true)]
private ?string $publishing_plan_entry_published_content_snapshot_id;
public function getPublishingPlanEntryPublishedContentSnapshotId(): ?string
{
return $this->publishing_plan_entry_published_content_snapshot_id;
}
#[ORM\Column(name: 'publishing_plan_entry_can_be_published', type: Types::BOOLEAN, nullable: true)]
private ?bool $publishing_plan_entry_can_be_published;
public function getPublishingPlanEntryCanBePublished(): ?bool
{
return $this->publishing_plan_entry_can_be_published;
}
#[ORM\Column(name: 'publishing_plan_entry_not_publishable_reason', type: Types::STRING, nullable: true, enumType: NotPublishableReason::class)]
private ?NotPublishableReason $publishing_plan_entry_not_publishable_reason;
public function getPublishingPlanEntryNotPublishableReason(): ?NotPublishableReason
{
return $this->publishing_plan_entry_not_publishable_reason;
}
#[ORM\Column(name: 'publishing_plan_entry_emplify_feed_item_category_variant', type: Types::STRING, nullable: true, enumType: EmplifyFeedItemCategoryVariant::class)]
private ?EmplifyFeedItemCategoryVariant $publishing_plan_entry_emplify_feed_item_category_variant;
public function getPublishingPlanEntryEmplifyFeedItemCategoryVariant(): ?EmplifyFeedItemCategoryVariant
{
return $this->publishing_plan_entry_emplify_feed_item_category_variant;
}
#[ORM\Column(name: 'recurrent_job_id', type: Types::GUID, nullable: true)]
private ?string $recurrentJobId = null;
public function getRecurrentJobId(): ?string
{
return $this->recurrentJobId;
}
public function setRecurrentJobId(?string $recurrentJobId): void
{
$this->recurrentJobId = $recurrentJobId;
}
#[ORM\Column(name: 'publishing_plan_entry_moved_to_campaign_id', type: Types::GUID, nullable: true)]
private ?string $publishingPlanEntryMovedToCampaignId = null;
public function getPublishingPlanEntryMovedToCampaignId(): ?string
{
return $this->publishingPlanEntryMovedToCampaignId;
}
public function setPublishingPlanEntryMovedToCampaignId(?string $publishingPlanEntryMovedToCampaignId): void
{
$this->publishingPlanEntryMovedToCampaignId = $publishingPlanEntryMovedToCampaignId;
}
#[ORM\Column(name: 'publishing_plan_entry_moved_to_campaign_name', type: Types::STRING, nullable: true)]
private ?string $publishingPlanEntryMovedToCampaignName = null;
public function getPublishingPlanEntryMovedToCampaignName(): ?string
{
return $this->publishingPlanEntryMovedToCampaignName;
}
public function setPublishingPlanEntryMovedToCampaignName(?string $publishingPlanEntryMovedToCampaignName): void
{
$this->publishingPlanEntryMovedToCampaignName = $publishingPlanEntryMovedToCampaignName;
}
}