Added distinct ids and uuids to the mock data

This commit is contained in:
Art Lowel
2017-02-16 15:52:50 +01:00
parent a952557616
commit de23b1aaeb
7 changed files with 51 additions and 57 deletions

View File

@@ -48,19 +48,13 @@ export class CollectionDataEffects {
@Effect() findById$ = this.actions$
.ofType(CollectionFindSingleActionTypes.FIND_BY_ID_REQUEST)
.switchMap(action => {
if (this.cache.has(action.payload)) {
return this.cache.get<Collection>(action.payload)
.map(collection => new CollectionFindByIdSuccessAction(collection.uuid));
}
else {
return this.restApi.get(`/collections/${action.payload}`)
.map((data: DSpaceRESTV2Response) => new DSpaceRESTv2Serializer(Collection).deserialize(data))
.do((collection: Collection) => {
this.cache.add(collection, GlobalConfig.cache.msToLive);
})
.map((collection: Collection) => new CollectionFindByIdSuccessAction(collection.uuid))
.catch((errorMsg: string) => Observable.of(new CollectionFindByIdErrorAction(errorMsg)));
}
return this.restApi.get(`/collections/${action.payload}`)
.map((data: DSpaceRESTV2Response) => new DSpaceRESTv2Serializer(Collection).deserialize(data))
.do((collection: Collection) => {
this.cache.add(collection, GlobalConfig.cache.msToLive);
})
.map((collection: Collection) => new CollectionFindByIdSuccessAction(collection.uuid))
.catch((errorMsg: string) => Observable.of(new CollectionFindByIdErrorAction(errorMsg)));
});
}

View File

@@ -48,19 +48,13 @@ export class ItemDataEffects {
@Effect() findById$ = this.actions$
.ofType(ItemFindSingleActionTypes.FIND_BY_ID_REQUEST)
.switchMap(action => {
if (this.cache.has(action.payload)) {
return this.cache.get<Item>(action.payload)
.map(item => new ItemFindByIdSuccessAction(item.uuid));
}
else {
return this.restApi.get(`/items/${action.payload}`)
.map((data: DSpaceRESTV2Response) => new DSpaceRESTv2Serializer(Item).deserialize(data))
.do((item: Item) => {
this.cache.add(item, GlobalConfig.cache.msToLive);
})
.map((item: Item) => new ItemFindByIdSuccessAction(item.uuid))
.catch((errorMsg: string) => Observable.of(new ItemFindByIdErrorAction(errorMsg)));
}
return this.restApi.get(`/items/${action.payload}`)
.map((data: DSpaceRESTV2Response) => new DSpaceRESTv2Serializer(Item).deserialize(data))
.do((item: Item) => {
this.cache.add(item, GlobalConfig.cache.msToLive);
})
.map((item: Item) => new ItemFindByIdSuccessAction(item.uuid))
.catch((errorMsg: string) => Observable.of(new ItemFindByIdErrorAction(errorMsg)));
});
}

View File

@@ -9,11 +9,17 @@ import { CacheableObject } from "../data-services/cache/cache.reducer";
export abstract class DSpaceObject implements CacheableObject {
/**
* The identifier of this DSpaceObject
* The human-readable identifier of this DSpaceObject
*/
@autoserialize
id: string;
/**
* The universally unique identifier of this DSpaceObject
*/
@autoserialize
uuid: string;
/**
* A string representing the kind of DSpaceObject, e.g. community, item, …
*/
@@ -65,12 +71,4 @@ export abstract class DSpaceObject implements CacheableObject {
return undefined;
}
}
get uuid(): string {
return this.id;
}
set uuid(val: string) {
this.id = val;
}
}

View File

@@ -5,7 +5,8 @@ export const BITSTREAMS = [
"bundle": { "href": "/bundles/35e0606d-5e18-4f9c-aa61-74fc751cc3f9" },
"retrieve": { "href": "/bitstreams/43c57c2b-206f-4645-8c8f-5f10c84b09fa/retrieve" }
},
"id": "43c57c2b-206f-4645-8c8f-5f10c84b09fa",
"id": "3678",
"uuid": "43c57c2b-206f-4645-8c8f-5f10c84b09fa",
"name": "do_open_access_CRL.pdf",
"size": 636626,
"checksum": {
@@ -25,7 +26,8 @@ export const BITSTREAMS = [
"bundle": { "href": "/bundles/a469c57a-abcf-45c3-83e4-b187ebd708fd" },
"retrieve": { "href": "/rest/bitstreams/1a013ecc-fb25-4689-a44f-f1383ad26632/retrieve" }
},
"id": "1a013ecc-fb25-4689-a44f-f1383ad26632",
"id": "8842",
"uuid": "1a013ecc-fb25-4689-a44f-f1383ad26632",
"name": "do_open_access_CRL.pdf.jpg",
"size": 41183,
"checksum": {

View File

@@ -3,14 +3,15 @@ export const BUNDLES = [
"_links": {
"self": { "href": "/bundles/35e0606d-5e18-4f9c-aa61-74fc751cc3f9" },
"items": [
{ "href": "/items/21539b1d-9ef1-4eda-9c77-49565b5bfb78" }
{ "href": "/items/8871" }
],
"bitstreams": [
{ "href": "/bitstreams/43c57c2b-206f-4645-8c8f-5f10c84b09fa" },
],
"primaryBitstream": { "href": "/bitstreams/43c57c2b-206f-4645-8c8f-5f10c84b09fa" }
},
"id": "35e0606d-5e18-4f9c-aa61-74fc751cc3f9",
"id": "2355",
"uuid": "35e0606d-5e18-4f9c-aa61-74fc751cc3f9",
"name": "ORIGINAL",
"metadata": [
{ "key": "dc.title", "value": "ORIGINAL", "language": "en" }
@@ -20,14 +21,15 @@ export const BUNDLES = [
"_links": {
"self": { "href": "/bundles/a469c57a-abcf-45c3-83e4-b187ebd708fd" },
"items": [
{ "href": "/items/21539b1d-9ef1-4eda-9c77-49565b5bfb78" }
{ "href": "/items/8871" }
],
"bitstreams": [
{ "href": "/bitstreams/1a013ecc-fb25-4689-a44f-f1383ad26632" },
],
"primaryBitstream": { "href": "/bitstreams/1a013ecc-fb25-4689-a44f-f1383ad26632" }
},
"id": "a469c57a-abcf-45c3-83e4-b187ebd708fd",
"id": "5687",
"uuid": "a469c57a-abcf-45c3-83e4-b187ebd708fd",
"name": "THUMBNAIL",
"metadata": [
{ "key": "dc.title", "value": "THUMBNAIL", "language": "en" }

View File

@@ -1,13 +1,14 @@
export const COLLECTIONS = [
{
"_links": {
"self": { "href": "/collections/9e32a2e2-6b91-4236-a361-995ccdc14c60" },
"self": { "href": "/collections/5179" },
"items": [
{ "href": "/items/21539b1d-9ef1-4eda-9c77-49565b5bfb78" },
{ "href": "/items/be8325f7-243b-49f4-8a4b-df2b793ff3b5" }
{ "href": "/items/8871" },
{ "href": "/items/9978" }
]
},
"id": "9e32a2e2-6b91-4236-a361-995ccdc14c60",
"id": "5179",
"uuid": "9e32a2e2-6b91-4236-a361-995ccdc14c60",
"name": "A Test Collection",
"handle": "123456789/5179",
"metadata": [
@@ -35,13 +36,14 @@ export const COLLECTIONS = [
},
{
"_links": {
"self": { "href": "/collections/598ce822-c357-46f3-ab70-63724d02d6ad" },
"self": { "href": "/collections/6547" },
"items": [
{ "href": "/items/21539b1d-9ef1-4eda-9c77-49565b5bfb78" },
{ "href": "/items/be8325f7-243b-49f4-8a4b-df2b793ff3b5" }
{ "href": "/items/8871" },
{ "href": "/items/9978" }
]
},
"id": "598ce822-c357-46f3-ab70-63724d02d6ad",
"id": "6547",
"uuid": "598ce822-c357-46f3-ab70-63724d02d6ad",
"name": "Another Test Collection",
"handle": "123456789/6547",
"metadata": [

View File

@@ -2,14 +2,14 @@ export const ITEMS = [
{
"_links": {
"self": {
"href": "/items/21539b1d-9ef1-4eda-9c77-49565b5bfb78"
"href": "/items/8871"
},
"collections": [
{
"href": "/collections/9e32a2e2-6b91-4236-a361-995ccdc14c60"
"href": "/collections/5179"
},
{
"href": "/collections/598ce822-c357-46f3-ab70-63724d02d6ad"
"href": "/collections/6547"
}
],
"bundles": [
@@ -21,7 +21,8 @@ export const ITEMS = [
}
]
},
"id": "21539b1d-9ef1-4eda-9c77-49565b5bfb78",
"id": "8871",
"uuid": "21539b1d-9ef1-4eda-9c77-49565b5bfb78",
"name": "Do Open-Access Articles Have a Greater Research Impact?",
"handle": "123456789/8871",
"lastModified": "2016-10-14 10:41:12.886",
@@ -93,14 +94,14 @@ export const ITEMS = [
{
"_links": {
"self": {
"href": "/items/be8325f7-243b-49f4-8a4b-df2b793ff3b5"
"href": "/items/9978"
},
"collections": [
{
"href": "/collections/9e32a2e2-6b91-4236-a361-995ccdc14c60"
"href": "/collections/5179"
},
{
"href": "/collections/598ce822-c357-46f3-ab70-63724d02d6ad"
"href": "/collections/6547"
}
],
"bundles": [
@@ -112,7 +113,8 @@ export const ITEMS = [
}
]
},
"id": "be8325f7-243b-49f4-8a4b-df2b793ff3b5",
"id": "9978",
"uuid": "be8325f7-243b-49f4-8a4b-df2b793ff3b5",
"name": "Another Test Item",
"handle": "123456789/9978",
"lastModified": "2016-05-27 03:00:20.063",