Skip to content

Commit 27eef00

Browse files
authored
Merge pull request #1765 from CSCfi/CSCTTV-3252
CSCTTV-3252
2 parents 9ee7825 + c1cd1d8 commit 27eef00

File tree

6 files changed

+212
-248
lines changed

6 files changed

+212
-248
lines changed

src/app/portal/components/single/single-publication/single-publication.component.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ export class SinglePublicationComponent
4242
implements OnInit, AfterViewInit, OnDestroy
4343
{
4444
public singleId: any;
45+
4546
responseData: Search;
4647
searchTerm: string;
4748
pageNumber: any;
4849
tab = 'publications';
4950
tabQueryParams: any;
51+
5052
private metaTags = MetaTags.singlePublication;
5153
private commonTags = MetaTags.common;
54+
5255
showMore = $localize`:@@showMore:Näytä enemmän`;
5356
showLess = $localize`:@@showLess:Näytä vähemmän`;
5457

@@ -542,7 +545,9 @@ export class SinglePublicationComponent
542545

543546
// Reset authors & organizations on new result
544547
this.authorAndOrganization = [];
548+
545549
const publication = this.responseData.publications[0];
550+
546551
if (publication) {
547552
switch (this.localeId) {
548553
case 'fi': {
@@ -558,13 +563,17 @@ export class SinglePublicationComponent
558563
break;
559564
}
560565
}
566+
561567
const titleString = this.utilityService.getTitle();
568+
562569
this.srHeader.nativeElement.innerHTML = titleString?.split(' - ', 1);
570+
563571
this.utilityService.addMeta(
564572
titleString,
565573
this.metaTags['description' + this.currentLocale],
566574
this.commonTags['imgAlt' + this.currentLocale]
567575
);
576+
568577
// juFoCode is used for exact search
569578
this.juFoCode = publication.jufoCode;
570579
this.shapeData();
@@ -781,9 +790,12 @@ export class SinglePublicationComponent
781790
organizations: this.authorAndOrganization.map((item) => item.orgId),
782791
};
783792

784-
source.internationalCollaboration = source.internationalCollaboration
785-
? $localize`:@@yes:Kyllä`
786-
: $localize`:@@no:Ei`;
793+
source.internationalCollaboration =
794+
source.internationalCollaboration === "1"
795+
? $localize`:@@yes:Kyllä`
796+
: source.internationalCollaboration === "0"
797+
? $localize`:@@no:Ei`
798+
: $localize`@@unknown:Ei tiedossa`;
787799

788800
source.internationalPublication =
789801
source.internationalPublication === 1
@@ -792,9 +804,12 @@ export class SinglePublicationComponent
792804
? $localize`:@@finland:Kotimainen`
793805
: '';
794806

795-
source.businessCollaboration = source.businessCollaboration
796-
? $localize`:@@yes:Kyllä`
797-
: $localize`:@@no:Ei`;
807+
source.businessCollaboration =
808+
source.businessCollaboration === "1"
809+
? $localize`:@@yes:Kyllä`
810+
: source.businessCollaboration === "0"
811+
? $localize`:@@no:Ei`
812+
: $localize`@@unknown:Ei tiedossa`;
798813

799814
// Get & set publication type label
800815
if (

src/app/portal/models/publication/publication.model.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ export class PublicationAdapter implements Adapter<Publication> {
129129
let archiveCodeText = '';
130130
if (item.selfArchivedCode === 1) {
131131
archiveCodeText = $localize`:@@yes:Kyllä`;
132-
} else {
132+
} else if (item.selfArchivedCode === 0) {
133133
archiveCodeText = $localize`:@@no:Ei`;
134+
} else {
135+
archiveCodeText = $localize`:@@unknown:Ei tiedossa`;
134136
}
135137

136138
let articleTypeText = '';

src/app/portal/services/filters/aggregation.service.ts

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,12 @@ export class AggregationService {
8181
if (!disableFiltering) {
8282
// Open access aggregations come from 3 different aggs and need special case for filters
8383
if (field === 'openAccess') {
84-
const filteredActive = active.filter(
85-
(item) =>
86-
Object.keys(item.bool.should[0].term)?.toString() !==
87-
'openAccessCode' &&
88-
Object.keys(item.bool.should[0].term)?.toString() !==
89-
'selfArchivedCode'
90-
);
91-
return filteredActive.concat(
92-
activeFiltered,
93-
activeNested,
94-
activeMultipleNested,
95-
coPublication ? coPublicationFilter : []
84+
const filteredActive = active.filter((item) =>
85+
Object.keys(item.bool.should[0].term)?.toString() !== 'openAccessCode' &&
86+
Object.keys(item.bool.should[0].term)?.toString() !== 'selfArchivedCode'
9687
);
88+
89+
return filteredActive.concat(activeFiltered, activeNested, activeMultipleNested, coPublication ? coPublicationFilter : []);
9790
} else {
9891
return active
9992
.filter(
@@ -533,7 +526,7 @@ export class AggregationService {
533526
aggs: {
534527
internationalCollaborationCodes: {
535528
terms: {
536-
field: 'internationalCollaboration',
529+
field: 'internationalCollaboration.keyword',
537530
size: 2,
538531
},
539532
},
@@ -602,7 +595,7 @@ export class AggregationService {
602595
aggs: {
603596
selfArchivedCodes: {
604597
terms: {
605-
field: 'selfArchivedCode',
598+
field: 'selfArchivedCode.keyword', // TODO will .keyword work even if nulls exists
606599
},
607600
},
608601
},
@@ -628,7 +621,7 @@ export class AggregationService {
628621
{
629622
selfArchived: {
630623
terms: {
631-
field: 'selfArchivedCode',
624+
field: 'selfArchivedCode.keyword',
632625
},
633626
},
634627
},
@@ -653,29 +646,11 @@ export class AggregationService {
653646
};
654647
payLoad.aggs.oaPublisherComposite = {
655648
composite: {
656-
size: 20,
649+
size: 1000,
657650
sources: [
658-
{
659-
openAccess: {
660-
terms: {
661-
field: 'openAccess',
662-
},
663-
},
664-
},
665-
{
666-
publisherOpenAccess: {
667-
terms: {
668-
field: 'publisherOpenAccessCode',
669-
},
670-
},
671-
},
672-
{
673-
selfArchived: {
674-
terms: {
675-
field: 'selfArchivedCode',
676-
},
677-
},
678-
},
651+
{ openAccess: { terms: { field: 'openAccess', }, }, },
652+
{ publisherOpenAccess: { terms: { field: 'publisherOpenAccessCode', }, }, },
653+
{ selfArchived: { terms: { field: 'selfArchivedCode.keyword' } } }
679654
],
680655
},
681656
aggs: {

src/app/portal/services/filters/filter.service.ts

Lines changed: 76 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class FilterService {
7373
fundingAmountFilter: string[];
7474
openAccessFilter: string[];
7575
internationalCollaborationFilter: {
76-
term: { internationalCollaboration: boolean | undefined };
76+
term: { internationalCollaboration: string | undefined };
7777
};
7878
okmDataCollectionFilter: string[];
7979
coPublicationFilter: string[];
@@ -591,7 +591,7 @@ export class FilterService {
591591

592592
filterByOpenAccess(code: string[]) {
593593
const res = [];
594-
if (code.includes('openAccess')) {
594+
if (code.includes('openAccess')) { // TODO 52012 vs 52012
595595
res.push({
596596
bool: {
597597
must: [
@@ -601,20 +601,12 @@ export class FilterService {
601601
},
602602
});
603603
}
604-
if (code.includes('otherOpen')) {
605-
res.push({
606-
bool: {
607-
must: [
608-
{ term: { openAccess: 0 } },
609-
{ term: { publisherOpenAccessCode: 2 } },
610-
],
611-
},
612-
});
613-
}
604+
614605
if (code.includes('selfArchived')) {
615-
res.push({ term: { selfArchivedCode: 1 } });
606+
res.push({ term: { selfArchivedCode: "1" } }); // TODO 64399 vs 64400
616607
}
617-
if (code.includes('delayedOpenAccess')) {
608+
609+
if (code.includes('delayedOpenAccess')) { // TODO 188 vs 188
618610
[0, 1].forEach((val) => {
619611
res.push({
620612
bool: {
@@ -626,12 +618,38 @@ export class FilterService {
626618
});
627619
});
628620
}
629-
if (code.includes('nonOpenAccess')) {
621+
622+
/*if (code.includes('otherOpen')) { // TODO 5890 vs 479
623+
res.push({
624+
bool: {
625+
must: [
626+
{ term: { openAccess: 0 } },
627+
{ term: { publisherOpenAccessCode: 2 } },
628+
],
629+
},
630+
});
631+
}*/
632+
633+
if (code.includes('otherOpen')) { // TODO 5890 vs 5890
634+
res.push({
635+
bool: {
636+
must_not: [
637+
{ term: { selfArchivedCode: '1' } }
638+
],
639+
filter: [
640+
{ term: { openAccess: 1 } },
641+
{ term: { publisherOpenAccessCode: 2 } }
642+
]
643+
}
644+
});
645+
}
646+
647+
/*if (code.includes('nonOpenAccess')) { // TODO 147 361 vs 143 004
630648
[0, 1, 2, 9].forEach((val) => {
631649
res.push({
632650
bool: {
633651
must: [
634-
{ term: { selfArchivedCode: 0 } },
652+
{ term: { selfArchivedCode: "0" } },
635653
{ term: { openAccess: 0 } },
636654
{ term: { publisherOpenAccessCode: val } },
637655
],
@@ -641,14 +659,51 @@ export class FilterService {
641659
res.push({
642660
bool: {
643661
must: [
644-
{ term: { selfArchivedCode: 0 } },
662+
{ term: { selfArchivedCode: "0" } },
645663
{ term: { openAccess: 1 } },
646664
{ term: { publisherOpenAccessCode: 0 } },
647665
],
648666
},
649667
});
668+
}*/
669+
670+
if (code.includes('nonOpenAccess')) { // TODO 147361 vs 147361
671+
res.push({
672+
bool: {
673+
must_not: [
674+
{ term: { selfArchivedCode: '1' } }
675+
],
676+
should: [
677+
{
678+
bool: {
679+
filter: [
680+
{ term: { openAccess: 0 } },
681+
{
682+
bool: {
683+
must_not: [
684+
{ term: { publisherOpenAccessCode: 3 } }
685+
]
686+
}
687+
}
688+
]
689+
}
690+
},
691+
{
692+
bool: {
693+
filter: [
694+
{ term: { openAccess: 1 } },
695+
{ term: { publisherOpenAccessCode: 0 } }
696+
]
697+
}
698+
}
699+
],
700+
minimum_should_match: 1
701+
}
702+
});
650703
}
651-
if (code.includes('noOpenAccessData')) {
704+
705+
706+
if (code.includes('noOpenAccessData')) { // TODO None appears
652707
const q = { bool: { must_not: [] } };
653708
const known = [
654709
[0, 0],
@@ -660,6 +715,7 @@ export class FilterService {
660715
[1, 2],
661716
[1, 3],
662717
];
718+
663719
known.forEach((pair) =>
664720
q.bool.must_not.push({
665721
bool: {
@@ -672,12 +728,13 @@ export class FilterService {
672728
);
673729
res.push(q);
674730
}
731+
675732
return res;
676733
}
677734

678735
filterByInternationalCollaboration(status: any) {
679736
if (status.length > 0 && JSON.parse(status)) {
680-
return { term: { internationalCollaboration: true } };
737+
return { term: { internationalCollaboration: "1" } };
681738
} else {
682739
return undefined;
683740
}

0 commit comments

Comments
 (0)