-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adds test for the tag-unscanned job * adds a test for when the unscanned tag is disabled * adds a test for the wontscan tag --------- Co-authored-by: Simonis, Matthias <[email protected]> (cherry picked from commit 49b9f62)
- Loading branch information
1 parent
fd01dc1
commit 27d1e59
Showing
5 changed files
with
166 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace OCA\GDataVaas\Command; | ||
|
||
use OCA\GDataVaas\Logging\ConsoleCommandLogger; | ||
use OCP\Files\IRootFolder; | ||
use OCP\SystemTag\ISystemTagManager; | ||
use OCP\SystemTag\ISystemTagObjectMapper; | ||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class GetTagsForFileCommand extends Command { | ||
public const FILE_PATH = 'file-path'; | ||
|
||
private LoggerInterface $logger; | ||
private IRootFolder $rootFolder; | ||
private ISystemTagObjectMapper $systemTagObjectMapper; | ||
private ISystemTagManager $tagManager; | ||
|
||
public function __construct(LoggerInterface $logger, IRootFolder $rootFolder, ISystemTagObjectMapper $systemTagObjectMapper, ISystemTagManager $tagManager) { | ||
parent::__construct(); | ||
|
||
$this->logger = $logger; | ||
$this->rootFolder = $rootFolder; | ||
$this->systemTagObjectMapper = $systemTagObjectMapper; | ||
$this->tagManager = $tagManager; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function configure() { | ||
$this->setName('gdatavaas:get-tags-for-file'); | ||
$this->setDescription('get tags for file'); | ||
|
||
$this->addArgument(self::FILE_PATH, InputArgument::REQUIRED, "path to file (username/files/filename)"); | ||
} | ||
|
||
/** | ||
* @param $argument | ||
* @return void | ||
* @throws \OCP\DB\Exception if the database platform is not supported | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int { | ||
$logger = new ConsoleCommandLogger($this->logger, $output); | ||
|
||
$filePath = $input->getArgument('file-path'); | ||
|
||
$node = $this->rootFolder->get($filePath); | ||
$tagIds = $this->systemTagObjectMapper->getTagIdsForObjects($node->getId(), 'files'); | ||
foreach ($tagIds[$node->getId()] as $tagId) { | ||
$tags = $this->tagManager->getTagsByIds([$tagId]); | ||
foreach ($tags as $tag) { | ||
$logger->info("tag: ".$tag->getName()); | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters