Merge remote-tracking branch 'artlowel/rest-relationships' into w2p-40416_simple-item-page

Conflicts:
	src/app/core/shared/dspace-object.model.ts
This commit is contained in:
Lotte Hofstede
2017-04-27 13:12:23 +02:00
90 changed files with 2537 additions and 1664 deletions

View File

@@ -8,75 +8,77 @@ import { CacheableObject } from "../cache/object-cache.reducer";
*/
export abstract class DSpaceObject implements CacheableObject {
/**
* The human-readable identifier of this DSpaceObject
*/
@autoserialize
id: string;
@autoserialize
self: string;
/**
* The universally unique identifier of this DSpaceObject
*/
@autoserialize
uuid: string;
/**
* The human-readable identifier of this DSpaceObject
*/
@autoserialize
id: string;
/**
* A string representing the kind of DSpaceObject, e.g. community, item, …
*/
type: string;
/**
* The universally unique identifier of this DSpaceObject
*/
@autoserialize
uuid: string;
/**
* The name for this DSpaceObject
*/
@autoserialize
name: string;
/**
* A string representing the kind of DSpaceObject, e.g. community, item, …
*/
type: string;
/**
* An array containing all metadata of this DSpaceObject
*/
@autoserializeAs(Metadatum)
metadata: Array<Metadatum>;
/**
* The name for this DSpaceObject
*/
@autoserialize
name: string;
/**
* An array of DSpaceObjects that are direct parents of this DSpaceObject
*/
parents: Array<DSpaceObject>;
/**
* An array containing all metadata of this DSpaceObject
*/
@autoserializeAs(Metadatum)
metadata: Array<Metadatum>;
/**
* The DSpaceObject that owns this DSpaceObject
*/
owner: DSpaceObject;
/**
* An array of DSpaceObjects that are direct parents of this DSpaceObject
*/
parents: Array<DSpaceObject>;
/**
* Find a metadata field by key and language
*
* This method returns the value of the first element
* in the metadata array that matches the provided
* key and language
*
* @param key
* @param language
* @return string
*/
findMetadata(key: string, language?: string): string {
const metadatum = this.metadata
.find((metadatum: Metadatum) => {
return metadatum.key === key &&
(isEmpty(language) || metadatum.language === language)
});
if (isNotEmpty(metadatum)) {
return metadatum.value;
}
else {
return undefined;
}
}
/**
* The DSpaceObject that owns this DSpaceObject
*/
owner: DSpaceObject;
filterMetadata(keys: string[]): Array<Metadatum> {
return this.metadata
.filter((metadatum: Metadatum) => {
return keys.some(key => key === metadatum.key);
});
}
/**
* Find a metadata field by key and language
*
* This method returns the value of the first element
* in the metadata array that matches the provided
* key and language
*
* @param key
* @param language
* @return string
*/
findMetadata(key: string, language?: string): string {
const metadatum = this.metadata
.find((metadatum: Metadatum) => {
return metadatum.key === key &&
(isEmpty(language) || metadatum.language === language)
});
if (isNotEmpty(metadatum)) {
return metadatum.value;
}
else {
return undefined;
}
}
filterMetadata(keys: string[]): Array<Metadatum> {
return this.metadata
.filter((metadatum: Metadatum) => {
return keys.some(key => key === metadatum.key);
});
}
}