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[]
|
* @return Stack[]
|
||||||
*/
|
*/
|
||||||
abstract function getStacks(): array;
|
abstract public function getStacks(): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Card[]
|
* @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 public function importComments(): self;
|
||||||
|
|
||||||
abstract function importComments(): self;
|
|
||||||
|
|
||||||
abstract public function importLabels(): self;
|
abstract public function importLabels(): self;
|
||||||
|
|
||||||
|
abstract public function assignCardsToLabels(): self;
|
||||||
|
|
||||||
abstract public function validateUsers(): self;
|
abstract public function validateUsers(): self;
|
||||||
|
|
||||||
public function setImportService($service): self {
|
public function setImportService($service): self {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace OCA\Deck\Service;
|
|||||||
use JsonSchema\Constraints\Constraint;
|
use JsonSchema\Constraints\Constraint;
|
||||||
use JsonSchema\Validator;
|
use JsonSchema\Validator;
|
||||||
use OCA\Deck\Command\BoardImport;
|
use OCA\Deck\Command\BoardImport;
|
||||||
use OCA\Deck\Service\BoardImportService;
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ use JsonSchema\Validator;
|
|||||||
use OCA\Deck\AppInfo\Application;
|
use OCA\Deck\AppInfo\Application;
|
||||||
use OCA\Deck\BadRequestException;
|
use OCA\Deck\BadRequestException;
|
||||||
use OCA\Deck\Db\AclMapper;
|
use OCA\Deck\Db\AclMapper;
|
||||||
|
use OCA\Deck\Db\AssignmentMapper;
|
||||||
use OCA\Deck\Db\Board;
|
use OCA\Deck\Db\Board;
|
||||||
use OCA\Deck\Db\BoardMapper;
|
use OCA\Deck\Db\BoardMapper;
|
||||||
use OCA\Deck\Db\Card;
|
|
||||||
use OCA\Deck\Db\CardMapper;
|
use OCA\Deck\Db\CardMapper;
|
||||||
use OCA\Deck\Db\Label;
|
use OCA\Deck\Db\Label;
|
||||||
use OCA\Deck\Db\LabelMapper;
|
use OCA\Deck\Db\LabelMapper;
|
||||||
@@ -38,7 +38,6 @@ use OCA\Deck\Db\StackMapper;
|
|||||||
use OCA\Deck\NotFoundException;
|
use OCA\Deck\NotFoundException;
|
||||||
use OCP\Comments\IComment;
|
use OCP\Comments\IComment;
|
||||||
use OCP\Comments\ICommentsManager;
|
use OCP\Comments\ICommentsManager;
|
||||||
use OCP\Comments\MessageTooLongException;
|
|
||||||
use OCP\Comments\NotFoundException as CommentNotFoundException;
|
use OCP\Comments\NotFoundException as CommentNotFoundException;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
@@ -58,6 +57,8 @@ class BoardImportService {
|
|||||||
private $stackMapper;
|
private $stackMapper;
|
||||||
/** @var CardMapper */
|
/** @var CardMapper */
|
||||||
private $cardMapper;
|
private $cardMapper;
|
||||||
|
/** @var AssignmentMapper */
|
||||||
|
private $assignmentMapper;
|
||||||
/** @var ICommentsManager */
|
/** @var ICommentsManager */
|
||||||
private $commentsManager;
|
private $commentsManager;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -88,6 +89,7 @@ class BoardImportService {
|
|||||||
AclMapper $aclMapper,
|
AclMapper $aclMapper,
|
||||||
LabelMapper $labelMapper,
|
LabelMapper $labelMapper,
|
||||||
StackMapper $stackMapper,
|
StackMapper $stackMapper,
|
||||||
|
AssignmentMapper $assignmentMapper,
|
||||||
CardMapper $cardMapper,
|
CardMapper $cardMapper,
|
||||||
ICommentsManager $commentsManager
|
ICommentsManager $commentsManager
|
||||||
) {
|
) {
|
||||||
@@ -98,6 +100,7 @@ class BoardImportService {
|
|||||||
$this->labelMapper = $labelMapper;
|
$this->labelMapper = $labelMapper;
|
||||||
$this->stackMapper = $stackMapper;
|
$this->stackMapper = $stackMapper;
|
||||||
$this->cardMapper = $cardMapper;
|
$this->cardMapper = $cardMapper;
|
||||||
|
$this->assignmentMapper = $assignmentMapper;
|
||||||
$this->commentsManager = $commentsManager;
|
$this->commentsManager = $commentsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,9 +152,9 @@ class BoardImportService {
|
|||||||
public function getAllowedImportSystems(): array {
|
public function getAllowedImportSystems(): array {
|
||||||
if (!$this->allowedSystems) {
|
if (!$this->allowedSystems) {
|
||||||
$allowedSystems = glob(__DIR__ . '/BoardImport*Service.php');
|
$allowedSystems = glob(__DIR__ . '/BoardImport*Service.php');
|
||||||
$allowedSystems = array_filter($allowedSystems, function($name) {
|
$allowedSystems = array_filter($allowedSystems, function ($name) {
|
||||||
$name = basename($name);
|
$name = basename($name);
|
||||||
switch($name) {
|
switch ($name) {
|
||||||
case 'ABoardImportService.php':
|
case 'ABoardImportService.php':
|
||||||
case 'BoardImportService.php':
|
case 'BoardImportService.php':
|
||||||
case 'BoardImportCommandService.php':
|
case 'BoardImportCommandService.php':
|
||||||
@@ -177,6 +180,11 @@ class BoardImportService {
|
|||||||
return $this->systemInstance;
|
return $this->systemInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function insertAssignment($assignment): self {
|
||||||
|
$this->assignmentMapper->insert($assignment);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function importBoard() {
|
public function importBoard() {
|
||||||
$board = $this->getImportSystem()->getBoard();
|
$board = $this->getImportSystem()->getBoard();
|
||||||
if ($board) {
|
if ($board) {
|
||||||
|
|||||||
@@ -25,33 +25,19 @@ namespace OCA\Deck\Service;
|
|||||||
|
|
||||||
use OC\Comments\Comment;
|
use OC\Comments\Comment;
|
||||||
use OCA\Deck\Db\Acl;
|
use OCA\Deck\Db\Acl;
|
||||||
use OCA\Deck\Db\AclMapper;
|
|
||||||
use OCA\Deck\Db\Assignment;
|
use OCA\Deck\Db\Assignment;
|
||||||
use OCA\Deck\Db\AssignmentMapper;
|
use OCA\Deck\Db\AssignmentMapper;
|
||||||
use OCA\Deck\Db\Board;
|
use OCA\Deck\Db\Board;
|
||||||
use OCA\Deck\Db\Card;
|
use OCA\Deck\Db\Card;
|
||||||
use OCA\Deck\Db\CardMapper;
|
|
||||||
use OCA\Deck\Db\Label;
|
use OCA\Deck\Db\Label;
|
||||||
use OCA\Deck\Db\Stack;
|
use OCA\Deck\Db\Stack;
|
||||||
use OCA\Deck\Db\StackMapper;
|
|
||||||
use OCP\IDBConnection;
|
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
|
|
||||||
class BoardImportTrelloService extends ABoardImportService {
|
class BoardImportTrelloService extends ABoardImportService {
|
||||||
/** @var LabelService */
|
|
||||||
private $labelService;
|
|
||||||
/** @var StackMapper */
|
|
||||||
private $stackMapper;
|
|
||||||
/** @var CardMapper */
|
|
||||||
private $cardMapper;
|
|
||||||
/** @var AssignmentMapper */
|
/** @var AssignmentMapper */
|
||||||
private $assignmentMapper;
|
private $assignmentMapper;
|
||||||
/** @var AclMapper */
|
|
||||||
private $aclMapper;
|
|
||||||
/** @var IDBConnection */
|
|
||||||
private $connection;
|
|
||||||
/** @var IUserManager */
|
/** @var IUserManager */
|
||||||
private $userManager;
|
private $userManager;
|
||||||
/** @var IL10N */
|
/** @var IL10N */
|
||||||
@@ -75,22 +61,12 @@ class BoardImportTrelloService extends ABoardImportService {
|
|||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
BoardService $boardService,
|
BoardService $boardService,
|
||||||
LabelService $labelService,
|
|
||||||
StackMapper $stackMapper,
|
|
||||||
CardMapper $cardMapper,
|
|
||||||
AssignmentMapper $assignmentMapper,
|
AssignmentMapper $assignmentMapper,
|
||||||
AclMapper $aclMapper,
|
|
||||||
IDBConnection $connection,
|
|
||||||
IUserManager $userManager,
|
IUserManager $userManager,
|
||||||
IL10N $l10n
|
IL10N $l10n
|
||||||
) {
|
) {
|
||||||
$this->boardService = $boardService;
|
$this->boardService = $boardService;
|
||||||
$this->labelService = $labelService;
|
|
||||||
$this->stackMapper = $stackMapper;
|
|
||||||
$this->cardMapper = $cardMapper;
|
|
||||||
$this->assignmentMapper = $assignmentMapper;
|
$this->assignmentMapper = $assignmentMapper;
|
||||||
$this->aclMapper = $aclMapper;
|
|
||||||
$this->connection = $connection;
|
|
||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
}
|
}
|
||||||
@@ -221,11 +197,11 @@ class BoardImportTrelloService extends ABoardImportService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$trelloCard->desc .= "\n\n## {$this->l10n->t('Attachments')}\n";
|
$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 .= "| {$this->l10n->t('File')} | {$this->l10n->t('date')} |\n";
|
||||||
$trelloCard->desc .= "|---|---|---|\n";
|
$trelloCard->desc .= "|---|---\n";
|
||||||
foreach ($trelloCard->attachments as $attachment) {
|
foreach ($trelloCard->attachments as $attachment) {
|
||||||
$name = $attachment->name === $attachment->url ? null : $attachment->name;
|
$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;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -237,7 +213,7 @@ class BoardImportTrelloService extends ABoardImportService {
|
|||||||
$assignment->setCardId($this->cards[$trelloCard->id]->getId());
|
$assignment->setCardId($this->cards[$trelloCard->id]->getId());
|
||||||
$assignment->setParticipant($this->members[$idMember]->getUID());
|
$assignment->setParticipant($this->members[$idMember]->getUID());
|
||||||
$assignment->setType(Assignment::TYPE_USER);
|
$assignment->setType(Assignment::TYPE_USER);
|
||||||
$assignment = $this->assignmentMapper->insert($assignment);
|
$this->getImportService()->insertAssignment($assignment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace OCA\Deck\Command;
|
|||||||
use OCA\Deck\Command\ImportHelper\TrelloHelper;
|
use OCA\Deck\Command\ImportHelper\TrelloHelper;
|
||||||
use OCA\Deck\Service\AImportService;
|
use OCA\Deck\Service\AImportService;
|
||||||
use OCA\Deck\Service\BoardImportService;
|
use OCA\Deck\Service\BoardImportService;
|
||||||
use OCA\Deck\Service\BoardService;
|
|
||||||
use Symfony\Component\Console\Helper\HelperSet;
|
use Symfony\Component\Console\Helper\HelperSet;
|
||||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
|||||||
Reference in New Issue
Block a user