Added rewrite options
Change-Id: I0de6b89d47f20bc4a4a8de12ce73a6d5c1f46a22
diff --git a/dev/js/src/vc/rewrite.js b/dev/js/src/vc/rewrite.js
index 78d2627..b577f14 100644
--- a/dev/js/src/vc/rewrite.js
+++ b/dev/js/src/vc/rewrite.js
@@ -3,7 +3,8 @@
*/
define(['vc/jsonld', 'util'], function (jsonldClass) {
- var _validRewriteOpRE = new RegExp("^(operation:)?(?:injec|inser|modifica)tion$");
+ // injection, modification, and deletion should probably be enough
+ var _validRewriteOpRE = new RegExp("^(operation:)?(?:injec|inser|modifica|dele)tion|override$");
return {
// Construction method
@@ -30,8 +31,8 @@
}
else {
KorAP.log(814, "Unknown rewrite operation");
- return;
- };
+ return;
+ };
};
return this._op || 'injection';
},
@@ -39,26 +40,26 @@
// Get or set scope
scope : function (attr) {
if (arguments.length === 1)
- this._scope = attr;
+ this._scope = attr;
return this._scope;
},
// Serialize from Json
fromJson : function (json) {
if (json === undefined)
- return this;
-
+ return this;
+
// Missing @type
if (json["@type"] === undefined) {
- KorAP.log(701, "JSON-LD group has no @type attribute");
- return;
+ KorAP.log(701, "JSON-LD group has no @type attribute");
+ return;
};
// Missing source
if (json["src"] === undefined ||
- typeof json["src"] !== 'string') {
- KorAP.log(815, "Rewrite expects source");
- return;
+ typeof json["src"] !== 'string') {
+ KorAP.log(815, "Rewrite expects source");
+ return;
};
// Set source
@@ -66,14 +67,14 @@
// Set operation
if (json["operation"] !== undefined) {
- var operation = json["operation"];
- this.operation(operation.replace(/^operation:/,''));
+ var operation = json["operation"];
+ this.operation(operation.replace(/^operation:/,''));
};
// Set scope
if (json["scope"] !== undefined &&
- typeof json["scope"] === 'string')
- this.scope(json["scope"]);
+ typeof json["scope"] === 'string')
+ this.scope(json["scope"]);
return this;
},
@@ -83,16 +84,16 @@
var op = this.operation();
str += op.charAt(0).toUpperCase() + op.slice(1);
str += ' of ' + (
- this._scope === null ?
- 'object' :
- '"' +
- this.scope().quote() +
- '"'
+ this._scope === null ?
+ 'object' :
+ '"' +
+ this.scope().quote() +
+ '"'
);
str += ' by ' +
- '"' +
- this.src().quote() +
- '"';
+ '"' +
+ this.src().quote() +
+ '"';
return str;
}
};