added annotation based exporter (#1831)

* added user exporter
* added project exporter
* added customer exporter
* added activity exporter
This commit is contained in:
Kevin Papst
2020-07-21 03:37:51 +02:00
committed by GitHub
parent 93a23f3fa3
commit aee063bb3c
79 changed files with 2980 additions and 215 deletions

View File

@@ -9,6 +9,7 @@
namespace App\Entity;
use App\Export\Annotation as Exporter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -44,6 +45,10 @@ use Symfony\Component\Validator\Constraints as Assert;
* @Serializer\Groups({"Default"})
* }
* )
*
* @Exporter\Order({"id", "name", "project", "budget", "timeBudget", "color", "visible", "comment"})
* @Exporter\Expose("project", label="label.project", exp="object.getProject() === null ? null : object.getProject().getName()")
* @ Exporter\Expose("teams", label="label.team", exp="object.getTeams().toArray()", type="array")
*/
class Activity implements EntityWithMetaFields
{
@@ -55,6 +60,8 @@ class Activity implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.id", type="integer")
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
@@ -75,6 +82,8 @@ class Activity implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.name")
*
* @ORM\Column(name="name", type="string", length=150, nullable=false)
* @Assert\NotBlank()
* @Assert\Length(min=2, max=150, allowEmptyString=false)
@@ -88,6 +97,8 @@ class Activity implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Activity_Entity"})
*
* @Exporter\Expose(label="label.comment")
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
@@ -99,6 +110,8 @@ class Activity implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.visible", type="boolean")
*
* @ORM\Column(name="visible", type="boolean", nullable=false, options={"default": true})
* @Assert\NotNull()
*/
@@ -115,6 +128,8 @@ class Activity implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Activity_Entity"})
*
* @ Exporter\Expose(label="label.budget")
*
* @ORM\Column(name="budget", type="float", nullable=false)
* @Assert\NotNull()
*/
@@ -127,6 +142,8 @@ class Activity implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Activity_Entity"})
*
* @ Exporter\Expose(label="label.timeBudget", type="duration")
*
* @ORM\Column(name="time_budget", type="integer", nullable=false)
* @Assert\NotNull()
*/

View File

@@ -9,6 +9,7 @@
namespace App\Entity;
use App\Export\Annotation as Exporter;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
@@ -23,6 +24,8 @@ trait ColorTrait
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.color")
*
* @ORM\Column(name="color", type="string", length=7, nullable=true)
* @Assert\Length(min=4, max=7)
*/

View File

@@ -9,6 +9,7 @@
namespace App\Entity;
use App\Export\Annotation as Exporter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -25,6 +26,9 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Entity(repositoryClass="App\Repository\CustomerRepository")
*
* @Serializer\ExclusionPolicy("all")
*
* @Exporter\Order({"id", "name", "company", "number", "vatId", "address", "contact","email", "phone", "mobile", "fax", "homepage", "country", "currency", "timezone", "budget", "timeBudget", "color", "visible", "teams", "comment"})
* @ Exporter\Expose("teams", label="label.team", exp="object.getTeams().toArray()", type="array")
*/
class Customer implements EntityWithMetaFields
{
@@ -36,6 +40,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.id", type="integer")
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
@@ -47,6 +53,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.name")
*
* @ORM\Column(name="name", type="string", length=150, nullable=false)
* @Assert\NotBlank()
* @Assert\Length(min=2, max=150, allowEmptyString=false)
@@ -58,6 +66,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.number")
*
* @ORM\Column(name="number", type="string", length=50, nullable=true)
* @Assert\Length(max=50)
*/
@@ -68,6 +78,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.comment")
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
@@ -77,6 +89,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.visible", type="boolean")
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
* @Assert\NotNull()
*/
@@ -87,6 +101,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.company")
*
* @ORM\Column(name="company", type="string", length=255, nullable=true)
* @Assert\Length(max=255)
*/
@@ -97,6 +113,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.vat_id")
*
* @ORM\Column(name="vat_id", type="string", length=50, nullable=true)
* @Assert\Length(max=50)
*/
@@ -107,6 +125,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.contact")
*
* @ORM\Column(name="contact", type="string", length=255, nullable=true)
* @Assert\Length(max=255)
*/
@@ -117,6 +137,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.address")
*
* @ORM\Column(name="address", type="text", nullable=true)
*/
private $address;
@@ -126,6 +148,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.country")
*
* @ORM\Column(name="country", type="string", length=2, nullable=false)
* @Assert\NotBlank()
* @Assert\Length(max=2)
@@ -137,6 +161,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer"})
*
* @Exporter\Expose(label="label.currency")
*
* @ORM\Column(name="currency", type="string", length=3, nullable=false)
* @Assert\NotBlank()
* @Assert\Length(max=3)
@@ -148,6 +174,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.phone")
*
* @ORM\Column(name="phone", type="string", length=255, nullable=true)
* @Assert\Length(max=255)
*/
@@ -158,6 +186,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.fax")
*
* @ORM\Column(name="fax", type="string", length=255, nullable=true)
* @Assert\Length(max=255)
*/
@@ -168,6 +198,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.mobile")
*
* @ORM\Column(name="mobile", type="string", length=255, nullable=true)
* @Assert\Length(max=255)
*/
@@ -182,6 +214,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.email")
*
* @ORM\Column(name="email", type="string", length=255, nullable=true)
* @Assert\Length(max=254)
*/
@@ -192,6 +226,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.homepage")
*
* @ORM\Column(name="homepage", type="string", length=255, nullable=true)
* @Assert\Length(max=255)
*/
@@ -206,6 +242,8 @@ class Customer implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.timezone")
*
* @ORM\Column(name="timezone", type="string", length=64, nullable=false)
* @Assert\NotBlank()
* @Assert\Length(max=64)
@@ -216,25 +254,29 @@ class Customer implements EntityWithMetaFields
use ColorTrait;
/**
* The total monetary budget, will be zero if unconfigured.
* The total monetary budget, will be zero if not configured.
*
* @var float
*
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @ Exporter\Expose(label="label.budget")
*
* @ORM\Column(name="budget", type="float", nullable=false)
* @Assert\NotNull()
*/
private $budget = 0.00;
/**
* The time budget in seconds, will be be zero if unconfigured.
* The time budget in seconds, will be be zero if not configured.
*
* @var int
*
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @ Exporter\Expose(label="label.timeBudget", type="duration")
*
* @ORM\Column(name="time_budget", type="integer", nullable=false)
* @Assert\NotNull()
*/

View File

@@ -9,6 +9,7 @@
namespace App\Entity;
use App\Export\Annotation as Exporter;
use App\Validator\Constraints as Constraints;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@@ -46,6 +47,10 @@ use Symfony\Component\Validator\Constraints as Assert;
* @Serializer\Groups({"Project", "Team", "Not_Expanded"})
* }
* )
*
* @Exporter\Order({"id", "name", "customer", "orderNumber", "orderDate", "start", "end", "budget", "timeBudget", "color", "visible", "teams", "comment"})
* @Exporter\Expose("customer", label="label.customer", exp="object.getCustomer() === null ? null : object.getCustomer().getName()")
* @ Exporter\Expose("teams", label="label.team", exp="object.getTeams().toArray()", type="array")
*/
class Project implements EntityWithMetaFields
{
@@ -57,6 +62,8 @@ class Project implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.id", type="integer")
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
@@ -84,6 +91,8 @@ class Project implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.name")
*
* @ORM\Column(name="name", type="string", length=150, nullable=false)
* @Assert\NotNull()
* @Assert\Length(min=2, max=150, allowEmptyString=false)
@@ -97,6 +106,8 @@ class Project implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Project_Entity"})
*
* @Exporter\Expose(label="label.orderNumber")
*
* @ORM\Column(name="order_number", type="text", length=20, nullable=true)
* @Assert\Length(max=20)
*/
@@ -108,6 +119,8 @@ class Project implements EntityWithMetaFields
* @Serializer\Groups({"Project_Entity"})
* @Serializer\Type(name="DateTime")
*
* @Exporter\Expose(label="label.orderDate", type="datetime")
*
* @ORM\Column(name="order_date", type="datetime", nullable=true)
*/
private $orderDate;
@@ -118,6 +131,8 @@ class Project implements EntityWithMetaFields
* @Serializer\Groups({"Project"})
* @Serializer\Type(name="DateTime")
*
* @Exporter\Expose(label="label.project_start", type="datetime")
*
* @ORM\Column(name="start", type="datetime", nullable=true)
*/
private $start;
@@ -128,6 +143,8 @@ class Project implements EntityWithMetaFields
* @Serializer\Groups({"Project"})
* @Serializer\Type(name="DateTime")
*
* @Exporter\Expose(label="label.project_end", type="datetime")
*
* @ORM\Column(name="end", type="datetime", nullable=true)
*/
private $end;
@@ -149,6 +166,8 @@ class Project implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Project_Entity"})
*
* @Exporter\Expose(label="label.comment")
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
@@ -158,6 +177,8 @@ class Project implements EntityWithMetaFields
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.visible", type="boolean")
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
* @Assert\NotNull()
*/
@@ -167,25 +188,29 @@ class Project implements EntityWithMetaFields
use ColorTrait;
/**
* The total monetary budget, will be zero if unconfigured.
* The total monetary budget, will be zero if not configured.
*
* @var float
*
* @Serializer\Expose()
* @Serializer\Groups({"Project_Entity"})
*
* @ Exporter\Expose(label="label.budget")
*
* @ORM\Column(name="budget", type="float", nullable=false)
* @Assert\NotNull()
*/
private $budget = 0.00;
/**
* The time budget in seconds, will be be zero if unconfigured.
* The time budget in seconds, will be be zero if not configured.
*
* @var int
*
* @Serializer\Expose()
* @Serializer\Groups({"Project_Entity"})
*
* @ Exporter\Expose(label="label.timeBudget", type="duration")
*
* @ORM\Column(name="time_budget", type="integer", nullable=false)
* @Assert\NotNull()
*/

View File

@@ -9,6 +9,7 @@
namespace App\Entity;
use App\Export\Annotation as Exporter;
use App\Utils\StringHelper;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@@ -49,6 +50,16 @@ use Symfony\Component\Validator\Constraints as Assert;
* @Serializer\Groups({"User_Entity"})
* }
* )
*
* @Exporter\Order({"id", "username", "alias", "title", "email", "last_login", "language", "timezone", "active", "registeredAt", "roles", "teams"})
* @Exporter\Expose("email", label="label.email", exp="object.getEmail()")
* @Exporter\Expose("username", label="label.username", exp="object.getUsername()")
* @Exporter\Expose("timezone", label="label.timezone", exp="object.getTimezone()")
* @Exporter\Expose("language", label="label.language", exp="object.getLanguage()")
* @Exporter\Expose("last_login", label="label.lastLogin", exp="object.getLastLogin()", type="datetime")
* @Exporter\Expose("roles", label="label.roles", exp="object.getRoles()", type="array")
* @ Exporter\Expose("teams", label="label.team", exp="object.getTeams().toArray()", type="array")
* @Exporter\Expose("active", label="label.active", exp="object.isEnabled()", type="boolean")
*/
class User extends BaseUser implements UserInterface
{
@@ -73,6 +84,8 @@ class User extends BaseUser implements UserInterface
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.id", type="integer")
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(name="id", type="integer")
@@ -86,6 +99,8 @@ class User extends BaseUser implements UserInterface
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.alias")
*
* @ORM\Column(name="alias", type="string", length=60, nullable=true)
* @Assert\Length(max=60)
*/
@@ -95,6 +110,8 @@ class User extends BaseUser implements UserInterface
*
* @var \DateTime
*
* @Exporter\Expose(label="profile.registration_date", type="datetime")
*
* @ORM\Column(name="registration_date", type="datetime", nullable=true)
*/
private $registeredAt;
@@ -106,6 +123,8 @@ class User extends BaseUser implements UserInterface
* @Serializer\Expose()
* @Serializer\Groups({"User_Entity"})
*
* @Exporter\Expose(label="label.title")
*
* @ORM\Column(name="title", type="string", length=50, nullable=true)
* @Assert\Length(max=50)
*/
@@ -179,7 +198,7 @@ class User extends BaseUser implements UserInterface
* This flag will be initialized in UserEnvironmentSubscriber.
*
* @var bool|null
* @internal has no database mapping. as the value is calculated from a permission
* @internal has no database mapping as the value is calculated from a permission
*/
private $isAllowedToSeeAllData = null;