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
No related merge requests found
......@@ -18,5 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const CONTEXT = './defaults/context.json';
const fs = require('fs-extra');
const _ = require('lodash');
const path = require('path');
const DEFAULTS = path.join(__dirname, "../defaults");
const CONTEXT = path.join(DEFAULTS, 'context.json');
/* datapub2catalog(options)
......@@ -74,12 +78,16 @@ async function datapub2catalog(options) {
};
const organisation = {
'@id': org['@id'],
'@id': org['id'],
'@type': 'Organization',
'identifier': org['@id'],
'identifier': org['id'],
'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
var people = make_creators(datapub, organisation);
......@@ -139,7 +147,8 @@ function link_id(item) {
function make_dataset(id, datapub, organisation, dates, files) {
const ds = {
'@id': id,
'type': 'Dataset',
'@type': 'Dataset',
'path': './',
'name': datapub['title'],
'description': datapub['description'],
'dateCreated': dates['dateCreated'],
......@@ -166,6 +175,7 @@ function make_history(dataset, people, owner, approver, dates) {
if( !owner_item ) {
owner_item = {
'@id': owner,
'@type': 'Person',
'email': owner
};
new_people.push(owner_item)
......@@ -173,10 +183,12 @@ function make_history(dataset, people, owner, approver, dates) {
if( !approver_item ) {
approver_item = {
'@id': approver,
'@type': 'Person',
'email': approver
};
new_people.push(approver_item)
}
// TODO: descriptions for these and maybe a link to the
// data record for the CreateAction
......@@ -186,6 +198,7 @@ function make_history(dataset, people, owner, approver, dates) {
'@id': dataset['@id'] + '_history1',
'@type': 'CreateAction',
'name': 'Create',
'description': 'Data record created',
'endTime': dates['dateCreated'],
'object': link_id(dataset),
'agent': link_id(owner_item)
......@@ -247,6 +260,7 @@ function make_creators(datapub, organisation) {
if( id ) {
return {
'@id': id,
'@type': 'Person',
'identifier': id,
'name': p['text_full_name'],
'familyName': p['family_name'],
......
......@@ -30,7 +30,7 @@ const catalog = require('../lib/catalog.js');
const ORG = {
'@id': 'https://www.uts.edu.au',
'id': 'https://www.uts.edu.au',
'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