Add locking version in job order entities and place TODOs in controller
This commit is contained in:
parent
f11f79f1b8
commit
59d76c3975
2 changed files with 56 additions and 0 deletions
|
|
@ -271,6 +271,12 @@ class JobOrderController extends BaseController
|
|||
{
|
||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
|
||||
// TODO: check if anyone is already processing
|
||||
|
||||
// TODO: lock and make this user be the processor
|
||||
|
||||
// TODO: throw error if unable to lock (means someone already locked it before us)
|
||||
|
||||
$params = $this->initParameters('jo_proc');
|
||||
$params['mode'] = 'update-processing';
|
||||
|
||||
|
|
@ -335,6 +341,8 @@ class JobOrderController extends BaseController
|
|||
{
|
||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
|
||||
// TODO: check if we're the one processing, return error otherwise
|
||||
|
||||
// initialize error list
|
||||
$error_array = [];
|
||||
|
||||
|
|
@ -398,6 +406,10 @@ class JobOrderController extends BaseController
|
|||
], 422);
|
||||
}
|
||||
|
||||
// TODO: unlock job order and set version to 0, so someone else can modify it
|
||||
|
||||
// NOTE: we don't touch processed_by since we're the one who processed it
|
||||
|
||||
// validated! save the entity
|
||||
$em->flush();
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,14 @@ class JobOrder
|
|||
*/
|
||||
protected $assigned_by;
|
||||
|
||||
// user that processed or is processing the job order
|
||||
// used to determine lock
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="job_orders_processed")
|
||||
* @ORM\JoinColumn(name="process_user_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
protected $processed_by;
|
||||
|
||||
// service type
|
||||
/**
|
||||
* @ORM\Column(type="string", length=25)
|
||||
|
|
@ -153,6 +161,18 @@ class JobOrder
|
|||
*/
|
||||
protected $delivery_address;
|
||||
|
||||
// invoice
|
||||
protected $invoice;
|
||||
|
||||
// version for optimistic locking
|
||||
// this will intiially be set to 0 then modified to be the id of the user that locks it
|
||||
// so only the user can update the entity
|
||||
/**
|
||||
* @ORM\Version
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date_create = new DateTime();
|
||||
|
|
@ -160,6 +180,8 @@ class JobOrder
|
|||
|
||||
$this->flag_advance = false;
|
||||
$this->source = 'mobile';
|
||||
|
||||
$this->version = 0;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
|
|
@ -255,6 +277,17 @@ class JobOrder
|
|||
return $this->assigned_by;
|
||||
}
|
||||
|
||||
public function setProcessedBy(User $user)
|
||||
{
|
||||
$this->processed_by = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProcessedBy()
|
||||
{
|
||||
return $this->processed_by;
|
||||
}
|
||||
|
||||
public function setServiceType($service_type)
|
||||
{
|
||||
$this->service_type = $service_type;
|
||||
|
|
@ -375,4 +408,15 @@ class JobOrder
|
|||
{
|
||||
return $this->delivery_address;
|
||||
}
|
||||
|
||||
public function setVersion($version)
|
||||
{
|
||||
$this->version = $version;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue