64503: MetadataConfig in ContentSource + JSDocs

This commit is contained in:
Kristof De Langhe
2019-08-20 17:54:58 +02:00
parent 1b9bc2f7a3
commit 8103321245
5 changed files with 59 additions and 1 deletions

View File

@@ -213,6 +213,9 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
*/
updateSub: Subscription;
/**
* The content harvesting type used when harvesting is disabled
*/
harvestTypeNone = ContentSourceHarvestType.None;
public constructor(public objectUpdatesService: ObjectUpdatesService,
@@ -371,6 +374,7 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
/**
* Loop over all inputs and update the Content Source with their value
* @param updateHarvestType When set to false, the harvestType of the contentSource will be ignored in the update
*/
updateContentSource(updateHarvestType: boolean) {
this.inputModels.forEach(
@@ -383,7 +387,8 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
/**
* Update the Content Source with the value from a DynamicInputModel
* @param fieldModel
* @param fieldModel The fieldModel to fetch the value from and update the contentSource with
* @param updateHarvestType When set to false, the harvestType of the contentSource will be ignored in the update
*/
updateContentSourceField(fieldModel: DynamicInputModel, updateHarvestType: boolean) {
if (hasValue(fieldModel.value) && !(fieldModel.id === this.harvestTypeModel.id && !updateHarvestType)) {

View File

@@ -74,12 +74,20 @@ export class CollectionDataService extends ComColDataService<Collection> {
);
}
/**
* Get the endpoint for the collection's content harvester
* @param collectionId
*/
getHarvesterEndpoint(collectionId: string): Observable<string> {
return this.halService.getEndpoint(this.linkPath).pipe(
map((href: string) => `${href}/${collectionId}/harvester`)
);
}
/**
* Get the collection's content harvester
* @param collectionId
*/
getContentSource(collectionId: string): Observable<ContentSource> {
return this.getHarvesterEndpoint(collectionId).pipe(
map((href: string) => new ContentSourceRequest(this.requestService.generateRequestId(), href)),
@@ -91,6 +99,11 @@ export class CollectionDataService extends ComColDataService<Collection> {
);
}
/**
* Update the settings of the collection's content harvester
* @param collectionId
* @param contentSource
*/
updateContentSource(collectionId: string, contentSource: ContentSource): Observable<ContentSource> {
const requestId = this.requestService.generateRequestId();
const serializedContentSource = new DSpaceRESTv2Serializer(ContentSource).serialize(contentSource);

View File

@@ -5,14 +5,26 @@ import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.
import { ContentSourceSuccessResponse, RestResponse } from '../cache/response.models';
import { DSpaceRESTv2Serializer } from '../dspace-rest-v2/dspace-rest-v2.serializer';
import { ContentSource } from '../shared/content-source.model';
import { MetadataConfig } from '../shared/metadata-config.model';
@Injectable()
/**
* A ResponseParsingService used to parse DSpaceRESTV2Response coming from the REST API to a ContentSource object
* wrapped in a ContentSourceSuccessResponse
*/
export class ContentSourceResponseParsingService implements ResponseParsingService {
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
const payload = data.payload;
const deserialized = new DSpaceRESTv2Serializer(ContentSource).deserialize(payload);
let metadataConfigs = [];
if (payload._embedded && payload._embedded.metadata_configs && payload._embedded.metadata_configs.configs) {
metadataConfigs = new DSpaceRESTv2Serializer(MetadataConfig).serializeArray(payload._embedded.metadata_configs.configs);
}
deserialized.metadataConfigs = metadataConfigs;
return new ContentSourceSuccessResponse(deserialized, data.statusCode, data.statusText);
}

View File

@@ -1,5 +1,9 @@
import { autoserialize, autoserializeAs, deserializeAs, deserialize } from 'cerialize';
import { MetadataConfig } from './metadata-config.model';
/**
* The type of content harvesting used
*/
export enum ContentSourceHarvestType {
None = 'NONE',
Metadata = 'METADATA_ONLY',
@@ -43,6 +47,11 @@ export class ContentSource {
@autoserializeAs('harvest_type')
harvestType = ContentSourceHarvestType.None;
/**
* The available metadata configurations
*/
metadataConfigs: MetadataConfig[];
/**
* The REST link to itself
*/

View File

@@ -0,0 +1,19 @@
/**
* A model class that holds information about a certain metadata configuration
*/
export class MetadataConfig {
/**
* A unique indentifier
*/
id: string;
/**
* The label used for display
*/
label: string;
/**
* The namespace of the metadata
*/
nameSpace: string;
}