partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit b2a9c637208340daf63d1bf448664b394d2b7960
parent 9ad07ef20f789fc7cd26d7d5196fe5452680b6ae
Author: Felicitus <felicitus@felicitus.org>
Date:   Mon, 16 Dec 2013 18:45:18 +0100

Migrated entities to Symfony2

Diffstat:
Msrc/backend/PartKeepr/Category/AbstractCategory.php | 17+++++++++--------
Msrc/backend/PartKeepr/CronLogger/CronLogger.php | 9+++++----
Msrc/backend/PartKeepr/Distributor/Distributor.php | 21+++++++++++----------
Msrc/backend/PartKeepr/EventNotification/Event.php | 8++++----
Msrc/backend/PartKeepr/EventNotification/LastNotification.php | 12+++++++-----
Msrc/backend/PartKeepr/Footprint/Footprint.php | 13+++++++------
Msrc/backend/PartKeepr/Footprint/FootprintAttachment.php | 9+++++----
Msrc/backend/PartKeepr/Footprint/FootprintImage.php | 7++++---
Msrc/backend/PartKeepr/FootprintCategory/FootprintCategory.php | 9++++++---
Msrc/backend/PartKeepr/Image/CachedImage.php | 17+++++++++--------
Msrc/backend/PartKeepr/Image/Image.php | 5+++--
Msrc/backend/PartKeepr/Manufacturer/Manufacturer.php | 21+++++++++++----------
Msrc/backend/PartKeepr/Manufacturer/ManufacturerICLogo.php | 7++++---
Msrc/backend/PartKeepr/Part/Part.php | 64+++++++++++++++++++++++++++++-----------------------------------
Msrc/backend/PartKeepr/Part/PartAttachment.php | 11++++++-----
Msrc/backend/PartKeepr/Part/PartDistributor.php | 17+++++++++--------
Msrc/backend/PartKeepr/Part/PartImage.php | 7++++---
Msrc/backend/PartKeepr/Part/PartManufacturer.php | 11++++++-----
Msrc/backend/PartKeepr/Part/PartUnit.php | 13+++++++------
Msrc/backend/PartKeepr/PartCategory/PartCategory.php | 9++++++---
Msrc/backend/PartKeepr/PartParameter/PartParameter.php | 23++++++++++++-----------
Msrc/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayout.php | 25+++++++++++++------------
Msrc/backend/PartKeepr/Printing/PrintingJob/PrintingJob.php | 18++++++++++--------
Msrc/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfiguration.php | 18++++++++++--------
Msrc/backend/PartKeepr/Project/Project.php | 15++++++++-------
Msrc/backend/PartKeepr/Project/ProjectAttachment.php | 9+++++----
Msrc/backend/PartKeepr/Project/ProjectPart.php | 13+++++++------
Msrc/backend/PartKeepr/Service/Annotations/Service.php | 17+++++++++++++++++
Msrc/backend/PartKeepr/Session/Session.php | 13+++++++------
Msrc/backend/PartKeepr/SiPrefix/SiPrefix.php | 11++++++-----
Msrc/backend/PartKeepr/Statistic/StatisticSnapshot.php | 17+++++++++--------
Msrc/backend/PartKeepr/Statistic/StatisticSnapshotUnit.php | 15++++++++-------
Msrc/backend/PartKeepr/Stock/StockEntry.php | 24+++++++++++++-----------
Msrc/backend/PartKeepr/StorageLocation/StorageLocation.php | 9+++++----
Msrc/backend/PartKeepr/StorageLocation/StorageLocationImage.php | 7++++---
Msrc/backend/PartKeepr/SystemNotice/SystemNotice.php | 15++++++++-------
Msrc/backend/PartKeepr/TempImage/TempImage.php | 5+++--
Msrc/backend/PartKeepr/TipOfTheDay/TipOfTheDay.php | 7++++---
Msrc/backend/PartKeepr/TipOfTheDay/TipOfTheDayHistory.php | 9+++++----
Msrc/backend/PartKeepr/Unit/Unit.php | 17+++++++++--------
Msrc/backend/PartKeepr/UploadedFile/TempUploadedFile.php | 4+++-
Msrc/backend/PartKeepr/UploadedFile/UploadedFile.php | 15++++++++-------
Msrc/backend/PartKeepr/User/User.php | 14++++++++------
Msrc/backend/PartKeepr/UserPreference/UserPreference.php | 18++++++++++--------
Msrc/backend/PartKeepr/Util/BaseEntity.php | 9+++++----
45 files changed, 349 insertions(+), 285 deletions(-)

diff --git a/src/backend/PartKeepr/Category/AbstractCategory.php b/src/backend/PartKeepr/Category/AbstractCategory.php @@ -3,11 +3,12 @@ namespace PartKeepr\Category; use PartKeepr\Util\BaseEntity; use PartKeepr\Util\Serializable; -use DoctrineExtensions\NestedSet\Node; +use DoctrineExtensions\NestedSet\Node, + Doctrine\ORM\Mapping as ORM; /** - * @MappedSuperclass - * @Table(indexes={@index(columns={"lft"}),@index(columns={"rgt"})}) + * @ORM\MappedSuperclass + * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) * * Represents an abstract category. This class isn't directly usable; you need to inherit it to take advantage of * the AbstractCategoryManager. @@ -17,28 +18,28 @@ use DoctrineExtensions\NestedSet\Node; class AbstractCategory extends BaseEntity implements Node, Serializable { /** * The "left" property of the nested set - * @Column(type="integer") + * @ORM\Column(type="integer") * @var integer */ private $lft; /** * The "right" property of the nested set - * @Column(type="integer") + * @ORM\Column(type="integer") * @var integer */ private $rgt; /** * The name of the category - * @Column(length=128) + * @ORM\Column(length=128) * @var string */ private $name; /** * The description of the category - * @Column(type="text",nullable=true) + * @ORM\Column(type="text",nullable=true) * @var string */ private $description; @@ -54,7 +55,7 @@ class AbstractCategory extends BaseEntity implements Node, Serializable { /** * Holds the category path. * - * @Column(type="text",nullable=true) + * @ORM\Column(type="text",nullable=true) * * @var string */ diff --git a/src/backend/PartKeepr/CronLogger/CronLogger.php b/src/backend/PartKeepr/CronLogger/CronLogger.php @@ -4,21 +4,22 @@ namespace PartKeepr\CronLogger; use PartKeepr\UploadedFile\UploadedFile, PartKeepr\Util\BaseEntity, PartKeepr\Util\Serializable, - PartKeepr\Util\Deserializable; + PartKeepr\Util\Deserializable, + Doctrine\ORM\Mapping as ORM; /** * Holds a project attachment - * @Entity + * @ORM\Entity **/ class CronLogger extends BaseEntity { /** - * @Column(type="datetime") + * @ORM\Column(type="datetime") * @var \DateTime */ private $lastRunDate; /** - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $cronjob; diff --git a/src/backend/PartKeepr/Distributor/Distributor.php b/src/backend/PartKeepr/Distributor/Distributor.php @@ -4,64 +4,65 @@ namespace PartKeepr\Distributor; use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, PartKeepr\Util\BaseEntity, - PartKeepr\PartKeepr; + PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM; /** * Represents a distributor - * @Entity **/ + * @ORM\Entity **/ class Distributor extends BaseEntity implements Serializable, Deserializable { /** * Holds the name of the distributor - * @Column(type="string",unique=true) + * @ORM\Column(type="string",unique=true) * @var string */ private $name; /** * Holds the address of the distributor - * @Column(type="text",nullable=true) + * @ORM\Column(type="text",nullable=true) * @var string */ private $address; /** * Holds the URL of the distributor - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $url; /** * Holds the phone number of the distributor - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $phone; /** * Holds the fax number of the distributor - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $fax; /** * Holds the email of the distributor - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $email; /** * Holds a comment for the distributor - * @Column(type="text",nullable=true) + * @ORM\Column(type="text",nullable=true) * @var string */ private $comment; /** * Holds the SKU lookup URL of the distributor - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $skuurl; diff --git a/src/backend/PartKeepr/EventNotification/Event.php b/src/backend/PartKeepr/EventNotification/Event.php @@ -1,7 +1,7 @@ <?php namespace PartKeepr\EventNotification; -use PartKeepr\Util\BaseEntity; +use PartKeepr\Util\BaseEntity, Doctrine\ORM\Mapping as ORM; /** * The event notification conecpt implements the main concept of notifying a @@ -13,19 +13,19 @@ use PartKeepr\Util\BaseEntity; * The Event class itself represents a type of event we * can signal. * - * @Entity + * @ORM\Entity */ class Event extends BaseEntity{ /** * Name of the event - * @Column(length=64,unique=true) + * @ORM\Column(length=64,unique=true) * @var string */ private $name; /** * This is a counter which counts up, everytime the event is issued. - * @Column(type="datetime") + * @ORM\Column(type="datetime") * @var datetime */ private $lastOccured; diff --git a/src/backend/PartKeepr/EventNotification/LastNotification.php b/src/backend/PartKeepr/EventNotification/LastNotification.php @@ -4,23 +4,25 @@ namespace PartKeepr\EventNotification; use PartKeepr\EventNotification\Event; use PartKeepr\Session\Session; use PartKeepr\Util\BaseEntity; +use Doctrine\ORM\Mapping as ORM; + /** * This entity is used to store the last notification of * an event. * - * @Entity + * @ORM\Entity */ class LastNotification extends BaseEntity{ /** * This is the associated event. - * @ManyToOne(targetEntity="PartKeepr\EventNotification\Event") + * @ORM\ManyToOne(targetEntity="PartKeepr\EventNotification\Event") */ private $event; /** - * @ManyToOne(targetEntity="PartKeepr\Session\Session") - * @JoinColumn(onDelete="CASCADE") + * @ORM\ManyToOne(targetEntity="PartKeepr\Session\Session") + * @ORM\JoinColumn(onDelete="CASCADE") */ private $session; @@ -28,7 +30,7 @@ class LastNotification extends BaseEntity{ * This is the last timestamp, the user was notified about * an occured event. * - * @Column(type="datetime") + * @ORM\Column(type="datetime") * @var datetime */ private $lastNotify; diff --git a/src/backend/PartKeepr/Footprint/Footprint.php b/src/backend/PartKeepr/Footprint/Footprint.php @@ -5,41 +5,42 @@ use PartKeepr\Util\Deserializable; use PartKeepr\Util\Serializable; use PartKeepr\FootprintCategory\FootprintCategory; use PartKeepr\Util\BaseEntity; +use Doctrine\ORM\Mapping as ORM; -/** @Entity */ +/** @ORM\Entity */ class Footprint extends BaseEntity implements Serializable, Deserializable { /** * Holds the footprint name - * @Column(length=64,unique=true) + * @ORM\Column(length=64,unique=true) * @var string */ private $name; /** * Holds the footprint description - * @Column(type="text",nullable=true) + * @ORM\Column(type="text",nullable=true) * @var string */ private $description; /** * The category of the footprint - * @ManyToOne(targetEntity="PartKeepr\FootprintCategory\FootprintCategory") + * @ORM\ManyToOne(targetEntity="PartKeepr\FootprintCategory\FootprintCategory") * @var Category */ private $category; /** * Holds the footprint image - * @OneToOne(targetEntity="PartKeepr\Footprint\FootprintImage",mappedBy="footprint",cascade={"persist", "remove"}) + * @ORM\OneToOne(targetEntity="PartKeepr\Footprint\FootprintImage",mappedBy="footprint",cascade={"persist", "remove"}) * @var FootprintImage */ private $image; /** * Holds the footprint attachments - * @OneToMany(targetEntity="PartKeepr\Footprint\FootprintAttachment",mappedBy="footprint",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Footprint\FootprintAttachment",mappedBy="footprint",cascade={"persist", "remove"}) * @var FootprintAttachment */ private $attachments; diff --git a/src/backend/PartKeepr/Footprint/FootprintAttachment.php b/src/backend/PartKeepr/Footprint/FootprintAttachment.php @@ -3,16 +3,17 @@ namespace PartKeepr\Footprint; use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, - PartKeepr\UploadedFile\UploadedFile; + PartKeepr\UploadedFile\UploadedFile, + Doctrine\ORM\Mapping as ORM; /** * Holds a footprint attachment - * @Entity + * @ORM\Entity **/ class FootprintAttachment extends UploadedFile implements Serializable, Deserializable { /** * The description of this attachment - * @Column(type="text") + * @ORM\Column(type="text") * @var string */ private $description; @@ -26,7 +27,7 @@ class FootprintAttachment extends UploadedFile implements Serializable, Deserial } /** * The footprint object - * @ManyToOne(targetEntity="PartKeepr\Footprint\Footprint") + * @ORM\ManyToOne(targetEntity="PartKeepr\Footprint\Footprint",inversedBy="attachments") * @var Footprint */ private $footprint = null; diff --git a/src/backend/PartKeepr/Footprint/FootprintImage.php b/src/backend/PartKeepr/Footprint/FootprintImage.php @@ -2,16 +2,17 @@ namespace PartKeepr\Footprint; use PartKeepr\Util\Serializable, - PartKeepr\Image\Image; + PartKeepr\Image\Image, + Doctrine\ORM\Mapping as ORM; /** * Holds a footprint image - * @Entity + * @ORM\Entity **/ class FootprintImage extends Image implements Serializable { /** * The footprint object - * @OneToOne(targetEntity="PartKeepr\Footprint\Footprint",inversedBy="image") + * @ORM\OneToOne(targetEntity="PartKeepr\Footprint\Footprint",inversedBy="image") * @var Footprint */ private $footprint = null; diff --git a/src/backend/PartKeepr/FootprintCategory/FootprintCategory.php b/src/backend/PartKeepr/FootprintCategory/FootprintCategory.php @@ -1,11 +1,14 @@ <?php namespace PartKeepr\FootprintCategory; -use PartKeepr\Category\AbstractCategory; +use PartKeepr\Category\AbstractCategory, + Doctrine\ORM\Mapping as ORM, + Doctrine\ORM\Mapping\Table, + Doctrine\ORM\Mapping\Index; /** - * @Entity - * @Table(indexes={@index(columns={"lft"}),@index(columns={"rgt"})}) + * @ORM\Entity + * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) * The entity for our footprint categories * */ diff --git a/src/backend/PartKeepr/Image/CachedImage.php b/src/backend/PartKeepr/Image/CachedImage.php @@ -1,23 +1,24 @@ <?php namespace PartKeepr\Image; -use PartKeepr\PartKeepr; +use PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM; /** * Represents a cached image. Cached images are used for scale/resize * operations, so that the resize/scale operation doesn't need to be done * every time a scaled/resized image is requested. * - * @Entity + * @ORM\Entity */ class CachedImage { /** * Specifies the ID of the cached image. * * @var integer - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") + * @ORM\Id + * @ORM\Column(type="integer") + * @ORM\GeneratedValue(strategy="AUTO") **/ private $id; @@ -25,7 +26,7 @@ class CachedImage { * Specifies the ID of the original image * * @var integer - * @Column(type="integer") + * @ORM\Column(type="integer") */ private $originalId; @@ -33,7 +34,7 @@ class CachedImage { * Specifies the type of the original image. * * @var string - * @Column(type="string") + * @ORM\Column(type="string") **/ private $originalType; @@ -41,7 +42,7 @@ class CachedImage { * The cache filename of the image * * @var string - * @Column(type="string") + * @ORM\Column(type="string") */ private $cacheFile; diff --git a/src/backend/PartKeepr/Image/Image.php b/src/backend/PartKeepr/Image/Image.php @@ -5,12 +5,13 @@ use PartKeepr\PartKeepr, PartKeepr\UploadedFile\UploadedFile, PartKeepr\Util\Configuration, PartKeepr\TempImage\TempImage, - PartKeepr\Image\Exceptions\InvalidImageTypeException; + PartKeepr\Image\Exceptions\InvalidImageTypeException, + Doctrine\ORM\Mapping as ORM; /** * This is only a storage class; actual image rendering is done by the ImageRenderer. * - * @MappedSuperclass + * @ORM\MappedSuperclass */ abstract class Image extends UploadedFile implements RenderableImage { const IMAGE_ICLOGO = "iclogo"; diff --git a/src/backend/PartKeepr/Manufacturer/Manufacturer.php b/src/backend/PartKeepr/Manufacturer/Manufacturer.php @@ -4,64 +4,65 @@ namespace PartKeepr\Manufacturer; use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, PartKeepr\Util\BaseEntity, - PartKeepr\PartKeepr; + PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM; /** * Represents a manufacturer - * @Entity **/ + * @ORM\Entity **/ class Manufacturer extends BaseEntity implements Serializable, Deserializable { /** * The name of the manufacturer - * @Column(type="string",unique=true) + * @ORM\Column(type="string",unique=true) * @var string */ private $name; /** * The address of the manufacturer - * @Column(type="text",nullable=true) + * @ORM\Column(type="text",nullable=true) * @var string */ private $address; /** * The URL - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $url; /** * The email - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $email; /** * The comment - * @Column(type="text",nullable=true) + * @ORM\Column(type="text",nullable=true) * @var string */ private $comment; /** * The phone number - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $phone; /** * The fax number - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $fax; /** * All ic logos of this manufacturer - * @OneToMany(targetEntity="PartKeepr\Manufacturer\ManufacturerICLogo",mappedBy="manufacturer",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Manufacturer\ManufacturerICLogo",mappedBy="manufacturer",cascade={"persist", "remove"}) */ private $icLogos; diff --git a/src/backend/PartKeepr/Manufacturer/ManufacturerICLogo.php b/src/backend/PartKeepr/Manufacturer/ManufacturerICLogo.php @@ -3,16 +3,17 @@ namespace PartKeepr\Manufacturer; use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, - PartKeepr\Image\Image; + PartKeepr\Image\Image, + Doctrine\ORM\Mapping as ORM; /** * Holds a manufacturer IC logo - * @Entity + * @ORM\Entity **/ class ManufacturerICLogo extends Image implements Serializable, Deserializable { /** * The manufacturer object - * @ManyToOne(targetEntity="PartKeepr\Manufacturer\Manufacturer") + * @ORM\ManyToOne(targetEntity="PartKeepr\Manufacturer\Manufacturer", inversedBy="icLogos") * @var Manufacturer */ private $manufacturer = null; diff --git a/src/backend/PartKeepr/Part/Part.php b/src/backend/PartKeepr/Part/Part.php @@ -11,39 +11,41 @@ use PartKeepr\StorageLocation\StorageLocation, PartKeepr\PartKeepr, PartKeepr\Part\Exceptions\CategoryNotAssignedException, PartKeepr\Util\Exceptions\OutOfRangeException, - PartKeepr\Part\Exceptions\StorageLocationNotAssignedException; + PartKeepr\Part\Exceptions\StorageLocationNotAssignedException, + Doctrine\ORM\Mapping as ORM, + Doctrine\ORM\Mapping\HasLifecycleCallbacks ; /** * Represents a part in the database. The heart of our project. Handle with care! * - * @Entity @HasLifecycleCallbacks + * @ORM\Entity @ORM\HasLifecycleCallbacks */ class Part extends BaseEntity implements Serializable, Deserializable { /** * The category of the part - * @ManyToOne(targetEntity="PartKeepr\PartCategory\PartCategory") + * @ORM\ManyToOne(targetEntity="PartKeepr\PartCategory\PartCategory") * @var Category */ private $category; /** * The part's name - * @Column + * @ORM\Column * @var string */ private $name; /** * The part's short description - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $description; /** * The footprint of this part - * @ManyToOne(targetEntity="PartKeepr\Footprint\Footprint") + * @ORM\ManyToOne(targetEntity="PartKeepr\Footprint\Footprint") * @var Footprint */ private $footprint; @@ -51,56 +53,56 @@ class Part extends BaseEntity implements Serializable, Deserializable { /** * The unit in which the part's "amount" is calculated. This is necessary to count parts * in "pieces", "meters" or "grams". - * @ManyToOne(targetEntity="PartKeepr\Part\PartUnit") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\PartUnit", inversedBy="parts") * @var PartUnit */ private $partUnit; /** * Defines the storage location of this part - * @ManyToOne(targetEntity="PartKeepr\StorageLocation\StorageLocation") + * @ORM\ManyToOne(targetEntity="PartKeepr\StorageLocation\StorageLocation") * @var StorageLocation */ private $storageLocation; /** * Holds the manufacturers which can manufacture this part - * @OneToMany(targetEntity="PartKeepr\Part\PartManufacturer",mappedBy="part",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Part\PartManufacturer",mappedBy="part",cascade={"persist", "remove"}) * @var ArrayCollection */ private $manufacturers; /** * Holds the distributors from where we can buy the part - * @OneToMany(targetEntity="PartKeepr\Part\PartDistributor",mappedBy="part",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Part\PartDistributor",mappedBy="part",cascade={"persist", "remove"}) * @var ArrayCollection */ private $distributors; /** * Holds the part images - * @OneToMany(targetEntity="PartKeepr\Part\PartImage",mappedBy="part",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Part\PartImage",mappedBy="part",cascade={"persist", "remove"}) * @var PartImage */ private $images; /** * Holds the part attachments - * @OneToMany(targetEntity="PartKeepr\Part\PartAttachment",mappedBy="part",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Part\PartAttachment",mappedBy="part",cascade={"persist", "remove"}) * @var PartAttachment */ private $attachments; /** * The comment for this part - * @Column(type="text") + * @ORM\Column(type="text") */ private $comment = ""; /** * The stock level. Note that this is a cached value, because it makes our summary queries easier. * @todo It would be nice if we could get rid of that. - * @Column(type="integer") + * @ORM\Column(type="integer") * @var integer */ private $stockLevel = 0; @@ -109,7 +111,7 @@ class Part extends BaseEntity implements Serializable, Deserializable { * The minimum stock level for this part. If we run out of this part (e.g. stockLevel < minStockLevel), * we can see that in the system and re-order parts. * - * @Column(type="integer") + * @ORM\Column(type="integer") * @var integer */ private $minStockLevel = 0; @@ -118,61 +120,61 @@ class Part extends BaseEntity implements Serializable, Deserializable { * The average price for the part. Note that this is a cached value. * * @todo It would be nice if we could get rid of that - * @Column(type="decimal",precision=13,scale=4,nullable=true) + * @ORM\Column(type="decimal",precision=13,scale=4,nullable=true) * @var float */ private $averagePrice = null; /** * The stock level history - * @OneToMany(targetEntity="PartKeepr\Stock\StockEntry",mappedBy="part",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Stock\StockEntry",mappedBy="part",cascade={"persist", "remove"}) * @var ArrayCollection */ private $stockLevels; /** * The parameters for this part - * @OneToMany(targetEntity="PartKeepr\PartParameter\PartParameter",mappedBy="part",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\PartParameter\PartParameter",mappedBy="part",cascade={"persist", "remove"}) * @var ArrayCollection */ private $parameters; /** * The part status for this part - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $status; /** * Defines if the part needs review - * @Column(type="boolean") + * @ORM\Column(type="boolean") * @var boolean */ private $needsReview; /** * Defines the condition of the part - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $partCondition; /** * The create date+time for this part - * @Column(type="datetime",nullable=true) + * @ORM\Column(type="datetime",nullable=true) * @var \DateTime */ private $createDate; /** - * @OneToMany(targetEntity="PartKeepr\Project\Project", mappedBy="part") + * @ORM\OneToMany(targetEntity="PartKeepr\Project\ProjectPart", mappedBy="part") **/ - private $projects; + private $projectParts; /** * The internal part number - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $internalPartNumber; @@ -340,14 +342,6 @@ class Part extends BaseEntity implements Serializable, Deserializable { } /** - * Returns all projects this part is used - * @return ArrayCollection the projects - */ - public function getProjects () { - return $this->projects; - } - - /** * Sets the storage location for this part * @param \PartKeepr\StorageLocation\StorageLocation $storageLocation The storage location */ @@ -642,7 +636,7 @@ class Part extends BaseEntity implements Serializable, Deserializable { * @throws CategoryNotAssignedException Thrown if no category is set * @throws StorageLocationNotAssignedException Thrown if no storage location is set * - * @PrePersist + * @ORM\PrePersist */ public function onPrePersist () { $this->checkCategoryConsistency(); @@ -656,7 +650,7 @@ class Part extends BaseEntity implements Serializable, Deserializable { * For a list of exceptions, see * @see PartKeepr\Part.Part::onPrePersist() * - * @PreUpdate */ + * @ORM\PreUpdate */ public function onPreUpdate () { $this->checkCategoryConsistency(); $this->checkStorageLocationConsistency(); diff --git a/src/backend/PartKeepr/Part/PartAttachment.php b/src/backend/PartKeepr/Part/PartAttachment.php @@ -3,23 +3,24 @@ namespace PartKeepr\Part; use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, - PartKeepr\UploadedFile\UploadedFile; + PartKeepr\UploadedFile\UploadedFile, + Doctrine\ORM\Mapping as ORM; /** * Holds a part attachment - * @Entity + * @ORM\Entity **/ class PartAttachment extends UploadedFile implements Serializable, Deserializable { /** * The description of this attachment - * @Column(type="text") + * @ORM\Column(type="text") * @var string */ private $description; /** * Defines if the attachment is an image. - * @Column(type="boolean",nullable=true) + * @ORM\Column(type="boolean",nullable=true) * @var boolean */ private $isImage; @@ -35,7 +36,7 @@ class PartAttachment extends UploadedFile implements Serializable, Deserializabl /** * The part object - * @ManyToOne(targetEntity="PartKeepr\Part\Part") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\Part", inversedBy="attachments") * @var Part */ private $part = null; diff --git a/src/backend/PartKeepr/Part/PartDistributor.php b/src/backend/PartKeepr/Part/PartDistributor.php @@ -5,25 +5,26 @@ use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, PartKeepr\Util\BaseEntity, PartKeepr\PartKeepr, - PartKeepr\Distributor\Distributor; + PartKeepr\Distributor\Distributor, + Doctrine\ORM\Mapping as ORM; /** * This class represents the link between a part and a distributor. - * @Entity **/ + * @ORM\Entity **/ class PartDistributor extends BaseEntity implements Serializable, Deserializable { /** - * @ManyToOne(targetEntity="PartKeepr\Part\Part") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\Part", inversedBy="distributors") */ private $part; /** - * @ManyToOne(targetEntity="PartKeepr\Distributor\Distributor") + * @ORM\ManyToOne(targetEntity="PartKeepr\Distributor\Distributor") */ private $distributor; /** * The order number for the part and distributor - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $orderNumber; @@ -32,7 +33,7 @@ class PartDistributor extends BaseEntity implements Serializable, Deserializable * Defines the packaging unit when ordering a part. Some items can't be ordered in a quantity of just one at * certain manufacturers. * - * @Column(type="integer") + * @ORM\Column(type="integer") * @var integer */ private $packagingUnit; @@ -41,14 +42,14 @@ class PartDistributor extends BaseEntity implements Serializable, Deserializable * Specifies the price of the part. Note that the price * needs to be per item, not per packaging unit. * - * @Column(type="decimal",precision=13,scale=4,nullable=true) + * @ORM\Column(type="decimal",precision=13,scale=4,nullable=true) * @var float */ private $price; /** * The distributor's SKU (stock keeping unit) for the part. Used with barcodes. - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $sku; diff --git a/src/backend/PartKeepr/Part/PartImage.php b/src/backend/PartKeepr/Part/PartImage.php @@ -2,16 +2,17 @@ namespace PartKeepr\Part; use PartKeepr\Util\Serializable, - PartKeepr\Image\Image; + PartKeepr\Image\Image, + Doctrine\ORM\Mapping as ORM; /** * Holds a part image - * @Entity + * @ORM\Entity **/ class PartImage extends Image implements Serializable { /** * The part object - * @ManyToOne(targetEntity="PartKeepr\Part\Part") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\Part", inversedBy="images") * @var Part */ private $part = null; diff --git a/src/backend/PartKeepr/Part/PartManufacturer.php b/src/backend/PartKeepr/Part/PartManufacturer.php @@ -5,22 +5,23 @@ use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, PartKeepr\Util\BaseEntity, PartKeepr\PartKeepr, - PartKeepr\Manufacturer\Manufacturer; + PartKeepr\Manufacturer\Manufacturer, + Doctrine\ORM\Mapping as ORM; -/** @Entity **/ +/** @ORM\Entity **/ class PartManufacturer extends BaseEntity implements Serializable, Deserializable { /** - * @ManyToOne(targetEntity="PartKeepr\Part\Part") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\Part",inversedBy="manufacturers") */ private $part; /** - * @ManyToOne(targetEntity="PartKeepr\Manufacturer\Manufacturer") + * @ORM\ManyToOne(targetEntity="PartKeepr\Manufacturer\Manufacturer") */ private $manufacturer; /** - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * Enter description here ... * @var unknown_type */ diff --git a/src/backend/PartKeepr/Part/PartUnit.php b/src/backend/PartKeepr/Part/PartUnit.php @@ -5,21 +5,22 @@ use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, PartKeepr\Util\BaseEntity, PartKeepr\PartKeepr, - PartKeepr\Util\Exceptions\OutOfRangeException; + PartKeepr\Util\Exceptions\OutOfRangeException, + Doctrine\ORM\Mapping as ORM; -/** @Entity **/ +/** @ORM\Entity **/ class PartUnit extends BaseEntity implements Serializable, Deserializable { /** * Defines the name of the unit - * @Column + * @ORM\Column * @var string */ private $name; /** * Defines the short name of the unit - * @Column + * @ORM\Column * @var string */ private $shortName; @@ -27,13 +28,13 @@ class PartUnit extends BaseEntity implements Serializable, Deserializable { /** * Defines if the unit is default or not. * - * @Column(type="boolean") + * @ORM\Column(type="boolean") * @var boolean */ private $is_default; /** - * @OneToMany(targetEntity="PartKeepr\Part\Part",mappedBy="partUnit") + * @ORM\OneToMany(targetEntity="PartKeepr\Part\Part",mappedBy="partUnit") */ private $parts; diff --git a/src/backend/PartKeepr/PartCategory/PartCategory.php b/src/backend/PartKeepr/PartCategory/PartCategory.php @@ -1,11 +1,14 @@ <?php namespace PartKeepr\PartCategory; -use PartKeepr\Category\AbstractCategory; +use PartKeepr\Category\AbstractCategory, + Doctrine\ORM\Mapping as ORM, + Doctrine\ORM\Mapping\Table, + Doctrine\ORM\Mapping\Index; /** - * @Entity - * @Table(indexes={@index(columns={"lft"}),@index(columns={"rgt"})}) + * @ORM\Entity + * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) * The entity for our part categories * */ diff --git a/src/backend/PartKeepr/PartParameter/PartParameter.php b/src/backend/PartKeepr/PartParameter/PartParameter.php @@ -5,25 +5,26 @@ use PartKeepr\PartKeepr, PartKeepr\Util\Exceptions\OutOfRangeException, PartKeepr\Unit\Unit, PartKeepr\Part\Part, -PartKeepr\SiPrefix\SiPrefix; +PartKeepr\SiPrefix\SiPrefix, + Doctrine\ORM\Mapping as ORM; /** * This object represents a parameter. Each parameter can have an unit (defined by the class "Unit") associated with * a numeric value. * - * @Entity @HasLifecycleCallbacks + * @ORM\Entity @ORM\HasLifecycleCallbacks **/ class PartParameter { /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") + * @ORM\Id @ORM\Column(type="integer") + * @ORM\GeneratedValue(strategy="AUTO") * @var integer */ private $id; /** - * @ManyToOne(targetEntity="PartKeepr\Part\Part") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\Part", inversedBy="parameters") * The part this parameter is bound to * @var Part */ @@ -31,14 +32,14 @@ class PartParameter { /** * The name of the parameter (e.g. Resistance, Voltage) - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $name; /** * A description for this parameter - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $description; @@ -46,7 +47,7 @@ class PartParameter { /** * The unit for this type. May be null. * - * @ManyToOne(targetEntity="PartKeepr\Unit\Unit") + * @ORM\ManyToOne(targetEntity="PartKeepr\Unit\Unit") * @var Unit */ private $unit; @@ -56,21 +57,21 @@ class PartParameter { * * Example: If you have 10µ, the value field will contain "10", the prefix object is linked to the SiPrefix * representing "µ" and the rawValue field will contain 0.000001 - * @Column(type="float") + * @ORM\Column(type="float") * @var float */ private $value; /** * The SiPrefix of the unit - * @ManyToOne(targetEntity="PartKeepr\SiPrefix\SiPrefix") + * @ORM\ManyToOne(targetEntity="PartKeepr\SiPrefix\SiPrefix") * @var object */ private $siPrefix; /** * The raw value of the unit. - * @Column(type="float") + * @ORM\Column(type="float") * @var float */ private $rawValue; diff --git a/src/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayout.php b/src/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayout.php @@ -3,7 +3,8 @@ namespace PartKeepr\Printing\PageBasicLayout; use PartKeepr\Util\BaseEntity, PartKeepr\Util\Deserializable, - PartKeepr\Util\Serializable; + PartKeepr\Util\Serializable, + Doctrine\ORM\Mapping as ORM; /** * This class is a layout which can be used to describe a typical page @@ -16,31 +17,31 @@ use PartKeepr\Util\BaseEntity, * - Width and height of the cells (every cell has the same size) * - Number of cells in columns an rows. * - * @Entity + * @ORM\Entity */ class PageBasicLayout extends BaseEntity implements Serializable, Deserializable { /** * The name of this layout. - * @Column(type="text") + * @ORM\Column(type="text") */ private $name; /** * The comment for this layout. - * @Column(type="text") + * @ORM\Column(type="text") */ private $comment; /** * The numbers of columns on the page - * @Column(type="integer") + * @ORM\Column(type="integer") * @var integer */ private $columnCount = 1; /** * The numbers of rows on the page - * @Column(type="integer") + * @ORM\Column(type="integer") * @var integer */ private $rowCount = 1; @@ -48,27 +49,27 @@ class PageBasicLayout extends BaseEntity implements Serializable, Deserializable /** * The size of the entire paper * - * @Column(type="text") + * @ORM\Column(type="text") */ private $paperSize = "A4"; /** * Indicates the orientation of the paper or better, the orientation * of the final text. - * @Column(type="boolean") + * @ORM\Column(type="boolean") */ private $paperPortrait = true; /** * This is the cell width in mm. - * @Column(type="float") + * @ORM\Column(type="float") * @var float */ private $cellWidthInMM = 100; /** * This is the cell height in mm. - * @Column(type="float") + * @ORM\Column(type="float") * @var float */ private $cellHeightInMM = 100; @@ -76,7 +77,7 @@ class PageBasicLayout extends BaseEntity implements Serializable, Deserializable /** * This is the top left X position of the first cell on the * sheet. - * @Column(type="float") + * @ORM\Column(type="float") * @var float */ private $topLeftXInMM = 0; @@ -84,7 +85,7 @@ class PageBasicLayout extends BaseEntity implements Serializable, Deserializable /** * This is the top left Y position of the first cell on the * sheet. - * @Column(type="float") + * @ORM\Column(type="float") * @var float */ private $topLeftYInMM = 0; diff --git a/src/backend/PartKeepr/Printing/PrintingJob/PrintingJob.php b/src/backend/PartKeepr/Printing/PrintingJob/PrintingJob.php @@ -7,42 +7,44 @@ use PartKeepr\Session\SessionManager, PartKeepr\User\User, PartKeepr\Util\BaseEntity, PartKeepr\Util\Deserializable, - PartKeepr\Util\Serializable; + PartKeepr\Util\Serializable, + Doctrine\ORM\Mapping as ORM; + /** * This is a single job waiting for beeing processed. * - * @Entity @HasLifecycleCallbacks + * @ORM\Entity @ORM\HasLifecycleCallbacks */ class PrintingJob extends BaseEntity implements Serializable { /** * The timestamp when the job was created. - * @Column(type="datetime") + * @ORM\Column(type="datetime") */ private $created; /** * Will be set if the job was processed successfully by somebody and is marked * as done. - * @Column(type="boolean") + * @ORM\Column(type="boolean") */ private $done; /** * This is the user which has created this printing job. - * @ManyToOne(targetEntity="PartKeepr\User\User") + * @ORM\ManyToOne(targetEntity="PartKeepr\User\User") */ private $owner; /** * Target user the printing job is for. This is mostly the printer or output queue * which should be used to process this job. - * @ManyToOne(targetEntity="PartKeepr\User\User") + * @ORM\ManyToOne(targetEntity="PartKeepr\User\User") */ private $target; /** * Holds the data which was rendered for printing. - * @OneToOne(targetEntity="PartKeepr\UploadedFile\TempUploadedFile") + * @ORM\OneToOne(targetEntity="PartKeepr\UploadedFile\TempUploadedFile") */ private $data; @@ -56,7 +58,7 @@ class PrintingJob extends BaseEntity implements Serializable { * This method is a callback for the PostPersist event. We will add it to our database * dependent eventNotification. * - * @PostPersist @PostUpdate + * @ORM\PostPersist @ORM\PostUpdate */ public function onPostPersist(){ if (!$this->done) { diff --git a/src/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfiguration.php b/src/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfiguration.php @@ -5,7 +5,9 @@ use PartKeepr\Printing\PageBasicLayout\PageBasicLayout; use PartKeepr\Util\BaseEntity, PartKeepr\Util\Deserializable, - PartKeepr\Util\Serializable; + PartKeepr\Util\Serializable, + Doctrine\ORM\Mapping as ORM; + /** * This is a configuration for a specific job to export. @@ -13,36 +15,36 @@ use PartKeepr\Util\BaseEntity, * holds all additional configuration options to execute * the job correctly. * - * @Entity + * @ORM\Entity */ class PrintingJobConfiguration extends BaseEntity implements Serializable, Deserializable { /** * The name of this layout. - * @Column(type="text") + * @ORM\Column(type="text") */ private $name; /** * The comment for this layout. - * @Column(type="text") + * @ORM\Column(type="text") */ private $comment; /** * This holds the object type this configuration is used for. - * @Column(type="text") + * @ORM\Column(type="text") */ private $objectType; /** * The classname of the export renderer. - * @Column(type="text") + * @ORM\Column(type="text") */ private $exportRenderer; /** * This is the layout to use if we are in printing mode. - * @ManyToOne(targetEntity="PartKeepr\Printing\PageBasicLayout\PageBasicLayout") + * @ORM\ManyToOne(targetEntity="PartKeepr\Printing\PageBasicLayout\PageBasicLayout") */ private $pageLayout; @@ -50,7 +52,7 @@ class PrintingJobConfiguration extends BaseEntity implements Serializable, Deser * This field holds additional renderer configuration data. This configuration * is very renderer specific and can be used to parametrize the output more. * - * @Column(type="text") + * @ORM\Column(type="text") */ private $rendererConfiguration; diff --git a/src/backend/PartKeepr/Project/Project.php b/src/backend/PartKeepr/Project/Project.php @@ -4,41 +4,42 @@ namespace PartKeepr\Project; use PartKeepr\User\User, PartKeepr\Util\Serializable, PartKeepr\Util\Deserializable, - PartKeepr\Util\BaseEntity; + PartKeepr\Util\BaseEntity, + Doctrine\ORM\Mapping as ORM; /** * Represents a part in the database. The heart of our project. Handle with care! - * @Entity **/ + * @ORM\Entity **/ class Project extends BaseEntity implements Serializable, Deserializable { /** * Specifies the name of the project - * @Column(type="string") + * @ORM\Column(type="string") */ private $name; /** * Specifies the user this project belongs to - * @ManyToOne(targetEntity="PartKeepr\User\User") + * @ORM\ManyToOne(targetEntity="PartKeepr\User\User") */ private $user; /** * Holds the parts needed for this project - * @OneToMany(targetEntity="PartKeepr\Project\ProjectPart",mappedBy="project",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Project\ProjectPart",mappedBy="project",cascade={"persist", "remove"}) * @var ArrayCollection */ private $parts; /** * Holds the description of this project - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $description; /** * Holds the project attachments - * @OneToMany(targetEntity="PartKeepr\Project\ProjectAttachment",mappedBy="project",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Project\ProjectAttachment",mappedBy="project",cascade={"persist", "remove"}) * @var ProjectAttachment */ private $attachments; diff --git a/src/backend/PartKeepr/Project/ProjectAttachment.php b/src/backend/PartKeepr/Project/ProjectAttachment.php @@ -3,16 +3,17 @@ namespace PartKeepr\Project; use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, - PartKeepr\UploadedFile\UploadedFile; + PartKeepr\UploadedFile\UploadedFile, + Doctrine\ORM\Mapping as ORM; /** * Holds a project attachment - * @Entity + * @ORM\Entity **/ class ProjectAttachment extends UploadedFile implements Serializable, Deserializable { /** * The description of this attachment - * @Column(type="text") + * @ORM\Column(type="text") * @var string */ private $description; @@ -26,7 +27,7 @@ class ProjectAttachment extends UploadedFile implements Serializable, Deserializ } /** * The project object - * @ManyToOne(targetEntity="PartKeepr\Project\Project") + * @ORM\ManyToOne(targetEntity="PartKeepr\Project\Project", inversedBy="attachments") * @var Project */ private $project = null; diff --git a/src/backend/PartKeepr/Project/ProjectPart.php b/src/backend/PartKeepr/Project/ProjectPart.php @@ -4,32 +4,33 @@ namespace PartKeepr\Project; use PartKeepr\Part\Part, PartKeepr\Util\Serializable, PartKeepr\Util\Deserializable, - PartKeepr\Util\BaseEntity; + PartKeepr\Util\BaseEntity, + Doctrine\ORM\Mapping as ORM; /** * Represents a part in the database. The heart of our project. Handle with care! - * @Entity **/ + * @ORM\Entity **/ class ProjectPart extends BaseEntity implements Serializable, Deserializable { /** - * @ManyToOne(targetEntity="PartKeepr\Part\Part") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\Part", inversedBy="projectParts") */ private $part; /** * Specifies the amount of parts - * @Column(type="integer") + * @ORM\Column(type="integer") */ private $quantity; /** * Specifies the project which belongs to this project part - * @ManyToOne(targetEntity="PartKeepr\Project\Project") + * @ORM\ManyToOne(targetEntity="PartKeepr\Project\Project", inversedBy="parts") */ private $project; /** * Specifies the remarks for this entry - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) */ private $remarks; diff --git a/src/backend/PartKeepr/Service/Annotations/Service.php b/src/backend/PartKeepr/Service/Annotations/Service.php @@ -25,4 +25,21 @@ class Service public function getDescription () { return $this->description; } + + /** + * The documentation of the service + * + * @var string + */ + public $documentation; + + /** + * Returns the documentation of the service + * + * @return string + */ + public function getDocumentation() + { + return $this->documentation; + } } \ No newline at end of file diff --git a/src/backend/PartKeepr/Session/Session.php b/src/backend/PartKeepr/Session/Session.php @@ -2,21 +2,22 @@ namespace PartKeepr\Session; use PartKeepr\User\User, - PartKeepr\PartKeepr; + PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM; -/** @Entity */ +/** @ORM\Entity */ class Session { - /** @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") + /** @ORM\Id @ORM\Column(type="integer") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; - /** @Column(length=50) */ + /** @ORM\Column(length=50) */ private $sessionid; /** - * @ManyToOne(targetEntity="PartKeepr\User\User") + * @ORM\ManyToOne(targetEntity="PartKeepr\User\User") */ private $user; diff --git a/src/backend/PartKeepr/SiPrefix/SiPrefix.php b/src/backend/PartKeepr/SiPrefix/SiPrefix.php @@ -3,28 +3,29 @@ namespace PartKeepr\SiPrefix; use PartKeepr\Util\BaseEntity, PartKeepr\PartKeepr, - PartKeepr\Util\Exceptions\OutOfRangeException; + PartKeepr\Util\Exceptions\OutOfRangeException, + Doctrine\ORM\Mapping as ORM; -/** @Entity **/ +/** @ORM\Entity **/ class SiPrefix extends BaseEntity { /** * The prefix of the Si-Prefix (e.g. yotta, deca, deci, centi) - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $prefix; /** * The symbol of the Si-Prefix (e.g. m, M, G) - * @Column(type="string",length=2) + * @ORM\Column(type="string",length=2) * @var string */ private $symbol; /** * The power of the Si-Prefix (e.g. milli = 10^-3) - * @Column(type="integer") + * @ORM\Column(type="integer") * @var int */ private $power; diff --git a/src/backend/PartKeepr/Statistic/StatisticSnapshot.php b/src/backend/PartKeepr/Statistic/StatisticSnapshot.php @@ -1,41 +1,42 @@ <?php namespace PartKeepr\Statistic; -use PartKeepr\PartKeepr; +use PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM; -/** @Entity **/ +/** @ORM\Entity **/ class StatisticSnapshot { /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") + * @ORM\Id @ORM\Column(type="integer") + * @ORM\GeneratedValue(strategy="AUTO") * @var integer */ private $id; /** * Defines the date when this snapshot has been taken - * @Column(type="datetime") + * @ORM\Column(type="datetime") * @var DateTime */ private $dateTime; /** * Defines the amount of different parts in the database - * @Column(type="integer") + * @ORM\Column(type="integer") * @var int */ private $parts; /** * Defines the amount of categories - * @Column(type="integer") + * @ORM\Column(type="integer") * @var int */ private $categories; /** * Holds all defined units in the database - * @OneToMany(targetEntity="PartKeepr\Statistic\StatisticSnapshotUnit",mappedBy="statisticSnapshot",cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="PartKeepr\Statistic\StatisticSnapshotUnit",mappedBy="statisticSnapshot",cascade={"persist", "remove"}) */ private $units; diff --git a/src/backend/PartKeepr/Statistic/StatisticSnapshotUnit.php b/src/backend/PartKeepr/Statistic/StatisticSnapshotUnit.php @@ -3,27 +3,28 @@ namespace PartKeepr\Statistic; use PartKeepr\Statistic\StatisticSnapshot, PartKeepr\Part\PartUnit, - PartKeepr\PartKeepr; + PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM; -/** @Entity **/ +/** @ORM\Entity **/ class StatisticSnapshotUnit { /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") + * @ORM\Id @ORM\Column(type="integer") + * @ORM\GeneratedValue(strategy="AUTO") * @var integer */ private $id; /** - * @ManyToOne(targetEntity="PartKeepr\Statistic\StatisticSnapshot") + * @ORM\ManyToOne(targetEntity="PartKeepr\Statistic\StatisticSnapshot",inversedBy="units") * The statistic snapshot this entity belongs to * @var StatisticSnapshot */ private $statisticSnapshot; /** - * @ManyToOne(targetEntity="PartKeepr\Part\PartUnit") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\PartUnit") * The statistic snapshot this entity belongs to * @var StatisticSnapshot */ @@ -31,7 +32,7 @@ class StatisticSnapshotUnit { /** * The stockLevel for the unit - * @Column(type="integer") + * @ORM\Column(type="integer") * @var int */ private $stockLevel; diff --git a/src/backend/PartKeepr/Stock/StockEntry.php b/src/backend/PartKeepr/Stock/StockEntry.php @@ -5,33 +5,35 @@ use PartKeepr\Part\Part, PartKeepr\User\User, PartKeepr\PartKeepr, PartKeepr\Util\BaseEntity, - PartKeepr\Util\Serializable; + PartKeepr\Util\Serializable, + Doctrine\ORM\Mapping as ORM, + Doctrine\ORM\Mapping\HasLifecycleCallbacks; -/** @Entity @HasLifecycleCallbacks **/ +/** @ORM\Entity @ORM\HasLifecycleCallbacks **/ class StockEntry extends BaseEntity implements Serializable { /** - * @Column(type="integer") + * @ORM\Column(type="integer") */ private $stockLevel; /** - * @ManyToOne(targetEntity="PartKeepr\Part\Part") + * @ORM\ManyToOne(targetEntity="PartKeepr\Part\Part", inversedBy="stockLevels") */ private $part; /** - * @ManyToOne(targetEntity="PartKeepr\User\User") + * @ORM\ManyToOne(targetEntity="PartKeepr\User\User") */ private $user; /** - * @Column(type="decimal",precision=13,scale=4,nullable=true) + * @ORM\Column(type="decimal",precision=13,scale=4,nullable=true) * @var float */ private $price; /** - * @Column(type="datetime") + * @ORM\Column(type="datetime") * @var DateTime */ private $dateTime; @@ -39,13 +41,13 @@ class StockEntry extends BaseEntity implements Serializable { /** * Indicates if the stock level is a correction entry. * - * @Column(type="boolean") + * @ORM\Column(type="boolean") * @var boolean */ private $correction; /** - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $comment; @@ -172,7 +174,7 @@ class StockEntry extends BaseEntity implements Serializable { /** * If the stock level is negative, we can't have a price. - * @PrePersist + * @ORM\PrePersist */ public function checkPrice () { if ($this->getStockLevel() < 0 && $this->getPrice() !== null) { @@ -182,7 +184,7 @@ class StockEntry extends BaseEntity implements Serializable { /** * Updates the stock leve for a part - * @PostPersist + * @ORM\PostPersist */ public function postPersist () { $this->part->updateStockLevel(); diff --git a/src/backend/PartKeepr/StorageLocation/StorageLocation.php b/src/backend/PartKeepr/StorageLocation/StorageLocation.php @@ -3,20 +3,21 @@ namespace PartKeepr\StorageLocation; use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, - PartKeepr\Util\BaseEntity; + PartKeepr\Util\BaseEntity, + Doctrine\ORM\Mapping as ORM; -/** @Entity **/ +/** @ORM\Entity **/ class StorageLocation extends BaseEntity implements Serializable, Deserializable { /** * Holds the name for our storage location - * @Column(type="string",unique=true) + * @ORM\Column(type="string",unique=true) * @var string */ private $name; /** * Holds the storage location image - * @OneToOne(targetEntity="PartKeepr\StorageLocation\StorageLocationImage",mappedBy="storageLocation",cascade={"persist", "remove"}) + * @ORM\OneToOne(targetEntity="PartKeepr\StorageLocation\StorageLocationImage",mappedBy="storageLocation",cascade={"persist", "remove"}) * @var StorageLocationImage */ private $image; diff --git a/src/backend/PartKeepr/StorageLocation/StorageLocationImage.php b/src/backend/PartKeepr/StorageLocation/StorageLocationImage.php @@ -2,16 +2,17 @@ namespace PartKeepr\StorageLocation; use PartKeepr\Util\Serializable, - PartKeepr\Image\Image; + PartKeepr\Image\Image, + Doctrine\ORM\Mapping as ORM; /** * Holds a storage location image - * @Entity + * @ORM\Entity **/ class StorageLocationImage extends Image implements Serializable { /** * The storage location object - * @OneToOne(targetEntity="PartKeepr\StorageLocation\StorageLocation",inversedBy="image") + * @ORM\OneToOne(targetEntity="PartKeepr\StorageLocation\StorageLocation",inversedBy="image") * @var StorageLocation */ private $storageLocation = null; diff --git a/src/backend/PartKeepr/SystemNotice/SystemNotice.php b/src/backend/PartKeepr/SystemNotice/SystemNotice.php @@ -4,42 +4,43 @@ namespace PartKeepr\SystemNotice; use PartKeepr\UploadedFile\UploadedFile, PartKeepr\Util\BaseEntity, PartKeepr\Util\Serializable, - PartKeepr\Util\Deserializable; + PartKeepr\Util\Deserializable, + Doctrine\ORM\Mapping as ORM; /** * Holds a system notice - * @Entity + * @ORM\Entity **/ class SystemNotice extends BaseEntity implements Serializable { /** - * @Column(type="datetime") + * @ORM\Column(type="datetime") * @var \DateTime */ private $date; /** - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $title; /** * The description of this attachment - * @Column(type="text") + * @ORM\Column(type="text") * @var string */ private $description; /** * Defines if the system notice has been acknowledged - * @Column(type="boolean") + * @ORM\Column(type="boolean") * @var boolean */ private $acknowledged = false; /** * Specifies the type. This is required for unique notices which shouldn't pop up every time we create them. - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $type; diff --git a/src/backend/PartKeepr/TempImage/TempImage.php b/src/backend/PartKeepr/TempImage/TempImage.php @@ -4,13 +4,14 @@ namespace PartKeepr\TempImage; use PartKeepr\Image\Exceptions\InvalidImageTypeException, PartKeepr\Util\Configuration, PartKeepr\Image\Image, - PartKeepr\PartKeepr; + PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM; /** * Represents a temporary image. Temporary images are used when * a user uploaded an image, but not attached it to an entity. * - * @Entity + * @ORM\Entity */ class TempImage extends Image { public function __construct () { diff --git a/src/backend/PartKeepr/TipOfTheDay/TipOfTheDay.php b/src/backend/PartKeepr/TipOfTheDay/TipOfTheDay.php @@ -7,7 +7,8 @@ use PartKeepr\PartKeepr; use PartKeepr\Util\Configuration; -use PartKeepr\Util\BaseEntity; +use PartKeepr\Util\BaseEntity, + Doctrine\ORM\Mapping as ORM; /** * Represents a tip of the day. @@ -18,11 +19,11 @@ use PartKeepr\Util\BaseEntity; * * Note: If you wish to link against a tip of the day, do it by name and not by id! * - * @Entity + * @ORM\Entity **/ class TipOfTheDay extends BaseEntity implements Serializable { /** - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $name; diff --git a/src/backend/PartKeepr/TipOfTheDay/TipOfTheDayHistory.php b/src/backend/PartKeepr/TipOfTheDay/TipOfTheDayHistory.php @@ -9,25 +9,26 @@ use PartKeepr\PartKeepr; use PartKeepr\Util\Configuration; -use PartKeepr\Util\BaseEntity; +use PartKeepr\Util\BaseEntity, + Doctrine\ORM\Mapping as ORM; /** * Represents a tip of the day history entry. * * This entity stores each tip of the day the user has already seen. * - * @Entity + * @ORM\Entity **/ class TipOfTheDayHistory extends BaseEntity { /** - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $name; /** * Defines the user - * @ManyToOne(targetEntity="PartKeepr\User\User") + * @ORM\ManyToOne(targetEntity="PartKeepr\User\User") * @var StorageLocation */ private $user; diff --git a/src/backend/PartKeepr/Unit/Unit.php b/src/backend/PartKeepr/Unit/Unit.php @@ -6,35 +6,36 @@ use PartKeepr\Util\Deserializable, PartKeepr\Util\BaseEntity, PartKeepr\PartKeepr, PartKeepr\Util\Exceptions\OutOfRangeException, - PartKeepr\SiPrefix\SiPrefix; + PartKeepr\SiPrefix\SiPrefix, + Doctrine\ORM\Mapping as ORM; /** * This object represents an unit. Units can be: Volt, Hertz etc. * - * @Entity + * @ORM\Entity **/ class Unit extends BaseEntity implements Serializable, Deserializable { /** * The name of the unit (e.g. Volts, Ampere, Farad, Metres) - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $name; /** * The symbol of the unit (e.g. V, A, F, m) - * @Column(type="string") + * @ORM\Column(type="string") * @var string */ private $symbol; /** * Defines the allowed SiPrefixes for this parameter unit - * @ManyToMany(targetEntity="PartKeepr\SiPrefix\SiPrefix") - * @JoinTable(name="UnitSiPrefixes", - * joinColumns={@JoinColumn(name="unit_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="siprefix_id", referencedColumnName="id")} + * @ORM\ManyToMany(targetEntity="PartKeepr\SiPrefix\SiPrefix") + * @ORM\JoinTable(name="UnitSiPrefixes", + * joinColumns={@ORM\JoinColumn(name="unit_id", referencedColumnName="id")}, + * inverseJoinColumns={@ORM\JoinColumn(name="siprefix_id", referencedColumnName="id")} * ) * @var ArrayCollection */ diff --git a/src/backend/PartKeepr/UploadedFile/TempUploadedFile.php b/src/backend/PartKeepr/UploadedFile/TempUploadedFile.php @@ -1,11 +1,13 @@ <?php namespace PartKeepr\UploadedFile; +use Doctrine\ORM\Mapping as ORM; + /** * Represents a temporary file. Temporary files are used when * a user uploaded a file, but not attached it to an entity. * - * @Entity + * @ORM\Entity */ class TempUploadedFile extends UploadedFile { public function __construct () { diff --git a/src/backend/PartKeepr/UploadedFile/UploadedFile.php b/src/backend/PartKeepr/UploadedFile/UploadedFile.php @@ -6,17 +6,18 @@ use PartKeepr\Util\SerializableException, PartKeepr\Util\Serializable, PartKeepr\PartKeepr, PartKeepr\UploadedFile\TempUploadedFile, - PartKeepr\Util\Configuration; + PartKeepr\Util\Configuration, + Doctrine\ORM\Mapping as ORM; /** - * @MappedSuperclass + * @ORM\MappedSuperclass */ abstract class UploadedFile extends BaseEntity implements Serializable { /** * Specifies the type of the file. * * @var string - * @Column(type="string") + * @ORM\Column(type="string") **/ private $type; @@ -24,13 +25,13 @@ abstract class UploadedFile extends BaseEntity implements Serializable { * The unique filename of the file * * @var string - * @Column(type="string") + * @ORM\Column(type="string") */ private $filename; /** * The original name of the file - * @Column(type="string",nullable=true) + * @ORM\Column(type="string",nullable=true) * @var string */ private $originalname; @@ -38,13 +39,13 @@ abstract class UploadedFile extends BaseEntity implements Serializable { /** * The mimetype for the file * @var string - * @Column(type="string") + * @ORM\Column(type="string") */ private $mimetype; /** * The size of the uploaded file - * @Column(type="integer") + * @ORM\Column(type="integer") * @var integer */ private $size; diff --git a/src/backend/PartKeepr/User/User.php b/src/backend/PartKeepr/User/User.php @@ -6,20 +6,22 @@ use PartKeepr\UserPreference\UserPreference; use PartKeepr\Util\Deserializable, PartKeepr\Util\Serializable, PartKeepr\Util\BaseEntity, - PartKeepr\PartKeepr; + PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM, + Doctrine\ORM\Mapping\Table; -/** @Entity @Table(name="PartKeeprUser") */ +/** @ORM\Entity @ORM\Table(name="PartKeeprUser") */ class User extends BaseEntity implements Serializable, Deserializable { - /** @Column(length=50,unique=true) */ + /** @ORM\Column(length=50,unique=true) */ private $username; - /** @Column(length=32) */ + /** @ORM\Column(length=32) */ private $password; - /** @Column(type="boolean") */ + /** @ORM\Column(type="boolean") */ private $admin; - /** @Column(type="datetime",nullable=true) */ + /** @ORM\Column(type="datetime",nullable=true) */ private $lastSeen; /** diff --git a/src/backend/PartKeepr/UserPreference/UserPreference.php b/src/backend/PartKeepr/UserPreference/UserPreference.php @@ -10,8 +10,10 @@ use PartKeepr\Util\Serializable, PartKeepr\Util\Exceptions\EntityNotPersistantException, Doctrine\ORM\NoResultException, PartKeepr\Service\Annotations\ApiType, + PartKeepr\Service\Annotations\Service, PartKeepr\Service\Annotations\ApiTypeOutput, - PartKeepr\Service\Annotations\ApiTypeOutputs; + PartKeepr\Service\Annotations\ApiTypeOutputs, + Doctrine\ORM\Mapping as ORM; /** * Represents a user preference entry. @@ -21,30 +23,30 @@ use PartKeepr\Util\Serializable, * * Note that values are stored internally as serialized PHP values to keep their type. * - * @ApiType(description="Represents a user preference", + * @Service(description="Represents a user preference", * documentation="User preferences are user-specific settings, which are identified by keys and values. Think of them as an associative array.") - * @Entity + * @ORM\Entity **/ class UserPreference implements Serializable { /** * Defines the key of the user preference - * @Column(type="string",length=255) - * @Id + * @ORM\Column(type="string",length=255) + * @ORM\Id * @var string */ private $preferenceKey; /** * Defines the value. Note that the value is internally stored as a serialized string. - * @Column(type="text") + * @ORM\Column(type="text") * @var mixed */ private $preferenceValue; /** * Defines the user - * @ManyToOne(targetEntity="PartKeepr\User\User") - * @Id + * @ORM\ManyToOne(targetEntity="PartKeepr\User\User") + * @ORM\Id * @var User */ private $user; diff --git a/src/backend/PartKeepr/Util/BaseEntity.php b/src/backend/PartKeepr/Util/BaseEntity.php @@ -2,13 +2,14 @@ namespace PartKeepr\Util; use PartKeepr\Util\Exceptions\EntityNotFoundException, - PartKeepr\PartKeepr; + PartKeepr\PartKeepr, + Doctrine\ORM\Mapping as ORM; -/** @MappedSuperclass */ +/** @ORM\MappedSuperclass */ class BaseEntity { /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") + * @ORM\Id @ORM\Column(type="integer") + * @ORM\GeneratedValue(strategy="AUTO") * @var unknown_type */ private $id;