commit 3fd25e99e7bbd66d8e1964890bdf197b21560859
parent 6732087a1d9447abdfcbd09599d319051db51fdd
Author: Felicitus <felicitus@felicitus.org>
Date: Mon, 3 Aug 2015 18:54:05 +0200
Added api entry for users, refactored partmanufacturers, partimages and partdistributors to their own bundle
Diffstat:
14 files changed, 592 insertions(+), 650 deletions(-)
diff --git a/app/config/config.yml b/app/config/config.yml
@@ -867,4 +867,17 @@ services:
arguments: [ { groups: [ "default" ] } ]
- method: "initDenormalizationContext"
arguments:
- - { groups: [ "default" ] }-
\ No newline at end of file
+ - { groups: [ "default" ] }
+
+ resource.user:
+ parent: "api.resource"
+ arguments: [ "PartKeepr\AuthBundle\Entity\User" ]
+ tags: [ { name: "api.resource" } ]
+ calls:
+ - method: "initFilters"
+ arguments: [ [ "@doctrine_reflection_service.search_filter" ] ]
+ - method: "initNormalizationContext"
+ arguments: [ { groups: [ "default" ] } ]
+ - method: "initDenormalizationContext"
+ arguments:
+ - { groups: [ "default" ] }
diff --git a/src/PartKeepr/AuthBundle/Entity/User.php b/src/PartKeepr/AuthBundle/Entity/User.php
@@ -3,10 +3,12 @@ namespace PartKeepr\AuthBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
+use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService;
/**
* @ORM\Entity
* @ORM\Table(name="PartKeeprUser")
+ * @TargetService(uri="/api/users")
*/
class User extends BaseUser
{
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js b/src/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js
@@ -255,7 +255,7 @@ Ext.application({
this.userStore = Ext.create("Ext.data.Store",
{
- model: 'PartKeepr.AuthBundle.Entity.User.User',
+ model: 'PartKeepr.AuthBundle.Entity.User',
pageSize: 99999999,
autoLoad: true
});
diff --git a/src/PartKeepr/PartBundle/Entity/Part.php b/src/PartKeepr/PartBundle/Entity/Part.php
@@ -7,7 +7,6 @@ use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService;
use PartKeepr\FootprintBundle\Entity\Footprint;
use PartKeepr\Part\Exceptions\CategoryNotAssignedException;
use PartKeepr\Part\Exceptions\StorageLocationNotAssignedException;
-use PartKeepr\Part\PartImage;
use PartKeepr\PartKeepr;
use PartKeepr\StorageLocationBundle\Entity\StorageLocation;
use PartKeepr\Util\BaseEntity;
@@ -76,7 +75,7 @@ class Part extends BaseEntity
/**
* Holds the manufacturers which can manufacture this part
- * @ORM\OneToMany(targetEntity="PartKeepr\Part\PartManufacturer",mappedBy="part",cascade={"persist", "remove"})
+ * @ORM\OneToMany(targetEntity="PartKeepr\PartBundle\Entity\PartManufacturer",mappedBy="part",cascade={"persist", "remove"})
*
* @var ArrayCollection
*/
@@ -84,7 +83,7 @@ class Part extends BaseEntity
/**
* Holds the distributors from where we can buy the part
- * @ORM\OneToMany(targetEntity="PartKeepr\Part\PartDistributor",mappedBy="part",cascade={"persist", "remove"})
+ * @ORM\OneToMany(targetEntity="PartKeepr\PartBundle\Entity\PartDistributor",mappedBy="part",cascade={"persist", "remove"})
*
* @var ArrayCollection
*/
@@ -92,7 +91,7 @@ class Part extends BaseEntity
/**
* Holds the part images
- * @ORM\OneToMany(targetEntity="PartKeepr\Part\PartImage",mappedBy="part",cascade={"persist", "remove"})
+ * @ORM\OneToMany(targetEntity="PartKeepr\PartBundle\Entity\PartImage",mappedBy="part",cascade={"persist", "remove"})
*
* @var PartImage
*/
@@ -153,7 +152,7 @@ class Part extends BaseEntity
/**
* The parameters for this part
- * @ORM\OneToMany(targetEntity="PartKeepr\PartParameter\PartParameter",
+ * @ORM\OneToMany(targetEntity="PartKeepr\PartBundle\Entity\PartParameter",
* mappedBy="part",cascade={"persist", "remove"})
*
* @var ArrayCollection
diff --git a/src/PartKeepr/PartBundle/Entity/PartDistributor.php b/src/PartKeepr/PartBundle/Entity/PartDistributor.php
@@ -0,0 +1,203 @@
+<?php
+namespace PartKeepr\PartBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use PartKeepr\DistributorBundle\Entity\Distributor;
+use PartKeepr\PartKeepr;
+use PartKeepr\Util\BaseEntity;
+use PartKeepr\Util\Exceptions\OutOfRangeException;
+
+/**
+ * This class represents the link between a part and a distributor.
+ *
+ * @ORM\Entity
+ */
+class PartDistributor extends BaseEntity
+{
+ /**
+ * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part", inversedBy="distributors")
+ * @var Part
+ */
+ private $part;
+
+ /**
+ * @ORM\ManyToOne(targetEntity="PartKeepr\DistributorBundle\Entity\Distributor")
+ */
+ private $distributor;
+
+ /**
+ * The order number for the part and distributor
+ * @ORM\Column(type="string",nullable=true)
+ *
+ * @var string
+ */
+ private $orderNumber;
+
+ /**
+ * Defines the packaging unit when ordering a part. Some items can't be ordered in a quantity of just one at
+ * certain manufacturers.
+ *
+ * @ORM\Column(type="integer")
+ * @var integer
+ */
+ private $packagingUnit;
+
+ /**
+ * Specifies the price of the part. Note that the price
+ * needs to be per item, not per packaging unit.
+ *
+ * @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.
+ * @ORM\Column(type="string",nullable=true)
+ *
+ * @var string
+ */
+ private $sku;
+
+ /**
+ * Cretes a new part->distributor link. Initializes the packaging unit with a quantity of "1".
+ */
+ public function __construct()
+ {
+ $this->setPackagingUnit(1);
+ }
+
+ /**
+ * Sets the packaging unit for a specific distributor.
+ *
+ * For example, some distributors only sell resistors in packs of 100, so you can't order just one. We use the
+ * packagingUnit to calculate how many pieces will be delivered once ordered. So if your stock level falls below
+ * the minimum (example: you would need to order 10 resistors), we suggest that you only order one resistor pack
+ * instead of 10.
+ *
+ * @param int $packagingUnit The amount of items in one package
+ *
+ * @throws OutOfRangeException When the packaging unit is less than 1
+ */
+ public function setPackagingUnit($packagingUnit)
+ {
+ $packagingUnit = intval($packagingUnit);
+
+ if ($packagingUnit < 1) {
+ $exception = new OutOfRangeException(PartKeepr::i18n("Packaging Unit is out of range"));
+ $exception->setDetail(PartKeepr::i18n("The packaging unit must be 1 or higher"));
+ throw $exception;
+ }
+
+ $this->packagingUnit = $packagingUnit;
+ }
+
+ /**
+ * Returns the packaging unit
+ *
+ * @return int The packaging unit
+ */
+ public function getPackagingUnit()
+ {
+ return $this->packagingUnit;
+ }
+
+ /**
+ * Sets the part
+ *
+ * @param Part $part The part
+ */
+ public function setPart(Part $part)
+ {
+ $this->part = $part;
+ }
+
+ /**
+ * Returns the part
+ *
+ * @return Part The part
+ */
+ public function getPart()
+ {
+ return $this->part;
+ }
+
+ /**
+ * Sets the distributor
+ *
+ * @param \PartKeepr\DistributorBundle\Entity\Distributor $distributor The distributor
+ */
+ public function setDistributor(Distributor $distributor)
+ {
+ $this->distributor = $distributor;
+ }
+
+ /**
+ * Returns the distributor
+ *
+ * @return Distributor The distributor
+ */
+ public function getDistributor()
+ {
+ return $this->distributor;
+ }
+
+ /**
+ * Sets the order number
+ *
+ * @param string $orderNumber The order number
+ */
+ public function setOrderNumber($orderNumber)
+ {
+ $this->orderNumber = $orderNumber;
+ }
+
+ /**
+ * Returns the order number
+ *
+ * @return string The order number
+ */
+ public function getOrderNumber()
+ {
+ return $this->orderNumber;
+ }
+
+ /**
+ * Sets the price
+ *
+ * @param float $price
+ */
+ public function setPrice($price)
+ {
+ echo "/** price set to ".$price." **/";
+ $this->price = $price;
+ }
+
+ /**
+ * Returns the price
+ */
+ public function getPrice()
+ {
+ return $this->price;
+ }
+
+ /**
+ * Sets the SKU (stock keeping unit)
+ *
+ * @param string $sku The SKU
+ */
+ public function setSKU($sku)
+ {
+ $this->sku = $sku;
+ }
+
+ /**
+ * Returns the SKU (stock keeping unit)
+ *
+ * @return string The SKU
+ */
+ public function getSKU()
+ {
+ return $this->sku;
+ }
+}
diff --git a/src/PartKeepr/PartBundle/Entity/PartImage.php b/src/PartKeepr/PartBundle/Entity/PartImage.php
@@ -0,0 +1,49 @@
+<?php
+namespace PartKeepr\PartBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use PartKeepr\ImageBundle\Entity\Image;
+
+/**
+ * Holds a part image
+ *
+ * @ORM\Entity
+ **/
+class PartImage extends Image
+{
+ /**
+ * The part object
+ * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part", inversedBy="images")
+ *
+ * @var Part
+ */
+ private $part = null;
+
+ /**
+ * Creates a new part image instance
+ */
+ public function __construct()
+ {
+ parent::__construct(Image::IMAGE_PART);
+ }
+
+ /**
+ * Sets the part
+ *
+ * @param Part $part The part to set
+ */
+ public function setPart(Part $part)
+ {
+ $this->part = $part;
+ }
+
+ /**
+ * Returns the part
+ *
+ * @return Part the part
+ */
+ public function getPart()
+ {
+ return $this->part;
+ }
+}
diff --git a/src/PartKeepr/PartBundle/Entity/PartManufacturer.php b/src/PartKeepr/PartBundle/Entity/PartManufacturer.php
@@ -0,0 +1,85 @@
+<?php
+namespace PartKeepr\PartBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use PartKeepr\ManufacturerBundle\Entity\Manufacturer;
+use PartKeepr\Part\unknown_type;
+use PartKeepr\Util\BaseEntity;
+
+/** @ORM\Entity */
+class PartManufacturer extends BaseEntity
+{
+ /**
+ * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part",inversedBy="manufacturers")
+ */
+ private $part;
+
+ /**
+ * @ORM\ManyToOne(targetEntity="PartKeepr\ManufacturerBundle\Entity\Manufacturer")
+ */
+ private $manufacturer;
+
+ /**
+ * @ORM\Column(type="string",nullable=true)
+ * Enter description here ...
+ *
+ * @var unknown_type
+ */
+ private $partNumber;
+
+ /**
+ * Sets the part which belongs to this manufacturer entry
+ *
+ * @param Part $part
+ */
+ public function setPart(Part $part)
+ {
+ $this->part = $part;
+ }
+
+ /**
+ * Returns the part which belongs to this manufacturer entry
+ */
+ public function getPart()
+ {
+ return $this->part;
+ }
+
+ /**
+ * Sets the manufacturer which belongs to this entry
+ *
+ * @param Manufacturer $manufacturer
+ */
+ public function setManufacturer(Manufacturer $manufacturer)
+ {
+ $this->manufacturer = $manufacturer;
+ }
+
+ /**
+ * Returns the manufacturer which belongs to this part
+ */
+ public function getManufacturer()
+ {
+ return $this->manufacturer;
+ }
+
+ /**
+ * Sets the manufacturer-specific part number
+ *
+ * @param string $partNumber
+ */
+ public function setPartNumber($partNumber)
+ {
+ $this->partNumber = $partNumber;
+ }
+
+ /**
+ * Returns the manufacturer-specific part number
+ *
+ * @return string The part number
+ */
+ public function getPartNumber()
+ {
+ return $this->partNumber;
+ }
+}
diff --git a/src/PartKeepr/PartBundle/Entity/PartParameter.php b/src/PartKeepr/PartBundle/Entity/PartParameter.php
@@ -0,0 +1,229 @@
+<?php
+namespace PartKeepr\PartBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use PartKeepr\SiPrefixBundle\Entity\SiPrefix;
+use PartKeepr\UnitBundle\Entity\Unit;
+
+
+/**
+ * This object represents a parameter. Each parameter can have an unit (defined by the class "Unit") associated with
+ * a numeric value.
+ *
+ * @ORM\Entity @ORM\HasLifecycleCallbacks
+ */
+class PartParameter
+{
+ /**
+ * @ORM\Id @ORM\Column(type="integer")
+ * @ORM\GeneratedValue(strategy="AUTO")
+ * @var integer
+ */
+ private $id;
+
+ /**
+ * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part", inversedBy="parameters")
+ * The part this parameter is bound to
+ *
+ * @var Part
+ */
+ private $part;
+
+ /**
+ * The name of the parameter (e.g. Resistance, Voltage)
+ * @ORM\Column(type="string")
+ *
+ * @var string
+ */
+ private $name;
+
+ /**
+ * A description for this parameter
+ * @ORM\Column(type="string")
+ *
+ * @var string
+ */
+ private $description;
+
+ /**
+ * The unit for this type. May be null.
+ *
+ * @ORM\ManyToOne(targetEntity="PartKeepr\UnitBundle\Entity\Unit")
+ * @var \PartKeepr\UnitBundle\Entity\Unit
+ */
+ private $unit;
+
+ /**
+ * The value of the unit. Together with the prefix, it becomes the actual value.
+ *
+ * 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
+ * @ORM\Column(type="float")
+ *
+ * @var float
+ */
+ private $value;
+
+ /**
+ * The SiPrefix of the unit
+ * @ORM\ManyToOne(targetEntity="PartKeepr\SiPrefixBundle\Entity\SiPrefix")
+ *
+ * @var object
+ */
+ private $siPrefix;
+
+ /**
+ * The raw value of the unit.
+ * @ORM\Column(type="float")
+ *
+ * @var float
+ */
+ private $rawValue;
+
+ /**
+ * Sets the name for this parameter
+ *
+ * @param string $name The name
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Returns the name for this parameter
+ *
+ * @return string The name for this parameter
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets the description for this parameter
+ *
+ * @param string $description The description
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ }
+
+ /**
+ * Returns the description
+ *
+ * @return string The description
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets the unit
+ *
+ * @param \PartKeepr\UnitBundle\Entity\Unit $unit The unit to set
+ */
+ public function setUnit(Unit $unit = null)
+ {
+ $this->unit = $unit;
+ }
+
+ /**
+ * Returns the unit
+ *
+ * @return \PartKeepr\UnitBundle\Entity\Unit the unit
+ */
+ public function getUnit()
+ {
+ return $this->unit;
+ }
+
+ /**
+ * Sets the part
+ *
+ * @param Part $part The part to set
+ */
+ public function setPart(Part $part)
+ {
+ $this->part = $part;
+ }
+
+ /**
+ * Returns the part
+ *
+ * @return \PartKeepr\PartBundle\Entity\Part the part
+ */
+ public function getPart()
+ {
+ return $this->part;
+ }
+
+ /**
+ * Sets the value
+ *
+ * @param float $value The value to set
+ */
+ public function setValue($value)
+ {
+ $this->value = $value;
+
+ $this->recalculateRawValue();
+ }
+
+ /**
+ * Returns the value
+ *
+ * @return float The value
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Sets the si prefix for this parameter
+ *
+ * @param \PartKeepr\SiPrefixBundle\Entity\SiPrefix $prefix The prefix to set, or null
+ */
+ public function setSiPrefix(SiPrefix $prefix = null)
+ {
+ $this->siPrefix = $prefix;
+
+ $this->recalculateRawValue();
+ }
+
+ /**
+ * Returns the si prefix for this parameter
+ *
+ * @return \PartKeepr\SiPrefixBundle\Entity\SiPrefix the si prefix or null
+ */
+ public function getSiPrefix()
+ {
+ return $this->siPrefix;
+ }
+
+ /**
+ * Returns the ID for this object.
+ *
+ * @param none
+ *
+ * @return int The ID for this object
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ private function recalculateRawValue()
+ {
+ if (is_object($this->getSiPrefix())) {
+ $power = $this->getSiPrefix()->getExponent();
+ } else {
+ $power = 0;
+ }
+
+ $this->rawValue = $this->getValue() * pow(10, $power);
+ }
+}
diff --git a/src/backend/PartKeepr/Part/PartDistributor.php b/src/backend/PartKeepr/Part/PartDistributor.php
@@ -1,223 +0,0 @@
-<?php
-namespace PartKeepr\Part;
-
-use PartKeepr\PartBundle\Entity\Part;
-use PartKeepr\Util\Deserializable,
- PartKeepr\Util\Serializable,
- PartKeepr\Util\BaseEntity,
- PartKeepr\PartKeepr,
- PartKeepr\DistributorBundle\Entity\Distributor,
- Doctrine\ORM\Mapping as ORM;
-
-/**
- * This class represents the link between a part and a distributor.
- * @ORM\Entity **/
-class PartDistributor extends BaseEntity implements Serializable, Deserializable {
- /**
- * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part", inversedBy="distributors")
- */
- private $part;
-
- /**
- * @ORM\ManyToOne(targetEntity="PartKeepr\DistributorBundle\Entity\Distributor")
- */
- private $distributor;
-
- /**
- * The order number for the part and distributor
- * @ORM\Column(type="string",nullable=true)
- * @var string
- */
- private $orderNumber;
-
- /**
- * Defines the packaging unit when ordering a part. Some items can't be ordered in a quantity of just one at
- * certain manufacturers.
- *
- * @ORM\Column(type="integer")
- * @var integer
- */
- private $packagingUnit;
-
- /**
- * Specifies the price of the part. Note that the price
- * needs to be per item, not per packaging unit.
- *
- * @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.
- * @ORM\Column(type="string",nullable=true)
- * @var string
- */
- private $sku;
-
- /**
- * Cretes a new part->distributor link. Initializes the packaging unit with a quantity of "1".
- *
- * @param Part $part The part
- * @param Distributor $distributor The distributor
- */
- public function __construct () {
- $this->setPackagingUnit(1);
- }
-
- /**
- * Sets the packaging unit for a specific distributor.
- *
- * For example, some distributors only sell resistors in packs of 100, so you can't order just one. We use the
- * packagingUnit to calculate how many pieces will be delivered once ordered. So if your stock level falls below
- * the minimum (example: you would need to order 10 resistors), we suggest that you only order one resistor pack
- * instead of 10.
- *
- * @param int $packagingUnit The amount of items in one package
- * @throws \PartKeepr\Part\OutOfRangeException When the packaging unit is less than 1
- */
- public function setPackagingUnit ($packagingUnit) {
- $packagingUnit = intval($packagingUnit);
-
- if ($packagingUnit < 1) {
- $exception = new OutOfRangeException(PartKeepr::i18n("Packaging Unit is out of range"));
- $exception->setDetail(PartKeepr::i18n("The packaging unit must be 1 or higher"));
- throw $exception;
- }
-
- $this->packagingUnit = $packagingUnit;
- }
-
- /**
- * Returns the packaging unit
- * @return int The packaging unit
- */
- public function getPackagingUnit () {
- return $this->packagingUnit;
- }
-
- /**
- * Sets the part
- * @param Part $part The part
- */
- public function setPart (Part $part) {
- $this->part = $part;
- }
-
- /**
- * Returns the part
- * @return Part The part
- */
- public function getPart () {
- return $this->part;
- }
-
- /**
- * Sets the distributor
- *
-*@param \PartKeepr\DistributorBundle\Entity\Distributor $distributor The distributor
- */
- public function setDistributor (Distributor $distributor) {
- $this->distributor = $distributor;
- }
-
- /**
- * Returns the distributor
- * @return Distributor The distributor
- */
- public function getDistributor () {
- return $this->distributor;
- }
-
- /**
- * Sets the order number
- * @param string $orderNumber The order number
- */
- public function setOrderNumber ($orderNumber) {
- $this->orderNumber = $orderNumber;
- }
-
- /**
- * Returns the order number
- * @return string The order number
- */
- public function getOrderNumber () {
- return $this->orderNumber;
- }
-
- /**
- * Sets the price
- * @param float $price
- */
- public function setPrice ($price) {
- echo "/** price set to ".$price." **/";
- $this->price = $price;
- }
-
- /**
- * Returns the price
- */
- public function getPrice () {
- return $this->price;
- }
-
- /**
- * Sets the SKU (stock keeping unit)
- * @param string $sku The SKU
- */
- public function setSKU ($sku) {
- $this->sku = $sku;
- }
-
- /**
- * Returns the SKU (stock keeping unit)
- * @return string The SKU
- */
- public function getSKU () {
- return $this->sku;
- }
-
- /**
- * (non-PHPdoc)
- * @see PartKeepr\Util.Serializable::serialize()
- */
- public function serialize () {
- return array(
- "id" => $this->getId(),
- "orderNumber" => $this->getOrderNumber(),
- "distributor_id" => $this->getDistributor()->getId(),
- "distributor_name" => $this->getDistributor()->getName(),
- "part_id" => $this->getPart()->getId(),
- "part_name" => $this->getPart()->getName(),
- "packagingUnit" => $this->getPackagingUnit(),
- "price" => $this->getPrice(),
- "sku" => $this->getSKU());
- }
-
- /**
- * Deserializes the part manufacturer
- * @param array $parameters The array with the parameters to set
- */
- public function deserialize (array $parameters) {
- foreach ($parameters as $key => $value) {
- switch ($key) {
- case "distributor_id":
- $distributor = Distributor::loadById($value);
- $this->setDistributor($distributor);
- break;
- case "orderNumber":
- $this->setOrderNumber($value);
- break;
- case "packagingUnit":
- $this->setPackagingUnit($value);
- break;
- case "price":
- $this->setPrice($value);
- break;
- case "sku":
- $this->setSKU($value);
- break;
- }
- }
- }
-}
diff --git a/src/backend/PartKeepr/Part/PartImage.php b/src/backend/PartKeepr/Part/PartImage.php
@@ -1,52 +0,0 @@
-<?php
-namespace PartKeepr\Part;
-
-use PartKeepr\PartBundle\Entity\Part;
-use PartKeepr\Util\Serializable,
- PartKeepr\ImageBundle\Entity\Image,
- Doctrine\ORM\Mapping as ORM;
-
-/**
- * Holds a part image
- * @ORM\Entity
- **/
-class PartImage extends Image implements Serializable {
- /**
- * The part object
- * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part", inversedBy="images")
- * @var Part
- */
- private $part = null;
-
- /**
- * Creates a new part image instance
- */
- public function __construct () {
- parent::__construct(Image::IMAGE_PART);
- }
-
- /**
- * Sets the part
- * @param Part $part The part to set
- */
- public function setPart (Part $part) {
- $this->part = $part;
- }
-
- /**
- * Returns the part
- * @return Part the part
- */
- public function getPart () {
- return $this->part;
- }
-
- /**
- *
- * Serializes this part image
- * @return array The serialized part imaage
- */
- public function serialize () {
- return array("id" => $this->getId(), "part_id" => $this->getPart()->getId());
- }
-}-
\ No newline at end of file
diff --git a/src/backend/PartKeepr/Part/PartManufacturer.php b/src/backend/PartKeepr/Part/PartManufacturer.php
@@ -1,108 +0,0 @@
-<?php
-namespace PartKeepr\Part;
-
-use PartKeepr\PartBundle\Entity\Part;
-use PartKeepr\Util\Deserializable,
- PartKeepr\Util\Serializable,
- PartKeepr\Util\BaseEntity,
- PartKeepr\PartKeepr,
- PartKeepr\ManufacturerBundle\Entity\Manufacturer,
- Doctrine\ORM\Mapping as ORM;
-
-/** @ORM\Entity **/
-class PartManufacturer extends BaseEntity implements Serializable, Deserializable {
- /**
- * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part",inversedBy="manufacturers")
- */
- private $part;
-
- /**
- * @ORM\ManyToOne(targetEntity="PartKeepr\ManufacturerBundle\Entity\Manufacturer")
- */
- private $manufacturer;
-
- /**
- * @ORM\Column(type="string",nullable=true)
- * Enter description here ...
- * @var unknown_type
- */
- private $partNumber;
-
- /**
- * Sets the part which belongs to this manufacturer entry
- * @param Part $part
- */
- public function setPart (Part $part) {
- $this->part = $part;
- }
-
- /**
- * Returns the part which belongs to this manufacturer entry
- */
- public function getPart () {
- return $this->part;
- }
-
- /**
- * Sets the manufacturer which belongs to this entry
- * @param Manufacturer $manufacturer
- */
- public function setManufacturer (Manufacturer $manufacturer) {
- $this->manufacturer = $manufacturer;
- }
-
- /**
- * Returns the manufacturer which belongs to this part
- */
- public function getManufacturer () {
- return $this->manufacturer;
- }
-
- /**
- * Sets the manufacturer-specific part number
- * @param string $partNumber
- */
- public function setPartNumber ($partNumber) {
- $this->partNumber = $partNumber;
- }
-
- /**
- * Returns the manufacturer-specific part number
- * @return string The part number
- */
- public function getPartNumber () {
- return $this->partNumber;
- }
-
- /**
- * Returns the data of this object in a serialized form.
- * @return array The result array
- */
- public function serialize () {
- return array(
- "id" => $this->getId(),
- "partNumber" => $this->getPartNumber(),
- "manufacturer_id" => $this->getManufacturer()->getId(),
- "manufacturer_name" => $this->getManufacturer()->getName(),
- "part_id" => $this->getPart()->getId(),
- "part_name" => $this->getPart()->getName());
- }
-
- /**
- * Deserializes the part manufacturer
- * @param array $parameters The array with the parameters to set
- */
- public function deserialize (array $parameters) {
- foreach ($parameters as $key => $value) {
- switch ($key) {
- case "manufacturer_id":
- $manufacturer = Manufacturer::loadById($value);
- $this->setManufacturer($manufacturer);
- break;
- case "partNumber":
- $this->setPartNumber($value);
- break;
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/src/backend/PartKeepr/PartKeepr.php b/src/backend/PartKeepr/PartKeepr.php
@@ -161,9 +161,9 @@ class PartKeepr {
'PartKeepr\PartBundle\Entity\Part',
'PartKeepr\PartBundle\Entity\PartUnit',
- 'PartKeepr\Part\PartManufacturer',
- 'PartKeepr\Part\PartDistributor',
- 'PartKeepr\Part\PartImage',
+ 'PartKeepr\PartBundle\Entity\PartManufacturer',
+ 'PartKeepr\PartBundle\Entity\PartDistributor',
+ 'PartKeepr\PartBundle\Entity\PartImage',
'PartKeepr\PartBundle\Entity\PartAttachment',
'PartKeepr\PartBundle\Entity\PartCategory',
@@ -195,7 +195,7 @@ class PartKeepr {
'PartKeepr\Statistic\StatisticSnapshotUnit',
'PartKeepr\SiPrefixBundle\Entity\SiPrefix',
'PartKeepr\Unit\Unit',
- 'PartKeepr\PartParameter\PartParameter',
+ 'PartKeepr\PartBundle\Entity\PartParameter',
'PartKeepr\TipOfTheDayBundle\Entity\TipOfTheDay',
'PartKeepr\TipOfTheDayBundle\Entity\TipOfTheDayHistory',
diff --git a/src/backend/PartKeepr/PartParameter/PartParameter.php b/src/backend/PartKeepr/PartParameter/PartParameter.php
@@ -1,252 +0,0 @@
-<?php
-namespace PartKeepr\PartParameter;
-
-use PartKeepr\PartKeepr,
-PartKeepr\Util\Exceptions\OutOfRangeException,
-PartKeepr\UnitBundle\Entity\Unit,
-PartKeepr\PartBundle\Entity\Part,
-PartKeepr\SiPrefixBundle\Entity\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.
- *
- * @ORM\Entity @ORM\HasLifecycleCallbacks
- **/
-class PartParameter {
- /**
- * @ORM\Id @ORM\Column(type="integer")
- * @ORM\GeneratedValue(strategy="AUTO")
- * @var integer
- */
- private $id;
-
- /**
- * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part", inversedBy="parameters")
- * The part this parameter is bound to
- * @var Part
- */
- private $part;
-
- /**
- * The name of the parameter (e.g. Resistance, Voltage)
- * @ORM\Column(type="string")
- * @var string
- */
- private $name;
-
- /**
- * A description for this parameter
- * @ORM\Column(type="string")
- * @var string
- */
- private $description;
-
- /**
- * The unit for this type. May be null.
- *
- * @ORM\ManyToOne(targetEntity="PartKeepr\UnitBundle\Entity\Unit")
- * @var \PartKeepr\UnitBundle\Entity\Unit
- */
- private $unit;
-
- /**
- * The value of the unit. Together with the prefix, it becomes the actual value.
- *
- * 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
- * @ORM\Column(type="float")
- * @var float
- */
- private $value;
-
- /**
- * The SiPrefix of the unit
- * @ORM\ManyToOne(targetEntity="PartKeepr\SiPrefixBundle\Entity\SiPrefix")
- * @var object
- */
- private $siPrefix;
-
- /**
- * The raw value of the unit.
- * @ORM\Column(type="float")
- * @var float
- */
- private $rawValue;
-
- /**
- * Sets the name for this parameter
- * @param string $name The name
- */
- public function setName ($name) {
- $this->name = $name;
- }
-
- /**
- * Returns the name for this parameter
- * @return string The name for this parameter
- */
- public function getName () {
- return $this->name;
- }
-
- /**
- * Sets the description for this parameter
- * @param string $description The description
- */
- public function setDescription ($description) {
- $this->description = $description;
- }
-
- /**
- * Returns the description
- * @return string The description
- */
- public function getDescription () {
- return $this->description;
- }
-
- /**
- * Sets the unit
- *
-*@param \PartKeepr\UnitBundle\Entity\Unit $unit The unit to set
- */
- public function setUnit (Unit $unit = null) {
- $this->unit = $unit;
- }
-
- /**
- * Returns the unit
- *
-*@return \PartKeepr\UnitBundle\Entity\Unit the unit
- */
- public function getUnit () {
- return $this->unit;
- }
-
- /**
- * Sets the part
- * @param Part $part The part to set
- */
- public function setPart (Part $part) {
- $this->part = $part;
- }
-
- /**
- * Returns the part
- * @return \PartKeepr\PartBundle\Entity\Part the part
- */
- public function getPart () {
- return $this->part;
- }
-
- /**
- * Sets the value
- * @param float $value The value to set
- */
- public function setValue ($value) {
- $this->value = $value;
-
- $this->recalculateRawValue();
- }
-
- /**
- * Returns the value
- * @return float The value
- */
- public function getValue () {
- return $this->value;
- }
-
- /**
- * Sets the si prefix for this parameter
- *
-*@param \PartKeepr\SiPrefixBundle\Entity\SiPrefix $prefix The prefix to set, or null
- */
- public function setSiPrefix (SiPrefix $prefix = null) {
- $this->siPrefix = $prefix;
-
- $this->recalculateRawValue();
- }
-
- /**
- * Returns the si prefix for this parameter
- *
-*@return \PartKeepr\SiPrefixBundle\Entity\SiPrefix the si prefix or null
- */
- public function getSiPrefix () {
- return $this->siPrefix;
- }
-
- /**
- * Returns the ID for this object.
- * @param none
- * @return int The ID for this object
- */
- public function getId () {
- return $this->id;
- }
-
- private function recalculateRawValue () {
- if (is_object($this->getSiPrefix())) {
- $power = $this->getSiPrefix()->getExponent();
- } else {
- $power = 0;
- }
-
- $this->rawValue = $this->getValue() * pow(10, $power);
- }
-
- /**
- * Returns the data of this object in a serialized form.
- * @return array The result array
- */
- public function serialize () {
- return array(
- "id" => $this->getId(),
- "name" => $this->getName(),
- "description" => $this->getDescription(),
- "value" => $this->getValue(),
- "part_id" => $this->getPart()->getId(),
- "siprefix_id" => is_object($this->getSiPrefix()) ? $this->getSiPrefix()->getId() : null,
- "prefixedValue" => array(
- /* We duplicate most data because of strange ExtJS stuff... */
- "value" => $this->getValue(),
- "exponent" => is_object($this->getSiPrefix()) ? $this->getSiPrefix()->getExponent() : 0,
- "symbol" => is_object($this->getSiPrefix()) ? $this->getSiPrefix()->getSymbol() : "",
- "siprefix_id" => is_object($this->getSiPrefix()) ? $this->getSiPrefix()->getId() : null
- ),
- "unit_id" => is_object($this->getUnit()) ? $this->getUnit()->getId() : null
- );
- }
-
- /**
- * Deserializes the part parameter
- * @param array $parameters The array with the parameters to set
- */
- public function deserialize (array $parameters) {
- foreach ($parameters as $key => $value) {
- switch ($key) {
- case "name":
- $this->setName($value);
- break;
- case "description":
- $this->setDescription($value);
- break;
- case "value":
- $this->setValue($value);
- break;
- case "siprefix_id":
- $prefix = SiPrefix::loadById($value);
- $this->setSiPrefix($prefix);
- break;
- case "unit_id":
- $unit = Unit::loadById($value);
- $this->setUnit($unit);
- break;
- }
- }
- }
-}
diff --git a/src/backend/PartKeepr/Setup/Migration/PartDB/PartMigration.php b/src/backend/PartKeepr/Setup/Migration/PartDB/PartMigration.php
@@ -4,7 +4,7 @@ namespace PartKeepr\Setup\Migration\PartDB;
use PartKeepr\PartKeepr,
PartKeepr\PartBundle\Entity\Part,
PartKeepr\PartBundle\Entity\PartAttachment,
- PartKeepr\Part\PartDistributor,
+ PartKeepr\PartBundle\Entity\PartDistributor,
PartKeepr\Part\PartManager,
PartKeepr\Stock\StockEntry,
PartKeepr\Distributor\DistributorManager,