Clean attachment table
Clean code Clean attachment table Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
committed by
Julius Härtl
parent
c5d10dafb8
commit
39a927de18
@@ -21,25 +21,25 @@ abstract class ABoardImportService {
|
||||
/**
|
||||
* @return Stack[]
|
||||
*/
|
||||
abstract function getStacks(): array;
|
||||
abstract public function getStacks(): array;
|
||||
|
||||
/**
|
||||
* @return Card[]
|
||||
*/
|
||||
abstract function getCards(): array;
|
||||
abstract public function getCards(): array;
|
||||
|
||||
abstract function updateStack(string $id, Stack $stack): self;
|
||||
abstract public function updateStack(string $id, Stack $stack): self;
|
||||
|
||||
abstract function updateCard(string $id, Card $card): self;
|
||||
abstract public function updateCard(string $id, Card $card): self;
|
||||
|
||||
abstract function assignCardsToLabels(): self;
|
||||
abstract public function importParticipants(): self;
|
||||
|
||||
abstract function importParticipants(): self;
|
||||
|
||||
abstract function importComments(): self;
|
||||
abstract public function importComments(): self;
|
||||
|
||||
abstract public function importLabels(): self;
|
||||
|
||||
abstract public function assignCardsToLabels(): self;
|
||||
|
||||
abstract public function validateUsers(): self;
|
||||
|
||||
public function setImportService($service): self {
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace OCA\Deck\Service;
|
||||
use JsonSchema\Constraints\Constraint;
|
||||
use JsonSchema\Validator;
|
||||
use OCA\Deck\Command\BoardImport;
|
||||
use OCA\Deck\Service\BoardImportService;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
@@ -28,9 +28,9 @@ use JsonSchema\Validator;
|
||||
use OCA\Deck\AppInfo\Application;
|
||||
use OCA\Deck\BadRequestException;
|
||||
use OCA\Deck\Db\AclMapper;
|
||||
use OCA\Deck\Db\AssignmentMapper;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\Label;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
@@ -38,7 +38,6 @@ use OCA\Deck\Db\StackMapper;
|
||||
use OCA\Deck\NotFoundException;
|
||||
use OCP\Comments\IComment;
|
||||
use OCP\Comments\ICommentsManager;
|
||||
use OCP\Comments\MessageTooLongException;
|
||||
use OCP\Comments\NotFoundException as CommentNotFoundException;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IUserManager;
|
||||
@@ -58,6 +57,8 @@ class BoardImportService {
|
||||
private $stackMapper;
|
||||
/** @var CardMapper */
|
||||
private $cardMapper;
|
||||
/** @var AssignmentMapper */
|
||||
private $assignmentMapper;
|
||||
/** @var ICommentsManager */
|
||||
private $commentsManager;
|
||||
/** @var string */
|
||||
@@ -88,6 +89,7 @@ class BoardImportService {
|
||||
AclMapper $aclMapper,
|
||||
LabelMapper $labelMapper,
|
||||
StackMapper $stackMapper,
|
||||
AssignmentMapper $assignmentMapper,
|
||||
CardMapper $cardMapper,
|
||||
ICommentsManager $commentsManager
|
||||
) {
|
||||
@@ -98,6 +100,7 @@ class BoardImportService {
|
||||
$this->labelMapper = $labelMapper;
|
||||
$this->stackMapper = $stackMapper;
|
||||
$this->cardMapper = $cardMapper;
|
||||
$this->assignmentMapper = $assignmentMapper;
|
||||
$this->commentsManager = $commentsManager;
|
||||
}
|
||||
|
||||
@@ -177,6 +180,11 @@ class BoardImportService {
|
||||
return $this->systemInstance;
|
||||
}
|
||||
|
||||
public function insertAssignment($assignment): self {
|
||||
$this->assignmentMapper->insert($assignment);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function importBoard() {
|
||||
$board = $this->getImportSystem()->getBoard();
|
||||
if ($board) {
|
||||
|
||||
@@ -25,33 +25,19 @@ namespace OCA\Deck\Service;
|
||||
|
||||
use OC\Comments\Comment;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\AclMapper;
|
||||
use OCA\Deck\Db\Assignment;
|
||||
use OCA\Deck\Db\AssignmentMapper;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\Label;
|
||||
use OCA\Deck\Db\Stack;
|
||||
use OCA\Deck\Db\StackMapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IL10N;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
|
||||
class BoardImportTrelloService extends ABoardImportService {
|
||||
/** @var LabelService */
|
||||
private $labelService;
|
||||
/** @var StackMapper */
|
||||
private $stackMapper;
|
||||
/** @var CardMapper */
|
||||
private $cardMapper;
|
||||
/** @var AssignmentMapper */
|
||||
private $assignmentMapper;
|
||||
/** @var AclMapper */
|
||||
private $aclMapper;
|
||||
/** @var IDBConnection */
|
||||
private $connection;
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
/** @var IL10N */
|
||||
@@ -75,22 +61,12 @@ class BoardImportTrelloService extends ABoardImportService {
|
||||
|
||||
public function __construct(
|
||||
BoardService $boardService,
|
||||
LabelService $labelService,
|
||||
StackMapper $stackMapper,
|
||||
CardMapper $cardMapper,
|
||||
AssignmentMapper $assignmentMapper,
|
||||
AclMapper $aclMapper,
|
||||
IDBConnection $connection,
|
||||
IUserManager $userManager,
|
||||
IL10N $l10n
|
||||
) {
|
||||
$this->boardService = $boardService;
|
||||
$this->labelService = $labelService;
|
||||
$this->stackMapper = $stackMapper;
|
||||
$this->cardMapper = $cardMapper;
|
||||
$this->assignmentMapper = $assignmentMapper;
|
||||
$this->aclMapper = $aclMapper;
|
||||
$this->connection = $connection;
|
||||
$this->userManager = $userManager;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
@@ -221,11 +197,11 @@ class BoardImportTrelloService extends ABoardImportService {
|
||||
return;
|
||||
}
|
||||
$trelloCard->desc .= "\n\n## {$this->l10n->t('Attachments')}\n";
|
||||
$trelloCard->desc .= "| {$this->l10n->t('URL')} | {$this->l10n->t('Name')} | {$this->l10n->t('date')} |\n";
|
||||
$trelloCard->desc .= "|---|---|---|\n";
|
||||
$trelloCard->desc .= "| {$this->l10n->t('File')} | {$this->l10n->t('date')} |\n";
|
||||
$trelloCard->desc .= "|---|---\n";
|
||||
foreach ($trelloCard->attachments as $attachment) {
|
||||
$name = $attachment->name === $attachment->url ? null : $attachment->name;
|
||||
$trelloCard->desc .= "| {$attachment->url} | {$name} | {$attachment->date} |\n";
|
||||
$trelloCard->desc .= "| [{$name}]({$attachment->url}) | {$attachment->date} |\n";
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -237,7 +213,7 @@ class BoardImportTrelloService extends ABoardImportService {
|
||||
$assignment->setCardId($this->cards[$trelloCard->id]->getId());
|
||||
$assignment->setParticipant($this->members[$idMember]->getUID());
|
||||
$assignment->setType(Assignment::TYPE_USER);
|
||||
$assignment = $this->assignmentMapper->insert($assignment);
|
||||
$this->getImportService()->insertAssignment($assignment);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace OCA\Deck\Command;
|
||||
use OCA\Deck\Command\ImportHelper\TrelloHelper;
|
||||
use OCA\Deck\Service\AImportService;
|
||||
use OCA\Deck\Service\BoardImportService;
|
||||
use OCA\Deck\Service\BoardService;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
Reference in New Issue
Block a user