Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a custom FindDataImpl for browsedefinitions
- Loading branch information
Showing
17 changed files
with
129 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,42 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { hasValue } from '../../shared/empty.util'; | ||
import { HIERARCHICAL_BROWSE_DEFINITION } from '../shared/hierarchical-browse-definition.resource-type'; | ||
import { | ||
HIERARCHICAL_BROWSE_DEFINITION | ||
} from '../shared/hierarchical-browse-definition.resource-type'; | ||
import { FLAT_BROWSE_DEFINITION } from '../shared/flat-browse-definition.resource-type'; | ||
import { HierarchicalBrowseDefinition } from '../shared/hierarchical-browse-definition.model'; | ||
import { FlatBrowseDefinition } from '../shared/flat-browse-definition.model'; | ||
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'; | ||
|
||
/** | ||
* A ResponseParsingService used to parse RawRestResponse coming from the REST API to a BrowseDefinition object | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
providedIn: 'root', | ||
}) | ||
export class BrowseResponseParsingService extends DSOResponseParsingService { | ||
protected objectCache: ObjectCacheService; | ||
protected toCache: boolean; | ||
constructor( | ||
protected objectCache: ObjectCacheService, | ||
) { | ||
super(objectCache); | ||
} | ||
|
||
protected deserialize<ObjectDomain>(obj): any { | ||
const browseType: string = obj.browseType; | ||
if (hasValue(browseType)) { | ||
if (obj.type === BROWSE_DEFINITION.value && hasValue(browseType)) { | ||
let serializer: Serializer<BrowseDefinition>; | ||
if (browseType === HIERARCHICAL_BROWSE_DEFINITION.value) { | ||
const serializer = new this.serializerConstructor(HierarchicalBrowseDefinition); | ||
return serializer.deserialize(obj); | ||
} else if (browseType === FLAT_BROWSE_DEFINITION.value) { | ||
const serializer = new this.serializerConstructor(FlatBrowseDefinition); | ||
return serializer.deserialize(obj); | ||
serializer = new this.serializerConstructor(HierarchicalBrowseDefinition); | ||
} else { | ||
serializer = new this.serializerConstructor(FlatBrowseDefinition); | ||
} | ||
return serializer.deserialize(obj); | ||
} else { | ||
console.warn('cannot deserialize type ' + browseType); | ||
return null; | ||
return super.deserialize(obj); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { autoserialize } from 'cerialize'; | ||
import { CacheableObject } from '../cache/cacheable-object.model'; | ||
|
||
/** | ||
* Base class for BrowseDefinition models | ||
*/ | ||
export abstract class BrowseDefinition extends CacheableObject { | ||
|
||
@autoserialize | ||
id: string; | ||
|
||
/** | ||
* Get the render type of the BrowseDefinition model | ||
*/ | ||
abstract getRenderType(): string; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.