-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (65 loc) · 2.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var metadataFilePath = './data/2016-02-13_metadata.xlsx',
paData2buildm = require('./lib/paData2buildm'),
e57Data2buildm = require('./lib/e57Data2buildm'),
Converter = require('./lib/converter'),
_ = require('underscore'),
util = require('util');
var converter = new Converter({
metadataFilePath: metadataFilePath,
sheetName: 'MetaData',
paRowStart: '6',
paRowEnd: '32',
e57RowStart: '48',
e57RowEnd: '60',
paData2buildm: paData2buildm,
e57Data2buildm: e57Data2buildm,
buildmBaseUrl: 'http://data.duraark.eu/vocab/buildm/'
}),
insertIntoSDAS = false,
cols = ['AA', 'AD', 'AI', 'AJ', 'AK', 'AL', 'AV', 'AZ', 'BA', 'BC', 'BL', 'BM', 'BN', 'BQ', 'BS', 'BT', 'BU', 'BW', 'BZ', 'CD', 'CI'];
// cols = ['AJ'];
_.forEach(cols, function(col) {
var paDataset = converter.getPADataFromSheet(col),
e57Dataset = converter.getE57DataFromSheet(col),
name = paDataset.name;
if (name) {
console.log('Processing physical asset: %s [row: %s]', name, col);
var paJsonLD = converter.createPhysicalAssetAsJsonLD(paDataset);
var e57sJsonLD = [];
var basePath = '/tmp/duraark-data' + paDataset.fileBaseUrl + '/';
converter.getDigitalObjectsUrls(basePath).then(function(filePaths) {
_.forEach(filePaths, function(filePath) {
// console.log(' adding file: ' + filePath);
if (filePath.split('.').pop().toLowerCase() !== 'zip') {
var e57JsonLD = converter.createE57AsJsonLD(filePath, e57Dataset, paJsonLD.uri, paDataset.rightsDetails, '/tmp/duraark-data'); // FIXXME: javascriptify parameters!
if (!paJsonLD.jsonld['http://data.duraark.eu/vocab/buildm/isRepresentedBy']) {
paJsonLD.jsonld['http://data.duraark.eu/vocab/buildm/isRepresentedBy'] = [];
}
paJsonLD.jsonld['http://data.duraark.eu/vocab/buildm/isRepresentedBy'].push({
'@value': e57JsonLD.uri
});
e57sJsonLD.push(e57JsonLD);
}
});
converter.writeWorkbenchUISessionFile(paJsonLD, e57sJsonLD);
var tmp = [];
_.forEach(e57sJsonLD, function(item) {
// delete item.jsonld['@type']; // the SDAVer does not cope with the @type predicate
tmp.push(item.jsonld);
});
// delete paJsonLD.jsonld['@type']; // the SDAVer does not cope with the @type predicate
tmp.push(paJsonLD.jsonld);
converter.writeRDFFile(tmp, paJsonLD.uri).then(function(rdfFilePath) {
if (insertIntoSDAS) {
converter.insertIntoSDAS(rdfFilePath).then(function() {
console.log('Successfully inserted data into the SDAS');
}).catch(function(err) {
console.log('ERROR inserting data into the SDAS for: ' + rdfFilePath);
});
}
});
});
} else {
console.log('Skipping bogus data from col: ' + col);
}
});