Commit 2d0dd207 authored by PTSEFTON's avatar PTSEFTON
Browse files

Working on sub datasets

parent 9d1a75eb
......@@ -44,7 +44,6 @@ program
.action(function(directories) {
dirs = directories;
})
.option("-n, --no", "No Citation - only applies ith --bag")
.option("-b, --bag [bag-dir]", "Create Bagit Bag(s) under [bag-dir])")
.option("-z --zip", "Zip the bagged ro-crate (only works with --bag")
.option("-p --partOf [partOf]", "This is part of another RO-Crate, supply the ro-crate-metadata.jsonld path.")
......@@ -122,6 +121,7 @@ async function generateHTML(metadataPath) {
if (!root["distribution"]) {
root["distribution"] = []
}
root["distribution"] = crate.utils.asArray(root["distribution"])
root["distribution"].push(
{
"@id": program.url
......@@ -135,30 +135,28 @@ async function generateHTML(metadataPath) {
"@type": "DataDownload",
"encodingFormat": "zip"
});
crate = new roCrate(crate.getJson());
fs.writeFileSync(metadataPath, JSON.stringify(crate.getJson(), null, 2))
crate = new ROCrate(crate.getJson());
}
if (program.partOf) {
var parentCrate = new ROCrate(JSON.parse(fs.readFileSync(program.partOf)));
await parentCrate.index();
parentRoot = await parentCrate.getRootDataset();
console.log("PARENT ROOT", parentRoot);
// Inherit metadata
if (!root.datePublished) {
console.log("Inherit")
root.datePublished = parentRoot.datePublished;
}
if (!root.name) {
root.name = "Part of: " + parentRoot.name;
}
if (!root.descripton) {
root.description = "This is a part of: " + parentRoot.name;
root.name = `${root['@id']} [part of: ${parentRoot.name}`;
}
var desc = crate.utils.asArray(root.description)
desc.push(`This dataset is a part of: ${parentRoot.name} [${parentRoot.description}]`);
root.description = desc;
if (!root.isPartOf && parentRoot.identifier) {
console.log("So here we are")
root.isPartOf = parentRoot.identifier;
}
console.log("ROOT", root)
}
......@@ -178,6 +176,7 @@ async function generateHTML(metadataPath) {
shell.rm("-rf", dest);
dir = bagger.bag(dir, dest, crate);
console.log("bagged", dir)
bagger.generate_bag_info();
bagger.save_bag_info();
if (!path.isAbsolute(dir)) {
......@@ -188,11 +187,11 @@ async function generateHTML(metadataPath) {
bagger.update();
if (program.zip){
var zipname = path.join(program.bag, path.basename(path.dirname(metadataPath)).replace(" ","_") + ".zip");
console.log('name', zipname)
var zipname = path.resolve(path.join(program.bag, path.basename(path.dirname(metadataPath)).replace(" ","_") + ".zip"));
console.log('Zipping to', zipname)
shell.cd(dir);
shell.rm("-f", `"${zipname}"`);
shell.exec("zip -r " + zipname + " " + "*");
shell.exec(`zip -r "${zipname}" *`);
}
}
......
......@@ -2236,7 +2236,6 @@
"contact": "http://schema.org/accountablePerson",
"File": "http://schema.org/MediaObject",
"path": "http://schema.org/contentUrl",
"hasFile": "https://pcdm.org/models#hasFile",
"hasMember": "https://pcdm.org/models#hasMember",
......
......@@ -19,9 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
const path = require("path");
const shell = require("shelljs");
const tmp = require("tmp");
const fs = require("fs");
const defaults = require("./defaults.js");
module.exports = function() {
return {
......@@ -76,7 +74,7 @@ module.exports = function() {
fs.writeFileSync(path.join(this.targetDir, "bag-info.txt"), bag_info);
},
update: function update_bag_tags() {
shell.exec("bagit updatetagmanifests " + this.targetDir);
shell.exec(`bagit updatetagmanifests "${this.targetDir}"`);
},
......@@ -92,10 +90,7 @@ module.exports = function() {
this.targetDir = bag_dir;
shell.exec(
"bagit create --excludebaginfo " +
this.targetDir +
" " +
path.join(source_dir, "*")
`bagit create --excludebaginfo "${this.targetDir}" "${path.join(source_dir, "*")}"`
);
return this.targetDir;
......
......@@ -138,7 +138,7 @@ module.exports = function() {
if (!value) {
value = uuidv4();
}
if (value.endsWith("/" ) || value.startsWith(".") || value.match(/^(https?:\/\/|mailto:.*@|_b:)/i)) {
if (value.startsWith("#" ) || value.endsWith("/" ) || value.startsWith(".") || value.match(/^(https?:\/\/|mailto:.*@|_b:)/i)) {
this.id = value;
}
else {
......
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