Skip to content

Commit

Permalink
Fix for DSpace#1602 Insufficient collection information when submitti…
Browse files Browse the repository at this point in the history
…ng an article
  • Loading branch information
im-shubham-vish authored and im-shubham-vish committed Dec 10, 2024
1 parent dcea3ba commit c62c0af
Show file tree
Hide file tree
Showing 13 changed files with 508 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -37,6 +46,52 @@ const parent = Object.assign(new Collection(), {
},
});

describe('JournalIssueSidebarSearchListElementComponent',
createSidebarSearchListElementTests(JournalIssueSidebarSearchListElementComponent, object, parent, 'parent title', 'title', '5 - 7'),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('JournalIssueSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(
JournalIssueSidebarSearchListElementComponent,
object,
parent,
hierarchicalTitle,
'title',
'1234, 5678',
);
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -40,6 +49,45 @@ const parent = Object.assign(new Collection(), {
},
});

describe('JournalVolumeSidebarSearchListElementComponent',
createSidebarSearchListElementTests(JournalVolumeSidebarSearchListElementComponent, object, parent, 'parent title', 'title', 'journal title (1) (2)'),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('JournalVolumeSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(JournalVolumeSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', 'journal title (1) (2)');
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import {
catchError,
map,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -35,6 +45,48 @@ const parent = Object.assign(new Collection(), {
},
});

describe('JournalSidebarSearchListElementComponent',
createSidebarSearchListElementTests(JournalSidebarSearchListElementComponent, object, parent, 'parent title', 'title', '1234, 5678'),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
if (remoteData.payload) {
return fetchParentTitles(remoteData.payload);
}
}
return of([]);
}),
catchError(() => of([])),
map(() => titles),
);
}
};

if (fetchParentTitles(currentParent)) {
return fetchParentTitles(currentParent).pipe(
map(() => titles.join(' > ')),
);
}
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('JournalSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(JournalSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', '1234, 5678');
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -37,6 +46,45 @@ const parent = Object.assign(new Collection(), {
},
});

describe('OrgUnitSidebarSearchListElementComponent',
createSidebarSearchListElementTests(OrgUnitSidebarSearchListElementComponent, object, parent, 'parent title', 'title', 'description'),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('OrgUnitSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(OrgUnitSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', 'description');
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -42,7 +51,45 @@ const parent = Object.assign(new Collection(), {
},
});

describe('PersonSidebarSearchListElementComponent',
createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, 'parent title', 'family name, given name', 'job title', [
]),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('PersonSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'family name,given name', 'job title', []);
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -27,6 +36,45 @@ const parent = Object.assign(new Collection(), {
},
});

describe('ProjectSidebarSearchListElementComponent',
createSidebarSearchListElementTests(ProjectSidebarSearchListElementComponent, object, parent, 'parent title', 'title', undefined),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('ProjectSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(ProjectSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', undefined);
});
});
}
Loading

0 comments on commit c62c0af

Please sign in to comment.