1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-31 19:20:13 -07:00

Update rebrickable entities

Update rebrickable entities to match new structure of rebrickable v3 data
This commit is contained in:
David Hübner 2017-02-07 13:54:05 +01:00
parent 83992cdcdd
commit 1a9b856b3e
15 changed files with 268 additions and 440 deletions

View File

@ -57,17 +57,17 @@ class Part
/** /**
* @return int * @return int
*/ */
public function getPartNum() public function getNumber()
{ {
return $this->partNum; return $this->number;
} }
/** /**
* @param int $partNum * @param int $number
*/ */
public function setPartNum($partNum) public function setNumber($number)
{ {
$this->partNum = $partNum; $this->number = $number;
} }
/** /**

View File

@ -1,112 +0,0 @@
<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Keyword.
*
* @ORM\Table(name="keyword")
* @ORM\Entity(repositoryClass="AppBundle\Repository\KeywordRepository")
*/
class Keyword
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, unique=true)
*/
private $name;
/**
* @var ArrayCollection
*
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\BuildingKit", inversedBy="keywords")
*/
private $building_kits;
/**
* Keyword constructor.
*/
public function __construct()
{
$this->building_kits = new ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Keyword
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return ArrayCollection
*/
public function getBuildingKits()
{
return $this->building_kits;
}
/**
* @param BuildingKit $building_kit
*
* @return Keyword
*/
public function addBuildingKit(BuildingKit $building_kit)
{
$this->building_kits->add($building_kit);
return $this;
}
/**
* @param BuildingKit $building_kit
*
* @return Keyword
*/
public function removeBuildingKit(BuildingKit $building_kit)
{
$this->building_kits->remove($building_kit);
return $this;
}
}

View File

@ -1,6 +1,6 @@
<?php <?php
namespace AppBundle\Entity; namespace AppBundle\Entity\Rebrickable;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
* Category. * Category.
* *
* @ORM\Table(name="category") * @ORM\Table(name="category")
* @ORM\Entity(repositoryClass="AppBundle\Repository\CategoryRepository") * @ORM\Entity
*/ */
class Category class Category
{ {
@ -33,14 +33,7 @@ class Category
/** /**
* @var Collection * @var Collection
* *
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Model", mappedBy="category") * @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Part", mappedBy="category")
*/
private $models;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Part", mappedBy="category")
*/ */
private $parts; private $parts;
@ -49,7 +42,6 @@ class Category
*/ */
public function __construct() public function __construct()
{ {
$this->models = new ArrayCollection();
$this->parts = new ArrayCollection(); $this->parts = new ArrayCollection();
} }
@ -87,40 +79,6 @@ class Category
return $this->name; return $this->name;
} }
/**
* Get models.
*
* @return ArrayCollection
*/
public function getModels()
{
return $this->models;
}
/**
* @param Model $model
*
* @return Category
*/
public function addModel(Model $model)
{
$this->models->add($model);
return $this;
}
/**
* @param Model $model
*
* @return Category
*/
public function removeModel(Model $model)
{
$this->models->remove($model);
return $this;
}
/** /**
* Get parts. * Get parts.
* *

View File

@ -1,7 +1,8 @@
<?php <?php
namespace AppBundle\Entity; namespace AppBundle\Entity\Rebrickable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -9,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
* Color. * Color.
* *
* @ORM\Table(name="color") * @ORM\Table(name="color")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ColorRepository") * @ORM\Entity
*/ */
class Color class Color
{ {
@ -35,12 +36,27 @@ class Color
*/ */
private $rgb; private $rgb;
/**
* @var bool
*
* @ORM\Column(name="transparent", type="boolean")
*/
private $transparent;
/** /**
* @var Collection * @var Collection
* *
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Part_BuildingKit", mappedBy="color") * @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Part_Set", mappedBy="color")
*/ */
private $part_building_kits; private $part_sets;
/**
* Constructor.
*/
public function __construct()
{
$this->part_sets = new ArrayCollection();
}
/** /**
* Set id. * Set id.
@ -114,43 +130,55 @@ class Color
return $this->rgb; return $this->rgb;
} }
/**
* Is transparent.
*
* @return bool
*/
public function isTransparent()
{
return $this->transparent;
}
/**
* Set transparent.
*
* @param bool $transparent
*/
public function setTransparent($transparent)
{
$this->transparent = $transparent;
}
/** /**
* @return Collection * @return Collection
*/ */
public function getPartBuildingKits() public function getPartBuildingKits()
{ {
return $this->part_building_kits; return $this->part_sets;
} }
/** /**
* @param Part_BuildingKit $part_building_kit * @param Part_Set $part_building_kit
* *
* @return Color * @return Color
*/ */
public function addPartBuildingKit(Part_BuildingKit $part_building_kit) public function addPartBuildingKit(Part_Set $part_set)
{ {
$this->part_building_kits->add($part_building_kit); $this->part_sets->add($part_set);
return $this; return $this;
} }
/** /**
* @param Part_BuildingKit $part_building_kit * @param Part_Set $part_building_kit
* *
* @return Color * @return Color
*/ */
public function removePartBuildingKit(Part_BuildingKit $part_building_kit) public function removePartBuildingKit(Part_Set $part_set)
{ {
$this->part_building_kits->remove($part_building_kit); $this->part_sets->remove($part_set);
return $this; return $this;
} }
/**
* Constructor.
*/
public function __construct()
{
$this->part_building_kits = new \Doctrine\Common\Collections\ArrayCollection();
}
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace AppBundle\Entity; namespace AppBundle\Entity\Rebrickable;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@ -10,23 +10,26 @@ use Doctrine\ORM\Mapping as ORM;
* Part. * Part.
* *
* @ORM\Table(name="part") * @ORM\Table(name="part")
* @ORM\Entity(repositoryClass="AppBundle\Repository\PartRepository") * @ORM\Entity
*/ */
class Part class Part
{ {
/** // /**
* @var int // * @var int
* // *
* @ORM\Column(name="id", type="integer") // * @ORM\Column(name="id", type="integer")
* @ORM\Id // * @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO") // * @ORM\GeneratedValue(strategy="AUTO")
*/ // */
private $id; // private $id;
/** /**
* Part ID number.
*
* @var string * @var string
* *
* @ORM\Column(name="number", type="string", length=255, unique=true) * @ORM\Id
* @ORM\Column(name="id", type="string", length=255, unique=true)
*/ */
private $number; private $number;
@ -40,40 +43,23 @@ class Part
/** /**
* @var Category * @var Category
* *
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Category", inversedBy="parts") * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Category", inversedBy="parts")
*/ */
private $category; private $category;
/**
* @var Model
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Model", inversedBy="parts")
*/
private $model;
/** /**
* @var Collection * @var Collection
* *
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Part_BuildingKit", mappedBy="part") * @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Part_Set", mappedBy="part")
*/ */
private $building_kits; private $sets;
/** /**
* Part constructor. * Part constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->building_kits = new ArrayCollection(); $this->sets = new ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
} }
/** /**
@ -124,54 +110,34 @@ class Part
return $this->name; return $this->name;
} }
/**
* @return Model
*/
public function getModel()
{
return $this->model;
}
/**
* @param Model $model
*
* @return Part
*/
public function setModel($model)
{
$this->model = $model;
return $this;
}
/** /**
* @return mixed * @return mixed
*/ */
public function getBuildingKits() public function getSets()
{ {
return $this->building_kits; return $this->sets;
} }
/** /**
* @param Part_BuildingKit $building_kit * @param Part_Set $set
* *
* @return Part * @return Part
*/ */
public function addBuildingKit(Part_BuildingKit $building_kit) public function addSet(Part_Set $set)
{ {
$this->building_kits->add($building_kit); $this->sets->add($set);
return $this; return $this;
} }
/** /**
* @param Part_BuildingKit $building_kit * @param Part_Set $set
* *
* @return Part * @return Part
*/ */
public function removeBuildingKit($building_kit) public function removeSet($set)
{ {
$this->building_kits->remove($building_kit); $this->sets->removeElement($set);
return $this; return $this;
} }

View File

@ -1,16 +1,16 @@
<?php <?php
namespace AppBundle\Entity; namespace AppBundle\Entity\Rebrickable;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* Part_BuildingKit. * Part_Set.
* *
* @ORM\Table(name="part__building_kit") * @ORM\Table(name="part_set")
* @ORM\Entity(repositoryClass="AppBundle\Repository\Part_BuildingKitRepository") * @ORM\Entity
*/ */
class Part_BuildingKit class Part_Set
{ {
/** /**
* @var int * @var int
@ -31,7 +31,7 @@ class Part_BuildingKit
/** /**
* @var Color * @var Color
* *
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Color", inversedBy="part_building_kits") * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Color", inversedBy="part_sets")
*/ */
private $color; private $color;
@ -45,16 +45,16 @@ class Part_BuildingKit
/** /**
* @var Part * @var Part
* *
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Part", inversedBy="building_kits" ) * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Part", inversedBy="sets" )
*/ */
private $part; private $part;
/** /**
* @var BuildingKit * @var Set
* *
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\BuildingKit", inversedBy="parts") * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Set", inversedBy="parts")
*/ */
private $building_kit; private $set;
/** /**
* Get id. * Get id.
@ -71,7 +71,7 @@ class Part_BuildingKit
* *
* @param int $count * @param int $count
* *
* @return Part_BuildingKit * @return Part_Set
*/ */
public function setCount($count) public function setCount($count)
{ {
@ -95,7 +95,7 @@ class Part_BuildingKit
* *
* @param Color $color * @param Color $color
* *
* @return Part_BuildingKit * @return Part_Set
*/ */
public function setColor($color) public function setColor($color)
{ {
@ -119,7 +119,7 @@ class Part_BuildingKit
* *
* @param bool $type * @param bool $type
* *
* @return Part_BuildingKit * @return Part_Set
*/ */
public function setType($type) public function setType($type)
{ {
@ -149,33 +149,33 @@ class Part_BuildingKit
/** /**
* @param Part $part * @param Part $part
* *
* @return Part_BuildingKit * @return Part_Set
*/ */
public function setPart(Part $part) public function setPart(Part $part)
{ {
$part->addBuildingKit($this); $part->addSet($this);
$this->part = $part; $this->part = $part;
return $this; return $this;
} }
/** /**
* @return BuildingKit * @return Set
*/ */
public function getBuildingKit() public function getSet()
{ {
return $this->building_kit; return $this->set;
} }
/** /**
* @param BuildingKit $building_kit * @param Set $set
* *
* @return Part_BuildingKit * @return Part_Set
*/ */
public function setBuildingKit(BuildingKit $building_kit) public function setSet(Set $set)
{ {
$building_kit->addPart($this); $set->addPart($this);
$this->building_kit = $building_kit; $this->set = $set;
return $this; return $this;
} }

View File

@ -1,32 +1,33 @@
<?php <?php
namespace AppBundle\Entity; namespace AppBundle\Entity\Rebrickable;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* BuildingKit. * Set.
* *
* @ORM\Table(name="building_kit") * @ORM\Table(name="set")
* @ORM\Entity(repositoryClass="AppBundle\Repository\BuildingKitRepository") * @ORM\Entity
*/ */
class BuildingKit class Set
{ {
/** // /**
* @var int // * @var int
* // *
* @ORM\Column(name="id", type="integer") // * @ORM\Column(name="id", type="integer")
* @ORM\Id // * @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO") // * @ORM\GeneratedValue(strategy="AUTO")
*/ // */
private $id; // private $id;
/** /**
* @var string * @var string
* *
* @ORM\Column(name="number", type="string", length=255, unique=true) * @ORM\Id
* @ORM\Column(name="id", type="string", length=255, unique=true)
*/ */
private $number; private $number;
@ -54,35 +55,35 @@ class BuildingKit
/** /**
* @var Collection * @var Collection
* *
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Part_BuildingKit", mappedBy="building_kit") * @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Part_Set", mappedBy="set")
*/ */
private $parts; private $parts;
/** /**
* @var Collection * @var Collection
* *
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Keyword", mappedBy="building_kits") * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Rebrickable\Theme", mappedBy="sets")
*/ */
private $keywords; private $themes;
/** /**
* BuildingKit constructor. * Set constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->parts = new ArrayCollection(); $this->parts = new ArrayCollection();
$this->keywords = new ArrayCollection(); $this->themes = new ArrayCollection();
} }
/** // /**
* Get id. // * Get id.
* // *
* @return int // * @return int
*/ // */
public function getId() // public function getId()
{ // {
return $this->id; // return $this->id;
} // }
/** /**
* @return string * @return string
@ -95,7 +96,7 @@ class BuildingKit
/** /**
* @param string $number * @param string $number
* *
* @return BuildingKit * @return Set
*/ */
public function setNumber($number) public function setNumber($number)
{ {
@ -109,7 +110,7 @@ class BuildingKit
* *
* @param string $name * @param string $name
* *
* @return BuildingKit * @return Set
*/ */
public function setName($name) public function setName($name)
{ {
@ -133,7 +134,7 @@ class BuildingKit
* *
* @param int $year * @param int $year
* *
* @return BuildingKit * @return Set
*/ */
public function setYear($year) public function setYear($year)
{ {
@ -163,7 +164,7 @@ class BuildingKit
/** /**
* @param int $partCount * @param int $partCount
* *
* @return BuildingKit * @return Set
*/ */
public function setPartCount($partCount) public function setPartCount($partCount)
{ {
@ -183,11 +184,11 @@ class BuildingKit
} }
/** /**
* @param Part_BuildingKit $part * @param Part_Set $part
* *
* @return BuildingKit * @return Set
*/ */
public function addPart(Part_BuildingKit $part) public function addPart(Part_Set $part)
{ {
$this->parts->add($part); $this->parts->add($part);
@ -195,48 +196,14 @@ class BuildingKit
} }
/** /**
* @param Part_BuildingKit $part * @param Part_Set $part
* *
* @return BuildingKit * @return Set
*/ */
public function removePart(Part_BuildingKit $part) public function removePart(Part_Set $part)
{ {
$this->parts->remove($part); $this->parts->remove($part);
return $this; return $this;
} }
/**
* Get keywords.
*
* @return Collection
*/
public function getKeywords()
{
return $this->keywords;
}
/**
* @param Keyword $keyword
*
* @return BuildingKit
*/
public function addKeyword(Keyword $keyword)
{
$this->keywords->add($keyword);
return $this;
}
/**
* @param Keyword $keyword
*
* @return BuildingKit
*/
public function removeKeyword(Keyword $keyword)
{
$this->keywords->remove($keyword);
return $this;
}
} }

View File

@ -0,0 +1,125 @@
<?php
namespace AppBundle\Entity\Rebrickable;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Theme.
*
* @ORM\Table(name="theme")
* @ORM\Entity
*/
class Theme
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var Collection
*
* @ORM\ManyToOne(targetEntity="Theme")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $parent;
/**
* @var Collection
*
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Rebrickable\Set", inversedBy="themes")
*/
private $sets;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return Collection
*/
public function getParent()
{
return $this->parent;
}
/**
* @param Collection $parent
*/
public function setParent($parent)
{
$this->parent = $parent;
}
/**
* @return mixed
*/
public function getSets()
{
return $this->sets;
}
/**
* @param Part_Set $set
*
* @return Theme
*/
public function addSet(Part_Set $set)
{
$this->sets->add($set);
return $this;
}
/**
* @param Part_Set $set
*
* @return Theme
*/
public function removeSet($set)
{
$this->sets->removeElement($set);
return $this;
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace AppBundle\Repository;
use AppBundle\Entity\Part;
/**
* BuildingSetRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class BuildingKitRepository extends \Doctrine\ORM\EntityRepository
{
public function findAllByPart(Part $part)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('building_kit')
->from('AppBundle:BuildingKit', 'building_kit')
->innerJoin('building_kit.parts', 'parts')
->where('parts.part = :id')->setParameter('id', $part->getId());
return $qb->getQuery()->getResult();
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace AppBundle\Repository;
/**
* CategoryRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class CategoryRepository extends \Doctrine\ORM\EntityRepository
{
}

View File

@ -1,13 +0,0 @@
<?php
namespace AppBundle\Repository;
/**
* ColorRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ColorRepository extends \Doctrine\ORM\EntityRepository
{
}

View File

@ -1,13 +0,0 @@
<?php
namespace AppBundle\Repository;
/**
* KeywordRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class KeywordRepository extends \Doctrine\ORM\EntityRepository
{
}

View File

@ -1,13 +0,0 @@
<?php
namespace AppBundle\Repository;
/**
* ModelRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ModelRepository extends \Doctrine\ORM\EntityRepository
{
}

View File

@ -1,13 +0,0 @@
<?php
namespace AppBundle\Repository;
/**
* PartRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class PartRepository extends \Doctrine\ORM\EntityRepository
{
}

View File

@ -1,13 +0,0 @@
<?php
namespace AppBundle\Repository;
/**
* Part_BuildingKitRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class Part_BuildingKitRepository extends \Doctrine\ORM\EntityRepository
{
}