removed hardcoded included metadata from mock items

This commit is contained in:
Art Lowel
2016-12-15 17:21:53 +01:00
parent 8f2b141076
commit 7bf5c22e5f
2 changed files with 4 additions and 188 deletions

View File

@@ -120,7 +120,7 @@ export function createMockApi() {
console.log('GET');
// 70ms latency
setTimeout(function() {
res.json(toJSONAPIResponse(req, ITEMS, METADATA));
res.json(toJSONAPIResponse(req, ITEMS));
}, 0);
// })
@@ -146,7 +146,7 @@ export function createMockApi() {
try {
req.item_id = id;
req.item = ITEMS.find((item) => {
return item.id = id;
return item.id === id;
});
next();
} catch (e) {
@@ -157,7 +157,7 @@ export function createMockApi() {
router.route('/items/:item_id')
.get(function(req, res) {
console.log('GET', util.inspect(req.item, { colors: true }));
const metadataIds: string[] = req.item.relationships.metadata.map(obj => obj.id);
const metadataIds: string[] = req.item.relationships.metadata.data.map(obj => obj.id);
const itemMetadata: any[] = METADATA.filter((metadatum) => {
return metadataIds.indexOf(metadatum.id) >= 0
});

View File

@@ -69,116 +69,6 @@ export const ITEMS = [
]
}
},
"included": [
{
"type": "metadata",
"id": "d58a3098-b390-4cd6-8f52-b088b3daa637",
"attributes": {
"key": "dc.contributor.author",
"value": "Antelman, Kristin",
"language": "en"
}
},
{
"type": "metadata",
"id": "56660730-0e0d-47ec-864a-bda2327d5716",
"attributes": {
"key": "dc.date.accessioned",
"value": "2016-10-14T10:41:13Z",
"language": null
}
},
{
"type": "metadata",
"id": "b9d4ae74-2758-4964-a95e-eecd35b62f26",
"attributes": {
"key": "dc.date.available",
"value": "2016-10-14T10:41:13Z",
"language": null
}
},
{
"type": "metadata",
"id": "311529ea-e339-4d8f-9292-813ebe515f03",
"attributes": {
"key": "dc.date.issued",
"value": "2004-09-01",
"language": "en"
}
},
{
"type": "metadata",
"id": "fa875444-3faf-482a-b099-77233bda914d",
"attributes": {
"key": "dc.identifier.uri",
"value": "http://hdl.handle.net/123456789/8871",
"language": null
}
},
{
"type": "metadata",
"id": "ddbb161b-6e52-4a90-9096-c8eae8cec4c9",
"attributes": {
"key": "dc.description.abstract",
"value": "Although many authors believe that their work has a greater research impact if it is freely available, studies to demonstrate that impact are few. This study looks at articles in four disciplines at varying stages of adoption of open access—philosophy, political science, electrical and electronic engineering and mathematics—to see whether they have a greater impact as measured by citations in the ISI Web of Science database when their authors make them freely available on the Internet. The finding is that, across all four disciplines, freely available articles do have a greater research impact. Shedding light on this category of open access reveals that scholars in diverse disciplines are adopting open-access practices and being rewarded for it.",
"language": "en"
}
},
{
"type": "metadata",
"id": "ba51287d-a2c9-409b-8129-060b693a7570",
"attributes": {
"key": "dc.publisher",
"value": "College & Research Libraries News",
"language": "en"
}
},
{
"type": "metadata",
"id": "e5c1c9d4-b4e2-4bdc-9153-6b769742b33f",
"attributes": {
"key": "dc.subject",
"value": "Publishing",
"language": "en"
}
},
{
"type": "metadata",
"id": "4c125844-1eca-47aa-98f8-61c51a9c962f",
"attributes": {
"key": "dc.subject",
"value": "Intellectual Property",
"language": "en"
}
},
{
"type": "metadata",
"id": "362c753c-a44d-468d-b256-486470b8c1e1",
"attributes": {
"key": "dc.subject",
"value": "Open Access",
"language": "en"
}
},
{
"type": "metadata",
"id": " 69a02355-37bb-479f-9496-c8743fcacf3c",
"attributes": {
"key": "dc.title",
"value": "Do Open-Access Articles Have a Greater Research Impact?",
"language": "en"
}
},
{
"type": "metadata",
"id": "ffbd75d5-bf3a-47ff-af22-490240f6fcc6",
"attributes": {
"key": "dc.type",
"value": "(not specified)",
"language": "en"
}
}
]
},
{
"id": "be8325f7-243b-49f4-8a4b-df2b793ff3b5",
@@ -233,80 +123,6 @@ export const ITEMS = [
}
]
}
},
"included": [
{
"type": "metadata",
"id": "981c725e-53f3-4749-89ee-ef042f23c3c3",
"attributes": {
"key": "dc.contributor.author",
"value": "John Doe",
"language": "en"
}
},
{
"type": "metadata",
"id": "521df61d-c541-4180-beb8-ac0a1bd1e852",
"attributes": {
"key": "dc.date.accessioned",
"value": "2016-05-27T07:45:04Z",
"language": null
}
},
{
"type": "metadata",
"id": "551a216d-5350-4b15-9398-9bc2e95e7a3d",
"attributes": {
"key": "dc.date.available",
"value": "2016-05-27T07:45:04Z",
"language": null
}
},
{
"type": "metadata",
"id": " eb17dce4-3892-47fe-b014-6ff8e17a93ef",
"attributes": {
"key": "dc.date.issued",
"value": "2016-05-27",
"language": "en"
}
},
{
"type": "metadata",
"id": "3e840957-cb1b-4521-8f5d-fb5f6956f303",
"attributes": {
"key": "dc.identifier.uri",
"value": "http://hdl.handle.net/123456789/9978",
"language": null
}
},
{
"type": "metadata",
"id": "ae0bc880-481b-4425-aa5b-354b38d24e4f",
"attributes": {
"key": "dc.description.abstract",
"value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas lacus velit, lacinia eu ultrices nec, auctor in sem. Donec interdum convallis ornare. Aliquam et tortor risus. Praesent ut feugiat eros, eu consequat nibh. Morbi id quam eu mi pellentesque consequat vel vitae sem. Praesent sed velit ullamcorper, efficitur odio non, aliquet urna. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque eu placerat urna. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nulla non aliquet mauris. Nulla quis posuere lorem. Pellentesque tempus maximus ipsum ac pretium. Nunc hendrerit tempus sem, vitae luctus erat consectetur vestibulum. Nulla sodales felis in dictum sagittis.\n\nNullam porta magna quis magna vulputate elementum. Pellentesque dictum lorem id nisl tincidunt condimentum. Sed est dolor, dapibus sit amet augue at, malesuada cursus quam. Pellentesque elit felis, malesuada dictum congue tristique, iaculis euismod ligula. Donec dignissim dolor eu lacus pulvinar porttitor. Sed quis semper augue, dictum sollicitudin eros. \n\nMauris congue lectus at turpis viverra scelerisque. Praesent at urna rhoncus, condimentum odio ac, sagittis libero. Nulla aliquam ornare bibendum. Duis quis ornare urna. Suspendisse semper tincidunt neque nec consequat. Sed enim diam, mollis eu neque vitae, lacinia varius risus. Fusce nec sem tempor, efficitur lectus sed, porta sem. Pellentesque sollicitudin ut dui vitae malesuada.",
"language": "en"
}
},
{
"type": "metadata",
"id": "8dc89ac4-d606-4f1a-8524-8f70a6b371de",
"attributes": {
"key": "dc.title",
"value": "Another Test Item",
"language": "en"
}
},
{
"type": "metadata",
"id": "13185eb9-dc05-4bd7-9c2d-5322a2ac5326",
"attributes": {
"key": "dc.type",
"value": "(not specified)",
"language": "en"
}
}
]
}
}
];