mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
64503: MetadataConfig in ContentSource + JSDocs
This commit is contained in:
@@ -213,6 +213,9 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
|
|||||||
*/
|
*/
|
||||||
updateSub: Subscription;
|
updateSub: Subscription;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The content harvesting type used when harvesting is disabled
|
||||||
|
*/
|
||||||
harvestTypeNone = ContentSourceHarvestType.None;
|
harvestTypeNone = ContentSourceHarvestType.None;
|
||||||
|
|
||||||
public constructor(public objectUpdatesService: ObjectUpdatesService,
|
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
|
* 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) {
|
updateContentSource(updateHarvestType: boolean) {
|
||||||
this.inputModels.forEach(
|
this.inputModels.forEach(
|
||||||
@@ -383,7 +387,8 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the Content Source with the value from a DynamicInputModel
|
* 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) {
|
updateContentSourceField(fieldModel: DynamicInputModel, updateHarvestType: boolean) {
|
||||||
if (hasValue(fieldModel.value) && !(fieldModel.id === this.harvestTypeModel.id && !updateHarvestType)) {
|
if (hasValue(fieldModel.value) && !(fieldModel.id === this.harvestTypeModel.id && !updateHarvestType)) {
|
||||||
|
@@ -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> {
|
getHarvesterEndpoint(collectionId: string): Observable<string> {
|
||||||
return this.halService.getEndpoint(this.linkPath).pipe(
|
return this.halService.getEndpoint(this.linkPath).pipe(
|
||||||
map((href: string) => `${href}/${collectionId}/harvester`)
|
map((href: string) => `${href}/${collectionId}/harvester`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the collection's content harvester
|
||||||
|
* @param collectionId
|
||||||
|
*/
|
||||||
getContentSource(collectionId: string): Observable<ContentSource> {
|
getContentSource(collectionId: string): Observable<ContentSource> {
|
||||||
return this.getHarvesterEndpoint(collectionId).pipe(
|
return this.getHarvesterEndpoint(collectionId).pipe(
|
||||||
map((href: string) => new ContentSourceRequest(this.requestService.generateRequestId(), href)),
|
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> {
|
updateContentSource(collectionId: string, contentSource: ContentSource): Observable<ContentSource> {
|
||||||
const requestId = this.requestService.generateRequestId();
|
const requestId = this.requestService.generateRequestId();
|
||||||
const serializedContentSource = new DSpaceRESTv2Serializer(ContentSource).serialize(contentSource);
|
const serializedContentSource = new DSpaceRESTv2Serializer(ContentSource).serialize(contentSource);
|
||||||
|
@@ -5,14 +5,26 @@ import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.
|
|||||||
import { ContentSourceSuccessResponse, RestResponse } from '../cache/response.models';
|
import { ContentSourceSuccessResponse, RestResponse } from '../cache/response.models';
|
||||||
import { DSpaceRESTv2Serializer } from '../dspace-rest-v2/dspace-rest-v2.serializer';
|
import { DSpaceRESTv2Serializer } from '../dspace-rest-v2/dspace-rest-v2.serializer';
|
||||||
import { ContentSource } from '../shared/content-source.model';
|
import { ContentSource } from '../shared/content-source.model';
|
||||||
|
import { MetadataConfig } from '../shared/metadata-config.model';
|
||||||
|
|
||||||
@Injectable()
|
@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 {
|
export class ContentSourceResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
||||||
const payload = data.payload;
|
const payload = data.payload;
|
||||||
|
|
||||||
const deserialized = new DSpaceRESTv2Serializer(ContentSource).deserialize(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);
|
return new ContentSourceSuccessResponse(deserialized, data.statusCode, data.statusText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
import { autoserialize, autoserializeAs, deserializeAs, deserialize } from 'cerialize';
|
import { autoserialize, autoserializeAs, deserializeAs, deserialize } from 'cerialize';
|
||||||
|
import { MetadataConfig } from './metadata-config.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of content harvesting used
|
||||||
|
*/
|
||||||
export enum ContentSourceHarvestType {
|
export enum ContentSourceHarvestType {
|
||||||
None = 'NONE',
|
None = 'NONE',
|
||||||
Metadata = 'METADATA_ONLY',
|
Metadata = 'METADATA_ONLY',
|
||||||
@@ -43,6 +47,11 @@ export class ContentSource {
|
|||||||
@autoserializeAs('harvest_type')
|
@autoserializeAs('harvest_type')
|
||||||
harvestType = ContentSourceHarvestType.None;
|
harvestType = ContentSourceHarvestType.None;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The available metadata configurations
|
||||||
|
*/
|
||||||
|
metadataConfigs: MetadataConfig[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The REST link to itself
|
* The REST link to itself
|
||||||
*/
|
*/
|
||||||
|
19
src/app/core/shared/metadata-config.model.ts
Normal file
19
src/app/core/shared/metadata-config.model.ts
Normal 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;
|
||||||
|
}
|
Reference in New Issue
Block a user