Skip to content

Commit

Permalink
Merge pull request #159 from OpenCatalogi/feature/OP/fixes
Browse files Browse the repository at this point in the history
Pr naar main
  • Loading branch information
smisidjan authored Nov 16, 2023
2 parents 403ddde + 773f2c8 commit 0fd365d
Show file tree
Hide file tree
Showing 19 changed files with 371 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Componenten Catalogus Application To Gateway",
"$id": "https://opencatalogi.nl/action/oc.ComponentenCatalogusApplicationToGatewayAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.4",
"version": "0.0.5",
"priority": 1,
"isLockable": true,
"listens": ["opencatalogi.bronnen.trigger"],
Expand All @@ -24,5 +24,6 @@
"repositorySchema": "https://opencatalogi.nl/oc.repository.schema.json",
"repositoryEndpoint": "/repositories",
"repositoryMapping": "https://api.github.com/oc.githubRepository.mapping.json"
}
},
"isEnabled": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Componenten Catalogus Component To Gateway",
"$id": "https://opencatalogi.nl/action/oc.ComponentenCatalogusComponentToGatewayAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.4",
"version": "0.0.5",
"priority": 1,
"isLockable": true,
"listens": ["opencatalogi.bronnen.trigger"],
Expand All @@ -22,5 +22,6 @@
"repositorySchema": "https://opencatalogi.nl/oc.repository.schema.json",
"repositoryEndpoint": "/repositories",
"repositoryMapping": "https://api.github.com/oc.githubRepository.mapping.json"
}
},
"isEnabled": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Developer Overheid Api To Gateway Action",
"$id": "https://opencatalogi.nl/action/oc.DeveloperOverheidApiToGatewayAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.4",
"version": "0.0.5",
"priority": 1,
"isLockable": true,
"listens": ["opencatalogi.bronnen.trigger"],
Expand All @@ -22,5 +22,6 @@
"repositorySchema": "https://opencatalogi.nl/oc.repository.schema.json",
"repositoryEndpoint": "/repositories",
"repositoryMapping": "https://api.github.com/oc.githubRepository.mapping.json"
}
},
"isEnabled": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Developer Overheid Repository To Gateway Action",
"$id": "https://opencatalogi.nl/action/oc.DeveloperOverheidRepositoryToGatewayAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.4",
"version": "0.0.5",
"priority": 1,
"isLockable": true,
"listens": ["opencatalogi.bronnen.trigger"],
Expand All @@ -17,5 +17,6 @@
"source": "https://opencatalogi.nl/source/oc.developerOverheid.source.json",
"repositorySchema": "https://opencatalogi.nl/oc.repository.schema.json",
"endpoint": "/repositories"
}
},
"isEnabled": false
}
20 changes: 20 additions & 0 deletions Installation/Action/oc.enrichOrganization.action.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"title": "Enrich Organization Action",
"$id": "https://opencatalogi.nl/action/oc.enrichOrganization.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.1",
"async": true,
"priority": 2,
"listens": ["opencatalogi.enrich.organization"],
"class": "OpenCatalogi\\OpenCatalogiBundle\\ActionHandler\\EnrichOrganizationHandler",
"conditions": {
"==": [
1,
1
]
},
"configuration": {
"githubSource": "https://opencatalogi.nl/source/oc.GitHubAPI.source.json",
"organizationSchema": "https://opencatalogi.nl/oc.organisation.schema.json"
}
}
7 changes: 4 additions & 3 deletions Installation/Action/oc.enrichPubliccode.action.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Enrich Publiccode",
"$id": "https://opencatalogi.nl/action/oc.EnrichPubliccodeAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.2",
"version": "0.0.3",
"listens": ["opencatalogi.default.listens"],
"class": "OpenCatalogi\\OpenCatalogiBundle\\ActionHandler\\EnrichPubliccodeHandler",
"conditions": {
Expand All @@ -15,6 +15,7 @@
"githubSource": "https://opencatalogi.nl/source/oc.GitHubAPI.source.json",
"repositorySchema": "https://opencatalogi.nl/oc.repository.schema.json",
"componentSchema": "https://opencatalogi.nl/oc.component.schema.json",
"componentMapping": "https://api.github.com/oc.githubPubliccodeComponent.mapping.json",
}
"componentMapping": "https://api.github.com/oc.githubPubliccodeComponent.mapping.json"
},
"isEnabled": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Enrich Publiccode From Github Url Action",
"$id": "https://opencatalogi.nl/action/oc.EnrichPubliccodeFromGithubUrlAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.2",
"version": "0.0.3",
"listens": ["opencatalogi.default.listens"],
"class": "OpenCatalogi\\OpenCatalogiBundle\\ActionHandler\\EnrichPubliccodeFromGithubUrlHandler",
"conditions": {
Expand All @@ -19,5 +19,6 @@
"componentMapping": "https://api.github.com/oc.githubPubliccodeComponent.mapping.json",
"memoryLimit": "2G",
"maxResults": 100
}
},
"isEnabled": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Find Organization Through Repositories Action",
"$id": "https://opencatalogi.nl/action/oc.FindOrganizationThroughRepositoriesAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.2",
"version": "0.0.3",
"listens": ["opencatalogi.default.listens"],
"class": "OpenCatalogi\\OpenCatalogiBundle\\ActionHandler\\FindOrganizationThroughRepositoriesHandler",
"conditions": {
Expand All @@ -18,5 +18,6 @@
"organisationSchema": "https://opencatalogi.nl/oc.organisation.schema.json",
"componentSchema": "https://opencatalogi.nl/oc.component.schema.json",
"organisationMapping": "https://api.github.com/oc.githubOrganisation.mapping.json"
}
},
"isEnabled": false
}
6 changes: 5 additions & 1 deletion Installation/Action/oc.formInput.action.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"title": "Form Input Action",
"$id": "https://opencatalogi.nl/action/oc.formInput.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.1",
"version": "0.0.2",
"priority": 1,
"listens": [
"opencatalogi.form.trigger"
],
"throws": [
"opencatalogi.enrich.organization"
],
"class": "OpenCatalogi\\OpenCatalogiBundle\\ActionHandler\\FormInputHandler",
"conditions": {
"==": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Github Api Get Publiccode Repositories Action",
"$id": "https://opencatalogi.nl/action/oc.GithubApiGetPubliccodeRepositoriesAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.4",
"version": "0.0.5",
"priority": 2,
"isLockable": true,
"listens": ["opencatalogi.bronnen.trigger"],
Expand All @@ -18,5 +18,6 @@
"repositorySchema": "https://opencatalogi.nl/oc.repository.schema.json",
"repositoryMapping": "https://api.github.com/oc.githubRepository.mapping.json",
"repositoriesMapping": "https://api.github.com/oc.githubPubliccodeRepository.mapping.json"
}
},
"isEnabled": false
}
6 changes: 5 additions & 1 deletion Installation/Action/oc.githubEvent.action.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"title": "Github Event Action",
"$id": "https://opencatalogi.nl/action/oc.GithubEventAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.3",
"version": "0.0.4",
"priority": 1,
"listens": [
"opencatalogi.githubevents.trigger"
],
"throws": [
"opencatalogi.enrich.organization"
],
"class": "OpenCatalogi\\OpenCatalogiBundle\\ActionHandler\\GithubEventHandler",
"conditions": {
"==": [
Expand Down
5 changes: 3 additions & 2 deletions Installation/Action/oc.rating.action.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Rating Action",
"$id": "https://opencatalogi.nl/action/oc.RatingAction.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.2",
"version": "0.0.3",
"listens": ["opencatalogi.rating.handler"],
"class": "OpenCatalogi\\OpenCatalogiBundle\\ActionHandler\\RatingHandler",
"conditions": {
Expand All @@ -14,5 +14,6 @@
"configuration": {
"ratingSchema": "https://opencatalogi.nl/oc.rating.schema.json",
"componentSchema": "https://opencatalogi.nl/oc.component.schema.json"
}
},
"isEnabled": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "ComponentenCatalogusComponentToOpenCatalogiComponent",
"$id": "https://componentencatalogus.commonground.nl/api/oc.componentenCatalogusComponent.mapping.json",
"$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json",
"version": "0.0.3",
"version": "0.0.4",
"passTrough": false,
"mapping": {
"name": "name",
Expand All @@ -16,5 +16,18 @@
"developmentStatus": "status",
"url.url": "repositoryUrl",
"url.name": "name"
},
"cast": {
"name": "keyCantBeValue",
"description.localisedName": "unsetIfValue==name",
"description.shortDescription": "unsetIfValue==description",
"description.longDescription": "unsetIfValue==description",
"legal.repoOwner.name": "unsetIfValue==owner.fullName",
"legal.repoOwner.email": "unsetIfValue==owner.email",
"nl.commonground.layerType": "unsetIfValue==",
"landingURL": "unsetIfValue==repositoryUrl",
"developmentStatus": "unsetIfValue==status",
"url.url": "unsetIfValue==repositoryUrl",
"url.name": "unsetIfValue==name"
}
}
16 changes: 15 additions & 1 deletion Installation/Mapping/oc.developerOverheidComponent.mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "DeveloperOverheidApisToComponent",
"$id": "https://developer.overheid.nl/api/oc.developerOverheidComponent.mapping.json",
"$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json",
"version": "0.0.2",
"version": "0.0.3",
"passTrough": false,
"mapping": {
"name": "service_name",
Expand All @@ -17,5 +17,19 @@
"legal.repoOwner.phone": "contact.phone",
"legal.repoOwner.website": "contact.url",
"legal.repoOwner.type": "Organization"
},
"cast": {
"name": "unsetIfValue==service_name",
"softwareType": "unsetIfValue==api",
"description.localisedName": "unsetIfValue==service_name",
"description.shortDescription": "unsetIfValue==description",
"description.longDescription": "unsetIfValue==description",
"description.documentation": "unsetIfValue==environments.0.documentation_url",
"description.apiDocumentation": "unsetIfValue==environments.0.specification_url",
"legal.repoOwner.name": "unsetIfValue==organization.name",
"legal.repoOwner.email": "unsetIfValue==contact.email",
"legal.repoOwner.phone": "unsetIfValue==contact.phone",
"legal.repoOwner.website": "unsetIfValue==contact.url",
"legal.repoOwner.type": "unsetIfValue==Organization"
}
}
11 changes: 10 additions & 1 deletion Installation/Mapping/oc.githubOrganisation.mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "GithubApiOrganisationToOrganisation",
"$id": "https://api.github.com/oc.githubOrganisation.mapping.json",
"$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json",
"version": "0.0.2",
"version": "0.0.3",
"passTrough": false,
"mapping": {
"name": "login",
Expand All @@ -12,5 +12,14 @@
"email": "email",
"source": "github",
"type": "type"
},
"cast": {
"name": "unsetIfValue==login",
"description": "keyCantBeValue",
"logo": "unsetIfValue==avatar_url",
"github": "unsetIfValue==html_url",
"email": "keyCantBeValue",
"source": "unsetIfValue==github",
"type": "keyCantBeValue"
}
}
10 changes: 9 additions & 1 deletion Installation/Mapping/oc.githubRepository.mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "GithubApiToRepository",
"$id": "https://api.github.com/oc.githubRepository.mapping.json",
"$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json",
"version": "0.0.3",
"version": "0.0.4",
"passTrough": false,
"mapping": {
"name": "name",
Expand All @@ -16,6 +16,14 @@
"archived": "{% if archived|default %}{{ archived }}{% else %}false{% endif %}"
},
"cast": {
"name": "keyCantBeValue",
"url": "unsetIfValue==html_url",
"last_change": "unsetIfValue==updated_at",
"stars": "unsetIfValue==stargazers_count",
"fork_count": "unsetIfValue==forks_count",
"issue_open_count": "unsetIfValue==open_issues_count",
"source": "unsetIfValue==github",
"forked_from": "unsetIfValue==",
"archived": "boolean"
}
}
Expand Down
85 changes: 85 additions & 0 deletions src/ActionHandler/EnrichOrganizationHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace OpenCatalogi\OpenCatalogiBundle\ActionHandler;

use CommonGateway\CoreBundle\ActionHandler\ActionHandlerInterface;
use OpenCatalogi\OpenCatalogiBundle\Service\EnrichOrganizationService;
use OpenCatalogi\OpenCatalogiBundle\Service\FindGithubRepositoryThroughOrganizationService;
use OpenCatalogi\OpenCatalogiBundle\Service\GithubApiService;

/**
* Executes a the EnrichOrganizationHandler and gets an organization from the response of the githubEventAction and formInputAction
* and enriches the organization.
*/
class EnrichOrganizationHandler implements ActionHandlerInterface
{

/**
* @var EnrichOrganizationService
*/
private EnrichOrganizationService $service;


/**
* @param EnrichOrganizationService $service The EnrichOrganizationService
*/
public function __construct(EnrichOrganizationService $service)
{
$this->service = $service;

}//end __construct()


/**
* This function returns the required configuration as a [json-schema](https://json-schema.org/) array.
*
* @return array a [json-schema](https://json-schema.org/) that this action should comply to
*/
public function getConfiguration()
{
return [
'$id' => 'https://opencatalogi.nl/ActionHandler/EnrichOrganizationHandler.ActionHandler.json',
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json',
'title' => 'EnrichOrganizationHandler',
'description' => 'This handler enriches the organizations',
'required' => [
'githubSource',
'organizationSchema',
],
'properties' => [
'githubSource' => [
'type' => 'string',
'description' => 'The source of the github api.',
'example' => 'https://opencatalogi.nl/source/oc.GitHubAPI.source.json',
'reference' => 'https://opencatalogi.nl/source/oc.GitHubAPI.source.json',
'required' => true,
],
'organizationSchema' => [
'type' => 'string',
'description' => 'The organisation schema.',
'example' => 'https://opencatalogi.nl/oc.organisation.schema.json',
'reference' => 'https://opencatalogi.nl/oc.organisation.schema.json',
'required' => true,
],
],
];

}//end getConfiguration()


/**
* This function runs the enrich organization service plugin.
*
* @param array $data The data from the call
* @param array $configuration The configuration of the action
*
* @return array
*/
public function run(array $data, array $configuration): array
{
return $this->service->enrichOrganizationHandler($data, $configuration);

}//end run()


}//end class
Loading

0 comments on commit 0fd365d

Please sign in to comment.