Skip to content

Commit

Permalink
Merge pull request #10 from OpenCatalogi/feature/componentencatalogus
Browse files Browse the repository at this point in the history
Github api, componentencatalogus and developer.overheid bronnen
  • Loading branch information
WilcoLouwerse authored Jan 27, 2023
2 parents dc60802 + 323c6be commit c5fbd23
Show file tree
Hide file tree
Showing 20 changed files with 836 additions and 252 deletions.
27 changes: 18 additions & 9 deletions Command/ComponentenCatalogusGetApplicationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace OpenCatalogi\OpenCatalogiBundle\Command;

use OpenCatalogi\OpenCatalogiBundle\Service\FindGithubRepositoryThroughOrganizationService;
use OpenCatalogi\OpenCatalogiBundle\Service\ComponentenCatalogusService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

Expand All @@ -14,28 +15,36 @@
class ComponentenCatalogusGetApplicationsCommand extends Command
{
protected static $defaultName = 'opencatalogi:componentencatalogus:applications';
private FindGithubRepositoryThroughOrganizationService $findGithubRepositoryThroughOrganizationService;
private ComponentenCatalogusService $componentenCatalogusService;

public function __construct(FindGithubRepositoryThroughOrganizationService $findGithubRepositoryThroughOrganizationService)
public function __construct(ComponentenCatalogusService $componentenCatalogusService)
{
$this->findGithubRepositoryThroughOrganizationService = $findGithubRepositoryThroughOrganizationService;
$this->componentenCatalogusService = $componentenCatalogusService;
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription('This command triggers OpenCatalogi FindGithubRepositoryThroughOrganizationService')
->setHelp('This command allows you to update a organizations with found opencatalogi.yml info');
->setDescription('This command triggers OpenCatalogi ComponentenCatalogusService')
->setHelp('This command allows you to get all applications or one application from componentencatalogus.commonground.nl/api/products')
->addOption('application', 'a', InputOption::VALUE_OPTIONAL, 'Get a single application by id');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$this->findGithubRepositoryThroughOrganizationService->setStyle($io);
$this->componentenCatalogusService->setStyle($io);

$this->findGithubRepositoryThroughOrganizationService->findGithubRepositoryThroughOrganizationHandler();
// Handle the command optiosn
$applicationId = $input->getOption('application', false);

return 0;
if (!$applicationId) {
$this->componentenCatalogusService->getApplications();
} elseif (!$this->componentenCatalogusService->getApplication($applicationId)) {
return Command::FAILURE;
}

return Command::SUCCES;
}
}
27 changes: 18 additions & 9 deletions Command/ComponentenCatalogusGetComponentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace OpenCatalogi\OpenCatalogiBundle\Command;

use OpenCatalogi\OpenCatalogiBundle\Service\FindGithubRepositoryThroughOrganizationService;
use OpenCatalogi\OpenCatalogiBundle\Service\ComponentenCatalogusService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

Expand All @@ -14,28 +15,36 @@
class ComponentenCatalogusGetComponentsCommand extends Command
{
protected static $defaultName = 'opencatalogi:componentencatalogus:components';
private FindGithubRepositoryThroughOrganizationService $findGithubRepositoryThroughOrganizationService;
private ComponentenCatalogusService $componentenCatalogusService;

public function __construct(FindGithubRepositoryThroughOrganizationService $findGithubRepositoryThroughOrganizationService)
public function __construct(ComponentenCatalogusService $componentenCatalogusService)
{
$this->findGithubRepositoryThroughOrganizationService = $findGithubRepositoryThroughOrganizationService;
$this->componentenCatalogusService = $componentenCatalogusService;
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription('This command triggers OpenCatalogi FindGithubRepositoryThroughOrganizationService')
->setHelp('This command allows you to update a organizations with found opencatalogi.yml info');
->setDescription('This command triggers OpenCatalogi ComponentenCatalogusService')
->setHelp('This command allows you to get all components or one component from componentencatalogus.commonground.nl/api/components')
->addOption('component', 'c', InputOption::VALUE_OPTIONAL, 'Get a single component by id');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$this->findGithubRepositoryThroughOrganizationService->setStyle($io);
$this->componentenCatalogusService->setStyle($io);

$this->findGithubRepositoryThroughOrganizationService->findGithubRepositoryThroughOrganizationHandler();
// Handle the command optiosn
$componentId = $input->getOption('component', false);

return 0;
if (!$componentId) {
$this->componentenCatalogusService->getComponents();
} elseif (!$this->componentenCatalogusService->getComponent($componentId)) {
return Command::FAILURE;
}

return Command::SUCCES;
}
}
2 changes: 1 addition & 1 deletion Command/DeveloperOverheidGetComponentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function configure(): void
$this
->setDescription('This command triggers OpenCatalogi DeveloperOverheidService')
->setHelp('This command allows you to get all components or one component from developer.overheid.nl/apis')
->addOption('component', 'c', InputOption::VALUE_OPTIONAL, 'Get a single component by id or name');
->addOption('component', 'c', InputOption::VALUE_OPTIONAL, 'Get a single component by id');
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
2 changes: 1 addition & 1 deletion Command/DeveloperOverheidGetRepositoriesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function configure(): void
$this
->setDescription('This command triggers OpenCatalogi DeveloperOverheidService')
->setHelp('This command allows you to get all repositories or one repository from developer.overheid.nl/repositories')
->addOption('repository', 'r', InputOption::VALUE_OPTIONAL, 'Get a single repository by id or name');
->addOption('repository', 'r', InputOption::VALUE_OPTIONAL, 'Get a single repository by id');
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
4 changes: 2 additions & 2 deletions Command/FederalizationGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function configure(): void
$this
->setDescription('This command gets al or a single catalogi from the federalized network')
->setHelp('This command allows you to run further installation an configuration actions afther installing a plugin')
->addOption('catalogus', 'c', InputOption::VALUE_OPTIONAL, 'Get a singe catalogue by id or name');
->addOption('catalogus', 'c', InputOption::VALUE_OPTIONAL, 'Get a single catalogue by id or name');
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down Expand Up @@ -55,6 +55,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->federalizationService->readCatalogus($catalogusObject);
}

return 0;
return Command::SUCCES;
}
}
6 changes: 3 additions & 3 deletions Command/FederalizationRegisterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function configure(): void
$this
->setDescription('This command gets al or a single catalogi from the federalized network')
->setHelp('This command allows you to run further installation an configuration actions afther installing a plugin')
->addOption('catalogus', 'c', InputOption::VALUE_OPTIONAL, 'Get a singe catalogue by id or name');
->addOption('catalogus', 'c', InputOption::VALUE_OPTIONAL, 'Get a single catalogue by id or name');
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand All @@ -50,11 +50,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (!$catalogusObject) {
$io->error('Could not find object entity by id or name '.$catalogusId);

return 1;
return Command::FAILURE;
}
$this->federalizationService->readCatalogus($catalogusObject);
}

return 0;
return Command::SUCCES;
}
}
51 changes: 51 additions & 0 deletions Command/GithubApiGetPubliccodeRepositoriesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace OpenCatalogi\OpenCatalogiBundle\Command;

use OpenCatalogi\OpenCatalogiBundle\Service\GithubPubliccodeService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

/**
* Command to execute the GithubService.
*/
class GithubApiGetPubliccodeRepositoriesCommand extends Command
{
// the name of the command (the part after "bin/console")
protected static $defaultName = 'opencatalogi:githubapi:repositories';
private GithubPubliccodeService $githubPubliccodeService;

public function __construct(GithubPubliccodeService $githubPubliccodeService)
{
$this->githubPubliccodeService = $githubPubliccodeService;
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription('This command triggers OpenCatalogi GithubPubliccodeService')
->setHelp('This command allows you to get all repositories or one repository from https://api.github.com/search/code')
->addOption('repository', 'r', InputOption::VALUE_OPTIONAL, 'Get a single repository by id');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$this->githubPubliccodeService->setStyle($io);

// Handle the command optiosn
$repositoryId = $input->getOption('repository', false);

if (!$repositoryId) {
$this->githubPubliccodeService->getRepositories();
} elseif (!$this->githubPubliccodeService->getRepository($repositoryId)) {
return Command::FAILURE;
}

return Command::SUCCES;
}
}
2 changes: 1 addition & 1 deletion Command/GithubFindPublicodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->findGithubRepositoryThroughOrganizationService->findGithubRepositoryThroughOrganizationHandler();

return 0;
return Command::SUCCES;
}
}
2 changes: 1 addition & 1 deletion Command/GithubOrganizationThroughRepositoryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->findGithubRepositoryThroughOrganizationService->findGithubRepositoryThroughOrganizationHandler();

return 0;
return Command::SUCCES;
}
}
2 changes: 1 addition & 1 deletion Command/GithubPublicodeFromReproCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->findGithubRepositoryThroughOrganizationService->findGithubRepositoryThroughOrganizationHandler();

return 0;
return Command::SUCCES;
}
}
2 changes: 1 addition & 1 deletion Command/GithubRepositoryThroughOrganizationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->findGithubRepositoryThroughOrganizationService->findGithubRepositoryThroughOrganizationHandler();

return 0;
return Command::SUCCES;
}
}
2 changes: 1 addition & 1 deletion Command/PublicCodeRatingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->findGithubRepositoryThroughOrganizationService->findGithubRepositoryThroughOrganizationHandler();

return 0;
return Command::SUCCES;
}
}
34 changes: 34 additions & 0 deletions Mapping/ComponentenCatalogusComponentToOpenCatalogiComponent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"title": "ComponentenCatalogusComponentToOpenCatalogiComponent",
"$id": "https://componentencatalogus.commonground.nl/api/components",
"$schema": "https://json-schema.org/draft/2020-12/mapping",
"version": "0.0.1",
"passTrough": false,
"mapping": {
"name": "{{ name }}",
"description.localisedName": "{{ name }}",
"description.shortDescription": "{{ description }}",
"description.longDescription": "{{ description }}",
"legal.repoOwner.name": "{{ owner.fullName }}",
"legal.repoOwner.email": "{{ owner.email }}",
"nl.commonground.layerType": "{{ layerType }}",
"landingURL": "{{ repositoryUrl }}",
"developmentStatus": "{{ status }}",
"url.url": "{{ repositoryUrl }}",
"url.organisation.name": "{{ organisationName }}"
},
"unset": [
"layerType",
"owner",
"status",
"expectedQuarter",
"expectedYear",
"developedBy",
"createdAt",
"reuseType",
"organisationName",
"repositoryUrl",
"contact"
],
"cast": []
}
2 changes: 1 addition & 1 deletion Mapping/DeveloperOverheidApistoComponent.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "DeveloperOverheidApisToComponent",
"$id": "https://developer.overheid.nl/api/components",
"$schema": "https://json-schema.org/draft/2020-12/maping",
"$schema": "https://json-schema.org/draft/2020-12/mapping",
"version": "0.0.1",
"passTrough": false,
"mapping": {
Expand Down
25 changes: 25 additions & 0 deletions Mapping/GithubApiPubliccodeRepositoryToRepository.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"title": "DeveloperOverheidApisToComponent",
"$id": "https://api.github.com/search/code",
"$schema": "https://json-schema.org/draft/2020-12/mapping",
"version": "0.0.1",
"passTrough": false,
"mapping": {
"name": "{{ repository.name }}",
"url": "{{ repository.html_url }}",
"publiccode_url": "{{ html_url }}",
"organisation.name": "{{ repository.owner.login }}",
"organisation.logo": "{{ repository.owner.avatar_url }}",
"organisation.github": "{{ repository.owner.url }}",
"organisation.type": "{{ repository.owner.type }}"
},
"unset": [
"path",
"sha",
"git_url",
"html_url",
"score",
"repository"
],
"cast": []
}
Loading

0 comments on commit c5fbd23

Please sign in to comment.