mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
fix folder name
This commit is contained in:
171
src/Bundle/ChillDocStoreBundle/Entity/Document.php
Normal file
171
src/Bundle/ChillDocStoreBundle/Entity/Document.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocStoreBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use ChampsLibres\AsyncUploaderBundle\Validator\Constraints\AsyncFileExists;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\MappedSuperclass()
|
||||
*/
|
||||
class Document implements HasScopeInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
* @Assert\Length(
|
||||
* min=2, max=250
|
||||
* )
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
private $description = '';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\DocStoreBundle\Entity\DocumentCategory")
|
||||
* @ORM\JoinColumns({
|
||||
* @ORM\JoinColumn(name="category_bundle_id", referencedColumnName="bundle_id"),
|
||||
* @ORM\JoinColumn(name="category_id_inside_bundle", referencedColumnName="id_inside_bundle")
|
||||
* })
|
||||
*/
|
||||
private $category;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\DocStoreBundle\Entity\StoredObject",
|
||||
* cascade={"persist"}
|
||||
* )
|
||||
* @Assert\Valid()
|
||||
* @Assert\NotNull(
|
||||
* message="Upload a document"
|
||||
* )
|
||||
*/
|
||||
private $object;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
|
||||
* @var \Chill\MainBundle\Entity\Scope The document's center
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @var \Chill\PersonBundle\Entity\user The user who encoded the exif_read_data
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
private $date;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description): self
|
||||
{
|
||||
$this->description = (string) $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DocumentCategory
|
||||
*/
|
||||
public function getCategory(): ?DocumentCategory
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function setCategory(DocumentCategory $category): self
|
||||
{
|
||||
$this->category = $category;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scope
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Scope
|
||||
*/
|
||||
public function getScope()
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
public function setScope($scope): self
|
||||
{
|
||||
$this->scope = $scope;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser($user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(\DateTimeInterface $date): self
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getObject(): ?StoredObject
|
||||
{
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
public function setObject(StoredObject $object = null)
|
||||
{
|
||||
$this->object = $object;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
93
src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
Normal file
93
src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocStoreBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Table("chill_doc.document_category")
|
||||
* @ORM\Entity(repositoryClass="Chill\DocStoreBundle\EntityRepository\DocumentCategoryRepository")
|
||||
*/
|
||||
class DocumentCategory
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\Column(type="string", name="bundle_id")
|
||||
* @var string The id of the bundle that has create the category (i.e. 'person', 'activity', ....)
|
||||
*/
|
||||
private $bundleId;
|
||||
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\Column(type="integer", name="id_inside_bundle")
|
||||
* @var int The id which is unique inside the bundle
|
||||
*/
|
||||
private $idInsideBundle;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", name="document_class")
|
||||
* @var string The class of the document (ie Chill\DocStoreBundle\PersonDocument)
|
||||
*/
|
||||
private $documentClass;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
public function __construct($bundleId, $idInsideBundle)
|
||||
{
|
||||
$this->bundleId = $bundleId;
|
||||
$this->idInsideBundle = $idInsideBundle;
|
||||
}
|
||||
|
||||
public function getBundleId() // ::class BundleClass (FQDN)
|
||||
{
|
||||
return $this->bundleId;
|
||||
}
|
||||
|
||||
public function getIdInsideBundle()
|
||||
{
|
||||
return $this->idInsideBundle;
|
||||
}
|
||||
|
||||
public function getDocumentClass()
|
||||
{
|
||||
return $this->documentClass;
|
||||
}
|
||||
|
||||
public function setDocumentClass($documentClass): self
|
||||
{
|
||||
$this->documentClass = $documentClass;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName($locale = null)
|
||||
{
|
||||
if ($locale) {
|
||||
if (isset($this->name[$locale])) {
|
||||
return $this->name[$locale];
|
||||
} else {
|
||||
foreach ($this->name as $name) {
|
||||
if (!empty($name)) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
} else {
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
public function setName($name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
46
src/Bundle/ChillDocStoreBundle/Entity/PersonDocument.php
Normal file
46
src/Bundle/ChillDocStoreBundle/Entity/PersonDocument.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocStoreBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Table("chill_doc.person_document")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class PersonDocument extends Document implements HasCenterInterface, HasScopeInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
|
||||
* @var Person
|
||||
*/
|
||||
private $person;
|
||||
|
||||
/**
|
||||
* Get person
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Person
|
||||
*/
|
||||
public function getPerson()
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function setPerson($person): self
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCenter()
|
||||
{
|
||||
return $this->getPerson()->getCenter();
|
||||
}
|
||||
}
|
157
src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php
Normal file
157
src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
*/
|
||||
namespace Chill\DocStoreBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use ChampsLibres\AsyncUploaderBundle\Model\AsyncFileInterface;
|
||||
use ChampsLibres\AsyncUploaderBundle\Validator\Constraints\AsyncFileExists;
|
||||
|
||||
/**
|
||||
* Represent a document stored in an object store
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table("chill_doc.stored_object")
|
||||
* @AsyncFileExists(
|
||||
* message="The file is not stored properly"
|
||||
* )
|
||||
*/
|
||||
class StoredObject implements AsyncFileInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
private $filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json_array", name="key")
|
||||
* @var array
|
||||
*/
|
||||
private $keyInfos = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var int[]
|
||||
* @ORM\Column(type="json_array", name="iv")
|
||||
*/
|
||||
private $iv = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \DateTime
|
||||
* @ORM\Column(type="datetime", name="creation_date")
|
||||
*/
|
||||
private $creationDate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
* @ORM\Column(type="text", name="type")
|
||||
*/
|
||||
private $type = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
* @ORM\Column(type="json_array", name="datas")
|
||||
*/
|
||||
private $datas = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->creationDate = new \DateTime();
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
public function getCreationDate(): \DateTime
|
||||
{
|
||||
return $this->creationDate;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getDatas()
|
||||
{
|
||||
return $this->datas;
|
||||
}
|
||||
|
||||
public function setFilename($filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreationDate(\DateTime $creationDate)
|
||||
{
|
||||
$this->creationDate = $creationDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDatas(array $datas)
|
||||
{
|
||||
$this->datas = $datas;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getObjectName()
|
||||
{
|
||||
return $this->getFilename();
|
||||
}
|
||||
|
||||
public function getKeyInfos()
|
||||
{
|
||||
return $this->keyInfos;
|
||||
}
|
||||
|
||||
public function getIv()
|
||||
{
|
||||
return $this->iv;
|
||||
}
|
||||
|
||||
public function setKeyInfos($keyInfos)
|
||||
{
|
||||
$this->keyInfos = $keyInfos;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setIv($iv)
|
||||
{
|
||||
$this->iv = $iv;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user