mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
101623: Add ValueListBrowseDefinition model + super NonHierarchicalBrowse class
This commit is contained in:
@@ -18,7 +18,7 @@ import { BrowseDefinitionRestRequest } from '../data/request.models';
|
||||
import { BrowseDefinition } from '../shared/browse-definition.model';
|
||||
|
||||
|
||||
class BrowseDefinitionDataImpl extends FindAllDataImpl<BrowseDefinition> {
|
||||
class BrowseDefinitionFindAllDataImpl extends FindAllDataImpl<BrowseDefinition> {
|
||||
/**
|
||||
* Create a GET request for the given href, and send it.
|
||||
* Use a GET request specific for BrowseDefinitions.
|
||||
@@ -57,7 +57,7 @@ class BrowseDefinitionDataImpl extends FindAllDataImpl<BrowseDefinition> {
|
||||
})
|
||||
@dataService(BROWSE_DEFINITION)
|
||||
export class BrowseDefinitionDataService extends IdentifiableDataService<BrowseDefinition> implements FindAllData<BrowseDefinition> {
|
||||
private findAllData: BrowseDefinitionDataImpl;
|
||||
private findAllData: BrowseDefinitionFindAllDataImpl;
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
@@ -67,7 +67,7 @@ export class BrowseDefinitionDataService extends IdentifiableDataService<BrowseD
|
||||
) {
|
||||
super('browses', requestService, rdbService, objectCache, halService);
|
||||
|
||||
this.findAllData = new BrowseDefinitionDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
|
||||
this.findAllData = new BrowseDefinitionFindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -171,6 +171,9 @@ import { OrcidAuthService } from './orcid/orcid-auth.service';
|
||||
import { VocabularyDataService } from './submission/vocabularies/vocabulary.data.service';
|
||||
import { VocabularyEntryDetailsDataService } from './submission/vocabularies/vocabulary-entry-details.data.service';
|
||||
import { HierarchicalBrowseDefinition } from './shared/hierarchical-browse-definition.model';
|
||||
import { FlatBrowseDefinition } from './shared/flat-browse-definition.model';
|
||||
import { ValueListBrowseDefinition } from './shared/value-list-browse-definition.model';
|
||||
import { NonHierarchicalBrowseDefinition } from './shared/non-hierarchical-browse-definition';
|
||||
|
||||
/**
|
||||
* When not in production, endpoint responses can be mocked for testing purposes
|
||||
@@ -326,6 +329,9 @@ export const models =
|
||||
AuthStatus,
|
||||
BrowseEntry,
|
||||
BrowseDefinition,
|
||||
NonHierarchicalBrowseDefinition,
|
||||
FlatBrowseDefinition,
|
||||
ValueListBrowseDefinition,
|
||||
HierarchicalBrowseDefinition,
|
||||
ClaimedTask,
|
||||
TaskObject,
|
||||
|
@@ -11,6 +11,8 @@ import { DSOResponseParsingService } from './dso-response-parsing.service';
|
||||
import { Serializer } from '../serializer';
|
||||
import { BrowseDefinition } from '../shared/browse-definition.model';
|
||||
import { BROWSE_DEFINITION } from '../shared/browse-definition.resource-type';
|
||||
import { ValueListBrowseDefinition } from '../shared/value-list-browse-definition.model';
|
||||
import { VALUE_LIST_BROWSE_DEFINITION } from '../shared/value-list-browse-definition.resource-type';
|
||||
|
||||
/**
|
||||
* A ResponseParsingService used to parse RawRestResponse coming from the REST API to a BrowseDefinition object
|
||||
@@ -31,12 +33,16 @@ export class BrowseResponseParsingService extends DSOResponseParsingService {
|
||||
let serializer: Serializer<BrowseDefinition>;
|
||||
if (browseType === HIERARCHICAL_BROWSE_DEFINITION.value) {
|
||||
serializer = new this.serializerConstructor(HierarchicalBrowseDefinition);
|
||||
} else {
|
||||
} else if (browseType === FLAT_BROWSE_DEFINITION.value) {
|
||||
serializer = new this.serializerConstructor(FlatBrowseDefinition);
|
||||
} else if (browseType === VALUE_LIST_BROWSE_DEFINITION.value) {
|
||||
serializer = new this.serializerConstructor(ValueListBrowseDefinition);
|
||||
} else {
|
||||
throw new Error('An error occurred while retrieving the browse definitions.');
|
||||
}
|
||||
return serializer.deserialize(obj);
|
||||
} else {
|
||||
return super.deserialize(obj);
|
||||
throw new Error('An error occurred while retrieving the browse definitions.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,13 @@
|
||||
import { autoserialize, autoserializeAs, deserialize, inheritSerialization } from 'cerialize';
|
||||
import { inheritSerialization } from 'cerialize';
|
||||
import { typedObject } from '../cache/builders/build-decorators';
|
||||
import { excludeFromEquals } from '../utilities/equals.decorators';
|
||||
import { FLAT_BROWSE_DEFINITION } from './flat-browse-definition.resource-type';
|
||||
import { HALLink } from './hal-link.model';
|
||||
import { ResourceType } from './resource-type';
|
||||
import { SortOption } from './sort-option.model';
|
||||
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-decorator';
|
||||
import { BrowseDefinition } from './browse-definition.model';
|
||||
import { NonHierarchicalBrowseDefinition } from './non-hierarchical-browse-definition';
|
||||
|
||||
@typedObject
|
||||
@inheritSerialization(BrowseDefinition)
|
||||
export class FlatBrowseDefinition extends BrowseDefinition {
|
||||
@inheritSerialization(NonHierarchicalBrowseDefinition)
|
||||
export class FlatBrowseDefinition extends NonHierarchicalBrowseDefinition {
|
||||
static type = FLAT_BROWSE_DEFINITION;
|
||||
|
||||
/**
|
||||
@@ -19,29 +16,10 @@ export class FlatBrowseDefinition extends BrowseDefinition {
|
||||
@excludeFromEquals
|
||||
type: ResourceType = FLAT_BROWSE_DEFINITION;
|
||||
|
||||
@autoserialize
|
||||
sortOptions: SortOption[];
|
||||
|
||||
@autoserializeAs('order')
|
||||
defaultSortOrder: string;
|
||||
|
||||
@autoserializeAs('metadata')
|
||||
metadataKeys: string[];
|
||||
|
||||
@autoserialize
|
||||
dataType: BrowseByDataType;
|
||||
|
||||
get self(): string {
|
||||
return this._links.self.href;
|
||||
}
|
||||
|
||||
@deserialize
|
||||
_links: {
|
||||
self: HALLink;
|
||||
entries: HALLink;
|
||||
items: HALLink;
|
||||
};
|
||||
|
||||
getRenderType(): string {
|
||||
return this.dataType;
|
||||
}
|
||||
|
32
src/app/core/shared/non-hierarchical-browse-definition.ts
Normal file
32
src/app/core/shared/non-hierarchical-browse-definition.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { autoserialize, autoserializeAs, deserialize, inheritSerialization } from 'cerialize';
|
||||
import { SortOption } from './sort-option.model';
|
||||
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-decorator';
|
||||
import { HALLink } from './hal-link.model';
|
||||
import { BrowseDefinition } from './browse-definition.model';
|
||||
|
||||
/**
|
||||
* Super class for NonHierarchicalBrowseDefinition models,
|
||||
* e.g. FlatBrowseDefinition and ValueListBrowseDefinition
|
||||
*/
|
||||
@inheritSerialization(BrowseDefinition)
|
||||
export abstract class NonHierarchicalBrowseDefinition extends BrowseDefinition {
|
||||
|
||||
@autoserialize
|
||||
sortOptions: SortOption[];
|
||||
|
||||
@autoserializeAs('order')
|
||||
defaultSortOrder: string;
|
||||
|
||||
@autoserializeAs('metadata')
|
||||
metadataKeys: string[];
|
||||
|
||||
@autoserialize
|
||||
dataType: BrowseByDataType;
|
||||
|
||||
@deserialize
|
||||
_links: {
|
||||
self: HALLink;
|
||||
entries: HALLink;
|
||||
items: HALLink;
|
||||
};
|
||||
}
|
26
src/app/core/shared/value-list-browse-definition.model.ts
Normal file
26
src/app/core/shared/value-list-browse-definition.model.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { inheritSerialization } from 'cerialize';
|
||||
import { typedObject } from '../cache/builders/build-decorators';
|
||||
import { excludeFromEquals } from '../utilities/equals.decorators';
|
||||
import { VALUE_LIST_BROWSE_DEFINITION } from './value-list-browse-definition.resource-type';
|
||||
import { ResourceType } from './resource-type';
|
||||
import { NonHierarchicalBrowseDefinition } from './non-hierarchical-browse-definition';
|
||||
|
||||
@typedObject
|
||||
@inheritSerialization(NonHierarchicalBrowseDefinition)
|
||||
export class ValueListBrowseDefinition extends NonHierarchicalBrowseDefinition {
|
||||
static type = VALUE_LIST_BROWSE_DEFINITION;
|
||||
|
||||
/**
|
||||
* The object type
|
||||
*/
|
||||
@excludeFromEquals
|
||||
type: ResourceType = VALUE_LIST_BROWSE_DEFINITION;
|
||||
|
||||
get self(): string {
|
||||
return this._links.self.href;
|
||||
}
|
||||
|
||||
getRenderType(): string {
|
||||
return this.dataType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
import { ResourceType } from './resource-type';
|
||||
|
||||
/**
|
||||
* The resource type for ValueListBrowseDefinition
|
||||
*
|
||||
* Needs to be in a separate file to prevent circular
|
||||
* dependencies in webpack.
|
||||
*/
|
||||
export const VALUE_LIST_BROWSE_DEFINITION = new ResourceType('valueList');
|
Reference in New Issue
Block a user