Added TypeDoc/comments

This commit is contained in:
Giuseppe Digilio
2019-02-07 18:17:04 +01:00
parent f267308a09
commit f6a88d846f
27 changed files with 306 additions and 24 deletions

View File

@@ -17,4 +17,7 @@ import { SubmissionSubmitComponent } from '../submission/submit/submission-submi
])
]
})
/**
* This module defines the default component to load when navigating to the submit page path.
*/
export class SubmitPageRoutingModule { }

View File

@@ -12,6 +12,9 @@ import { SubmissionModule } from '../submission/submission.module';
SubmissionModule,
],
})
/**
* This module handles all modules that need to access the submit page.
*/
export class SubmitPageModule {
}

View File

@@ -17,4 +17,7 @@ import { SubmissionEditComponent } from '../submission/edit/submission-edit.comp
])
]
})
/**
* This module defines the default component to load when navigating to the workflowitems edit page path.
*/
export class WorkflowitemsEditPageRoutingModule { }

View File

@@ -13,6 +13,9 @@ import { SubmissionModule } from '../submission/submission.module';
],
declarations: []
})
/**
* This module handles all modules that need to access the workflowitems edit page.
*/
export class WorkflowitemsEditPageModule {
}

View File

@@ -17,4 +17,7 @@ import { SubmissionEditComponent } from '../submission/edit/submission-edit.comp
])
]
})
/**
* This module defines the default component to load when navigating to the workspaceitems edit page path
*/
export class WorkspaceitemsEditPageRoutingModule { }

View File

@@ -13,6 +13,9 @@ import { SubmissionModule } from '../submission/submission.module';
],
declarations: []
})
/**
* This module handles all modules that need to access the workspaceitems edit page.
*/
export class WorkspaceitemsEditPageModule {
}

View File

@@ -3,12 +3,15 @@ import { mapsTo } from '../builders/build-decorators';
import { NormalizedDSpaceObject } from './normalized-dspace-object.model';
import { License } from '../../shared/license.model';
/**
* Normalized model class for a Collection License
*/
@mapsTo(License)
@inheritSerialization(NormalizedDSpaceObject)
export class NormalizedLicense extends NormalizedDSpaceObject {
/**
* Is the license custom?
* A boolean representing if this License is custom or not
*/
@autoserialize
custom: boolean;

View File

@@ -13,7 +13,6 @@ import { NormalizedEPerson } from '../../eperson/models/normalized-eperson.model
import { NormalizedGroup } from '../../eperson/models/normalized-group.model';
import { NormalizedWorkflowItem } from '../../submission/models/normalized-workflowitem.model';
import { NormalizedBitstreamFormat } from './normalized-bitstream-format.model';
import { SubmissionResourceType } from '../../submission/submission-resource-type';
import { SubmissionDefinitionsModel } from '../../config/models/config-submission-definitions.model';
import { SubmissionFormsModel } from '../../config/models/config-submission-forms.model';
import { SubmissionSectionModel } from '../../config/models/config-submission-section.model';

View File

@@ -1,4 +1,7 @@
/**
* Class representing a query parameter (query?fieldName=fieldValue) used in FindAllOptions object
*/
export class SearchParam {
constructor(public fieldName: string, public fieldValue: any) {

View File

@@ -1,8 +1,35 @@
/**
* Model class for an Access Condition
*/
export class AccessConditionOption {
/**
* The name for this Access Condition
*/
name: string;
/**
* The uuid of the Group this Access Condition applies to
*/
groupUUID: string;
/**
* A boolean representing if this Access Condition has a start date
*/
hasStartDate: boolean;
/**
* A boolean representing if this Access Condition has an end date
*/
hasEndDate: boolean;
/**
* Maximum value of the start date
*/
maxStartDate: string;
/**
* Maximum value of the end date
*/
maxEndDate: string;
}

View File

@@ -3,12 +3,21 @@ import { ConfigObject } from './config.model';
import { AccessConditionOption } from './config-access-condition-option.model';
import {SubmissionFormsModel} from './config-submission-forms.model';
/**
* Normalized model class for the configuration describing the submission upload section
*/
@inheritSerialization(ConfigObject)
export class SubmissionUploadsModel extends ConfigObject {
/**
* A list of available bitstream access conditions
*/
@autoserialize
accessConditionOptions: AccessConditionOption[];
/**
* An object representing the configuration describing the bistream metadata form
*/
@autoserializeAs(SubmissionFormsModel)
metadata: SubmissionFormsModel;

View File

@@ -4,6 +4,9 @@ import { ResponseCacheService } from '../cache/response-cache.service';
import { RequestService } from '../data/request.service';
import { HALEndpointService } from '../shared/hal-endpoint.service';
/**
* Provides methods to retrieve, from REST server, bitstream access conditions configurations applicable during the submission process.
*/
@Injectable()
export class SubmissionUploadsConfigService extends ConfigService {
protected linkPath = 'submissionuploads';

View File

@@ -232,6 +232,9 @@ export class IntegrationRequest extends GetRequest {
}
}
/**
* Class representing a submission HTTP GET request object
*/
export class SubmissionRequest extends GetRequest {
constructor(uuid: string, href: string) {
super(uuid, href);
@@ -242,6 +245,9 @@ export class SubmissionRequest extends GetRequest {
}
}
/**
* Class representing a submission HTTP DELETE request object
*/
export class SubmissionDeleteRequest extends DeleteRequest {
constructor(public uuid: string,
public href: string) {
@@ -253,6 +259,9 @@ export class SubmissionDeleteRequest extends DeleteRequest {
}
}
/**
* Class representing a submission HTTP PATCH request object
*/
export class SubmissionPatchRequest extends PatchRequest {
constructor(public uuid: string,
public href: string,
@@ -265,6 +274,9 @@ export class SubmissionPatchRequest extends PatchRequest {
}
}
/**
* Class representing a submission HTTP POST request object
*/
export class SubmissionPostRequest extends PostRequest {
constructor(public uuid: string,
public href: string,
@@ -278,6 +290,9 @@ export class SubmissionPostRequest extends PostRequest {
}
}
/**
* Class representing an eperson HTTP GET request object
*/
export class EpersonRequest extends GetRequest {
constructor(uuid: string, href: string) {
super(uuid, href);

View File

@@ -13,6 +13,9 @@ import { NormalizedObject } from '../cache/models/normalized-object.model';
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
import { ResourceType } from '../shared/resource-type';
/**
* Provides method to parse response from eperson endpoint.
*/
@Injectable()
export class EpersonResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {

View File

@@ -6,6 +6,9 @@ import { HALEndpointService } from '../shared/hal-endpoint.service';
import { NormalizedObject } from '../cache/models/normalized-object.model';
import { DataService } from '../data/data.service';
/**
* An abstract class that provides methods to make HTTP request to eperson endpoint.
*/
export abstract class EpersonService<TNormalized extends NormalizedObject, TDomain> extends DataService<TNormalized, TDomain> {
protected request: EpersonRequest;
protected abstract responseCache: ResponseCacheService;

View File

@@ -18,6 +18,9 @@ import { SearchParam } from '../cache/models/search-param.model';
import { RemoteData } from '../data/remote-data';
import { PaginatedList } from '../data/paginated-list';
/**
* Provides methods to retrieve eperson group resources.
*/
@Injectable()
export class GroupEpersonService extends EpersonService<NormalizedGroup, Group> {
protected linkPath = 'groups';
@@ -35,6 +38,14 @@ export class GroupEpersonService extends EpersonService<NormalizedGroup, Group>
super();
}
/**
* Check if the current user is member of to the indicated group
*
* @param groupName
* the group name
* @return boolean
* true if user is member of the indicated group, false otherwise
*/
isMemberOf(groupName: string): Observable<boolean> {
const searchHref = 'isMemberOf';
const options = new FindAllOptions();

View File

@@ -3,31 +3,69 @@ import { isNotEmpty } from '../../../shared/empty.util';
import { PLACEHOLDER_PARENT_METADATA } from '../../../shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model';
import { OtherInformation } from '../../../shared/form/builder/models/form-field-metadata-value.model';
/**
* Class representing an authority object
*/
export class AuthorityValue extends IntegrationModel {
/**
* The identifier of this authority
*/
id: string;
/**
* The display value of this authority
*/
display: string;
/**
* The value of this authority
*/
value: string;
/**
* An object containing additional information related to this authority
*/
otherInformation: OtherInformation;
/**
* The language code of this authority value
*/
language: string;
/**
* This method checks if authority has an identifier value
*
* @return boolean
*/
hasAuthority(): boolean {
return isNotEmpty(this.id);
}
/**
* This method checks if authority has a value
*
* @return boolean
*/
hasValue(): boolean {
return isNotEmpty(this.value);
}
/**
* This method checks if authority has related information object
*
* @return boolean
*/
hasOtherInformation(): boolean {
return isNotEmpty(this.otherInformation);
}
hasPlaceholder() {
/**
* This method checks if authority has a placeholder as value
*
* @return boolean
*/
hasPlaceholder(): boolean {
return this.hasValue() && this.value === PLACEHOLDER_PARENT_METADATA;
}
}

View File

@@ -1,16 +1,19 @@
/**
* Combines a variable number of strings representing parts
* of a relative REST URL in to a single, absolute REST URL
*
*/
import { isNotUndefined } from '../../../shared/empty.util';
/**
* Interface used to represent a JSON-PATCH path member
* in JsonPatchOperationsState
*/
export interface JsonPatchOperationPathObject {
rootElement: string;
subRootElement: string;
path: string;
}
/**
* Combines a variable number of strings representing parts
* of a JSON-PATCH path
*/
export class JsonPatchOperationPathCombiner {
private _rootElement: string;
private _subRootElement: string;
@@ -28,6 +31,15 @@ export class JsonPatchOperationPathCombiner {
return this._subRootElement;
}
/**
* Combines the parts of this JsonPatchOperationPathCombiner in to a JSON-PATCH path member
*
* e.g. new JsonPatchOperationPathCombiner('sections', 'basic').getPath(['dc.title', '0'])
* returns: sections/basic/dc.title/0
*
* @return {string}
* The combined path
*/
public getPath(fragment?: string|string[]): JsonPatchOperationPathObject {
if (isNotUndefined(fragment) && Array.isArray(fragment)) {
fragment = fragment.join('/');

View File

@@ -13,12 +13,27 @@ import { AuthorityValue } from '../../integration/models/authority.value';
import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model';
import { FormFieldLanguageValueObject } from '../../../shared/form/builder/models/form-field-language-value.model';
/**
* Provides methods to dispatch JsonPatch Operations Actions
*/
@Injectable()
export class JsonPatchOperationsBuilder {
constructor(private store: Store<CoreState>) {
}
/**
* Dispatches a new NewPatchAddOperationAction
*
* @param path
* a JsonPatchOperationPathObject representing path
* @param value
* The value to update the referenced path
* @param first
* A boolean representing if the value to be added is the first of an array
* @param plain
* A boolean representing if the value to be added is a plain text value
*/
add(path: JsonPatchOperationPathObject, value, first = false, plain = false) {
this.store.dispatch(
new NewPatchAddOperationAction(
@@ -27,6 +42,16 @@ export class JsonPatchOperationsBuilder {
path.path, this.prepareValue(value, plain, first)));
}
/**
* Dispatches a new NewPatchReplaceOperationAction
*
* @param path
* a JsonPatchOperationPathObject representing path
* @param value
* the value to update the referenced path
* @param plain
* a boolean representing if the value to be added is a plain text value
*/
replace(path: JsonPatchOperationPathObject, value, plain = false) {
this.store.dispatch(
new NewPatchReplaceOperationAction(
@@ -36,6 +61,12 @@ export class JsonPatchOperationsBuilder {
this.prepareValue(value, plain, false)));
}
/**
* Dispatches a new NewPatchRemoveOperationAction
*
* @param path
* a JsonPatchOperationPathObject representing path
*/
remove(path: JsonPatchOperationPathObject) {
this.store.dispatch(
new NewPatchRemoveOperationAction(
@@ -57,8 +88,6 @@ export class JsonPatchOperationsBuilder {
operationValue.push(this.prepareObjectValue(entry));
} else {
operationValue.push(new FormFieldMetadataValueObject(entry));
// operationValue.push({value: entry});
// operationValue.push(entry);
}
});
} else if (typeof value === 'object') {
@@ -83,7 +112,6 @@ export class JsonPatchOperationsBuilder {
operationValue = new FormFieldMetadataValueObject(value.value, value.language);
} else if (value.hasOwnProperty('value')) {
operationValue = new FormFieldMetadataValueObject(value.value);
// operationValue = value;
} else {
Object.keys(value)
.forEach((key) => {
@@ -93,7 +121,6 @@ export class JsonPatchOperationsBuilder {
operationValue[key] = value[key];
}
});
// operationValue = {value: value};
}
return operationValue;
}

View File

@@ -8,9 +8,15 @@ import {
JsonPatchOperationsActionTypes
} from './json-patch-operations.actions';
/**
* Provides effect methods for jsonPatch Operations actions
*/
@Injectable()
export class JsonPatchOperationsEffects {
/**
* Dispatches a FlushPatchOperationsAction for every dispatched CommitPatchOperationsAction
*/
@Effect() commit$ = this.actions$.pipe(
ofType(JsonPatchOperationsActionTypes.COMMIT_JSON_PATCH_OPERATIONS),
map((action: CommitPatchOperationsAction) => {

View File

@@ -15,15 +15,25 @@ import {
} from './json-patch-operations.actions';
import { JsonPatchOperationModel, JsonPatchOperationType } from './json-patch.model';
/**
* An interface to represent JSON-PATCH Operation objects to execute
*/
export interface JsonPatchOperationObject {
operation: JsonPatchOperationModel;
timeAdded: number;
}
/**
* An interface to represent the body containing a list of JsonPatchOperationObject
*/
export interface JsonPatchOperationsEntry {
body: JsonPatchOperationObject[];
}
/**
* Interface used to represent a JSON-PATCH path member
* in JsonPatchOperationsState
*/
export interface JsonPatchOperationsResourceEntry {
children: { [resourceId: string]: JsonPatchOperationsEntry };
transactionStartTime: number;
@@ -42,6 +52,16 @@ export interface JsonPatchOperationsState {
const initialState: JsonPatchOperationsState = Object.create(null);
/**
* The JSON-PATCH operations Reducer
*
* @param state
* the current state
* @param action
* the action to perform on the state
* @return JsonPatchOperationsState
* the new state
*/
export function jsonPatchOperationsReducer(state = initialState, action: PatchOperationsActions): JsonPatchOperationsState {
switch (action.type) {

View File

@@ -19,6 +19,9 @@ import {
} from './json-patch-operations.actions';
import { JsonPatchOperationModel } from './json-patch.model';
/**
* An abstract class that provides methods to make JSON Patch requests.
*/
export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, PatchRequestDefinition extends PatchRequest> {
protected abstract responseCache: ResponseCacheService;
protected abstract requestService: RequestService;
@@ -40,6 +43,18 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
return observableMerge(errorResponses, successResponses);
}
/**
* Submit a new JSON Patch request with all operations stored in the state that are ready to be dispatched
*
* @param hrefObs
* Observable of request href
* @param resourceType
* The resource type value
* @param resourceId
* The resource id value
* @return Observable<ResponseDefinitionDomain>
* observable of response
*/
protected submitJsonPatchOperations(hrefObs: Observable<string>, resourceType: string, resourceId?: string): Observable<ResponseDefinitionDomain> {
let startTransactionTime = null;
const [patchRequest$, emptyRequest$] = partition((request: PatchRequestDefinition) => isNotEmpty(request.body))(hrefObs.pipe(
@@ -101,6 +116,18 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
);
}
/**
* Return an instance for RestRequest class
*
* @param uuid
* The request uuid
* @param href
* The request href
* @param body
* The request body
* @return Object<PatchRequestDefinition>
* instance of PatchRequestDefinition
*/
protected getRequestInstance(uuid: string, href: string, body?: any): PatchRequestDefinition {
return new this.patchRequestConstructor(uuid, href, body);
}
@@ -109,8 +136,20 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
return isNotEmpty(resourceID) ? `${endpoint}/${resourceID}` : `${endpoint}`;
}
public jsonPatchByResourceType(linkName: string, scopeId: string, resourceType: string): Observable<ResponseDefinitionDomain> {
const href$ = this.halService.getEndpoint(linkName).pipe(
/**
* Make a new JSON Patch request with all operations related to the specified resource type
*
* @param linkPath
* The link path of the request
* @param scopeId
* The scope id
* @param resourceType
* The resource type value
* @return Observable<ResponseDefinitionDomain>
* observable of response
*/
public jsonPatchByResourceType(linkPath: string, scopeId: string, resourceType: string): Observable<ResponseDefinitionDomain> {
const href$ = this.halService.getEndpoint(linkPath).pipe(
filter((href: string) => isNotEmpty(href)),
distinctUntilChanged(),
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, scopeId)));
@@ -118,8 +157,22 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
return this.submitJsonPatchOperations(href$, resourceType);
}
public jsonPatchByResourceID(linkName: string, scopeId: string, resourceType: string, resourceId: string): Observable<ResponseDefinitionDomain> {
const hrefObs = this.halService.getEndpoint(linkName).pipe(
/**
* Make a new JSON Patch request with all operations related to the specified resource id
*
* @param linkPath
* The link path of the request
* @param scopeId
* The scope id
* @param resourceType
* The resource type value
* @param resourceId
* The resource id value
* @return Observable<ResponseDefinitionDomain>
* observable of response
*/
public jsonPatchByResourceID(linkPath: string, scopeId: string, resourceType: string, resourceId: string): Observable<ResponseDefinitionDomain> {
const hrefObs = this.halService.getEndpoint(linkPath).pipe(
filter((href: string) => isNotEmpty(href)),
distinctUntilChanged(),
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, scopeId)));

View File

@@ -1,3 +1,6 @@
/**
* Represents all JSON Patch operations type.
*/
export enum JsonPatchOperationType {
test = 'test',
remove = 'remove',
@@ -7,6 +10,9 @@ export enum JsonPatchOperationType {
copy = 'copy',
}
/**
* Represents a JSON Patch operations.
*/
export class JsonPatchOperationModel {
op: JsonPatchOperationType;
path: string;

View File

@@ -24,11 +24,29 @@ export function subStateSelector<T, V>(parentSelector: Selector<any, any>, subSt
});
}
/**
* Return MemoizedSelector to select all jsonPatchOperations for a specified resource type, stored in the state
*
* @param resourceType
* the resource type
* @return MemoizedSelector<CoreState, JsonPatchOperationsResourceEntry>
* MemoizedSelector
*/
export function jsonPatchOperationsByResourceType(resourceType: string): MemoizedSelector<CoreState, JsonPatchOperationsResourceEntry> {
return keySelector<CoreState, JsonPatchOperationsResourceEntry>(coreSelector,'json/patch', resourceType);
}
export function jsonPatchOperationsByResourcId(resourceType: string, resourceId: string): MemoizedSelector<CoreState, JsonPatchOperationsEntry> {
/**
* Return MemoizedSelector to select all jsonPatchOperations for a specified resource id, stored in the state
*
* @param resourceType
* the resource type
* @param resourceId
* the resourceId type
* @return MemoizedSelector<CoreState, JsonPatchOperationsResourceEntry>
* MemoizedSelector
*/
export function jsonPatchOperationsByResourceId(resourceType: string, resourceId: string): MemoizedSelector<CoreState, JsonPatchOperationsEntry> {
const resourceTypeSelector = jsonPatchOperationsByResourceType(resourceType);
return subStateSelector<CoreState, JsonPatchOperationsEntry>(resourceTypeSelector, resourceId);
}

View File

@@ -6,12 +6,21 @@ import { RestRequestMethod } from '../data/request.models';
import { saveAs } from 'file-saver';
import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model';
/**
* Provides utility methods to save files on the client-side.
*/
@Injectable()
export class FileService {
constructor(
private restService: DSpaceRESTv2Service
) { }
/**
* Makes a HTTP Get request to download a file
*
* @param url
* file url
*/
downloadFile(url: string) {
const headers = new HttpHeaders();
const options: HttpOptions = Object.create({headers, responseType: 'blob'});
@@ -24,12 +33,12 @@ export class FileService {
/**
* Derives file name from the http response
* by looking inside content-disposition
* @param res http DSpaceRESTV2Response
* @param res
* http DSpaceRESTV2Response
*/
getFileNameFromResponseContentDisposition(res: DSpaceRESTV2Response) {
const contentDisposition = res.headers.get('content-disposition') || '';
const matches = /filename="([^;]+)"/ig.exec(contentDisposition) || [];
const fileName = (matches[1] || 'untitled').trim().replace(/\.[^/.]+$/, '');
return fileName;
return (matches[1] || 'untitled').trim().replace(/\.[^/.]+$/, '');
};
}

View File

@@ -1,5 +1,8 @@
import { ConfigObject } from '../config/models/config.model';
import { SubmissionObject } from '../submission/models/submission-object.model';
/**
* Defines a type for submission request responses.
*/
export type SubmitDataResponseDefinitionObject
= Array<SubmissionObject | ConfigObject | string>;

View File

@@ -1,7 +1,3 @@
/**
* TODO replace with actual string enum after upgrade to TypeScript 2.4:
* https://github.com/Microsoft/TypeScript/pull/15486
*/
export enum SubmissionResourceType {
Bundle = 'bundle',
Bitstream = 'bitstream',