Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 13x 13x 13x 13x 2x 2x 2x 1x 1x 1x 1x 2x 1x 2x 2x 1x 1x 1x | import { Injectable } from '@angular/core';
import { ContentConfigurationParameterMapper } from 'ish-core/models/content-configuration-parameter/content-configuration-parameter.mapper';
import { ContentPageletEntryPointData } from 'ish-core/models/content-pagelet-entry-point/content-pagelet-entry-point.interface';
import { ContentPageletEntryPoint } from 'ish-core/models/content-pagelet-entry-point/content-pagelet-entry-point.model';
import { ContentPageletMapper } from 'ish-core/models/content-pagelet/content-pagelet.mapper';
import { ContentPagelet } from 'ish-core/models/content-pagelet/content-pagelet.model';
@Injectable({ providedIn: 'root' })
export class ContentPageletEntryPointMapper {
constructor(
private contentConfigurationParameterMapper: ContentConfigurationParameterMapper,
private contentPageletMapper: ContentPageletMapper
) {}
/**
* Converts {@link ContentPageletEntryPointData} to the model entity {@link ContentPageletEntryPoint} and enclosed {@link ContentPagelet}s.
*/
fromData(data: ContentPageletEntryPointData): [ContentPageletEntryPoint, ContentPagelet[]] {
if (!data) {
throw new Error('falsy input');
}
let pagelets: ContentPagelet[] = [];
let pageletIDs: string[] = [];
if (data.pagelets) {
pageletIDs = data.pagelets.map(p => p.id);
pagelets = data.pagelets
.map(x => this.contentPageletMapper.fromData(x))
.reduce((acc, val) => [...acc, ...val], []);
}
const configurationParameters = this.contentConfigurationParameterMapper.fromData(data.configurationParameters);
const pageletEntryPoint: ContentPageletEntryPoint = {
id: data.id,
definitionQualifiedName: data.definitionQualifiedName,
displayName: data.displayName,
domain: data.domain,
resourceSetId: data.resourceSetId,
pageletIDs,
configurationParameters,
};
return [pageletEntryPoint, pagelets];
}
}
|