diff --git a/Installation/Action/oc.componentenCatalogusApplicationToGateway.action.json b/Installation/Action/oc.componentenCatalogusApplicationToGateway.action.json index 2af50473..770eb3b4 100644 --- a/Installation/Action/oc.componentenCatalogusApplicationToGateway.action.json +++ b/Installation/Action/oc.componentenCatalogusApplicationToGateway.action.json @@ -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"], @@ -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 } diff --git a/Installation/Action/oc.componentenCatalogusComponentToGateway.action.json b/Installation/Action/oc.componentenCatalogusComponentToGateway.action.json index a953f60a..b504b379 100644 --- a/Installation/Action/oc.componentenCatalogusComponentToGateway.action.json +++ b/Installation/Action/oc.componentenCatalogusComponentToGateway.action.json @@ -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"], @@ -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 } diff --git a/Installation/Action/oc.developerOverheidApiToGateway.action.json b/Installation/Action/oc.developerOverheidApiToGateway.action.json index 46883d1b..317be678 100644 --- a/Installation/Action/oc.developerOverheidApiToGateway.action.json +++ b/Installation/Action/oc.developerOverheidApiToGateway.action.json @@ -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"], @@ -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 } diff --git a/Installation/Action/oc.developerOverheidRepositoryToGateway.action.json b/Installation/Action/oc.developerOverheidRepositoryToGateway.action.json index 50e3159c..4e4d5283 100644 --- a/Installation/Action/oc.developerOverheidRepositoryToGateway.action.json +++ b/Installation/Action/oc.developerOverheidRepositoryToGateway.action.json @@ -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"], @@ -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 } diff --git a/Installation/Action/oc.enrichOrganization.action.json b/Installation/Action/oc.enrichOrganization.action.json new file mode 100644 index 00000000..b4050e81 --- /dev/null +++ b/Installation/Action/oc.enrichOrganization.action.json @@ -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" + } +} diff --git a/Installation/Action/oc.enrichPubliccode.action.json b/Installation/Action/oc.enrichPubliccode.action.json index c2d51167..ef1377a2 100644 --- a/Installation/Action/oc.enrichPubliccode.action.json +++ b/Installation/Action/oc.enrichPubliccode.action.json @@ -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": { @@ -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 } diff --git a/Installation/Action/oc.enrichPubliccodeFromGithubUrl.action.json b/Installation/Action/oc.enrichPubliccodeFromGithubUrl.action.json index 8a4d7a08..80a8a304 100644 --- a/Installation/Action/oc.enrichPubliccodeFromGithubUrl.action.json +++ b/Installation/Action/oc.enrichPubliccodeFromGithubUrl.action.json @@ -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": { @@ -19,5 +19,6 @@ "componentMapping": "https://api.github.com/oc.githubPubliccodeComponent.mapping.json", "memoryLimit": "2G", "maxResults": 100 - } + }, + "isEnabled": false } diff --git a/Installation/Action/oc.findOrganizationThroughRepositories.action.json b/Installation/Action/oc.findOrganizationThroughRepositories.action.json index a5bd50a0..6018c02c 100644 --- a/Installation/Action/oc.findOrganizationThroughRepositories.action.json +++ b/Installation/Action/oc.findOrganizationThroughRepositories.action.json @@ -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": { @@ -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 } diff --git a/Installation/Action/oc.formInput.action.json b/Installation/Action/oc.formInput.action.json index 4b70007f..45dfc2b8 100644 --- a/Installation/Action/oc.formInput.action.json +++ b/Installation/Action/oc.formInput.action.json @@ -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": { "==": [ diff --git a/Installation/Action/oc.githubApiGetPubliccodeRepositories.action.json b/Installation/Action/oc.githubApiGetPubliccodeRepositories.action.json index ebbb99fd..d66ef20c 100644 --- a/Installation/Action/oc.githubApiGetPubliccodeRepositories.action.json +++ b/Installation/Action/oc.githubApiGetPubliccodeRepositories.action.json @@ -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"], @@ -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 } diff --git a/Installation/Action/oc.githubEvent.action.json b/Installation/Action/oc.githubEvent.action.json index 1547e91d..e1b84d30 100644 --- a/Installation/Action/oc.githubEvent.action.json +++ b/Installation/Action/oc.githubEvent.action.json @@ -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": { "==": [ diff --git a/Installation/Action/oc.rating.action.json b/Installation/Action/oc.rating.action.json index e41de07a..481152dd 100644 --- a/Installation/Action/oc.rating.action.json +++ b/Installation/Action/oc.rating.action.json @@ -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": { @@ -14,5 +14,6 @@ "configuration": { "ratingSchema": "https://opencatalogi.nl/oc.rating.schema.json", "componentSchema": "https://opencatalogi.nl/oc.component.schema.json" - } + }, + "isEnabled": false } diff --git a/Installation/Mapping/oc.componentenCatalogusComponent.mapping.json b/Installation/Mapping/oc.componentenCatalogusComponent.mapping.json index bb95668c..43a7e0a4 100644 --- a/Installation/Mapping/oc.componentenCatalogusComponent.mapping.json +++ b/Installation/Mapping/oc.componentenCatalogusComponent.mapping.json @@ -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", @@ -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" } } diff --git a/Installation/Mapping/oc.developerOverheidComponent.mapping.json b/Installation/Mapping/oc.developerOverheidComponent.mapping.json index e11baf1a..1642e15e 100644 --- a/Installation/Mapping/oc.developerOverheidComponent.mapping.json +++ b/Installation/Mapping/oc.developerOverheidComponent.mapping.json @@ -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", @@ -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" } } diff --git a/Installation/Mapping/oc.githubOrganisation.mapping.json b/Installation/Mapping/oc.githubOrganisation.mapping.json index 502340f4..ed1b5dec 100644 --- a/Installation/Mapping/oc.githubOrganisation.mapping.json +++ b/Installation/Mapping/oc.githubOrganisation.mapping.json @@ -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", @@ -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" } } \ No newline at end of file diff --git a/Installation/Mapping/oc.githubRepository.mapping.json b/Installation/Mapping/oc.githubRepository.mapping.json index 16fe4239..e1d63966 100644 --- a/Installation/Mapping/oc.githubRepository.mapping.json +++ b/Installation/Mapping/oc.githubRepository.mapping.json @@ -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", @@ -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" } } diff --git a/src/ActionHandler/EnrichOrganizationHandler.php b/src/ActionHandler/EnrichOrganizationHandler.php new file mode 100644 index 00000000..f53f40c1 --- /dev/null +++ b/src/ActionHandler/EnrichOrganizationHandler.php @@ -0,0 +1,85 @@ +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 diff --git a/src/Service/EnrichOrganizationService.php b/src/Service/EnrichOrganizationService.php new file mode 100644 index 00000000..02810b19 --- /dev/null +++ b/src/Service/EnrichOrganizationService.php @@ -0,0 +1,171 @@ +entityManager = $entityManager; + $this->pluginLogger = $pluginLogger; + $this->resourceService = $resourceService; + $this->githubApiService = $githubApiService; + + $this->configuration = []; + $this->data = []; + + }//end __construct() + + + /** + * This function gets all the repositories from the given organization and sets it to the owns of the organization. + * + * @param ObjectEntity $organization Catalogi organization https://opencatalogi.nl/oc.organisation.schema.json + * + * @throws GuzzleException|Exception + * + * @return ObjectEntity + */ + public function enrichOrganization(ObjectEntity $organization): ObjectEntity + { + // Get the github api source. + $source = $this->resourceService->getSource($this->configuration['githubSource'], 'open-catalogi/open-catalogi-bundle'); + if ($source === null + || $this->githubApiService->checkGithubAuth($source) === false + ) { + return $organization; + }//end if + + // Get the path of the github url. + $githubPath = \Safe\parse_url($organization->getValue('github'))['path']; + + // Get the organization from the github api. + $organizationArray = $this->githubApiService->getOrganization(trim($githubPath, '/'), $source); + + // If we get an empty string we set the description from the github api. + if ($organization->getValue('description') !== false + || $organization->getValue('description') !== null + ) { + $organization->hydrate(['description' => $organizationArray['description']]); + $this->entityManager->persist($organization); + $this->entityManager->flush(); + } + + $this->pluginLogger->debug($organization->getName().' succesfully updated the organization with a description.'); + + return $organization; + + }//end enrichOrganization() + + + /** + * Makes sure the action the action can actually runs and then executes functions to update an organization with fetched opencatalogi.yaml info. + * + * @param ?array $data data set at the start of the handler (not needed here) + * @param ?array $configuration configuration of the action (not needed here) + * + * @throws GuzzleException|Exception + * + * @return array|null dataset at the end of the handler (not needed here) + */ + public function enrichOrganizationHandler(?array $data=[], ?array $configuration=[], ?string $organizationId=null): ?array + { + $this->configuration = $configuration; + $this->data = $data; + + // Get the response. + try { + $response = json_decode($this->data['response']->getContent(), true); + } catch (Exception $exception) { + $this->pluginLogger->error('Cannot get the response.'); + } + + if (isset($response) === false) { + return $this->data; + } + + // Get the organization object. + $organization = $this->entityManager->find('App:ObjectEntity', $response['_self']['id']); + + // Check if the name and github is not null. + if ($organization instanceof ObjectEntity === true + && $organization->getValue('name') !== null + && $organization->getValue('github') !== null + ) { + // Enrich the organization object. + $this->enrichOrganization($organization); + }//end if + + if ($organization instanceof ObjectEntity === false) { + $this->pluginLogger->error('Could not find given organization'); + + return $this->data; + }//end if + + return $this->data; + + }//end enrichOrganizationHandler() + + +}//end class diff --git a/src/Service/GithubApiService.php b/src/Service/GithubApiService.php index d40398bb..4f0ab223 100644 --- a/src/Service/GithubApiService.php +++ b/src/Service/GithubApiService.php @@ -247,17 +247,17 @@ public function cleanupRepository(ObjectEntity $repository): ?ObjectEntity * * @return ObjectEntity */ - public function enrichWithOrganization(ObjectEntity $repository, array $organizationArray, Source $source): ObjectEntity + public function enrichWithOrganization(ObjectEntity $repository, array $repositoryArray, Source $source): ObjectEntity { $organizationSchema = $this->resourceService->getSchema('https://opencatalogi.nl/oc.organisation.schema.json', 'open-catalogi/open-catalogi-bundle'); - $organizationSync = $this->syncService->findSyncBySource($source, $organizationSchema, $organizationArray['html_url']); + $organizationSync = $this->syncService->findSyncBySource($source, $organizationSchema, $repositoryArray['owner']['html_url']); if ($organizationSync->getObject() === null) { $organizationMapping = $this->resourceService->getMapping('https://api.github.com/oc.githubOrganisation.mapping.json', 'open-catalogi/open-catalogi-bundle'); $organizationSync->setMapping($organizationMapping); - $organizationSync = $this->syncService->synchronize($organizationSync, $organizationArray); + $organizationSync = $this->syncService->synchronize($organizationSync, $repositoryArray['owner']); $this->entityManager->persist($organizationSync); } @@ -308,8 +308,7 @@ public function enrichRepository(ObjectEntity $repository, array $repositoryArra { // If there is no organization create one. if ($repository->getValue('organisation') === false) { - $organizationArray = $this->getOrganization($repositoryArray['owner']['login'], $source); - $repository = $this->enrichWithOrganization($repository, $organizationArray, $source); + $repository = $this->enrichWithOrganization($repository, $repositoryArray, $source); } // If there is no component create one. @@ -351,6 +350,8 @@ public function getConnectedComponents(ObjectEntity $organization, array $openca // Get the github repository from the given url if the object is null. if ($repositorySync->getObject() === null) { + $this->entityManager->remove($repositorySync); + $this->entityManager->flush(); $repository = $this->getGithubRepository($repositoryUrl); } @@ -409,6 +410,8 @@ public function getConnectedComponents(ObjectEntity $organization, array $openca // Get the github repository from the given url if the object is null. if ($repositorySync->getObject() === null) { + $this->entityManager->remove($repositorySync); + $this->entityManager->flush(); $repository = $this->getGithubRepository($repositoryUrl); } @@ -486,29 +489,6 @@ public function enrichOpencatalogiOrg(array $opencatalogiArray, array $opencatal $organization->hydrate(['logo' => $opencatalogiArray['repository']['owner']['avatar_url']]); } - // If the opencatalogi description is set to null or false we set the organization description to null. - if (key_exists('description', $opencatalogi) === true - && $opencatalogi['description'] === false - || key_exists('description', $opencatalogi) === true - && $opencatalogi['description'] === null - ) { - $organization->hydrate(['description' => null]); - } - - // If we get an empty string we set the description from the github api. - if (key_exists('description', $opencatalogi) === true - && $opencatalogi['description'] === '' - ) { - $organizationArray = $this->getOrganization($opencatalogiArray['repository']['owner']['login'], $source); - $organization->hydrate(['description' => $organizationArray['description']]); - } - - // If we don't get a opencatalogi description we set the description from the github api. - if (key_exists('description', $opencatalogi) === false) { - $organizationArray = $this->getOrganization($opencatalogiArray['repository']['owner']['login'], $source); - $organization->hydrate(['description' => $organizationArray['description']]); - } - return $organization; }//end enrichOpencatalogiOrg() @@ -691,7 +671,7 @@ public function handlePubliccodeFile(array $publiccodeArray, Source $source, Obj if ($this->syncService->doesShaMatch($componentSync, $urlReference) === true) { $componentSync->getObject()->hydrate(['url' => $repository]); - $this->entityManager->persist($component); + $this->entityManager->persist($componentSync->getObject()); $this->entityManager->flush(); return $repository; @@ -742,8 +722,6 @@ public function importRepoFiles(array $dataArray, Source $source, ObjectEntity $ ]; // Loop through the array of publiccode/opencatalogi files. - $opencatalogiUrls = []; - $publiccodeUrls = []; foreach ($dataArray as $item) { // Check if the item name is the same as the openCatalogiNames array. // If so go the the function for the opencatalogi file.