Commit 8fa6062c authored by PTSEFTON's avatar PTSEFTON
Browse files

Fixed a couple of bugs with IDs

parent 34ec105a
......@@ -64,11 +64,9 @@ table.table {
</div>
<p>This file was created at <%- time_stamp %> by
<p>This file was created at <%- time_stamp.toUTCString() %> by
<a href='https://code.research.uts.edu.au/eresearch/calcytejs'>
Calcyte</a> which implements the <a href='<%- spec_id %>'>
Draft RO-Crate format</a>, version <%- ROCrate_version %>
</p>
Calcyte</a>.
</body>
......
......@@ -48,7 +48,8 @@ module.exports = function() {
this.field_names_by_type = {};
this.existing_metadatas = [];
this.root_node = {};
this.extraContext = {};
this.extraContext = {}; // TODO add additional context
this.extraProps = [];
function get_collection_metadata(workbook, collection) {
// TODO - make the collection just another kind of item object
......@@ -91,13 +92,13 @@ module.exports = function() {
json["@context"] = defaults.context;
fs.writeFileSync("test.jsonld", JSON.stringify(json, null, 2));
defaults.context.push(collection.extraContext)
console.log(defaults.context)
var promise = promises.flatten(json, defaults.context);
return promise;
}
return {
extraContext: this.extraContext,
extraProps: this.extraProps,
collection_metadata: this.collection_metadata,
children: this.children,
rel_path: this.rel_path,
......@@ -211,7 +212,8 @@ module.exports = function() {
exists = false;
}
}
if (exists) {
//item_json["EXTRA"]= "1";
if (exists && !item_json["*MISSING-FILE"]) {
graph.push(item_json);
}
}
......@@ -441,11 +443,21 @@ module.exports = function() {
this.workbook.Sheets["@context"]
);
for (var item of extra_context) {
if (item["Key"] && item["Value"]) {
this.extraContext[item["Key"]] = item["Value"]
if (item["name"] && item["URL"]) {
this.extraContext[item["name"]] = item["URL"]
if (item["SameAs"]) {
this.same_as.push({"@id": item["Value"], "sameAs": item["SameAs"], "@type": "Thing"})
this.same_as.push({"@id": item["URL"], "sameAs": item["SameAs"], "@type": "Thing"})
}
} else if (item["name"] && item["description"] && item["namespace"]){
const URI = `http://purl.org/adhoc?@type=rdf:Property&rdfs:label=${item["name"]}&rdfs:comment=${item["description"]}`
this.extraContext[item["name"]] = URI
/* this.graph.push(
{
"@id": URI,
"@type": "rdf:Property",
"rdfs:comment": item["description"],
"rdfs:label": item["name"]
}); */
}
}
}
......
......@@ -40,6 +40,10 @@ module.exports = function() {
function links_to_id(string, collection) {
var links_to = collection.lookup_id(string);
if (!links_to) {
links_to = collection.lookup_id("#" + string)
//console.log("looked up", string, links_to);
}
//console.log("Linksto", string, links_to)
if (!links_to) {
links_to = collection.lookup_name(string)
......@@ -65,17 +69,17 @@ module.exports = function() {
//console.log("Keys at start of output", Object.keys(this.properties));
var id = this.collection.make_id(this.id);
var frag = { "@id": String(id) };
//console.log("Setting id", this.id, this.name, this.nested_items);
//console.log(" NAMELOOKUPS", this.collection.name_lookup);
for (let [key, i] of Object.entries(this.nested_items)) {
frag[key] = i.to_json_ld_fragment();
}
for (let [key, f] of Object.entries(this.properties)) {
if (f.is_type) {
types = f.data; //Don't output now
} else if (f.name != "ID") {
frag[f.name] = [];
if (!Array.isArray(f.data)) {
f.data = [f.data];
......@@ -84,14 +88,12 @@ module.exports = function() {
var link_id = f.links_to
? f.links_to
: links_to_id(f.data[k], this.collection);
//console.log("link_id", link_id, "relational", f.is_relational)
if (f.is_file) {
this.is_file = true;
//types.push("schema:MediaObject");
} else if (f.is_relational && link_id && link_id != id) {
//console.log("Looking for relations", f.data[k], this.collection)
//console.log("GOT A LINK", f.name, f.id);
frag[f.name].push({ "@id": link_id }); //, "@type" : "@id"
} else if (f.is_json) {
frag[f.name] = JSON.parse(f.data[k])
......@@ -107,7 +109,7 @@ module.exports = function() {
frag["@type"] = this.types;
this.json_ld_fragment = frag;
//console.log(frag);
return frag;
return frag;
},
load_json: function load_json(json_item, collection) {
//console.log("JSON IS: ", json_item);
......
......@@ -76,7 +76,6 @@ module.exports = function() {
this.raw_name = name;
this.name = name;
this.nested_item_json = [];
if (this.name === "ID") {
this.is_id = true;
} else if (this.name === "TYPE:") {
......@@ -120,6 +119,7 @@ module.exports = function() {
this.nested_item_json.push(nested_json);
this.data = "";
}
console.log(name, this.is_repeating, this.is_relational)
this.property_URI = get_RDF_for_column(this.name);
......
......@@ -35,8 +35,12 @@
"description": "Photo snapped on a photo walk on a misty day",
"endTime": "2017:06:11T12:56:14+10:00",
"instrument": [
"EPL1",
"Panny20mm"
{
"@id": "#EPL1"
},
{
"@id": "#Panny20mm"
}
],
"name": "Took dog picture",
"object": {
......@@ -66,11 +70,7 @@
}
},
{
"@id": "#ba671201-2b5c-4c90-9a72-1f8aa710e6eb",
"*MISSING-FILE": "1"
},
{
"@id": "#ea0e7767-c702-4403-b815-2aefbe07d45c",
"@id": "#d2c5b5e0-a720-4b21-ad3a-f44ad89488e7",
"@type": "GeoCoordinates",
"latitude": "-33.7152",
"longitude": "150.30119",
......@@ -122,7 +122,7 @@
"license": {
"@id": "https://creativecommons.org/licenses/by-nc-sa/3.0/au/"
},
"name": "Sample dataset for RO-Crate v0.2",
"name": "Sample dataset for RO-Crate v1.0",
"publisher": {
"@id": "https://ror.org/0384j8v12"
},
......@@ -2630,7 +2630,7 @@
"address": "Katoomba, NSW",
"description": "Catalina Park is a disused motor racing venue, located at Katoomba, in the Blue Mountains, New South Wales, Australia, and is recognised as an Aboriginal Place due to the long association of the local Gundungarra and Darug clans to the area.",
"geo": {
"@id": "#ea0e7767-c702-4403-b815-2aefbe07d45c"
"@id": "#d2c5b5e0-a720-4b21-ad3a-f44ad89488e7"
},
"name": "Catalina Park"
},
......
This diff is collapsed.
Markdown is supported
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