Skip to content

Commit 79fa943

Browse files
committed
Merge branch 'develop' into release/6.68.0
2 parents ac1c756 + 7fd5ce1 commit 79fa943

File tree

11 files changed

+359
-258
lines changed

11 files changed

+359
-258
lines changed

assets/js/vue/components/search/Facet.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<span class="float-right badge badge-light round">{{
9393
facet.count
9494
}}</span>
95-
{{ facet.shortName ? facet.shortName : facet.name }}
95+
{{ facetName.queryParam === 'researchGroup' ? facet.name : facet.shortName ? facet.shortName : facet.name }}
9696
</span>
9797
</label>
9898
</div>

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"devDependencies": {
3-
"@babel/core": "^7.24.4",
3+
"@babel/core": "^7.26.0",
44
"@babel/preset-env": "7.26.0",
55
"@babel/preset-react": "^7.26.3",
66
"@fortawesome/fontawesome-free": "^5.11.1",
77
"@hotwired/stimulus": "^3.0.0",
8-
"@symfony/stimulus-bridge": "^3.0.0",
8+
"@symfony/stimulus-bridge": "^3.2.3",
99
"@symfony/webpack-encore": "^4.6.1",
1010
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
1111
"@vue/babel-preset-jsx": "^1.1.2",
1212
"autoprefixer": "^9.7.4",
13-
"core-js": "^3.0.0",
13+
"core-js": "^3.40.0",
1414
"eslint": "^7.29.0",
1515
"eslint-config-airbnb-base": "^15.0.0",
1616
"eslint-import-resolver-alias": "^1.1.2",
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
3+
namespace App\Controller\Api;
4+
5+
use App\Entity\FundingOrganization;
6+
use App\Entity\ResearchGroup;
7+
use App\Repository\FundingOrganizationRepository;
8+
use App\Repository\ResearchGroupRepository;
9+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
10+
use Symfony\Component\HttpFoundation\HeaderUtils;
11+
use Symfony\Component\HttpFoundation\Response;
12+
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
13+
use Symfony\Component\Routing\Attribute\Route;
14+
use Symfony\Component\Serializer\SerializerInterface;
15+
16+
class ReportController extends AbstractController
17+
{
18+
#[Route(path: '/api/grp-datasets-people-report', name: 'pelagos_api_grp_datasets_people_report', methods: ['GET'])]
19+
public function getGrpDatasetAndPeopleReport(ResearchGroupRepository $researchGroupRepository, FundingOrganizationRepository $fundingOrganizationRepository, SerializerInterface $serialzer): Response
20+
{
21+
$fundingOrganization = $fundingOrganizationRepository->findOneBy(['shortName' => 'NAS']);
22+
23+
$researchGroupIds = [];
24+
if ($fundingOrganization instanceof FundingOrganization) {
25+
foreach ($fundingOrganization->getFundingCycles() as $fundingCycle) {
26+
foreach ($fundingCycle->getResearchGroups() as $researchGroup) {
27+
$researchGroupIds[] = $researchGroup->getId();
28+
}
29+
}
30+
}
31+
32+
$researchGroups = $researchGroupRepository->findBy(['id' => $researchGroupIds], ['name' => 'ASC']);
33+
34+
usort($researchGroups, function (ResearchGroup $a, ResearchGroup $b) {
35+
return $a->getFundingCycle()->getName() <=> $b->getFundingCycle()->getName();
36+
});
37+
38+
$data = $serialzer->serialize(
39+
$researchGroups,
40+
'csv',
41+
[
42+
'groups' => 'grp-dp-report',
43+
'csv_headers' => [
44+
'fundingCycle.name',
45+
'ResearchGroupName',
46+
'approvedDifsCount',
47+
'submittedDatasets',
48+
'availableDatasets',
49+
'restrictedDataset',
50+
'peopleCount',
51+
],
52+
'output_utf8_bom' => true,
53+
]
54+
);
55+
56+
$csvFilename = 'GRP-Datasets-People-Report-' .
57+
(new \DateTime('now'))->format('Ymd\THis') .
58+
'.csv';
59+
60+
$response = new Response($data);
61+
62+
$response->headers->set(
63+
'Content-disposition',
64+
HeaderUtils::makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $csvFilename)
65+
);
66+
$response->headers->set('Content-Type', 'text/csv; charset=UTF-8');
67+
$response->headers->set('Content-Encoding', 'UTF-8');
68+
69+
return $response;
70+
}
71+
72+
#[Route(path: '/api/grp-datasets-keywords-report', name: 'pelagos_api_grp_datasets_keywords_report', methods: ['GET'])]
73+
public function getGrpDatasetAndKeywordsReport(FundingOrganizationRepository $fundingOrganizationRepository, SerializerInterface $serialzer): Response
74+
{
75+
$fundingOrganization = $fundingOrganizationRepository->findOneBy(['shortName' => 'NAS']);
76+
77+
$datasets = $fundingOrganization->getDatasets();
78+
79+
$data = $serialzer->serialize(
80+
$datasets,
81+
'csv',
82+
[
83+
'groups' => 'grp-dk-report',
84+
'csv_headers' => [
85+
'researchGroup.fundingCycle.name',
86+
'researchGroup.ResearchGroupName',
87+
'udi',
88+
'title',
89+
'doi',
90+
],
91+
'output_utf8_bom' => true,
92+
'enable_max_depth' => true,
93+
]
94+
);
95+
96+
$csvFilename = 'GRP-Dataset-Keywords-Report-' .
97+
(new \DateTime('now'))->format('Ymd\THis') .
98+
'.csv';
99+
100+
$response = new Response($data);
101+
102+
$response->headers->set(
103+
'Content-disposition',
104+
HeaderUtils::makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $csvFilename)
105+
);
106+
$response->headers->set('Content-Type', 'text/csv; charset=UTF-8');
107+
$response->headers->set('Content-Encoding', 'UTF-8');
108+
109+
return $response;
110+
}
111+
}

src/Entity/DOI.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\ORM\Mapping as ORM;
66
use JMS\Serializer\Annotation as Serializer;
7+
use Symfony\Component\Serializer\Attribute\Groups;
78

89
/**
910
* DOI Entity class.
@@ -38,6 +39,7 @@ class DOI extends Entity
3839
*/
3940
#[ORM\Column(type: 'text', nullable: false)]
4041
#[Serializer\Groups(['doi'])]
42+
#[Groups(['grp-dk-report'])]
4143
protected $doi;
4244

4345
/**

src/Entity/Dataset.php

Lines changed: 124 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
namespace App\Entity;
44

55
use App\Enum\DatasetLifecycleStatus;
6+
use App\Enum\KeywordType;
67
use App\Util\DatasetCitationUtil;
8+
use App\Util\GenerateUrl;
79
use Doctrine\Common\Collections\ArrayCollection;
810
use Doctrine\Common\Collections\Collection;
911
use Doctrine\ORM\Mapping as ORM;
1012
use JMS\Serializer\Annotation as Serializer;
13+
use Symfony\Component\Routing\RouterInterface;
14+
use Symfony\Component\Serializer\Attribute\Groups;
15+
use Symfony\Component\Serializer\Attribute\MaxDepth;
16+
use Symfony\Component\Serializer\Attribute\SerializedName;
1117

1218
/**
1319
* Dataset Entity class.
@@ -93,6 +99,7 @@ class Dataset extends Entity
9399
*/
94100
#[ORM\Column(type: 'text', nullable: true)]
95101
#[Serializer\Groups(['card', 'search'])]
102+
#[Groups(['grp-dk-report'])]
96103
protected $udi;
97104

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

107115
/**
@@ -131,6 +139,8 @@ class Dataset extends Entity
131139
#[ORM\ManyToOne(targetEntity: 'ResearchGroup', inversedBy: 'datasets')]
132140
#[Serializer\MaxDepth(1)]
133141
#[Serializer\Groups(['search'])]
142+
#[Groups(['grp-dk-report'])]
143+
#[MaxDepth(1)]
134144
protected $researchGroup;
135145

136146
/**
@@ -342,7 +352,7 @@ public function setDatasetSubmission(DatasetSubmission $datasetSubmission)
342352
*
343353
* @return DatasetSubmission
344354
*/
345-
public function getDatasetSubmission()
355+
public function getDatasetSubmission(): ?DatasetSubmission
346356
{
347357
return $this->datasetSubmission;
348358
}
@@ -439,14 +449,22 @@ public function setDoi(DOI $doi)
439449

440450
/**
441451
* Get the DOI for this Dataset.
442-
*
443-
* @return DOI
444452
*/
445-
public function getDoi()
453+
public function getDoi(): ?DOI
446454
{
447455
return $this->doi;
448456
}
449457

458+
/**
459+
* Get the DOI string for this Dataset.
460+
*/
461+
#[Groups(['grp-dk-report'])]
462+
#[SerializedName('doi')]
463+
public function getDoiString(): string
464+
{
465+
return $this->getDoi()?->getDoi() ?? '';
466+
}
467+
450468
/**
451469
* Set the identified status.
452470
*
@@ -1084,4 +1102,106 @@ public function getDatasetLifecycleStatus(): DatasetLifecycleStatus
10841102

10851103
return $datasetLifeCycleStatus;
10861104
}
1105+
1106+
/**
1107+
* Get Dataset Lifecycle Status as a string.
1108+
*/
1109+
#[Groups(['grp-dk-report'])]
1110+
#[SerializedName('datasetLifecycleStatus')]
1111+
public function getDatasetLifecycleStatusString(): string
1112+
{
1113+
return $this->getDatasetLifecycleStatus()->value;
1114+
}
1115+
1116+
/**
1117+
* Get a link to the dataset landing page.
1118+
*/
1119+
#[Groups(['grp-dk-report'])]
1120+
public function getLandingPage(): string
1121+
{
1122+
return 'https://grp.griidc.org/data/' . $this->getUdi();
1123+
}
1124+
1125+
/**
1126+
* Get ANZRC keys as a string.
1127+
*/
1128+
#[Groups(['grp-dk-report'])]
1129+
public function getAnzrcKeywords(): ?string
1130+
{
1131+
$keywords = $this->getKeywordsByType(KeywordType::TYPE_ANZSRC);
1132+
1133+
if ($keywords instanceof Collection) {
1134+
$keywords = $keywords->map(
1135+
function (Keyword $keyword) {
1136+
return $keyword->getLabel();
1137+
}
1138+
);
1139+
}
1140+
1141+
return implode(',', $keywords?->toArray() ?? []);
1142+
}
1143+
1144+
/**
1145+
* Get ANZRC keys as a string.
1146+
*/
1147+
#[Groups(['grp-dk-report'])]
1148+
public function getGcmdKeywords(): ?string
1149+
{
1150+
$keywords = $this->getKeywordsByType(KeywordType::TYPE_GCMD);
1151+
1152+
if ($keywords instanceof Collection) {
1153+
$keywords = $keywords->map(
1154+
function (Keyword $keyword) {
1155+
return $keyword->getLabel();
1156+
}
1157+
);
1158+
}
1159+
1160+
return implode(',', $keywords?->toArray() ?? []);
1161+
}
1162+
1163+
/**
1164+
* Get theme keywords as string.
1165+
*/
1166+
#[Groups(['grp-dk-report'])]
1167+
public function getThemeKeywords(): ?string
1168+
{
1169+
$keywords = $this->getDatasetSubmission()?->getThemeKeywords();
1170+
1171+
return implode(',', $keywords ?? []);
1172+
}
1173+
1174+
/**
1175+
* Get place keywords as string.
1176+
*/
1177+
#[Groups(['grp-dk-report'])]
1178+
public function getPlaceKeywords(): ?string
1179+
{
1180+
$keywords = $this->getDatasetSubmission()?->getPlaceKeywords();
1181+
1182+
return implode(',', $keywords ?? []);
1183+
}
1184+
1185+
/**
1186+
* Get topic keywords as string.
1187+
*/
1188+
#[Groups(['grp-dk-report'])]
1189+
public function getTopicKeywords(): ?string
1190+
{
1191+
$keywords = $this->getDatasetSubmission()?->getTopicKeywords();
1192+
1193+
return implode(',', $keywords ?? []);
1194+
}
1195+
1196+
/**
1197+
* Key keywords by type.
1198+
*/
1199+
private function getKeywordsByType(KeywordType $type): ?Collection
1200+
{
1201+
$keywords = $this->getDatasetSubmission()?->getKeywords();
1202+
1203+
return $keywords = $keywords?->filter(function (Keyword $keyword) use ($type) {
1204+
return $keyword->getType() === $type;
1205+
});
1206+
}
10871207
}

src/Entity/FundingCycle.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Doctrine\ORM\Mapping as ORM;
1010
use JMS\Serializer\Annotation as Serializer;
1111
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
12+
use Symfony\Component\Serializer\Attribute\Groups;
13+
use Symfony\Component\Serializer\Attribute\MaxDepth;
1214
use Symfony\Component\Validator\Constraints as Assert;
1315

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

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

9498
/**

0 commit comments

Comments
 (0)