mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Added TypeDoc/comments
This commit is contained in:
@@ -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 { }
|
export class SubmitPageRoutingModule { }
|
||||||
|
@@ -12,6 +12,9 @@ import { SubmissionModule } from '../submission/submission.module';
|
|||||||
SubmissionModule,
|
SubmissionModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* This module handles all modules that need to access the submit page.
|
||||||
|
*/
|
||||||
export class SubmitPageModule {
|
export class SubmitPageModule {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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 { }
|
export class WorkflowitemsEditPageRoutingModule { }
|
||||||
|
@@ -13,6 +13,9 @@ import { SubmissionModule } from '../submission/submission.module';
|
|||||||
],
|
],
|
||||||
declarations: []
|
declarations: []
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* This module handles all modules that need to access the workflowitems edit page.
|
||||||
|
*/
|
||||||
export class WorkflowitemsEditPageModule {
|
export class WorkflowitemsEditPageModule {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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 { }
|
export class WorkspaceitemsEditPageRoutingModule { }
|
||||||
|
@@ -13,6 +13,9 @@ import { SubmissionModule } from '../submission/submission.module';
|
|||||||
],
|
],
|
||||||
declarations: []
|
declarations: []
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* This module handles all modules that need to access the workspaceitems edit page.
|
||||||
|
*/
|
||||||
export class WorkspaceitemsEditPageModule {
|
export class WorkspaceitemsEditPageModule {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,12 +3,15 @@ import { mapsTo } from '../builders/build-decorators';
|
|||||||
import { NormalizedDSpaceObject } from './normalized-dspace-object.model';
|
import { NormalizedDSpaceObject } from './normalized-dspace-object.model';
|
||||||
import { License } from '../../shared/license.model';
|
import { License } from '../../shared/license.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalized model class for a Collection License
|
||||||
|
*/
|
||||||
@mapsTo(License)
|
@mapsTo(License)
|
||||||
@inheritSerialization(NormalizedDSpaceObject)
|
@inheritSerialization(NormalizedDSpaceObject)
|
||||||
export class NormalizedLicense extends NormalizedDSpaceObject {
|
export class NormalizedLicense extends NormalizedDSpaceObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the license custom?
|
* A boolean representing if this License is custom or not
|
||||||
*/
|
*/
|
||||||
@autoserialize
|
@autoserialize
|
||||||
custom: boolean;
|
custom: boolean;
|
||||||
|
@@ -13,7 +13,6 @@ import { NormalizedEPerson } from '../../eperson/models/normalized-eperson.model
|
|||||||
import { NormalizedGroup } from '../../eperson/models/normalized-group.model';
|
import { NormalizedGroup } from '../../eperson/models/normalized-group.model';
|
||||||
import { NormalizedWorkflowItem } from '../../submission/models/normalized-workflowitem.model';
|
import { NormalizedWorkflowItem } from '../../submission/models/normalized-workflowitem.model';
|
||||||
import { NormalizedBitstreamFormat } from './normalized-bitstream-format.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 { SubmissionDefinitionsModel } from '../../config/models/config-submission-definitions.model';
|
||||||
import { SubmissionFormsModel } from '../../config/models/config-submission-forms.model';
|
import { SubmissionFormsModel } from '../../config/models/config-submission-forms.model';
|
||||||
import { SubmissionSectionModel } from '../../config/models/config-submission-section.model';
|
import { SubmissionSectionModel } from '../../config/models/config-submission-section.model';
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing a query parameter (query?fieldName=fieldValue) used in FindAllOptions object
|
||||||
|
*/
|
||||||
export class SearchParam {
|
export class SearchParam {
|
||||||
constructor(public fieldName: string, public fieldValue: any) {
|
constructor(public fieldName: string, public fieldValue: any) {
|
||||||
|
|
||||||
|
@@ -1,8 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Model class for an Access Condition
|
||||||
|
*/
|
||||||
export class AccessConditionOption {
|
export class AccessConditionOption {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name for this Access Condition
|
||||||
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The uuid of the Group this Access Condition applies to
|
||||||
|
*/
|
||||||
groupUUID: string;
|
groupUUID: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A boolean representing if this Access Condition has a start date
|
||||||
|
*/
|
||||||
hasStartDate: boolean;
|
hasStartDate: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A boolean representing if this Access Condition has an end date
|
||||||
|
*/
|
||||||
hasEndDate: boolean;
|
hasEndDate: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum value of the start date
|
||||||
|
*/
|
||||||
maxStartDate: string;
|
maxStartDate: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum value of the end date
|
||||||
|
*/
|
||||||
maxEndDate: string;
|
maxEndDate: string;
|
||||||
}
|
}
|
||||||
|
@@ -3,12 +3,21 @@ import { ConfigObject } from './config.model';
|
|||||||
import { AccessConditionOption } from './config-access-condition-option.model';
|
import { AccessConditionOption } from './config-access-condition-option.model';
|
||||||
import {SubmissionFormsModel} from './config-submission-forms.model';
|
import {SubmissionFormsModel} from './config-submission-forms.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalized model class for the configuration describing the submission upload section
|
||||||
|
*/
|
||||||
@inheritSerialization(ConfigObject)
|
@inheritSerialization(ConfigObject)
|
||||||
export class SubmissionUploadsModel extends ConfigObject {
|
export class SubmissionUploadsModel extends ConfigObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of available bitstream access conditions
|
||||||
|
*/
|
||||||
@autoserialize
|
@autoserialize
|
||||||
accessConditionOptions: AccessConditionOption[];
|
accessConditionOptions: AccessConditionOption[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object representing the configuration describing the bistream metadata form
|
||||||
|
*/
|
||||||
@autoserializeAs(SubmissionFormsModel)
|
@autoserializeAs(SubmissionFormsModel)
|
||||||
metadata: SubmissionFormsModel;
|
metadata: SubmissionFormsModel;
|
||||||
|
|
||||||
|
@@ -4,6 +4,9 @@ import { ResponseCacheService } from '../cache/response-cache.service';
|
|||||||
import { RequestService } from '../data/request.service';
|
import { RequestService } from '../data/request.service';
|
||||||
import { HALEndpointService } from '../shared/hal-endpoint.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()
|
@Injectable()
|
||||||
export class SubmissionUploadsConfigService extends ConfigService {
|
export class SubmissionUploadsConfigService extends ConfigService {
|
||||||
protected linkPath = 'submissionuploads';
|
protected linkPath = 'submissionuploads';
|
||||||
|
@@ -232,6 +232,9 @@ export class IntegrationRequest extends GetRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing a submission HTTP GET request object
|
||||||
|
*/
|
||||||
export class SubmissionRequest extends GetRequest {
|
export class SubmissionRequest extends GetRequest {
|
||||||
constructor(uuid: string, href: string) {
|
constructor(uuid: string, href: string) {
|
||||||
super(uuid, href);
|
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 {
|
export class SubmissionDeleteRequest extends DeleteRequest {
|
||||||
constructor(public uuid: string,
|
constructor(public uuid: string,
|
||||||
public href: 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 {
|
export class SubmissionPatchRequest extends PatchRequest {
|
||||||
constructor(public uuid: string,
|
constructor(public uuid: string,
|
||||||
public href: 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 {
|
export class SubmissionPostRequest extends PostRequest {
|
||||||
constructor(public uuid: string,
|
constructor(public uuid: string,
|
||||||
public href: 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 {
|
export class EpersonRequest extends GetRequest {
|
||||||
constructor(uuid: string, href: string) {
|
constructor(uuid: string, href: string) {
|
||||||
super(uuid, href);
|
super(uuid, href);
|
||||||
|
@@ -13,6 +13,9 @@ import { NormalizedObject } from '../cache/models/normalized-object.model';
|
|||||||
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
|
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
|
||||||
import { ResourceType } from '../shared/resource-type';
|
import { ResourceType } from '../shared/resource-type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides method to parse response from eperson endpoint.
|
||||||
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EpersonResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class EpersonResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
|
@@ -6,6 +6,9 @@ import { HALEndpointService } from '../shared/hal-endpoint.service';
|
|||||||
import { NormalizedObject } from '../cache/models/normalized-object.model';
|
import { NormalizedObject } from '../cache/models/normalized-object.model';
|
||||||
import { DataService } from '../data/data.service';
|
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> {
|
export abstract class EpersonService<TNormalized extends NormalizedObject, TDomain> extends DataService<TNormalized, TDomain> {
|
||||||
protected request: EpersonRequest;
|
protected request: EpersonRequest;
|
||||||
protected abstract responseCache: ResponseCacheService;
|
protected abstract responseCache: ResponseCacheService;
|
||||||
|
@@ -18,6 +18,9 @@ import { SearchParam } from '../cache/models/search-param.model';
|
|||||||
import { RemoteData } from '../data/remote-data';
|
import { RemoteData } from '../data/remote-data';
|
||||||
import { PaginatedList } from '../data/paginated-list';
|
import { PaginatedList } from '../data/paginated-list';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides methods to retrieve eperson group resources.
|
||||||
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GroupEpersonService extends EpersonService<NormalizedGroup, Group> {
|
export class GroupEpersonService extends EpersonService<NormalizedGroup, Group> {
|
||||||
protected linkPath = 'groups';
|
protected linkPath = 'groups';
|
||||||
@@ -35,6 +38,14 @@ export class GroupEpersonService extends EpersonService<NormalizedGroup, Group>
|
|||||||
super();
|
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> {
|
isMemberOf(groupName: string): Observable<boolean> {
|
||||||
const searchHref = 'isMemberOf';
|
const searchHref = 'isMemberOf';
|
||||||
const options = new FindAllOptions();
|
const options = new FindAllOptions();
|
||||||
|
@@ -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 { 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';
|
import { OtherInformation } from '../../../shared/form/builder/models/form-field-metadata-value.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing an authority object
|
||||||
|
*/
|
||||||
export class AuthorityValue extends IntegrationModel {
|
export class AuthorityValue extends IntegrationModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier of this authority
|
||||||
|
*/
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The display value of this authority
|
||||||
|
*/
|
||||||
display: string;
|
display: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of this authority
|
||||||
|
*/
|
||||||
value: string;
|
value: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object containing additional information related to this authority
|
||||||
|
*/
|
||||||
otherInformation: OtherInformation;
|
otherInformation: OtherInformation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The language code of this authority value
|
||||||
|
*/
|
||||||
language: string;
|
language: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method checks if authority has an identifier value
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
hasAuthority(): boolean {
|
hasAuthority(): boolean {
|
||||||
return isNotEmpty(this.id);
|
return isNotEmpty(this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method checks if authority has a value
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
hasValue(): boolean {
|
hasValue(): boolean {
|
||||||
return isNotEmpty(this.value);
|
return isNotEmpty(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method checks if authority has related information object
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
hasOtherInformation(): boolean {
|
hasOtherInformation(): boolean {
|
||||||
return isNotEmpty(this.otherInformation);
|
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;
|
return this.hasValue() && this.value === PLACEHOLDER_PARENT_METADATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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';
|
import { isNotUndefined } from '../../../shared/empty.util';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface used to represent a JSON-PATCH path member
|
||||||
|
* in JsonPatchOperationsState
|
||||||
|
*/
|
||||||
export interface JsonPatchOperationPathObject {
|
export interface JsonPatchOperationPathObject {
|
||||||
rootElement: string;
|
rootElement: string;
|
||||||
subRootElement: string;
|
subRootElement: string;
|
||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combines a variable number of strings representing parts
|
||||||
|
* of a JSON-PATCH path
|
||||||
|
*/
|
||||||
export class JsonPatchOperationPathCombiner {
|
export class JsonPatchOperationPathCombiner {
|
||||||
private _rootElement: string;
|
private _rootElement: string;
|
||||||
private _subRootElement: string;
|
private _subRootElement: string;
|
||||||
@@ -28,6 +31,15 @@ export class JsonPatchOperationPathCombiner {
|
|||||||
return this._subRootElement;
|
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 {
|
public getPath(fragment?: string|string[]): JsonPatchOperationPathObject {
|
||||||
if (isNotUndefined(fragment) && Array.isArray(fragment)) {
|
if (isNotUndefined(fragment) && Array.isArray(fragment)) {
|
||||||
fragment = fragment.join('/');
|
fragment = fragment.join('/');
|
||||||
|
@@ -13,12 +13,27 @@ import { AuthorityValue } from '../../integration/models/authority.value';
|
|||||||
import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model';
|
||||||
import { FormFieldLanguageValueObject } from '../../../shared/form/builder/models/form-field-language-value.model';
|
import { FormFieldLanguageValueObject } from '../../../shared/form/builder/models/form-field-language-value.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides methods to dispatch JsonPatch Operations Actions
|
||||||
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JsonPatchOperationsBuilder {
|
export class JsonPatchOperationsBuilder {
|
||||||
|
|
||||||
constructor(private store: Store<CoreState>) {
|
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) {
|
add(path: JsonPatchOperationPathObject, value, first = false, plain = false) {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
new NewPatchAddOperationAction(
|
new NewPatchAddOperationAction(
|
||||||
@@ -27,6 +42,16 @@ export class JsonPatchOperationsBuilder {
|
|||||||
path.path, this.prepareValue(value, plain, first)));
|
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) {
|
replace(path: JsonPatchOperationPathObject, value, plain = false) {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
new NewPatchReplaceOperationAction(
|
new NewPatchReplaceOperationAction(
|
||||||
@@ -36,6 +61,12 @@ export class JsonPatchOperationsBuilder {
|
|||||||
this.prepareValue(value, plain, false)));
|
this.prepareValue(value, plain, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatches a new NewPatchRemoveOperationAction
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
* a JsonPatchOperationPathObject representing path
|
||||||
|
*/
|
||||||
remove(path: JsonPatchOperationPathObject) {
|
remove(path: JsonPatchOperationPathObject) {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
new NewPatchRemoveOperationAction(
|
new NewPatchRemoveOperationAction(
|
||||||
@@ -57,8 +88,6 @@ export class JsonPatchOperationsBuilder {
|
|||||||
operationValue.push(this.prepareObjectValue(entry));
|
operationValue.push(this.prepareObjectValue(entry));
|
||||||
} else {
|
} else {
|
||||||
operationValue.push(new FormFieldMetadataValueObject(entry));
|
operationValue.push(new FormFieldMetadataValueObject(entry));
|
||||||
// operationValue.push({value: entry});
|
|
||||||
// operationValue.push(entry);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (typeof value === 'object') {
|
} else if (typeof value === 'object') {
|
||||||
@@ -83,7 +112,6 @@ export class JsonPatchOperationsBuilder {
|
|||||||
operationValue = new FormFieldMetadataValueObject(value.value, value.language);
|
operationValue = new FormFieldMetadataValueObject(value.value, value.language);
|
||||||
} else if (value.hasOwnProperty('value')) {
|
} else if (value.hasOwnProperty('value')) {
|
||||||
operationValue = new FormFieldMetadataValueObject(value.value);
|
operationValue = new FormFieldMetadataValueObject(value.value);
|
||||||
// operationValue = value;
|
|
||||||
} else {
|
} else {
|
||||||
Object.keys(value)
|
Object.keys(value)
|
||||||
.forEach((key) => {
|
.forEach((key) => {
|
||||||
@@ -93,7 +121,6 @@ export class JsonPatchOperationsBuilder {
|
|||||||
operationValue[key] = value[key];
|
operationValue[key] = value[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// operationValue = {value: value};
|
|
||||||
}
|
}
|
||||||
return operationValue;
|
return operationValue;
|
||||||
}
|
}
|
||||||
|
@@ -8,9 +8,15 @@ import {
|
|||||||
JsonPatchOperationsActionTypes
|
JsonPatchOperationsActionTypes
|
||||||
} from './json-patch-operations.actions';
|
} from './json-patch-operations.actions';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides effect methods for jsonPatch Operations actions
|
||||||
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JsonPatchOperationsEffects {
|
export class JsonPatchOperationsEffects {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatches a FlushPatchOperationsAction for every dispatched CommitPatchOperationsAction
|
||||||
|
*/
|
||||||
@Effect() commit$ = this.actions$.pipe(
|
@Effect() commit$ = this.actions$.pipe(
|
||||||
ofType(JsonPatchOperationsActionTypes.COMMIT_JSON_PATCH_OPERATIONS),
|
ofType(JsonPatchOperationsActionTypes.COMMIT_JSON_PATCH_OPERATIONS),
|
||||||
map((action: CommitPatchOperationsAction) => {
|
map((action: CommitPatchOperationsAction) => {
|
||||||
|
@@ -15,15 +15,25 @@ import {
|
|||||||
} from './json-patch-operations.actions';
|
} from './json-patch-operations.actions';
|
||||||
import { JsonPatchOperationModel, JsonPatchOperationType } from './json-patch.model';
|
import { JsonPatchOperationModel, JsonPatchOperationType } from './json-patch.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface to represent JSON-PATCH Operation objects to execute
|
||||||
|
*/
|
||||||
export interface JsonPatchOperationObject {
|
export interface JsonPatchOperationObject {
|
||||||
operation: JsonPatchOperationModel;
|
operation: JsonPatchOperationModel;
|
||||||
timeAdded: number;
|
timeAdded: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface to represent the body containing a list of JsonPatchOperationObject
|
||||||
|
*/
|
||||||
export interface JsonPatchOperationsEntry {
|
export interface JsonPatchOperationsEntry {
|
||||||
body: JsonPatchOperationObject[];
|
body: JsonPatchOperationObject[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface used to represent a JSON-PATCH path member
|
||||||
|
* in JsonPatchOperationsState
|
||||||
|
*/
|
||||||
export interface JsonPatchOperationsResourceEntry {
|
export interface JsonPatchOperationsResourceEntry {
|
||||||
children: { [resourceId: string]: JsonPatchOperationsEntry };
|
children: { [resourceId: string]: JsonPatchOperationsEntry };
|
||||||
transactionStartTime: number;
|
transactionStartTime: number;
|
||||||
@@ -42,6 +52,16 @@ export interface JsonPatchOperationsState {
|
|||||||
|
|
||||||
const initialState: JsonPatchOperationsState = Object.create(null);
|
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 {
|
export function jsonPatchOperationsReducer(state = initialState, action: PatchOperationsActions): JsonPatchOperationsState {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
||||||
|
@@ -19,6 +19,9 @@ import {
|
|||||||
} from './json-patch-operations.actions';
|
} from './json-patch-operations.actions';
|
||||||
import { JsonPatchOperationModel } from './json-patch.model';
|
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> {
|
export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, PatchRequestDefinition extends PatchRequest> {
|
||||||
protected abstract responseCache: ResponseCacheService;
|
protected abstract responseCache: ResponseCacheService;
|
||||||
protected abstract requestService: RequestService;
|
protected abstract requestService: RequestService;
|
||||||
@@ -40,6 +43,18 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
|
|||||||
return observableMerge(errorResponses, successResponses);
|
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> {
|
protected submitJsonPatchOperations(hrefObs: Observable<string>, resourceType: string, resourceId?: string): Observable<ResponseDefinitionDomain> {
|
||||||
let startTransactionTime = null;
|
let startTransactionTime = null;
|
||||||
const [patchRequest$, emptyRequest$] = partition((request: PatchRequestDefinition) => isNotEmpty(request.body))(hrefObs.pipe(
|
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 {
|
protected getRequestInstance(uuid: string, href: string, body?: any): PatchRequestDefinition {
|
||||||
return new this.patchRequestConstructor(uuid, href, body);
|
return new this.patchRequestConstructor(uuid, href, body);
|
||||||
}
|
}
|
||||||
@@ -109,8 +136,20 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
|
|||||||
return isNotEmpty(resourceID) ? `${endpoint}/${resourceID}` : `${endpoint}`;
|
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)),
|
filter((href: string) => isNotEmpty(href)),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, scopeId)));
|
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, scopeId)));
|
||||||
@@ -118,8 +157,22 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
|
|||||||
return this.submitJsonPatchOperations(href$, resourceType);
|
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)),
|
filter((href: string) => isNotEmpty(href)),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, scopeId)));
|
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, scopeId)));
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Represents all JSON Patch operations type.
|
||||||
|
*/
|
||||||
export enum JsonPatchOperationType {
|
export enum JsonPatchOperationType {
|
||||||
test = 'test',
|
test = 'test',
|
||||||
remove = 'remove',
|
remove = 'remove',
|
||||||
@@ -7,6 +10,9 @@ export enum JsonPatchOperationType {
|
|||||||
copy = 'copy',
|
copy = 'copy',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a JSON Patch operations.
|
||||||
|
*/
|
||||||
export class JsonPatchOperationModel {
|
export class JsonPatchOperationModel {
|
||||||
op: JsonPatchOperationType;
|
op: JsonPatchOperationType;
|
||||||
path: string;
|
path: string;
|
||||||
|
@@ -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> {
|
export function jsonPatchOperationsByResourceType(resourceType: string): MemoizedSelector<CoreState, JsonPatchOperationsResourceEntry> {
|
||||||
return keySelector<CoreState, JsonPatchOperationsResourceEntry>(coreSelector,'json/patch', resourceType);
|
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);
|
const resourceTypeSelector = jsonPatchOperationsByResourceType(resourceType);
|
||||||
return subStateSelector<CoreState, JsonPatchOperationsEntry>(resourceTypeSelector, resourceId);
|
return subStateSelector<CoreState, JsonPatchOperationsEntry>(resourceTypeSelector, resourceId);
|
||||||
}
|
}
|
||||||
|
@@ -6,12 +6,21 @@ import { RestRequestMethod } from '../data/request.models';
|
|||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model';
|
import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides utility methods to save files on the client-side.
|
||||||
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FileService {
|
export class FileService {
|
||||||
constructor(
|
constructor(
|
||||||
private restService: DSpaceRESTv2Service
|
private restService: DSpaceRESTv2Service
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a HTTP Get request to download a file
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* file url
|
||||||
|
*/
|
||||||
downloadFile(url: string) {
|
downloadFile(url: string) {
|
||||||
const headers = new HttpHeaders();
|
const headers = new HttpHeaders();
|
||||||
const options: HttpOptions = Object.create({headers, responseType: 'blob'});
|
const options: HttpOptions = Object.create({headers, responseType: 'blob'});
|
||||||
@@ -24,12 +33,12 @@ export class FileService {
|
|||||||
/**
|
/**
|
||||||
* Derives file name from the http response
|
* Derives file name from the http response
|
||||||
* by looking inside content-disposition
|
* by looking inside content-disposition
|
||||||
* @param res http DSpaceRESTV2Response
|
* @param res
|
||||||
|
* http DSpaceRESTV2Response
|
||||||
*/
|
*/
|
||||||
getFileNameFromResponseContentDisposition(res: DSpaceRESTV2Response) {
|
getFileNameFromResponseContentDisposition(res: DSpaceRESTV2Response) {
|
||||||
const contentDisposition = res.headers.get('content-disposition') || '';
|
const contentDisposition = res.headers.get('content-disposition') || '';
|
||||||
const matches = /filename="([^;]+)"/ig.exec(contentDisposition) || [];
|
const matches = /filename="([^;]+)"/ig.exec(contentDisposition) || [];
|
||||||
const fileName = (matches[1] || 'untitled').trim().replace(/\.[^/.]+$/, '');
|
return (matches[1] || 'untitled').trim().replace(/\.[^/.]+$/, '');
|
||||||
return fileName;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
import { ConfigObject } from '../config/models/config.model';
|
import { ConfigObject } from '../config/models/config.model';
|
||||||
import { SubmissionObject } from '../submission/models/submission-object.model';
|
import { SubmissionObject } from '../submission/models/submission-object.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a type for submission request responses.
|
||||||
|
*/
|
||||||
export type SubmitDataResponseDefinitionObject
|
export type SubmitDataResponseDefinitionObject
|
||||||
= Array<SubmissionObject | ConfigObject | string>;
|
= Array<SubmissionObject | ConfigObject | string>;
|
||||||
|
@@ -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 {
|
export enum SubmissionResourceType {
|
||||||
Bundle = 'bundle',
|
Bundle = 'bundle',
|
||||||
Bitstream = 'bitstream',
|
Bitstream = 'bitstream',
|
||||||
|
Reference in New Issue
Block a user