Improved serialized fields

This commit is contained in:
Jan Böhmer 2023-03-12 01:12:35 +01:00
parent b99e6c9a21
commit 2c67586873
18 changed files with 84 additions and 1 deletions

View file

@ -29,6 +29,7 @@ use App\Entity\Contracts\HasMasterAttachmentInterface;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
@ -43,6 +44,7 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element") * //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
* *
* Mapping is done in sub classes like part * Mapping is done in sub classes like part
* @Groups({"full"})
*/ */
protected $attachments; protected $attachments;

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Entity\Base; namespace App\Entity\Base;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use function is_string; use function is_string;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@ -36,18 +37,21 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
/** /**
* @var string The address of the company * @var string The address of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Groups({"full"})
*/ */
protected string $address = ''; protected string $address = '';
/** /**
* @var string The phone number of the company * @var string The phone number of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Groups({"full"})
*/ */
protected string $phone_number = ''; protected string $phone_number = '';
/** /**
* @var string The fax number of the company * @var string The fax number of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Groups({"full"})
*/ */
protected string $fax_number = ''; protected string $fax_number = '';
@ -55,6 +59,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
* @var string The email address of the company * @var string The email address of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Assert\Email() * @Assert\Email()
* @Groups({"full"})
*/ */
protected string $email_address = ''; protected string $email_address = '';
@ -62,6 +67,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
* @var string The website of the company * @var string The website of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Assert\Url() * @Assert\Url()
* @Groups({"full"})
*/ */
protected string $website = ''; protected string $website = '';

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Entity\Base; namespace App\Entity\Base;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/** /**
* Class PartsContainingDBElement. * Class PartsContainingDBElement.
@ -31,4 +32,6 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement
{ {
/** @Groups({"full"}) */
protected $parameters;
} }

View file

@ -63,7 +63,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
/** /**
* @var string The comment info for this element * @var string The comment info for this element
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"simple", "extended", "full"}) * @Groups({"full"})
*/ */
protected string $comment = ''; protected string $comment = '';
@ -71,6 +71,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
* @var bool If this property is set, this element can not be selected for part properties. * @var bool If this property is set, this element can not be selected for part properties.
* Useful if this element should be used only for grouping, sorting. * Useful if this element should be used only for grouping, sorting.
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"full"})
*/ */
protected bool $not_selectable = false; protected bool $not_selectable = false;

View file

@ -46,6 +46,7 @@ use App\Entity\Base\AbstractNamedDBElement;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException; use InvalidArgumentException;
use LogicException; use LogicException;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use function sprintf; use function sprintf;
@ -84,6 +85,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
* @var string The mathematical symbol for this specification. Can be rendered pretty later. Should be short * @var string The mathematical symbol for this specification. Can be rendered pretty later. Should be short
* @Assert\Length(max=20) * @Assert\Length(max=20)
* @ORM\Column(type="string", nullable=false) * @ORM\Column(type="string", nullable=false)
* @Groups({"full"})
*/ */
protected string $symbol = ''; protected string $symbol = '';
@ -93,6 +95,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
* @Assert\LessThanOrEqual(propertyPath="value_typical", message="parameters.validator.min_lesser_typical") * @Assert\LessThanOrEqual(propertyPath="value_typical", message="parameters.validator.min_lesser_typical")
* @Assert\LessThan(propertyPath="value_max", message="parameters.validator.min_lesser_max") * @Assert\LessThan(propertyPath="value_max", message="parameters.validator.min_lesser_max")
* @ORM\Column(type="float", nullable=true) * @ORM\Column(type="float", nullable=true)
* @Groups({"full"})
*/ */
protected ?float $value_min = null; protected ?float $value_min = null;
@ -100,6 +103,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
* @var float|null the typical value of this property * @var float|null the typical value of this property
* @Assert\Type({"null", "float"}) * @Assert\Type({"null", "float"})
* @ORM\Column(type="float", nullable=true) * @ORM\Column(type="float", nullable=true)
* @Groups({"full"})
*/ */
protected ?float $value_typical = null; protected ?float $value_typical = null;
@ -108,24 +112,29 @@ abstract class AbstractParameter extends AbstractNamedDBElement
* @Assert\Type({"float", "null"}) * @Assert\Type({"float", "null"})
* @Assert\GreaterThanOrEqual(propertyPath="value_typical", message="parameters.validator.max_greater_typical") * @Assert\GreaterThanOrEqual(propertyPath="value_typical", message="parameters.validator.max_greater_typical")
* @ORM\Column(type="float", nullable=true) * @ORM\Column(type="float", nullable=true)
* @Groups({"full"})
*/ */
protected ?float $value_max = null; protected ?float $value_max = null;
/** /**
* @var string The unit in which the value values are given (e.g. V) * @var string The unit in which the value values are given (e.g. V)
* @ORM\Column(type="string", nullable=false) * @ORM\Column(type="string", nullable=false)
* @Groups({"full"})
*/ */
protected string $unit = ''; protected string $unit = '';
/** /**
* @var string a text value for the given property * @var string a text value for the given property
* @ORM\Column(type="string", nullable=false) * @ORM\Column(type="string", nullable=false)
* @Groups({"full"})
*/ */
protected string $value_text = ''; protected string $value_text = '';
/** /**
* @var string the group this parameter belongs to * @var string the group this parameter belongs to
* @ORM\Column(type="string", nullable=false, name="param_group") * @ORM\Column(type="string", nullable=false, name="param_group")
* @Groups({"full"})
* @Groups({"full"})
*/ */
protected string $group = ''; protected string $group = '';

View file

@ -27,6 +27,7 @@ use App\Entity\Base\AbstractPartsContainingDBElement;
use App\Entity\Parameters\CategoryParameter; use App\Entity\Parameters\CategoryParameter;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -56,48 +57,56 @@ class Category extends AbstractPartsContainingDBElement
/** /**
* @var string * @var string
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"full"})
*/ */
protected string $partname_hint = ''; protected string $partname_hint = '';
/** /**
* @var string * @var string
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"full"})
*/ */
protected string $partname_regex = ''; protected string $partname_regex = '';
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"full"})
*/ */
protected bool $disable_footprints = false; protected bool $disable_footprints = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"full"})
*/ */
protected bool $disable_manufacturers = false; protected bool $disable_manufacturers = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"full"})
*/ */
protected bool $disable_autodatasheets = false; protected bool $disable_autodatasheets = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"full"})
*/ */
protected bool $disable_properties = false; protected bool $disable_properties = false;
/** /**
* @var string * @var string
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"full"})
*/ */
protected string $default_description = ''; protected string $default_description = '';
/** /**
* @var string * @var string
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"full"})
*/ */
protected string $default_comment = ''; protected string $default_comment = '';
/** /**
@ -105,6 +114,7 @@ class Category extends AbstractPartsContainingDBElement
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"}) * @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid() * @Assert\Valid()
* @Groups({"full"})
*/ */
protected $attachments; protected $attachments;
@ -112,6 +122,7 @@ class Category extends AbstractPartsContainingDBElement
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid() * @Assert\Valid()
* @Groups({"full"})
*/ */
protected $parameters; protected $parameters;

View file

@ -28,6 +28,7 @@ use App\Entity\Parameters\MeasurementUnitParameter;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -48,6 +49,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
* or m (for meters). * or m (for meters).
* @ORM\Column(type="string", name="unit", nullable=true) * @ORM\Column(type="string", name="unit", nullable=true)
* @Assert\Length(max=10) * @Assert\Length(max=10)
* @Groups({"extended", "full"})
*/ */
protected ?string $unit = null; protected ?string $unit = null;
@ -55,6 +57,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
* @var bool Determines if the amount value associated with this unit should be treated as integer. * @var bool Determines if the amount value associated with this unit should be treated as integer.
* Set to false, to measure continuous sizes likes masses or lengths. * Set to false, to measure continuous sizes likes masses or lengths.
* @ORM\Column(type="boolean", name="is_integer") * @ORM\Column(type="boolean", name="is_integer")
* @Groups({"extended", "full"})
*/ */
protected bool $is_integer = false; protected bool $is_integer = false;
@ -63,6 +66,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
* Useful for sizes like meters. For this the unit must be set * Useful for sizes like meters. For this the unit must be set
* @ORM\Column(type="boolean", name="use_si_prefix") * @ORM\Column(type="boolean", name="use_si_prefix")
* @Assert\Expression("this.isUseSIPrefix() == false or this.getUnit() != null", message="validator.measurement_unit.use_si_prefix_needs_unit") * @Assert\Expression("this.isUseSIPrefix() == false or this.getUnit() != null", message="validator.measurement_unit.use_si_prefix_needs_unit")
* @Groups({"full"})
*/ */
protected bool $use_si_prefix = false; protected bool $use_si_prefix = false;

View file

@ -40,6 +40,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface;
@ -72,6 +73,7 @@ class Part extends AttachmentContainingDBElement
* @Assert\Valid() * @Assert\Valid()
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\PartParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(targetEntity="App\Entity\Parameters\PartParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Groups({"full"})
*/ */
protected $parameters; protected $parameters;
@ -96,6 +98,7 @@ class Part extends AttachmentContainingDBElement
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\PartAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(targetEntity="App\Entity\Attachments\PartAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"}) * @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid() * @Assert\Valid()
* @Groups({"full"})
*/ */
protected $attachments; protected $attachments;

View file

@ -31,6 +31,7 @@ use App\Validator\Constraints\ValidPartLot;
use DateTime; use DateTime;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Exception; use Exception;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -52,12 +53,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/** /**
* @var string A short description about this lot, shown in table * @var string A short description about this lot, shown in table
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"simple", "extended", "full"})
*/ */
protected string $description = ''; protected string $description = '';
/** /**
* @var string a comment stored with this lot * @var string a comment stored with this lot
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"full"})
*/ */
protected string $comment = ''; protected string $comment = '';
@ -65,6 +68,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
* @var ?DateTime Set a time until when the lot must be used. * @var ?DateTime Set a time until when the lot must be used.
* Set to null, if the lot can be used indefinitely. * Set to null, if the lot can be used indefinitely.
* @ORM\Column(type="datetime", name="expiration_date", nullable=true) * @ORM\Column(type="datetime", name="expiration_date", nullable=true)
* @Groups({"extended", "full"})
*/ */
protected ?DateTime $expiration_date = null; protected ?DateTime $expiration_date = null;
@ -73,12 +77,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
* @ORM\ManyToOne(targetEntity="Storelocation") * @ORM\ManyToOne(targetEntity="Storelocation")
* @ORM\JoinColumn(name="id_store_location", referencedColumnName="id", nullable=true) * @ORM\JoinColumn(name="id_store_location", referencedColumnName="id", nullable=true)
* @Selectable() * @Selectable()
* @Groups({"simple", "extended", "full"})
*/ */
protected ?Storelocation $storage_location = null; protected ?Storelocation $storage_location = null;
/** /**
* @var bool If this is set to true, the instock amount is marked as not known * @var bool If this is set to true, the instock amount is marked as not known
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"simple", "extended", "full"})
*/ */
protected bool $instock_unknown = false; protected bool $instock_unknown = false;
@ -86,12 +92,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
* @var float For continuous sizes (length, volume, etc.) the instock is saved here. * @var float For continuous sizes (length, volume, etc.) the instock is saved here.
* @ORM\Column(type="float") * @ORM\Column(type="float")
* @Assert\PositiveOrZero() * @Assert\PositiveOrZero()
* @Groups({"simple", "extended", "full"})
*/ */
protected float $amount = 0.0; protected float $amount = 0.0;
/** /**
* @var bool determines if this lot was manually marked for refilling * @var bool determines if this lot was manually marked for refilling
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"extended", "full"})
*/ */
protected bool $needs_refill = false; protected bool $needs_refill = false;

View file

@ -26,6 +26,7 @@ use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint; use App\Entity\Parts\Footprint;
use App\Validator\Constraints\Selectable; use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
trait BasicPropertyTrait trait BasicPropertyTrait
@ -33,12 +34,14 @@ trait BasicPropertyTrait
/** /**
* @var string A text describing what this part does * @var string A text describing what this part does
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"simple", "extended", "full"})
*/ */
protected string $description = ''; protected string $description = '';
/** /**
* @var string A comment/note related to this part * @var string A comment/note related to this part
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"extended", "full"})
*/ */
protected string $comment = ''; protected string $comment = '';
@ -51,6 +54,7 @@ trait BasicPropertyTrait
/** /**
* @var bool true, if the part is marked as favorite * @var bool true, if the part is marked as favorite
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"extended", "full"})
*/ */
protected bool $favorite = false; protected bool $favorite = false;
@ -61,6 +65,7 @@ trait BasicPropertyTrait
* @ORM\JoinColumn(name="id_category", referencedColumnName="id", nullable=false) * @ORM\JoinColumn(name="id_category", referencedColumnName="id", nullable=false)
* @Selectable() * @Selectable()
* @Assert\NotNull(message="validator.select_valid_category") * @Assert\NotNull(message="validator.select_valid_category")
* @Groups({"simple", "extended", "full"})
*/ */
protected ?Category $category = null; protected ?Category $category = null;
@ -69,6 +74,7 @@ trait BasicPropertyTrait
* @ORM\ManyToOne(targetEntity="Footprint") * @ORM\ManyToOne(targetEntity="Footprint")
* @ORM\JoinColumn(name="id_footprint", referencedColumnName="id") * @ORM\JoinColumn(name="id_footprint", referencedColumnName="id")
* @Selectable() * @Selectable()
* @Groups({"simple", "extended", "full"})
*/ */
protected ?Footprint $footprint = null; protected ?Footprint $footprint = null;

View file

@ -26,6 +26,7 @@ use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\PartLot; use App\Entity\Parts\PartLot;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -38,6 +39,7 @@ trait InstockTrait
* @ORM\OneToMany(targetEntity="PartLot", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(targetEntity="PartLot", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid() * @Assert\Valid()
* @ORM\OrderBy({"amount" = "DESC"}) * @ORM\OrderBy({"amount" = "DESC"})
* @Groups({"extended", "full"})
*/ */
protected $partLots; protected $partLots;
@ -46,6 +48,7 @@ trait InstockTrait
* Given in the partUnit. * Given in the partUnit.
* @ORM\Column(type="float") * @ORM\Column(type="float")
* @Assert\PositiveOrZero() * @Assert\PositiveOrZero()
* @Groups({"extended", "full"})
*/ */
protected float $minamount = 0; protected float $minamount = 0;
@ -53,6 +56,7 @@ trait InstockTrait
* @var ?MeasurementUnit the unit in which the part's amount is measured * @var ?MeasurementUnit the unit in which the part's amount is measured
* @ORM\ManyToOne(targetEntity="MeasurementUnit") * @ORM\ManyToOne(targetEntity="MeasurementUnit")
* @ORM\JoinColumn(name="id_part_unit", referencedColumnName="id", nullable=true) * @ORM\JoinColumn(name="id_part_unit", referencedColumnName="id", nullable=true)
* @Groups({"extended", "full"})
*/ */
protected ?MeasurementUnit $partUnit = null; protected ?MeasurementUnit $partUnit = null;

View file

@ -26,6 +26,7 @@ use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Validator\Constraints\Selectable; use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -45,12 +46,14 @@ trait ManufacturerTrait
* @var string the url to the part on the manufacturer's homepage * @var string the url to the part on the manufacturer's homepage
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Assert\Url() * @Assert\Url()
* @Groups({"full"})
*/ */
protected string $manufacturer_product_url = ''; protected string $manufacturer_product_url = '';
/** /**
* @var string The product number used by the manufacturer. If this is set to "", the name field is used. * @var string The product number used by the manufacturer. If this is set to "", the name field is used.
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Groups({"extended", "full"})
*/ */
protected string $manufacturer_product_number = ''; protected string $manufacturer_product_number = '';
@ -58,6 +61,7 @@ trait ManufacturerTrait
* @var string The production status of this part. Can be one of the specified ones. * @var string The production status of this part. Can be one of the specified ones.
* @ORM\Column(type="string", length=255, nullable=true) * @ORM\Column(type="string", length=255, nullable=true)
* @Assert\Choice({"announced", "active", "nrfnd", "eol", "discontinued", ""}) * @Assert\Choice({"announced", "active", "nrfnd", "eol", "discontinued", ""})
* @Groups({"extended", "full"})
*/ */
protected ?string $manufacturing_status = ''; protected ?string $manufacturing_status = '';

View file

@ -24,6 +24,7 @@ namespace App\Entity\Parts\PartTraits;
use App\Entity\PriceInformations\Orderdetail; use App\Entity\PriceInformations\Orderdetail;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use function count; use function count;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@ -39,6 +40,7 @@ trait OrderTrait
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid() * @Assert\Valid()
* @ORM\OrderBy({"supplierpartnr" = "ASC"}) * @ORM\OrderBy({"supplierpartnr" = "ASC"})
* @Groups({"extended", "full"})
*/ */
protected $orderdetails; protected $orderdetails;

View file

@ -27,6 +27,7 @@ use App\Entity\Base\AbstractPartsContainingDBElement;
use App\Entity\Parameters\StorelocationParameter; use App\Entity\Parameters\StorelocationParameter;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -70,12 +71,14 @@ class Storelocation extends AbstractPartsContainingDBElement
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"full"})
*/ */
protected bool $is_full = false; protected bool $is_full = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"full"})
*/ */
protected bool $only_single_part = false; protected bool $only_single_part = false;

View file

@ -32,6 +32,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -60,6 +61,7 @@ class Currency extends AbstractStructuralDBElement
* @var string the 3-letter ISO code of the currency * @var string the 3-letter ISO code of the currency
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Assert\Currency() * @Assert\Currency()
* @Groups({"extended", "full"})
*/ */
protected string $iso_code = ""; protected string $iso_code = "";

View file

@ -34,6 +34,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -54,12 +55,14 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid() * @Assert\Valid()
* @ORM\OrderBy({"min_discount_quantity" = "ASC"}) * @ORM\OrderBy({"min_discount_quantity" = "ASC"})
* @Groups({"extended", "full"})
*/ */
protected $pricedetails; protected $pricedetails;
/** /**
* @var string * @var string
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Groups({"extended", "full"})
*/ */
protected string $supplierpartnr = ''; protected string $supplierpartnr = '';
@ -73,6 +76,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @var string * @var string
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Assert\Url() * @Assert\Url()
* @Groups({"full"})
*/ */
protected string $supplier_product_url = ''; protected string $supplier_product_url = '';
@ -89,6 +93,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="orderdetails") * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="orderdetails")
* @ORM\JoinColumn(name="id_supplier", referencedColumnName="id") * @ORM\JoinColumn(name="id_supplier", referencedColumnName="id")
* @Assert\NotNull(message="validator.orderdetail.supplier_must_not_be_null") * @Assert\NotNull(message="validator.orderdetail.supplier_must_not_be_null")
* @Groups({"extended", "full"})
*/ */
protected ?Supplier $supplier = null; protected ?Supplier $supplier = null;

View file

@ -32,6 +32,7 @@ use Brick\Math\RoundingMode;
use DateTime; use DateTime;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -55,6 +56,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* @var BigDecimal The price related to the detail. (Given in the selected currency) * @var BigDecimal The price related to the detail. (Given in the selected currency)
* @ORM\Column(type="big_decimal", precision=11, scale=5) * @ORM\Column(type="big_decimal", precision=11, scale=5)
* @BigDecimalPositive() * @BigDecimalPositive()
* @Groups({"extended", "full"})
*/ */
protected BigDecimal $price; protected BigDecimal $price;
@ -64,6 +66,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* @ORM\ManyToOne(targetEntity="Currency", inversedBy="pricedetails") * @ORM\ManyToOne(targetEntity="Currency", inversedBy="pricedetails")
* @ORM\JoinColumn(name="id_currency", referencedColumnName="id", nullable=true) * @ORM\JoinColumn(name="id_currency", referencedColumnName="id", nullable=true)
* @Selectable() * @Selectable()
* @Groups({"extended", "full"})
*/ */
protected ?Currency $currency = null; protected ?Currency $currency = null;
@ -71,6 +74,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* @var float * @var float
* @ORM\Column(type="float") * @ORM\Column(type="float")
* @Assert\Positive() * @Assert\Positive()
* @Groups({"extended", "full"})
*/ */
protected float $price_related_quantity = 1.0; protected float $price_related_quantity = 1.0;
@ -78,12 +82,14 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* @var float * @var float
* @ORM\Column(type="float") * @ORM\Column(type="float")
* @Assert\Positive() * @Assert\Positive()
* @Groups({"extended", "full"})
*/ */
protected float $min_discount_quantity = 1.0; protected float $min_discount_quantity = 1.0;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Groups({"extended", "full"})
*/ */
protected bool $manual_input = true; protected bool $manual_input = true;

View file

@ -30,6 +30,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException; use InvalidArgumentException;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface;
@ -57,6 +58,7 @@ class Project extends AbstractStructuralDBElement
/** /**
* @ORM\OneToMany(targetEntity="ProjectBOMEntry", mappedBy="project", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(targetEntity="ProjectBOMEntry", mappedBy="project", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid() * @Assert\Valid()
* @Groups({"extended", "full"})
*/ */
protected $bom_entries; protected $bom_entries;
@ -69,6 +71,7 @@ class Project extends AbstractStructuralDBElement
* @var string The current status of the project * @var string The current status of the project
* @ORM\Column(type="string", length=64, nullable=true) * @ORM\Column(type="string", length=64, nullable=true)
* @Assert\Choice({"draft","planning","in_production","finished","archived"}) * @Assert\Choice({"draft","planning","in_production","finished","archived"})
* @Groups({"extended", "full"})
*/ */
protected ?string $status = null; protected ?string $status = null;
@ -86,6 +89,7 @@ class Project extends AbstractStructuralDBElement
/** /**
* @ORM\Column(type="text", nullable=false, columnDefinition="DEFAULT ''") * @ORM\Column(type="text", nullable=false, columnDefinition="DEFAULT ''")
* @Groups({"simple", "extended", "full"})
*/ */
protected string $description = ''; protected string $description = '';