From e44aeba344de9faaad8dc9a5093971674df3e876 Mon Sep 17 00:00:00 2001 From: Carlos Rueda Date: Mon, 20 Jun 2016 21:37:57 -0700 Subject: [PATCH] resolve #15 "v2r: for column property definition allow selection from standard vocabularies" A selected property is displayed with associated typical prefix, eg., skos:definition (#19). --- ChangeLog.md | 3 + src/app/js/ont/v2r/v2r-edit-id.html | 132 ++++++++++++++++++---------- src/app/js/ont/v2r/v2r.js | 51 ++++++++--- src/app/js/vocabulary/vocabulary.js | 22 ++++- 4 files changed, 146 insertions(+), 62 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cb5ef53..a19b0a0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,9 @@ ## change log ## * 2016-06-20: 3.0.alpha: + - implement #15 "v2r: for column property definition allow selection from standard vocabularies" + A selected property is displayed with associated typical prefix, eg., skos:definition (#19). + The list is for now hard-coded. TODO capture list in a registered (internal) ontology. - implement #15 "branding" * 2016-06-18: 0.3.2: diff --git a/src/app/js/ont/v2r/v2r-edit-id.html b/src/app/js/ont/v2r/v2r-edit-id.html index ae6e230..c93afed 100644 --- a/src/app/js/ont/v2r/v2r-edit-id.html +++ b/src/app/js/ont/v2r/v2r-edit-id.html @@ -8,9 +8,12 @@

- To construct the URI of this entity either specify a "local name" - (relative to the URI of this ontology), - or a full URI. + To construct the URI of this {{vm.what}} either specify a "local name" + (relative to the URI of this ontology) + or a full URI, where you can also select from a list of standard properties + that may be applicable to your vocabulary + .


@@ -24,65 +27,98 @@
-
- - -
- +
+
+ + +
+ +
-
-
- +
+ -
- - URI:  + + URI: {{vm.namespace}}/? + >? + - +
-
+
+
+ + +
+
+ Tip: + Consider using a +
+ + +
+
+
+
+ +
- + -
- +
+ +
-
-
+
+ + + + + + +
- - - - -
-
diff --git a/src/app/js/ont/v2r/v2r.js b/src/app/js/ont/v2r/v2r.js index c1e2d72..281a152 100644 --- a/src/app/js/ont/v2r/v2r.js +++ b/src/app/js/ont/v2r/v2r.js @@ -24,13 +24,13 @@ } } - V2rDataViewerController.$inject = ['$window']; - function V2rDataViewerController($window) { + V2rDataViewerController.$inject = ['$window', 'vocabulary']; + function V2rDataViewerController($window, vocabulary) { var vm = this; vm.debug = debug; if (debug) console.log("++V2rDataViewerController++ vm=", vm); - setCommonMethods(vm); + setCommonMethods(vm, vocabulary); // mainly a workaround as the ng-href link in a "text/ng-template" // used in doesn't work for some reason @@ -67,26 +67,26 @@ }; } - V2rDataEditorController.$inject = ['$scope', '$uibModal', '$filter', '$timeout', 'utl', 'focus']; - function V2rDataEditorController($scope, $uibModal, $filter, $timeout, utl, focus) { + V2rDataEditorController.$inject = ['$scope', '$uibModal', '$filter', '$timeout', 'utl', 'focus', 'vocabulary']; + function V2rDataEditorController($scope, $uibModal, $filter, $timeout, utl, focus, vocabulary) { var vm = this; vm.debug = debug; if (debug) console.log("++V2rDataEditorController++ vm=", vm); - setCommonMethods(vm); + setCommonMethods(vm, vocabulary); ////////////////////////////////////// // Class and property editing vm.editVocabClass = function(idModel) { - return editIdModel("Vocabulary class", idModel); + return editIdModel("Vocabulary class", "class", idModel); }; vm.editVocabProperty = function(idModel) { - return editIdModel("Vocabulary property", idModel); + return editIdModel("Vocabulary property", "property", idModel); }; - function editIdModel(title, idModel) { + function editIdModel(title, what, idModel) { //console.log("editId': title=", title, "idModel=", idModel); return $uibModal.open({ templateUrl: 'js/ont/v2r/v2r-edit-id.html', @@ -96,6 +96,7 @@ info: function () { return { title: title, + what: what, namespace: vm.uri, idModel: idModel }; @@ -422,16 +423,18 @@ } } - V2rEditIdController.$inject = ['$scope', '$uibModalInstance', 'info']; - function V2rEditIdController($scope, $uibModalInstance, info) { + V2rEditIdController.$inject = ['$scope', '$uibModalInstance', 'vocabulary', 'info']; + function V2rEditIdController($scope, $uibModalInstance, vocabulary, info) { console.log("V2rEditIdController: info=", info); var vm = $scope.vm = { title: info.title, + what: info.what, namespace: info.namespace, lname: info.idModel.name, uri: info.idModel.uri, - idType: info.idModel.name ? "lname" : "uri" + idType: info.idModel.name ? "lname" : "uri", + stdProperties: getStdProperties(vocabulary) }; $scope.$watch("vm.lname", function(val) { @@ -439,6 +442,11 @@ if (val) vm.lname = val.replace(/[\s/|?&!,;'\\]/gi, ""); }); + $scope.stdPropertySelected = function(stdProp) { + console.debug("stdPropertySelected: stdProp=", stdProp); + vm.uri = stdProp.uri; + }; + $scope.idEditFormOk = function() { return vm.idType === 'lname' && vm.lname || vm.idType === 'uri' && vm.uri; @@ -461,7 +469,7 @@ }; } - function setCommonMethods(vm) { + function setCommonMethods(vm, vocabulary) { vm.getUri = function(e) { if (e.uri) return e.uri; if (!vm.uri) return undefined; @@ -476,6 +484,10 @@ vm.getLabel = function(e) { if (e.label) return e.label; if (e.name) return capitalizeFirstLetter(e.name); + var def = vocabulary.byUri[e.uri]; + if (def) { + return def.prefix + ':' + def.label; + } return e.uri; }; @@ -489,6 +501,19 @@ }; } + // TODO retrieve list from a registered (internal) ontology + function getStdProperties(vocabulary) { + return [ + vocabulary.skos.definition, + vocabulary.skos.note, + vocabulary.rdfs.seeAlso, + vocabulary.dct.title, + vocabulary.dct.description, + vocabulary.dct.creator, + vocabulary.dct.contributor + ] + } + function capitalizeFirstLetter(s) { if (s) s = s.substr(0, 1).toUpperCase() + s.substr(1); return s; diff --git a/src/app/js/vocabulary/vocabulary.js b/src/app/js/vocabulary/vocabulary.js index 70c8198..78c7006 100644 --- a/src/app/js/vocabulary/vocabulary.js +++ b/src/app/js/vocabulary/vocabulary.js @@ -6,15 +6,28 @@ ; function vocabulary() { + var byUri = {}; return { + byUri: byUri, + rdf: setDetails("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#", { type: { } }), rdfs: setDetails("rdfs", "http://www.w3.org/2000/01/rdf-schema#", { + label: { + tooltip: "A human-readable name for the subject." + }, + comment: { + tooltip: "A description of the subject resource." + }, + isDefinedBy: { + tooltip: "Used to indicate a resource defining the subject resource. " + + "This property may be used to indicate an RDF vocabulary in which a resource is described." + }, seeAlso: { - tooltip: "Further information about the subject resource." + tooltip: "Used to indicate a resource that might provide additional information about the subject resource." } }), @@ -70,6 +83,12 @@ }), skos: setDetails("skos", "http://www.w3.org/2004/02/skos/core#", { + note: { + tooltip: "SKOS property for general documentation purposes." + }, + definition: { + tooltip: "A complete explanation of the intended meaning of a concept." + }, exactMatch: { tooltip: "The property skos:exactMatch is used to link two concepts, indicating a high degree " + "of confidence that the concepts can be used interchangeably across a wide range of " + @@ -197,6 +216,7 @@ term.uri = namespace + localName; term.localName = localName; term.label = term.label || localName; + byUri[term.uri] = term; }); obj.NS = namespace; return obj;