Support VC references in VC builder to fix #62
Change-Id: Iec84c12ade2f64e8bbbd3d42b9e52788a0fba3fe
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index 58926f2..d3097e9 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -8,10 +8,12 @@
'vc/jsonld',
'vc/unspecified',
'vc/doc',
+ 'vc/docgroupref',
'util'
], function (jsonldClass,
- unspecClass,
- docClass) {
+ unspecClass,
+ docClass,
+ docGroupRefClass) {
const _validGroupOpRE = new RegExp("^(?:and|or)$");
@@ -41,6 +43,10 @@
// The doc is already set in the group
_duplicate : function (operand) {
+
+ // TODO:
+ // Also check for duplicate docGroupRefs!
+
if (operand.ldType() !== 'doc')
return null;
@@ -73,7 +79,8 @@
// No @type defined
if (operand["ldType"] !== undefined) {
if (operand.ldType() !== 'doc' &&
- operand.ldType() !== 'docGroup') {
+ operand.ldType() !== 'docGroup' &&
+ operand.ldType() !== 'docGroupRef') {
KorAP.log(812, "Operand not supported in document group");
return;
};
@@ -127,6 +134,28 @@
this._operands.push(docGroup);
return docGroup;
+ case "koral:docGroupRef":
+
+ var docGroupRef = docGroupRefClass.create(this, operand);
+
+ if (docGroupRef === undefined) {
+ return
+ };
+
+ // TODO:
+ // Currently this doesn't do anything meaningful,
+ // as duplicate only checks on docs for the moment
+ /*
+ var dupl = this._duplicate(doc);
+ if (dupl === null) {
+ this._operands.push(doc);
+ return doc;
+ };
+ return dupl;
+ */
+ this._operands.push(docGroupRef);
+ return docGroupRef;
+
default:
KorAP.log(812, "Operand not supported in document group");
return;
@@ -229,6 +258,7 @@
// Just insert a doc or ...
if (newOp.ldType() === "doc" ||
newOp.ldType() === "non" ||
+ newOp.ldType() === 'docGroupRef' ||
// ... insert a group of a different operation
// (i.e. "and" in "or"/"or" in "and")
newOp.operation() != this.operation()) {