forked from zedomel/dwca-gsheet-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DwCAMetadata.js
executable file
·433 lines (376 loc) · 27 KB
/
DwCAMetadata.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
/**
* Opens a dialog to user set the relationship between
* sheets in the document. The relationships are used to
* set the Core and the Extensions relations based on their ID's
*
*/
function openDwCAMetadataEditor(){
var html = HtmlService.createTemplateFromFile('MetadataEditor')
.evaluate()
.setWidth(400)
.setHeight(500);
SpreadsheetApp.getUi()
.showModalDialog(html, 'DwC-Archive Metadata');
}
/**
* Saves DwC-A Metadata form in document properties.
*
* @param {array} form data
*/
function generateDwCA(data){
var valid = validateDwCArchive_();
if (valid !== true) {
return {
error: true,
message: valid
};
}
var prop = PropertiesService.getDocumentProperties();
var folderId = checkAndCreateDwCAFolder();
var folderIter = DriveApp.getFolderById(folderId).getFoldersByName(SpreadsheetApp.getActive().getId());
var dwcaFolder = null;
// Check if a subfolder for this spreadsheet already exists.
// If so, get the Folder, otherwise create a new one
if (folderIter.hasNext()){
dwcaFolder = folderIter.next();
} else {
dwcaFolder = DriveApp.getFolderById(folderId).createFolder(SpreadsheetApp.getActive().getId());
}
// Create Zenodo deposition
var result = createZenodoDeposition_();
var packageId = !result ? Utilities.getUuid() : result.metadata.prereserve_doi.doi;
var eml = createEML_(dwcaFolder, packageId);
var meta = createMetaXML_(dwcaFolder);
var csvFiles = createCSVFiles_(dwcaFolder);
var blobsSource = [];
var iter = dwcaFolder.getFiles();
while(iter.hasNext()) {
var file = iter.next();
if (!file.getName().endsWith('.zip')) {
blobsSource.push(file.getBlob());
}
}
var dwcArchive = dwcaFolder.createFile(Utilities.zip(blobsSource, 'dwca-' + (new Date().getTime()) + '.zip'));
if ( dwcArchive ) {
if ( result && result.id ) {
prop.setProperty('zedonoId', result.id);
result = uploadToZenodo_(result, dwcArchive);
if (result) {
showurl(result.doi_url);
}
} else {
// Download DwCA
var downloadURL = dwcArchive.getDownloadUrl().slice(0, -8);
showurl(downloadURL);
}
}
}
function createMetaXML_(folder) {
var props = PropertiesService.getDocumentProperties();
var root = XmlService.createElement("archive")
.setAttribute("metadata", "eml.xml")
.setNamespace(XmlService.getNamespace("http://rs.tdwg.org/dwc/text/"));
var mappedSheets = getMappedSheets();
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
var coreSheetIndex = props.getProperty('dwca-core-sheet');
var coreSheet = sheets[parseInt(coreSheetIndex)-1];
for (var i = 0; i < mappedSheets.length; i++) {
var sheet = sheets[mappedSheets[i].index-1];
var elem = createMetaElem_(sheet, mappedSheets[i].core, mappedSheets[i].rowType);
root.addContent(elem);
}
var document = XmlService.createDocument(root);
var xml = XmlService.getPrettyFormat().format(document);
var iter = folder.getFilesByName('meta.xml');
if (iter.hasNext()) {
var file = iter.next();
file.setContent(xml);
return file;
}
return folder.createFile("meta.xml", xml);
}
function createCSVFiles_(folder) {
var mappedSheets = getMappedSheets();
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
var csvFiles = [];
for (var i = 0; i < mappedSheets.length; i++) {
var sheet = sheets[parseInt(mappedSheets[i].index)-1];
rowType = mappedSheets[i].rowType;
fileName = rowType.substr(rowType.lastIndexOf(':')+1).toLowerCase() + '.csv';
csvFile = convertRangeToCsvFile_(fileName, sheet);
var file;
var iter = folder.getFilesByName(fileName);
if (iter.hasNext()) {
file = iter.next();
file.setContent(csvFile);
} else {
file = folder.createFile(fileName, csvFile);
}
csvFiles.push(file);
}
return csvFiles;
}
function convertRangeToCsvFile_(csvFileName, sheet) {
// get available data range in the spreadsheet
var activeRange = sheet.getDataRange();
try {
var data = activeRange.getValues();
var csvFile = undefined;
// loop through the data in the range and build a string with the csv data
if (data.length > 2) {
var csv = "";
for (var row = 1; row < data.length; row++) {
for (var col = 0; col < data[row].length; col++) {
if (data[row][col].toString().indexOf(",") != -1) {
data[row][col] = "\"" + data[row][col] + "\"";
}
}
// join each row's columns
// add a carriage return to end of each row, except for the last one
if (row < data.length-1) {
csv += data[row].join(",") + "\r\n";
}
else {
csv += data[row];
}
}
csvFile = csv;
}
return csvFile;
}
catch(err) {
Logger.log(err);
}
}
function createMetaElem_(sheet, isCore, rowType) {
var elem = XmlService.createElement(isCore ? 'core' : 'extension')
.setAttribute('encoding', 'UTF-8')
.setAttribute('fieldsTerminatedBy', ',')
.setAttribute('linesTerminatedBy', '\\n')
.setAttribute('fieldsEnclosedBy', '')
.setAttribute('ignoreHeaderLines', '1')
.setAttribute('rowType', getTermURI(rowType))
.addContent(XmlService.createElement('files')
.addContent(XmlService.createElement('location')
.setText(rowType.toLowerCase()+'.csv'))
);
var coreColumn = getCoreIdColumn_(sheet);
var coreColumIndex = coreColumn[0].getColumn();
if (isCore) {
elem.addContent(XmlService.createElement('id')
.setAttribute('index', coreColumIndex - 1));
} else {
elem.addContent(XmlService.createElement('coreid')
.setAttribute('index', coreColumIndex - 1));
}
var headerRow = sheet.getRange(1, 1, 1, sheet.getLastColumn());
var terms = headerRow.getValues()[0];
for(var col = 0; col < terms.length; col++) {
var termURI = getTermURI(terms[col]);
if (termURI != null) {
elem.addContent(XmlService.createElement('field')
.setAttribute('index', col)
.setAttribute('term', termURI)
);
}
}
return elem;
}
function getTermURI(term) {
var props = PropertiesService.getDocumentProperties();
var namespaces = JSON.parse(props.getProperty('ns'));
var index = term.lastIndexOf(':');
if (index >= 0) {
var prefix = term.substr(0, index);
return namespaces[prefix] !== undefined ? (namespaces[prefix] + term.substr(index+1)) : null;
}
return null;
}
function validateDwCArchive_() {
var mappedSheets = getMappedSheets();
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
// Has extensions?
if (mappedSheets.length > 1) {
// Has CORE sheet
var props = PropertiesService.getDocumentProperties();
var coreSheetIndex = props.getProperty('dwca-core-sheet'), coreSheet = null;
if (!coreSheetIndex) {
// Does not have CORE sheet
return 'No CORE sheet defined. Please select the core sheet before generate the DwC-Archive.';
}
for (var i = 0; i < mappedSheets.length; i++) {
var sheet = sheets[mappedSheets[i].index-1];
var coreColumns = getCoreIdColumn_(sheet);
if (coreColumns.length == 0) {
// Missing CORE_ID
return 'Sheet ' + sheet.getName() + ' is missing CORE_ID column.';
} else if ( coreColumns.length > 1) {
// More than one CORE_ID
return 'Sheet ' + sheet.getName() + ' has more than one CORE_ID column.';
}
// Check for duplicated terms
var duplicates = hasDuplicateTerms_(sheet);
if (duplicates.length > 0) {
// Has duplications
return 'Sheet ' + sheet.getName() + ' has duplicated terms: ' + duplications.join(', ');
}
return true;
}
} else if (mappedSheets.length == 1) {
var sheet = sheets[mappedSheets[0].index];
// Check for duplicated terms
var duplicates = hasDuplicateTerms_(sheet);
if (duplicates.length > 0) {
// Has duplications
return 'Sheet ' + sheet.getName() + ' has duplicated terms: ' + duplications.join(', ');
}
return true;
}
function hasDuplicateTerms_(sheet) {
var headerRow = sheet.getRange(1, 1, 1, sheet.getLastColumn());
var values = headerRow.getValues().map(function(r){ return r[0]; });
var duplicatesMap = {}, duplicates = [];
for (var i = 0; i < values.length; i++) {
var term = values[i];
if (duplicatesMap[term] !== undefined) {
duplicates.push(term);
} else {
duplicatesMap[term] = 1;
}
}
return duplicates;
}
// Does not have a mapped sheet
return 'No header row found! Add a mapping row before generating the DwC-Archive.';
}
/**
* Returns all DwC-A metadata stored in document properties
* @return {array} DwC-A metadata
*/
function getMetadata(sheet) {
var props = PropertiesService.getDocumentProperties();
var coreSheetIndex = props.getProperty('dwca-core-sheet')
var sheetKey = sheet.getName().replace(/\s+/gi, '-').toLowerCase();
var hasMappingRow = props.getProperty(sheetKey + '-dwcheader');
if(hasMappingRow) {
return {
name: sheet.getName(),
index: sheet.getIndex(),
core: coreSheetIndex == sheet.getIndex(),
rowType: props.getProperty(sheetKey + '-rowtype')
};
}
return null;
}
function getMappedSheets() {
var props = PropertiesService.getDocumentProperties();
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
var mappedSheets = [];
for(var i = 0; i < sheets.length; i++) {
var metadata = getMetadata(sheets[i]);
if (metadata != null) {
mappedSheets.push(metadata);
}
}
return mappedSheets;
}
function setCoreSheet(sheetIndex) {
var props = PropertiesService.getDocumentProperties();
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
if (sheetIndex > 0 && sheetIndex <= sheets.length) {
var coreSheet = sheets[sheetIndex-1];
var coreColumns = getCoreIdColumn_(coreSheet);
if (coreColumns.length === 1) {
// Set core sheet
props.setProperty('dwca-core-sheet', coreSheet.getIndex());
return true;
} else if(coreColumns.length > 1) {
// More than one core id column (error)
return {
error: true,
message: 'More than one CORE_ID column found in sheet ' + coreSheet.getName() + '. Terms can not be duplicated!'
};
} else {
// No core id column (error)
return {
error: true,
message: 'No CORE_ID column found in sheet ' + coreSheet.getName() + '. Please, specify the CORE_ID column or create one!'
};
}
}
return {
error: true,
message: 'Sheet does not exists!'
};
}
function setRowType(rowType, sheetIndex) {
var props = PropertiesService.getDocumentProperties();
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
if (sheetIndex > 0 && sheetIndex <= sheets.length) {
var sheetKey = sheets[sheetIndex-1].getName().replace(/\s+/gi, '-').toLowerCase();
props.setProperty(sheetKey+'-rowtype', rowType);
}
}
function getCoreIdColumn_(sheet) {
var range = sheet.getRange(1, 1, 1, sheet.getLastColumn());
var finder = range.createTextFinder('CORE_ID');
var coreColumns = finder.findAll();
return coreColumns;
}
function getDwCArchiveSchema() {
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
var mappedSheets = getMappedSheets();
var dwcArchiveSchema = {
nodes: [],
edges: []
};
var props = PropertiesService.getDocumentProperties();
var coreSheetIndex = props.getProperty('dwca-core-sheet');
var edgeId = 1, x = 0, y = 0;
for (var i = mappedSheets.length - 1; i >= 0; i--) {
var sheet = sheets[mappedSheets[i].index-1];
if (x > y){
++y;
} else {
++x;
}
var isCore = mappedSheets[i].index == coreSheetIndex;
var node = {
id: sheet.getIndex(),
label: sheet.getName(),
size: 10,
color: isCore ? '#f00' : '#000',
x: isCore ? 0 : x,
y: isCore ? 0 : y,
type: 'image',
data: isCore ?
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAABVdSURBVHic7d17kJ11fcfx7/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HLe7f+OAbrl5XekYbUgRARMSSrcveHRHfLb0DgG6qJqot1bLBy0vvaEuaANhw1rot0avPjIgfl94CQMf0qvl6j+rUB15z7QOlp7QlTQBERGx85X9vqOve6VHFXaW3ANARdTXXm+q/YuPrrv1q6SltShUAEdvfFVD346VNxLWltwBQ2ES9qV5WHbfxTVddWXpK29IFQETE/Wd88Sebtux5WlTxroh4qPQeAFpWR1Mt7q9/cOkzVm563bU3lZ5TQlV6QGnLLlu7d7/adk7VxFsjYmXpPdCm+Xu3lJ4ArarqGMRU/7rBfO+tD735yttK7ykpfQD82jWn9Gc2T50SgzitqeL4iDg8IlZExNLCy2BoBABjrY4mqmoQdTxY9+pbo+6t3zS14mNx1rptpad1wf8DJdTHLGMr4bQAAAAASUVORK5CYII='
}
dwcArchiveSchema.nodes.push(node);
if (!mappedSheets[i].core && getCoreIdColumn_(sheet).length > 0){
var edge = {
id: edgeId,
source: parseInt(coreSheetIndex),
target: sheet.getIndex()
}
++edgeId;
dwcArchiveSchema.edges.push(edge);
}
}
return dwcArchiveSchema;
}
function getRowTypes() {
return [
'dwc:Taxon',
'dwc:Occurrence',
'dwc:Organism',
'dwc:Event',
'dwc:Location',
'dwc:GeologicalContexy',
'dwc:Identification',
'dwc:ResourceRelationship',
'dwc:MeasurementOrFact',
'dwc:MaterialSample'
];
}