Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port dspace-7_x] ORCID Push Queue: add support for Products and Patents #3351

Open
wants to merge 7 commits into
base: dspace-7_x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@
switch (orcidQueue.recordType.toLowerCase()) {
case 'publication':
return 'fas fa-book';
case 'product':
return 'fas fa-database';

Check warning on line 122 in src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.ts#L122

Added line #L122 was not covered by tests
case 'funding':
return 'fa fa-wallet';

Check warning on line 124 in src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.ts#L124

Added line #L124 was not covered by tests
case 'project':
return 'fas fa-wallet';
case 'patent':
return 'fas fa-file';

Check warning on line 128 in src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.ts#L128

Added line #L128 was not covered by tests
case 'education':
return 'fas fa-school';
case 'affiliation':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,29 @@ <h2>{{'person.orcid.sync.setting' | translate}}</h2>
</div>
</div>
</div>
<div class="col-md mb-3">
<div class="card h-100" data-test="sync-mode-product">
<div class="card-header">{{ 'person.page.orcid.product-preferences'| translate }}</div>
<div class="card-body">
<div class="container">
<div class="row">
<ds-alert [type]="'alert-info'">
{{ 'person.page.orcid.synchronization-mode-product-message' | translate}}
</ds-alert>
</div>
<div class="form-group">
<div *ngFor="let option of syncProductOptions" class="row form-check">
<input type="radio" [(ngModel)]="currentSyncProduct"
name="syncProducts" id="productOption_{{option.value}}" [value]="option.value"
required>
<label for="productOption_{{option.value}}"
class="ml-2">{{option.label | translate}}</label>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md mb-3">
<div class="card h-100" data-test="sync-mode-funding">
<div class="card-header">{{ 'person.page.orcid.funding-preferences'| translate }}</div>
Expand All @@ -71,6 +94,28 @@ <h2>{{'person.orcid.sync.setting' | translate}}</h2>
</div>
</div>
</div>
<div class="col-md mb-3">
<div class="card h-100" data-test="sync-mode-patent">
<div class="card-header">{{ 'person.page.orcid.patent-preferences'| translate }}</div>
<div class="card-body">
<div class="container">
<div class="row">
<ds-alert [type]="'alert-info'">
{{ 'person.page.orcid.synchronization-mode-patent-message' | translate}}
</ds-alert>
</div>
<div class="form-group">
<div *ngFor="let option of syncPatentOptions" class="row form-check">
<input type="radio" [(ngModel)]="currentSyncPatent"
name="syncPatents" id="patentOption_{{option.value}}" [value]="option.value"
required>
<label for="patentOption_{{option.value}}" class="ml-2">{{option.label | translate}}</label>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md mb-3">
<div class="card h-100" data-test="profile-preferences">
<div class="card-header">{{ 'person.page.orcid.profile-preferences'| translate }}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ describe('OrcidSyncSettingsComponent test suite', () => {
'confidence': -1,
'place': 0
}],
'dspace.orcid.sync-patents': [{
'value': 'DISABLED',
'language': null,
'authority': null,
'confidence': -1,
'place': 0
}],
'person.identifier.orcid': [{
'value': 'orcid-id',
'language': null,
Expand Down Expand Up @@ -168,19 +175,25 @@ describe('OrcidSyncSettingsComponent test suite', () => {

it('should create cards properly', () => {
const modes = fixture.debugElement.query(By.css('[data-test="sync-mode"]'));
const patent = fixture.debugElement.query(By.css('[data-test="sync-mode-patent"]'));
const publication = fixture.debugElement.query(By.css('[data-test="sync-mode-publication"]'));
const product = fixture.debugElement.query(By.css('[data-test="sync-mode-product"]'));
const funding = fixture.debugElement.query(By.css('[data-test="sync-mode-funding"]'));
const preferences = fixture.debugElement.query(By.css('[data-test="profile-preferences"]'));
expect(modes).toBeTruthy();
expect(publication).toBeTruthy();
expect(product).toBeTruthy();
expect(patent).toBeTruthy();
expect(funding).toBeTruthy();
expect(preferences).toBeTruthy();
});

it('should init sync modes properly', () => {
expect(comp.currentSyncMode).toBe('MANUAL');
expect(comp.currentSyncPublications).toBe('ALL');
expect(comp.currentSyncProduct).toBe('DISABLED');
expect(comp.currentSyncFunding).toBe('DISABLED');
expect(comp.currentSyncPatent).toBe('DISABLED');
});

describe('form submit', () => {
Expand All @@ -190,6 +203,8 @@ describe('OrcidSyncSettingsComponent test suite', () => {
formGroup = new UntypedFormGroup({
syncMode: new UntypedFormControl('MANUAL'),
syncFundings: new UntypedFormControl('ALL'),
syncProducts: new UntypedFormControl('ALL'),
syncPatents: new UntypedFormControl('ALL'),
syncPublications: new UntypedFormControl('ALL'),
syncProfile_BIOGRAPHICAL: new UntypedFormControl(true),
syncProfile_IDENTIFIERS: new UntypedFormControl(true),
Expand All @@ -204,10 +219,18 @@ describe('OrcidSyncSettingsComponent test suite', () => {
path: '/orcid/mode',
op: 'replace',
value: 'MANUAL'
}, {
path: '/orcid/patents',
op: 'replace',
value: 'ALL'
}, {
path: '/orcid/publications',
op: 'replace',
value: 'ALL'
}, {
path: '/orcid/products',
op: 'replace',
value: 'ALL'
}, {
path: '/orcid/fundings',
op: 'replace',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,22 @@ export class OrcidSyncSettingsComponent implements OnInit, OnDestroy {
* The current synchronization mode
*/
currentSyncMode: string;

/**
* The current synchronization mode for patents
*/
currentSyncPatent: string;

/**
* The current synchronization mode for publications
*/
currentSyncPublications: string;

/**
* The current synchronization mode for product
*/
currentSyncProduct: string;

/**
* The current synchronization mode for funding
*/
Expand All @@ -43,10 +55,22 @@ export class OrcidSyncSettingsComponent implements OnInit, OnDestroy {
* The synchronization options
*/
syncModes: { value: string, label: string }[];

/**
* The synchronization options for patents
*/
syncPatentOptions: { value: string, label: string }[];

/**
* The synchronization options for publications
*/
syncPublicationOptions: { value: string, label: string }[];

/**
* The synchronization options for products
*/
syncProductOptions: { value: string, label: string }[];

/**
* The synchronization options for funding
*/
Expand Down Expand Up @@ -115,6 +139,22 @@ export class OrcidSyncSettingsComponent implements OnInit, OnDestroy {
};
});

this.syncProductOptions = ['DISABLED', 'ALL']
.map((value) => {
return {
label: this.messagePrefix + '.sync-products.' + value.toLowerCase(),
value: value,
};
});

this.syncPatentOptions = ['DISABLED', 'ALL']
.map((value) => {
return {
label: this.messagePrefix + '.sync-patents.' + value.toLowerCase(),
value: value,
};
});

this.syncFundingOptions = ['DISABLED', 'ALL']
.map((value) => {
return {
Expand Down Expand Up @@ -148,7 +188,9 @@ export class OrcidSyncSettingsComponent implements OnInit, OnDestroy {
onSubmit(form: UntypedFormGroup): void {
const operations: Operation[] = [];
this.fillOperationsFor(operations, '/orcid/mode', form.value.syncMode);
this.fillOperationsFor(operations, '/orcid/patents', form.value.syncPatents);
this.fillOperationsFor(operations, '/orcid/publications', form.value.syncPublications);
this.fillOperationsFor(operations, '/orcid/products', form.value.syncProducts);
this.fillOperationsFor(operations, '/orcid/fundings', form.value.syncFundings);

const syncProfileValue = this.syncProfileOptions
Expand All @@ -170,11 +212,11 @@ export class OrcidSyncSettingsComponent implements OnInit, OnDestroy {
take(1)
)
.subscribe((remoteData: RemoteData<ResearcherProfile>) => {
if (remoteData.hasFailed) {
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.synchronization-settings-update.error'));
} else {
if (remoteData.hasSucceeded) {
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.synchronization-settings-update.success'));
this.settingsUpdated.emit();
} else {
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.synchronization-settings-update.error'));
}
});
}
Expand All @@ -190,18 +232,28 @@ export class OrcidSyncSettingsComponent implements OnInit, OnDestroy {
item.pipe(
filter(hasValue),
map(i => this.getCurrentPreference(i, 'dspace.orcid.sync-mode', ['BATCH', 'MANUAL'], 'MANUAL')),
takeUntil(this.#destroy$)
takeUntil(this.#destroy$),
).subscribe(val => this.currentSyncMode = val);
item.pipe(
filter(hasValue),
map(i => this.getCurrentPreference(i, 'dspace.orcid.sync-publications', ['DISABLED', 'ALL'], 'DISABLED')),
takeUntil(this.#destroy$)
takeUntil(this.#destroy$),
).subscribe(val => this.currentSyncPublications = val);
item.pipe(
filter(hasValue),
map(i => this.getCurrentPreference(i, 'dspace.orcid.sync-fundings', ['DISABLED', 'ALL'], 'DISABLED')),
takeUntil(this.#destroy$)
takeUntil(this.#destroy$),
).subscribe(val => this.currentSyncFunding = val);
item.pipe(
filter(hasValue),
map(i => this.getCurrentPreference(i, 'dspace.orcid.sync-patents', ['DISABLED', 'ALL'], 'DISABLED')),
takeUntil(this.#destroy$),
).subscribe(val => this.currentSyncPatent = val);
item.pipe(
filter(hasValue),
map(i => this.getCurrentPreference(i, 'dspace.orcid.sync-products', ['DISABLED', 'ALL'], 'DISABLED')),
takeUntil(this.#destroy$),
).subscribe(val => this.currentSyncProduct = val);
}

/**
Expand Down
Loading
Loading