Skip to content

Commit 7baf989

Browse files
Include OCA package and bundle SAIDs in DEE spreadsheet
1 parent aa144e8 commit 7baf989

File tree

1 file changed

+57
-25
lines changed

1 file changed

+57
-25
lines changed

src/Landing/CreateDataEntryExcel.js

+57-25
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function WorkbookError(message) {
1616
function readJSON(originJsonData_jsonSaid, e) {
1717
let isOcaPackage = false;
1818
let extensions = null;
19+
let ocaPackageSaid = "";
1920

2021
try {
2122
const textDecoder = new TextDecoder("utf-8");
@@ -27,6 +28,7 @@ function readJSON(originJsonData_jsonSaid, e) {
2728
if (rawJson.type && rawJson.type.includes("oca_package")) {
2829
isOcaPackage = true;
2930
extensions = rawJson.extensions;
31+
ocaPackageSaid = rawJson?.d || "";
3032
json = rawJson.oca_bundle.bundle;
3133
} else if (rawJson.oca_bundle && rawJson.oca_bundle.bundle) {
3234
json = rawJson.oca_bundle.bundle;
@@ -59,7 +61,7 @@ function readJSON(originJsonData_jsonSaid, e) {
5961
throw new WorkbookError(".. Error in reading the json file ...");
6062
}
6163
// exports oca_bundle organized, if it is an oca-package, and the extensions
62-
return [originJsonData_jsonSaid, isOcaPackage, extensions];
64+
return [originJsonData_jsonSaid, isOcaPackage, extensions, ocaPackageSaid];
6365
}
6466

6567
async function readZIP(originJsonData_jsonSaid, e) {
@@ -70,12 +72,14 @@ async function readZIP(originJsonData_jsonSaid, e) {
7072
const loadData = await file.async("text");
7173
const parsedData = replaceAttributeCharsInJsonString(loadData, true);
7274
originJsonData_jsonSaid.originJsonData.push(parsedData);
75+
if (parsedData.type && parsedData.type.includes("capture_base")) {
76+
originJsonData_jsonSaid.jsonSaid = parsedData.digest || "unavailable";
77+
}
7378
}
7479
} catch (error) {
7580
throw new WorkbookError(".. Error in reading the zip file ...");
7681
}
7782

78-
originJsonData_jsonSaid.jsonSaid = "unavailable";
7983
// return originJsonData_jsonSaid;
8084
return [originJsonData_jsonSaid, false, null];
8185
}
@@ -105,9 +109,10 @@ export async function CreateDataEntryExcel(data, selectedLang) {
105109
}
106110
}
107111

108-
const { originJsonData } = inPutJsonResult[0];
112+
const { jsonSaid, originJsonData } = inPutJsonResult[0];
109113

110114
const isOcaPackage = inPutJsonResult[1];
115+
const ocaPackageSaid = inPutJsonResult[3];
111116
let attribute_ordering_container = null;
112117
let entry_code_ordering = null;
113118

@@ -309,7 +314,6 @@ export async function CreateDataEntryExcel(data, selectedLang) {
309314
let schemaDescription = null;
310315
let schemaLanguage = null;
311316
let schemaClassification = null;
312-
let schemaSAID = null;
313317

314318
try {
315319
schemaTitle = metaOverlays[0].name;
@@ -318,44 +322,72 @@ export async function CreateDataEntryExcel(data, selectedLang) {
318322
schemaClassification = jsonData.find(
319323
(o) => o.type && o.type.includes("/capture_base/")
320324
).classification;
321-
schemaSAID = originJsonData[0].jsonSaid;
322325
} catch (error) {
323326
throw new WorkbookError(".. Error in reading the meta overlay ...");
324327
}
325328

326329
// Step 5: Schema Description Sheet Content
327-
sheet1.getCell(1, 1).value =
330+
let introSectionCurrentRow = 1;
331+
sheet1.getCell(introSectionCurrentRow, 1).value =
328332
"This is an Excel workbook for data display and data entry.";
329-
formatFirstPage(sheet1.getCell(1, 1));
333+
formatFirstPage(sheet1.getCell(introSectionCurrentRow, 1));
334+
introSectionCurrentRow++;
330335

331-
sheet1.getCell(2, 2).value =
336+
sheet1.getCell(introSectionCurrentRow, 2).value =
332337
"This workbook has been prefilled with information to help users use the data. The prefilled information comes from a schema.";
333-
sheet1.getCell(3, 2).value =
338+
introSectionCurrentRow++;
339+
340+
sheet1.getCell(introSectionCurrentRow, 2).value =
334341
"Enter or view your data in 'Data' while referencing 'Schema Description' for guidance.";
342+
introSectionCurrentRow += 2;
343+
344+
sheet1.getCell(introSectionCurrentRow, 1).value = "Schema details:";
345+
formatFirstPage(sheet1.getCell(introSectionCurrentRow, 1));
346+
introSectionCurrentRow++;
347+
348+
sheet1.getCell(introSectionCurrentRow, 2).value = `Schema title: ${schemaTitle}`;
349+
introSectionCurrentRow++;
350+
351+
sheet1.getCell(introSectionCurrentRow, 2).value =
352+
`Schema description: ${schemaDescription}`;
353+
introSectionCurrentRow++;
335354

336-
sheet1.getCell(5, 1).value = "Schema details:";
337-
formatFirstPage(sheet1.getCell(5, 1));
355+
sheet1.getCell(introSectionCurrentRow, 2).value = `Schema language: ${schemaLanguage}`;
356+
introSectionCurrentRow++;
338357

339-
sheet1.getCell(6, 2).value = `Schema title: ${schemaTitle}`;
340-
sheet1.getCell(7, 2).value = `Schema description: ${schemaDescription}`;
341-
sheet1.getCell(8, 2).value = `Schema language: ${schemaLanguage}`;
342-
sheet1.getCell(9, 2).value = `Schema SAID: ${schemaSAID}`;
343-
sheet1.getCell(10, 2).value = `Schema classification: ${schemaClassification}`;
358+
sheet1.getCell(introSectionCurrentRow, 2).value = `Schema SAID: ${jsonSaid}`;
359+
introSectionCurrentRow++;
344360

345-
sheet1.getCell(12, 1).value = "What is a schema?";
346-
formatFirstPage(sheet1.getCell(12, 1));
361+
if (ocaPackageSaid) {
362+
sheet1.getCell(introSectionCurrentRow, 2).value = `Package SAID: ${ocaPackageSaid}`;
363+
introSectionCurrentRow++;
364+
}
365+
366+
sheet1.getCell(introSectionCurrentRow, 2).value =
367+
`Schema classification: ${schemaClassification}`;
368+
introSectionCurrentRow += 2;
369+
370+
sheet1.getCell(introSectionCurrentRow, 1).value = "What is a schema?";
371+
formatFirstPage(sheet1.getCell(introSectionCurrentRow, 1));
372+
introSectionCurrentRow++;
347373

348-
sheet1.getCell(13, 2).value = "A schema describes structures and rules of a dataset.";
349-
sheet1.getCell(14, 2).value =
374+
sheet1.getCell(introSectionCurrentRow, 2).value =
375+
"A schema describes structures and rules of a dataset.";
376+
introSectionCurrentRow++;
377+
378+
sheet1.getCell(introSectionCurrentRow, 2).value =
350379
"Learn more and write your own schema at https://semanticengine.org";
380+
introSectionCurrentRow += 2;
381+
382+
sheet1.getCell(introSectionCurrentRow, 1).value = "Schema Description:";
383+
formatFirstPage(sheet1.getCell(introSectionCurrentRow, 1));
384+
introSectionCurrentRow++;
351385

352-
sheet1.getCell(16, 1).value = "Schema Description:";
353-
formatFirstPage(sheet1.getCell(16, 1));
354-
sheet1.getCell(17, 2).value =
355-
"Here is a table describing of each of the attributes which you will find on the Data sheet. This information has been supplied by your schema.";
386+
sheet1.getCell(introSectionCurrentRow, 2).value =
387+
"Here is a table describing each of the attributes which you will find on the Data sheet. This information has been supplied by your schema.";
356388

357389
// Step 6: Start the Workbook
358-
const shift = 17;
390+
const shift = introSectionCurrentRow;
359391

360392
try {
361393
sheet1.getColumn(1).width = 17;

0 commit comments

Comments
 (0)