--- a/common/corpus-common-addon/addon/utils/utils.js Wed Jan 18 11:33:56 2017 +0100
+++ b/common/corpus-common-addon/addon/utils/utils.js Thu Jan 19 13:53:17 2017 +0100
@@ -75,3 +75,36 @@
return constants.NOID_CHARS[sum % constants.NOID_CHARS.length];
}
+
+export function getOLACBaseUrl(literalVal) {
+ let olacRes = null;
+
+ if (!literalVal) {
+ return null;
+ }
+ if (typeof literalVal !== 'object') {
+ return null;
+ }
+ const datatype = literalVal.datatype;
+
+ if (!datatype) {
+ return null;
+ }
+
+ _.forEach(constants.OLAC_BASE_URL, function (olacDef, urlPrefix) {
+ if (_.startsWith(datatype, urlPrefix)) {
+ olacRes = olacDef;
+ return false; // we found it, we exit early
+ }
+
+ return true;
+ });
+
+ return olacRes;
+}
+
+export function isOLACLiteral(literalDef) {
+ const olacDef = getOLACBaseUrl(literalDef);
+
+ return Boolean(olacDef);
+}