2019-09-16 21:40:47 +02:00
|
|
|
<?php
|
2020-02-22 18:14:36 +01:00
|
|
|
/**
|
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
|
|
|
*
|
2022-11-29 22:28:53 +01:00
|
|
|
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
|
2020-02-22 18:14:36 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-01-05 15:46:58 +01:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-09-16 21:40:47 +02:00
|
|
|
namespace App\Entity\Parts\PartTraits;
|
|
|
|
|
2023-06-11 14:55:06 +02:00
|
|
|
use Doctrine\DBAL\Types\Types;
|
2019-09-16 21:40:47 +02:00
|
|
|
use App\Entity\Parts\Part;
|
2022-08-14 19:32:53 +02:00
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2023-03-12 01:41:44 +01:00
|
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
2022-08-14 19:32:53 +02:00
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
2019-09-16 21:40:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Advanced properties of a part, not related to a more specific group.
|
|
|
|
*/
|
|
|
|
trait AdvancedPropertyTrait
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var bool Determines if this part entry needs review (for example, because it is work in progress)
|
|
|
|
*/
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Groups(['extended', 'full', 'import'])]
|
2023-06-11 14:55:06 +02:00
|
|
|
#[ORM\Column(type: Types::BOOLEAN)]
|
2022-09-18 22:59:31 +02:00
|
|
|
protected bool $needs_review = false;
|
2019-09-16 21:40:47 +02:00
|
|
|
|
|
|
|
/**
|
2020-01-04 20:24:09 +01:00
|
|
|
* @var string a comma separated list of tags, associated with the part
|
2019-09-16 21:40:47 +02:00
|
|
|
*/
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Groups(['extended', 'full', 'import'])]
|
2023-06-11 14:55:06 +02:00
|
|
|
#[ORM\Column(type: Types::TEXT)]
|
2022-09-18 22:59:31 +02:00
|
|
|
protected string $tags = '';
|
2019-09-16 21:40:47 +02:00
|
|
|
|
|
|
|
/**
|
2020-01-04 20:24:09 +01:00
|
|
|
* @var float|null how much a single part unit weighs in grams
|
2019-09-16 21:40:47 +02:00
|
|
|
*/
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Assert\PositiveOrZero]
|
|
|
|
#[Groups(['extended', 'full', 'import'])]
|
2023-06-11 14:55:06 +02:00
|
|
|
#[ORM\Column(type: Types::FLOAT, nullable: true)]
|
2022-09-18 22:59:31 +02:00
|
|
|
protected ?float $mass = null;
|
2019-09-16 21:40:47 +02:00
|
|
|
|
2022-12-04 02:28:47 +01:00
|
|
|
/**
|
2023-04-15 21:49:19 +02:00
|
|
|
* @var string|null The internal part number of the part
|
2022-12-04 02:28:47 +01:00
|
|
|
*/
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Assert\Length(max: 100)]
|
|
|
|
#[Groups(['extended', 'full', 'import'])]
|
2023-06-11 14:55:06 +02:00
|
|
|
#[ORM\Column(type: Types::STRING, length: 100, nullable: true, unique: true)]
|
2022-12-04 02:28:47 +01:00
|
|
|
protected ?string $ipn = null;
|
|
|
|
|
2019-09-16 21:40:47 +02:00
|
|
|
/**
|
|
|
|
* Checks if this part is marked, for that it needs further review.
|
|
|
|
*/
|
|
|
|
public function isNeedsReview(): bool
|
|
|
|
{
|
|
|
|
return $this->needs_review;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the "needs review" status of this part.
|
2020-01-04 20:24:09 +01:00
|
|
|
*
|
2019-11-10 14:00:56 +01:00
|
|
|
* @param bool $needs_review The new status
|
2020-01-04 20:24:09 +01:00
|
|
|
*
|
2019-09-16 21:40:47 +02:00
|
|
|
* @return Part|self
|
|
|
|
*/
|
|
|
|
public function setNeedsReview(bool $needs_review): self
|
|
|
|
{
|
|
|
|
$this->needs_review = $needs_review;
|
2019-11-09 00:47:20 +01:00
|
|
|
|
2019-09-16 21:40:47 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-11-09 00:47:20 +01:00
|
|
|
* Gets a comma separated list, of tags, that are assigned to this part.
|
2019-09-16 21:40:47 +02:00
|
|
|
*/
|
|
|
|
public function getTags(): string
|
|
|
|
{
|
|
|
|
return $this->tags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a comma separated list of tags, that are assigned to this part.
|
2019-11-09 00:47:20 +01:00
|
|
|
*
|
2019-11-10 14:00:56 +01:00
|
|
|
* @param string $tags The new tags
|
2020-03-15 13:56:31 +01:00
|
|
|
*
|
2020-02-02 14:05:36 +01:00
|
|
|
* @return $this
|
2019-09-16 21:40:47 +02:00
|
|
|
*/
|
|
|
|
public function setTags(string $tags): self
|
|
|
|
{
|
|
|
|
$this->tags = $tags;
|
2019-11-09 00:47:20 +01:00
|
|
|
|
2019-09-16 21:40:47 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the mass of a single part unit.
|
2019-11-09 00:47:20 +01:00
|
|
|
* Returns null, if the mass is unknown/not set yet.
|
2019-09-16 21:40:47 +02:00
|
|
|
*/
|
|
|
|
public function getMass(): ?float
|
|
|
|
{
|
|
|
|
return $this->mass;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the mass of a single part unit.
|
|
|
|
* Sett to null, if the mass is unknown.
|
2019-11-09 00:47:20 +01:00
|
|
|
*
|
2020-01-04 20:24:09 +01:00
|
|
|
* @param float|null $mass the new mass
|
2020-03-15 13:56:31 +01:00
|
|
|
*
|
2020-02-02 14:05:36 +01:00
|
|
|
* @return $this
|
2019-09-16 21:40:47 +02:00
|
|
|
*/
|
|
|
|
public function setMass(?float $mass): self
|
|
|
|
{
|
|
|
|
$this->mass = $mass;
|
2019-11-09 00:47:20 +01:00
|
|
|
|
2019-09-16 21:40:47 +02:00
|
|
|
return $this;
|
|
|
|
}
|
2022-12-04 02:28:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the internal part number of the part.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getIpn(): ?string
|
|
|
|
{
|
|
|
|
return $this->ipn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the internal part number of the part
|
|
|
|
* @param string $ipn The new IPN of the part
|
|
|
|
*/
|
|
|
|
public function setIpn(?string $ipn): Part
|
|
|
|
{
|
|
|
|
$this->ipn = $ipn;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-09 00:47:20 +01:00
|
|
|
}
|