Skip to content

Commit

Permalink
Merge pull request #1751 from griidc/release/6.68.0
Browse files Browse the repository at this point in the history
Release/6.68.0
  • Loading branch information
mickel1138 authored Jan 21, 2025
2 parents ac1c756 + 79fa943 commit b3743a9
Show file tree
Hide file tree
Showing 11 changed files with 359 additions and 258 deletions.
2 changes: 1 addition & 1 deletion assets/js/vue/components/search/Facet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<span class="float-right badge badge-light round">{{
facet.count
}}</span>
{{ facet.shortName ? facet.shortName : facet.name }}
{{ facetName.queryParam === 'researchGroup' ? facet.name : facet.shortName ? facet.shortName : facet.name }}
</span>
</label>
</div>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/core": "^7.26.0",
"@babel/preset-env": "7.26.0",
"@babel/preset-react": "^7.26.3",
"@fortawesome/fontawesome-free": "^5.11.1",
"@hotwired/stimulus": "^3.0.0",
"@symfony/stimulus-bridge": "^3.0.0",
"@symfony/stimulus-bridge": "^3.2.3",
"@symfony/webpack-encore": "^4.6.1",
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
"@vue/babel-preset-jsx": "^1.1.2",
"autoprefixer": "^9.7.4",
"core-js": "^3.0.0",
"core-js": "^3.40.0",
"eslint": "^7.29.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-import-resolver-alias": "^1.1.2",
Expand Down
111 changes: 111 additions & 0 deletions src/Controller/Api/ReportController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace App\Controller\Api;

use App\Entity\FundingOrganization;
use App\Entity\ResearchGroup;
use App\Repository\FundingOrganizationRepository;
use App\Repository\ResearchGroupRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;

class ReportController extends AbstractController
{
#[Route(path: '/api/grp-datasets-people-report', name: 'pelagos_api_grp_datasets_people_report', methods: ['GET'])]
public function getGrpDatasetAndPeopleReport(ResearchGroupRepository $researchGroupRepository, FundingOrganizationRepository $fundingOrganizationRepository, SerializerInterface $serialzer): Response
{
$fundingOrganization = $fundingOrganizationRepository->findOneBy(['shortName' => 'NAS']);

$researchGroupIds = [];
if ($fundingOrganization instanceof FundingOrganization) {
foreach ($fundingOrganization->getFundingCycles() as $fundingCycle) {
foreach ($fundingCycle->getResearchGroups() as $researchGroup) {
$researchGroupIds[] = $researchGroup->getId();
}
}
}

$researchGroups = $researchGroupRepository->findBy(['id' => $researchGroupIds], ['name' => 'ASC']);

usort($researchGroups, function (ResearchGroup $a, ResearchGroup $b) {
return $a->getFundingCycle()->getName() <=> $b->getFundingCycle()->getName();
});

$data = $serialzer->serialize(
$researchGroups,
'csv',
[
'groups' => 'grp-dp-report',
'csv_headers' => [
'fundingCycle.name',
'ResearchGroupName',
'approvedDifsCount',
'submittedDatasets',
'availableDatasets',
'restrictedDataset',
'peopleCount',
],
'output_utf8_bom' => true,
]
);

$csvFilename = 'GRP-Datasets-People-Report-' .
(new \DateTime('now'))->format('Ymd\THis') .
'.csv';

$response = new Response($data);

$response->headers->set(
'Content-disposition',
HeaderUtils::makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $csvFilename)
);
$response->headers->set('Content-Type', 'text/csv; charset=UTF-8');
$response->headers->set('Content-Encoding', 'UTF-8');

return $response;
}

#[Route(path: '/api/grp-datasets-keywords-report', name: 'pelagos_api_grp_datasets_keywords_report', methods: ['GET'])]
public function getGrpDatasetAndKeywordsReport(FundingOrganizationRepository $fundingOrganizationRepository, SerializerInterface $serialzer): Response
{
$fundingOrganization = $fundingOrganizationRepository->findOneBy(['shortName' => 'NAS']);

$datasets = $fundingOrganization->getDatasets();

$data = $serialzer->serialize(
$datasets,
'csv',
[
'groups' => 'grp-dk-report',
'csv_headers' => [
'researchGroup.fundingCycle.name',
'researchGroup.ResearchGroupName',
'udi',
'title',
'doi',
],
'output_utf8_bom' => true,
'enable_max_depth' => true,
]
);

$csvFilename = 'GRP-Dataset-Keywords-Report-' .
(new \DateTime('now'))->format('Ymd\THis') .
'.csv';

$response = new Response($data);

$response->headers->set(
'Content-disposition',
HeaderUtils::makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $csvFilename)
);
$response->headers->set('Content-Type', 'text/csv; charset=UTF-8');
$response->headers->set('Content-Encoding', 'UTF-8');

return $response;
}
}
2 changes: 2 additions & 0 deletions src/Entity/DOI.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Attribute\Groups;

/**
* DOI Entity class.
Expand Down Expand Up @@ -38,6 +39,7 @@ class DOI extends Entity
*/
#[ORM\Column(type: 'text', nullable: false)]
#[Serializer\Groups(['doi'])]
#[Groups(['grp-dk-report'])]
protected $doi;

/**
Expand Down
128 changes: 124 additions & 4 deletions src/Entity/Dataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
namespace App\Entity;

use App\Enum\DatasetLifecycleStatus;
use App\Enum\KeywordType;
use App\Util\DatasetCitationUtil;
use App\Util\GenerateUrl;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Attribute\MaxDepth;
use Symfony\Component\Serializer\Attribute\SerializedName;

/**
* Dataset Entity class.
Expand Down Expand Up @@ -93,6 +99,7 @@ class Dataset extends Entity
*/
#[ORM\Column(type: 'text', nullable: true)]
#[Serializer\Groups(['card', 'search'])]
#[Groups(['grp-dk-report'])]
protected $udi;

/**
Expand All @@ -102,6 +109,7 @@ class Dataset extends Entity
*/
#[ORM\Column(type: 'text', nullable: true)]
#[Serializer\Groups(['card', 'search'])]
#[Groups(['grp-dk-report'])]
protected $title;

/**
Expand Down Expand Up @@ -131,6 +139,8 @@ class Dataset extends Entity
#[ORM\ManyToOne(targetEntity: 'ResearchGroup', inversedBy: 'datasets')]
#[Serializer\MaxDepth(1)]
#[Serializer\Groups(['search'])]
#[Groups(['grp-dk-report'])]
#[MaxDepth(1)]
protected $researchGroup;

/**
Expand Down Expand Up @@ -342,7 +352,7 @@ public function setDatasetSubmission(DatasetSubmission $datasetSubmission)
*
* @return DatasetSubmission
*/
public function getDatasetSubmission()
public function getDatasetSubmission(): ?DatasetSubmission
{
return $this->datasetSubmission;
}
Expand Down Expand Up @@ -439,14 +449,22 @@ public function setDoi(DOI $doi)

/**
* Get the DOI for this Dataset.
*
* @return DOI
*/
public function getDoi()
public function getDoi(): ?DOI
{
return $this->doi;
}

/**
* Get the DOI string for this Dataset.
*/
#[Groups(['grp-dk-report'])]
#[SerializedName('doi')]
public function getDoiString(): string
{
return $this->getDoi()?->getDoi() ?? '';
}

/**
* Set the identified status.
*
Expand Down Expand Up @@ -1084,4 +1102,106 @@ public function getDatasetLifecycleStatus(): DatasetLifecycleStatus

return $datasetLifeCycleStatus;
}

/**
* Get Dataset Lifecycle Status as a string.
*/
#[Groups(['grp-dk-report'])]
#[SerializedName('datasetLifecycleStatus')]
public function getDatasetLifecycleStatusString(): string
{
return $this->getDatasetLifecycleStatus()->value;
}

/**
* Get a link to the dataset landing page.
*/
#[Groups(['grp-dk-report'])]
public function getLandingPage(): string
{
return 'https://grp.griidc.org/data/' . $this->getUdi();
}

/**
* Get ANZRC keys as a string.
*/
#[Groups(['grp-dk-report'])]
public function getAnzrcKeywords(): ?string
{
$keywords = $this->getKeywordsByType(KeywordType::TYPE_ANZSRC);

if ($keywords instanceof Collection) {
$keywords = $keywords->map(
function (Keyword $keyword) {
return $keyword->getLabel();
}
);
}

return implode(',', $keywords?->toArray() ?? []);
}

/**
* Get ANZRC keys as a string.
*/
#[Groups(['grp-dk-report'])]
public function getGcmdKeywords(): ?string
{
$keywords = $this->getKeywordsByType(KeywordType::TYPE_GCMD);

if ($keywords instanceof Collection) {
$keywords = $keywords->map(
function (Keyword $keyword) {
return $keyword->getLabel();
}
);
}

return implode(',', $keywords?->toArray() ?? []);
}

/**
* Get theme keywords as string.
*/
#[Groups(['grp-dk-report'])]
public function getThemeKeywords(): ?string
{
$keywords = $this->getDatasetSubmission()?->getThemeKeywords();

return implode(',', $keywords ?? []);
}

/**
* Get place keywords as string.
*/
#[Groups(['grp-dk-report'])]
public function getPlaceKeywords(): ?string
{
$keywords = $this->getDatasetSubmission()?->getPlaceKeywords();

return implode(',', $keywords ?? []);
}

/**
* Get topic keywords as string.
*/
#[Groups(['grp-dk-report'])]
public function getTopicKeywords(): ?string
{
$keywords = $this->getDatasetSubmission()?->getTopicKeywords();

return implode(',', $keywords ?? []);
}

/**
* Key keywords by type.
*/
private function getKeywordsByType(KeywordType $type): ?Collection
{
$keywords = $this->getDatasetSubmission()?->getKeywords();

return $keywords = $keywords?->filter(function (Keyword $keyword) use ($type) {
return $keyword->getType() === $type;
});
}
}
4 changes: 4 additions & 0 deletions src/Entity/FundingCycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Attribute\MaxDepth;
use Symfony\Component\Validator\Constraints as Assert;

/**
Expand All @@ -34,6 +36,7 @@ class FundingCycle extends Entity
#[ORM\Column(type: 'citext')]
#[Serializer\Groups(['organization'])]
#[Assert\NotBlank(message: 'Name is required')]
#[Groups(['grp-dp-report', 'grp-dk-report'])]
protected $name;

/**
Expand Down Expand Up @@ -89,6 +92,7 @@ class FundingCycle extends Entity
#[ORM\OneToMany(targetEntity: 'ResearchGroup', mappedBy: 'fundingCycle')]
#[ORM\OrderBy(['name' => 'ASC'])]
#[Serializer\MaxDepth(2)]
#[MaxDepth(1)]
protected $researchGroups;

/**
Expand Down
Loading

0 comments on commit b3743a9

Please sign in to comment.