This commit is contained in:
Yuri Kuznetsov
2022-11-10 17:53:57 +02:00
parent f37f59aff9
commit a5da02df0f
2 changed files with 47 additions and 15 deletions

View File

@@ -0,0 +1,37 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Entities;
use Espo\Core\ORM\Entity;
class KanbanOrder extends Entity
{
public const ENTITY_TYPE = 'KanbanOrder';
}

View File

@@ -29,30 +29,25 @@
namespace Espo\Tools\Kanban;
use Espo\Core\{
ORM\EntityManager,
Utils\Metadata,
Utils\Util,
};
use Espo\Entities\KanbanOrder;
use Espo\Core\ORM\EntityManager;
use Espo\Core\Utils\Metadata;
use Espo\Core\Utils\Util;
use LogicException;
class OrdererProcessor
{
private const MAX_GROUP_LENGTH = 100;
private const DEFAULT_MAX_NUMBER = 50;
private ?string $entityType = null;
private ?string $group = null;
private ?string $userId = null;
private int $maxNumber = self::DEFAULT_MAX_NUMBER;
private EntityManager $entityManager;
private Metadata $metadata;
public function __construct(EntityManager $entityManager, Metadata $metadata)
@@ -115,7 +110,7 @@ class OrdererProcessor
$deleteQuery1 = $this->entityManager
->getQueryBuilder()
->delete()
->from('KanbanOrder')
->from(KanbanOrder::ENTITY_TYPE)
->where([
'entityType' => $this->entityType,
'userId' => $this->userId,
@@ -128,7 +123,7 @@ class OrdererProcessor
$minOrder = null;
$first = $this->entityManager
->getRDBRepository('KanbanOrder')
->getRDBRepository(KanbanOrder::ENTITY_TYPE)
->select(['id', 'order'])
->where([
'entityType' => $this->entityType,
@@ -148,7 +143,7 @@ class OrdererProcessor
$updateQuery = $this->entityManager
->getQueryBuilder()
->update()
->in('KanbanOrder')
->in(KanbanOrder::ENTITY_TYPE)
->where([
'entityType' => $this->entityType,
'group' => $this->group,
@@ -164,10 +159,10 @@ class OrdererProcessor
$collection = $this->entityManager
->getCollectionFactory()
->create('KanbanOrder');
->create(KanbanOrder::ENTITY_TYPE);
foreach ($ids as $i => $id) {
$item = $this->entityManager->getNewEntity('KanbanOrder');
$item = $this->entityManager->getNewEntity(KanbanOrder::ENTITY_TYPE);
$item->set([
'id' => Util::generateId(),
@@ -186,7 +181,7 @@ class OrdererProcessor
$deleteQuery2 = $this->entityManager
->getQueryBuilder()
->delete()
->from('KanbanOrder')
->from(KanbanOrder::ENTITY_TYPE)
->where([
'entityType' => $this->entityType,
'group' => $this->group,