Skip to content
Snippets Groups Projects
Commit 259fea65 authored by Mike Lynch's avatar Mike Lynch
Browse files

Committing before pushing to npm

parent fbae3ae3
Branches
Tags
No related merge requests found
...@@ -18,5 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -18,5 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
module.exports = { module.exports = {
Catalog: require('./lib/catalog.js') catalog: require('./lib/catalog.js')
} }
...@@ -16,11 +16,15 @@ You should have received a copy of the GNU General Public License ...@@ -16,11 +16,15 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
const CONTEXT = './defaults/context.json';
const fs = require('fs-extra'); const fs = require('fs-extra');
const _ = require('lodash'); const _ = require('lodash');
const path = require('path');
const DEFAULTS = path.join(__dirname, "../defaults");
const CONTEXT = path.join(DEFAULTS, 'context.json');
/* datapub2catalog(options) /* datapub2catalog(options)
...@@ -74,12 +78,16 @@ async function datapub2catalog(options) { ...@@ -74,12 +78,16 @@ async function datapub2catalog(options) {
}; };
const organisation = { const organisation = {
'@id': org['@id'], '@id': org['id'],
'@type': 'Organization', '@type': 'Organization',
'identifier': org['@id'], 'identifier': org['id'],
'name': org['name'] 'name': org['name']
}; };
if( ! (organisation['@id'] && organisation['name'] ) ) {
throw Error("Organization must have an id and a name");
}
// assuming that all creators are affiliated to this one organisation // assuming that all creators are affiliated to this one organisation
var people = make_creators(datapub, organisation); var people = make_creators(datapub, organisation);
...@@ -139,7 +147,8 @@ function link_id(item) { ...@@ -139,7 +147,8 @@ function link_id(item) {
function make_dataset(id, datapub, organisation, dates, files) { function make_dataset(id, datapub, organisation, dates, files) {
const ds = { const ds = {
'@id': id, '@id': id,
'type': 'Dataset', '@type': 'Dataset',
'path': './',
'name': datapub['title'], 'name': datapub['title'],
'description': datapub['description'], 'description': datapub['description'],
'dateCreated': dates['dateCreated'], 'dateCreated': dates['dateCreated'],
...@@ -166,6 +175,7 @@ function make_history(dataset, people, owner, approver, dates) { ...@@ -166,6 +175,7 @@ function make_history(dataset, people, owner, approver, dates) {
if( !owner_item ) { if( !owner_item ) {
owner_item = { owner_item = {
'@id': owner, '@id': owner,
'@type': 'Person',
'email': owner 'email': owner
}; };
new_people.push(owner_item) new_people.push(owner_item)
...@@ -173,10 +183,12 @@ function make_history(dataset, people, owner, approver, dates) { ...@@ -173,10 +183,12 @@ function make_history(dataset, people, owner, approver, dates) {
if( !approver_item ) { if( !approver_item ) {
approver_item = { approver_item = {
'@id': approver, '@id': approver,
'@type': 'Person',
'email': approver 'email': approver
}; };
new_people.push(approver_item) new_people.push(approver_item)
} }
// TODO: descriptions for these and maybe a link to the // TODO: descriptions for these and maybe a link to the
// data record for the CreateAction // data record for the CreateAction
...@@ -186,6 +198,7 @@ function make_history(dataset, people, owner, approver, dates) { ...@@ -186,6 +198,7 @@ function make_history(dataset, people, owner, approver, dates) {
'@id': dataset['@id'] + '_history1', '@id': dataset['@id'] + '_history1',
'@type': 'CreateAction', '@type': 'CreateAction',
'name': 'Create', 'name': 'Create',
'description': 'Data record created',
'endTime': dates['dateCreated'], 'endTime': dates['dateCreated'],
'object': link_id(dataset), 'object': link_id(dataset),
'agent': link_id(owner_item) 'agent': link_id(owner_item)
...@@ -247,6 +260,7 @@ function make_creators(datapub, organisation) { ...@@ -247,6 +260,7 @@ function make_creators(datapub, organisation) {
if( id ) { if( id ) {
return { return {
'@id': id, '@id': id,
'@type': 'Person',
'identifier': id, 'identifier': id,
'name': p['text_full_name'], 'name': p['text_full_name'],
'familyName': p['family_name'], 'familyName': p['family_name'],
......
...@@ -30,7 +30,7 @@ const catalog = require('../lib/catalog.js'); ...@@ -30,7 +30,7 @@ const catalog = require('../lib/catalog.js');
const ORG = { const ORG = {
'@id': 'https://www.uts.edu.au', 'id': 'https://www.uts.edu.au',
'name': 'University of Technology Sydney' 'name': 'University of Technology Sydney'
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment