mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 13:03:04 +00:00
CC License Submission Step - implement contract change
This commit is contained in:
@@ -12,12 +12,17 @@ import { RequestService } from '../data/request.service';
|
||||
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service';
|
||||
import { SubmissionCcLicenceUrl } from './models/submission-cc-license-url.model';
|
||||
import { SUBMISSION_CC_LICENSE_URL } from './models/submission-cc-licence-link.resource-type';
|
||||
import { Field, Option, SubmissionCcLicence } from "./models/submission-cc-license.model";
|
||||
import { Observable } from "rxjs";
|
||||
import { filter, map, switchMap } from "rxjs/operators";
|
||||
import { getRemoteDataPayload, getSucceededRemoteData } from "../shared/operators";
|
||||
import { isNotEmpty } from "../../shared/empty.util";
|
||||
|
||||
@Injectable()
|
||||
@dataService(SUBMISSION_CC_LICENSE_URL)
|
||||
export class SubmissionCcLicenseUrlDataService extends DataService<SubmissionCcLicenceUrl> {
|
||||
|
||||
protected linkPath = 'submissioncclicenses';
|
||||
protected linkPath = 'submissioncclicenseUrl-search';
|
||||
|
||||
constructor(
|
||||
protected comparator: DefaultChangeAnalyzer<SubmissionCcLicenceUrl>,
|
||||
@@ -31,4 +36,41 @@ export class SubmissionCcLicenseUrlDataService extends DataService<SubmissionCcL
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the link to the Creative Commons license corresponding to the given type and options.
|
||||
* @param ccLicense the Creative Commons license type
|
||||
* @param options the selected options of the license fields
|
||||
*/
|
||||
getCcLicenseLink(ccLicense: SubmissionCcLicence, options: Map<Field, Option>): Observable<string> {
|
||||
|
||||
return this.getSearchByHref(
|
||||
'rightsByQuestions',{
|
||||
searchParams: [
|
||||
{
|
||||
fieldName: 'license',
|
||||
fieldValue: ccLicense.id
|
||||
},
|
||||
...ccLicense.fields.map(
|
||||
(field) => {
|
||||
return {
|
||||
fieldName: `answer_${field.id}`,
|
||||
fieldValue: options.get(field).id,
|
||||
}
|
||||
}),
|
||||
]
|
||||
}
|
||||
).pipe(
|
||||
switchMap((href) => this.findByHref(href)),
|
||||
getSucceededRemoteData(),
|
||||
getRemoteDataPayload(),
|
||||
map((response) => response.url),
|
||||
);
|
||||
}
|
||||
|
||||
protected getSearchEndpoint(searchMethod: string): Observable<string> {
|
||||
return this.halService.getEndpoint(`${this.linkPath}`).pipe(
|
||||
filter((href: string) => isNotEmpty(href)),
|
||||
map((href: string) => `${href}/${searchMethod}`));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user