diff --git a/src/app/+item-page/simple/entity-types/shared/entity-page-fields.component.ts b/src/app/+item-page/simple/entity-types/shared/entity-page-fields.component.ts index 7b23c87806..e480472dac 100644 --- a/src/app/+item-page/simple/entity-types/shared/entity-page-fields.component.ts +++ b/src/app/+item-page/simple/entity-types/shared/entity-page-fields.component.ts @@ -11,6 +11,10 @@ import { getRemoteDataPayload } from '../../../../core/shared/operators'; import { hasValue } from '../../../../shared/empty.util'; import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; +/** + * Operator for comparing arrays using a mapping function + * @param mapFn Function for mapping the arrays + */ const compareArraysUsing = (mapFn: (t: T) => any) => (a: T[], b: T[]): boolean => { if (!Array.isArray(a) || ! Array.isArray(b)) { @@ -25,6 +29,9 @@ const compareArraysUsing = (mapFn: (t: T) => any) => bIds.every((e) => aIds.includes(e)); }; +/** + * Operator for comparing arrays using the object's ids + */ const compareArraysUsingIds = () => compareArraysUsing((t: T) => hasValue(t) ? t.id : undefined); diff --git a/src/app/+search-page/search-page.component.ts b/src/app/+search-page/search-page.component.ts index 7c4879409c..417c61152c 100644 --- a/src/app/+search-page/search-page.component.ts +++ b/src/app/+search-page/search-page.component.ts @@ -18,12 +18,6 @@ import { SearchConfigurationService } from './search-service/search-configuratio import { getSucceededRemoteData } from '../core/shared/operators'; import { RouteService } from '../shared/services/route.service'; -/** - * This component renders a simple item page. - * The route parameter 'id' is used to request the item it represents. - * All fields of the item that should be displayed, are defined in its template. - */ - @Component({ selector: 'ds-search-page', styleUrls: ['./search-page.component.scss'], @@ -34,6 +28,7 @@ import { RouteService } from '../shared/services/route.service'; /** * This component represents the whole search page + * It renders search results depending on the current search options */ export class SearchPageComponent implements OnInit { diff --git a/src/app/+search-page/search-results/search-results.component.ts b/src/app/+search-page/search-results/search-results.component.ts index 62ef393a2e..07360add0c 100644 --- a/src/app/+search-page/search-results/search-results.component.ts +++ b/src/app/+search-page/search-results/search-results.component.ts @@ -9,11 +9,6 @@ import { SearchResult } from '../search-result.model'; import { PaginatedList } from '../../core/data/paginated-list'; import { hasValue, isNotEmpty } from '../../shared/empty.util'; -/** - * This component renders a simple item page. - * The route parameter 'id' is used to request the item it represents. - * All fields of the item that should be displayed, are defined in its template. - */ @Component({ selector: 'ds-search-results', templateUrl: './search-results.component.html', diff --git a/src/app/core/cache/models/entities/normalized-entity-type.model.ts b/src/app/core/cache/models/entities/normalized-entity-type.model.ts index 2abbd71ed1..729aa39d7b 100644 --- a/src/app/core/cache/models/entities/normalized-entity-type.model.ts +++ b/src/app/core/cache/models/entities/normalized-entity-type.model.ts @@ -5,16 +5,28 @@ import { mapsTo } from '../../builders/build-decorators'; import { NormalizedObject } from '../normalized-object.model'; import { IDToUUIDSerializer } from '../../id-to-uuid-serializer'; +/** + * Normalized model class for a DSpace EntityType + */ @mapsTo(EntityType) @inheritSerialization(NormalizedObject) export class NormalizedEntityType extends NormalizedObject { + /** + * The label that describes the ResourceType of the Entity + */ @autoserialize label: string; + /** + * The identifier of this EntityType + */ @autoserialize id: string; + /** + * The universally unique identifier of this EntityType + */ @autoserializeAs(new IDToUUIDSerializer(ResourceType.EntityType), 'id') uuid: string; } diff --git a/src/app/core/cache/models/entities/normalized-relationship-type.model.ts b/src/app/core/cache/models/entities/normalized-relationship-type.model.ts index e8e832d18e..a7e46a9d1b 100644 --- a/src/app/core/cache/models/entities/normalized-relationship-type.model.ts +++ b/src/app/core/cache/models/entities/normalized-relationship-type.model.ts @@ -6,12 +6,22 @@ import { NormalizedDSpaceObject } from '../normalized-dspace-object.model'; import { NormalizedObject } from '../normalized-object.model'; import { IDToUUIDSerializer } from '../../id-to-uuid-serializer'; +/** + * Normalized model class for a DSpace RelationshipType + */ @mapsTo(RelationshipType) @inheritSerialization(NormalizedDSpaceObject) export class NormalizedRelationshipType extends NormalizedObject { + + /** + * The identifier of this RelationshipType + */ @autoserialize id: string; + /** + * The label that describes the Relation to the left of this RelationshipType + */ @autoserialize leftLabel: string; @@ -21,6 +31,9 @@ export class NormalizedRelationshipType extends NormalizedObject { @autoserialize leftMinCardinality: number; + /** + * The label that describes the Relation to the right of this RelationshipType + */ @autoserialize rightLabel: string; @@ -30,14 +43,23 @@ export class NormalizedRelationshipType extends NormalizedObject { @autoserialize rightMinCardinality: number; + /** + * The type of Entity found to the left of this RelationshipType + */ @autoserialize @relationship(ResourceType.EntityType, false) leftType: string; + /** + * The type of Entity found to the right of this RelationshipType + */ @autoserialize @relationship(ResourceType.EntityType, false) rightType: string; + /** + * The universally unique identifier of this RelationshipType + */ @autoserializeAs(new IDToUUIDSerializer(ResourceType.RelationshipType), 'id') uuid: string; } diff --git a/src/app/core/cache/models/entities/normalized-relationship.model.ts b/src/app/core/cache/models/entities/normalized-relationship.model.ts index 191dc08f7b..7c7508d9ef 100644 --- a/src/app/core/cache/models/entities/normalized-relationship.model.ts +++ b/src/app/core/cache/models/entities/normalized-relationship.model.ts @@ -5,26 +5,44 @@ import { mapsTo, relationship } from '../../builders/build-decorators'; import { NormalizedObject } from '../normalized-object.model'; import { IDToUUIDSerializer } from '../../id-to-uuid-serializer'; +/** + * Normalized model class for a DSpace Relationship + */ @mapsTo(Relationship) @inheritSerialization(NormalizedObject) export class NormalizedRelationship extends NormalizedObject { + /** + * The identifier of this Relationship + */ @autoserialize id: string; + /** + * The identifier of the Relationship to the left side of this Relationship + */ @autoserialize leftId: string; @autoserialize place: number; + /** + * The identifier of the Relationship to the right side of this Relationship + */ @autoserialize rightId: string; + /** + * The type of Relationship + */ @autoserialize @relationship(ResourceType.RelationshipType, false) relationshipType: string; + /** + * The universally unique identifier of this Relationship + */ @autoserializeAs(new IDToUUIDSerializer(ResourceType.Relationship), 'id') uuid: string; } diff --git a/src/app/core/data/filtered-discovery-page-response-parsing.service.ts b/src/app/core/data/filtered-discovery-page-response-parsing.service.ts index ee87230214..299207b12b 100644 --- a/src/app/core/data/filtered-discovery-page-response-parsing.service.ts +++ b/src/app/core/data/filtered-discovery-page-response-parsing.service.ts @@ -8,6 +8,10 @@ import { ObjectCacheService } from '../cache/object-cache.service'; import { GlobalConfig } from '../../../config/global-config.interface'; import { GLOBAL_CONFIG } from '../../../config'; +/** + * A ResponseParsingService used to parse DSpaceRESTV2Response coming from the REST API to a discovery query (string) + * wrapped in a FilteredDiscoveryQueryResponse + */ @Injectable() export class FilteredDiscoveryPageResponseParsingService extends BaseResponseParsingService implements ResponseParsingService { objectFactory = {}; @@ -17,6 +21,13 @@ export class FilteredDiscoveryPageResponseParsingService extends BaseResponsePar protected objectCache: ObjectCacheService, ) { super(); } + + /** + * Parses data from the REST API to a discovery query wrapped in a FilteredDiscoveryQueryResponse + * @param {RestRequest} request + * @param {DSpaceRESTV2Response} data + * @returns {RestResponse} + */ parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse { const query = data.payload['discovery-query']; return new FilteredDiscoveryQueryResponse(query, data.statusCode); diff --git a/src/app/core/shared/entities/entity-type.model.ts b/src/app/core/shared/entities/entity-type.model.ts index 93e60f3efc..bfca58fa1a 100644 --- a/src/app/core/shared/entities/entity-type.model.ts +++ b/src/app/core/shared/entities/entity-type.model.ts @@ -2,8 +2,23 @@ import { CacheableObject } from '../../cache/object-cache.reducer'; import { ResourceType } from '../resource-type'; export class EntityType implements CacheableObject { + /** + * The identifier of this EntityType + */ id: string; + + /** + * The link to the rest endpoint where this object can be found + */ self: string; + + /** + * The type of Resource this is + */ type: ResourceType; + + /** + * The universally unique identifier of this EntityType + */ uuid: string; } diff --git a/src/app/core/shared/entities/relationship-type.model.ts b/src/app/core/shared/entities/relationship-type.model.ts index ff3abd2d1b..943a8f94f5 100644 --- a/src/app/core/shared/entities/relationship-type.model.ts +++ b/src/app/core/shared/entities/relationship-type.model.ts @@ -5,29 +5,56 @@ import { ResourceType } from '../resource-type'; import { EntityType } from './entity-type.model'; export class RelationshipType implements CacheableObject { + /** + * The link to the rest endpoint where this object can be found + */ self: string; + /** + * The type of Resource this is + */ type: ResourceType; + /** + * The label that describes this RelationshipType + */ label: string; + /** + * The identifier of this RelationshipType + */ id: string; + /** + * The universally unique identifier of this RelationshipType + */ uuid: string; + /** + * The label that describes the Relation to the left of this RelationshipType + */ leftLabel: string; leftMaxCardinality: number; leftMinCardinality: number; + /** + * The label that describes the Relation to the right of this RelationshipType + */ rightLabel: string; rightMaxCardinality: number; rightMinCardinality: number; + /** + * The type of Entity found to the left of this RelationshipType + */ leftType: Observable>; + /** + * The type of Entity found to the right of this RelationshipType + */ rightType: Observable>; } diff --git a/src/app/core/shared/entities/relationship.model.ts b/src/app/core/shared/entities/relationship.model.ts index a26d6f5179..4df3e32b86 100644 --- a/src/app/core/shared/entities/relationship.model.ts +++ b/src/app/core/shared/entities/relationship.model.ts @@ -5,19 +5,40 @@ import { ResourceType } from '../resource-type'; import { RelationshipType } from './relationship-type.model'; export class Relationship implements CacheableObject { + /** + * The link to the rest endpoint where this object can be found + */ self: string; + /** + * The type of Resource this is + */ type: ResourceType; + /** + * The universally unique identifier of this Relationship + */ uuid: string; + /** + * The identifier of this Relationship + */ id: string; + /** + * The identifier of the Relationship to the left side of this Relationship + */ leftId: string; place: string; + /** + * The identifier of the Relationship to the right side of this Relationship + */ rightId: string; + /** + * The type of Relationship + */ relationshipType: Observable>; } diff --git a/src/app/shared/entities/entity-type-decorator.ts b/src/app/shared/entities/entity-type-decorator.ts index 60bdab7412..9af226ea3d 100644 --- a/src/app/shared/entities/entity-type-decorator.ts +++ b/src/app/shared/entities/entity-type-decorator.ts @@ -4,6 +4,12 @@ import { ElementViewMode } from '../view-mode'; export const DEFAULT_ENTITY_TYPE = 'Default'; const map = new Map(); + +/** + * Decorator used for rendering simple item pages for an Entity by type and viewMode + * @param type + * @param viewMode + */ export function rendersEntityType(type: string, viewMode: ElementViewMode) { return function decorator(component: any) { if (hasNoValue(map.get(viewMode))) { @@ -16,6 +22,11 @@ export function rendersEntityType(type: string, viewMode: ElementViewMode) { }; } +/** + * Get the component used for rendering an entity by type and viewMode + * @param type + * @param viewMode + */ export function getComponentByEntityType(type: string, viewMode: ElementViewMode) { let component = map.get(viewMode).get(type); if (hasNoValue(component)) { diff --git a/src/app/shared/view-mode.ts b/src/app/shared/view-mode.ts index b0e180c290..2825f20c50 100644 --- a/src/app/shared/view-mode.ts +++ b/src/app/shared/view-mode.ts @@ -1,11 +1,24 @@ +/** + * Enum used for defining the view-mode of a set of elements + * List Display the elements in a (vertical) list + * Grid Display the elements in a grid + */ export enum SetViewMode { List = 'list', Grid = 'grid' } +/** + * Enum used for defining the view-mode of a single element + * Full Display the full element + * SetElement Display the element as part of a set + */ export enum ElementViewMode { Full, SetElement } +/** + * ViewMode refers to either a SetViewMode or ElementViewMode + */ export type ViewMode = SetViewMode | ElementViewMode;