Skip to content

Commit

Permalink
Merge branch 'feature/queries-validation'
Browse files Browse the repository at this point in the history
  • Loading branch information
anan02-admin authored and anan02-admin committed Mar 1, 2023
2 parents 00798f0 + 1a3bfd3 commit 4ff25f7
Show file tree
Hide file tree
Showing 37 changed files with 706 additions and 74 deletions.
3 changes: 1 addition & 2 deletions app/components/behaviors/behavior-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import globals from "ajan-editor/helpers/global-parameters";
import nodeDefs from "ajan-editor/helpers/RDFServices/node-definitions/common";
import rdfGraph from "ajan-editor/helpers/RDFServices/RDF-graph";
import rdfManager from "ajan-editor/helpers/RDFServices/RDF-manager";
import utility from "ajan-editor/helpers/RDFServices/utility";
import { AGENTS, XSD, RDF, RDFS } from "ajan-editor/helpers/RDFServices/vocabulary";
import { AGENTS } from "ajan-editor/helpers/RDFServices/vocabulary";
import Split from "npm:split.js";

let $ = Ember.$;
Expand Down
1 change: 0 additions & 1 deletion app/components/behaviors/manipulation/bt-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default Component.extend({


selectedBTChange: observer("selectedValue", function() {

localStorage.setItem("bt-selected", this.get("selectedValue"));
selectBT(this);
}),
Expand Down
6 changes: 3 additions & 3 deletions app/components/behaviors/properties-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export default Component.extend({

$("#node-properties").on("sendNodeData", function (e, nodeData) {
let node = Node.create(nodeData);
that.set("node", node);
that.set("node", node);
that.set("showProperties", true);
that.get("queryInsertion").set("nodeType", node.nodeType);
that.get("queryInsertion").set("uri", node.uri);
});

$("#node-properties").on("blurProperties", function() {
that.set("showProperties", false);
});
});
},

advancedMode: computed(function() {
Expand All @@ -62,7 +62,7 @@ export default Component.extend({
localStorage.setItem(modeId, this.advancedMode);
}),

labelChange: observer("node.label", function() {
labelChange: observer("node.label", function () {
this.get("nodeProperties").updateLabel(this.get("node"));
}),

Expand Down
11 changes: 6 additions & 5 deletions app/components/behaviors/properties/parameter-structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import {computed, observer} from "@ember/object";
import {ND, XSD} from "ajan-editor/helpers/RDFServices/vocabulary";
import {ND, BT, XSD} from "ajan-editor/helpers/RDFServices/vocabulary";
import Component from "@ember/component";
import rdfGraph from "ajan-editor/helpers/RDFServices/RDF-graph";

Expand Down Expand Up @@ -87,13 +87,14 @@ export default Component.extend({
});

function getValue(that) {
let structure = that.get("parameter");
let value = rdfGraph.getObjectValue(that.get("uri"), structure.mapping);
let parameter = that.get("parameter");

let value = rdfGraph.getObjectValue(that.get("uri"), parameter.mapping);
if (!value && typeof value !== "boolean")
console.warn(
"Value not defined, using default",
that.get("uri"),
structure
parameter
);
return value || structure.default;
return value || parameter.default;
}
29 changes: 28 additions & 1 deletion app/components/behaviors/properties/parameter/actn-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ let that;

export default Component.extend({
ajax: Ember.inject.service(),

nodeProperties: Ember.inject.service("behaviors/node-properties"),
availableACTNs: null,
selected: undefined,
validation: undefined,
uri: null,

init() {
Expand All @@ -42,12 +43,22 @@ export default Component.extend({
loadActionsRdfGraphData();
},

didUpdateAttrs() {
initErrorsList(this);
validateActionField(this);
},

selectedChanged: observer("selected", function () {
this.set("selected", this.selected);
setBase(this.get("uri"), this.get("structure.mapping"), this.selected);
let base = getSelected(that.get("availableACTNs"), this.selected);
this.set("selectedBaseValue", base);
initErrorsList(this);
validateActionField(this);
}),

uriChange: observer("uri", function () {
that = this;
setAvailableActions();
})
});
Expand Down Expand Up @@ -78,6 +89,7 @@ function setAvailableActions() {
that.set("availableACTNs", allActions);
var base = getSelected(that.get("availableACTNs"), that.get("value"));
that.set("selectedBaseValue", base);
validateActionField(that);
}

function getSelected(ele, uri) {
Expand All @@ -87,3 +99,18 @@ function getSelected(ele, uri) {
function setBase(uri, basePredicate, value) {
rdfGraph.setObject(uri, basePredicate, rdfFact.toNode(value));
}

function initErrorsList(comp) {
let node = getNode(comp);
if (node && !node.errors) {
getNode(comp).errors = new Array();
}
}

function validateActionField(comp) {
comp.get("nodeProperties").validateEventGoalActionField(comp, "No Action Definition is selected!");
}

function getNode(comp) {
return comp.get("nodeProperties").getNode(comp);
}
35 changes: 32 additions & 3 deletions app/components/behaviors/properties/parameter/event-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,37 @@ let that;

export default Component.extend({
ajax: Ember.inject.service(),

nodeProperties: Ember.inject.service("behaviors/node-properties"),
availableEvents: null,
selected: undefined,
validation: undefined,

uri: null,

init() {
this._super(...arguments);
that = this;
initializeGlobals(this);
loadAgentsRdfGraphData();
initErrorsList(this);
loadAvailableEventsRdfGraphData();
},

didUpdateAttrs() {
initErrorsList(this);
validateEventGoalField(this);
},

selectedChanged: observer("selected", function () {
this.set("selected", this.selected);
setBase(this.get("uri"), this.get("structure.mapping"), this.selected);
let base = getSelected(that.get("availableEvents"), this.selected);
this.set("selectedBaseValue", base);
initErrorsList(this);
validateEventGoalField(this);
}),

uriChange: observer("uri", function () {
that = this;
setAvailableEvents();
})
});
Expand All @@ -66,7 +79,7 @@ function initializeAjax() {
globals.ajax = ajax;
}

function loadAgentsRdfGraphData() {
function loadAvailableEventsRdfGraphData() {
let repo = (localStorage.currentStore || "http://localhost:8090/rdf4j/repositories")
+ globals.agentsRepository;
actionsAgnt.getFromServer(ajax, repo).then(setAvailableEvents);
Expand All @@ -77,6 +90,7 @@ function setAvailableEvents() {
that.set("availableEvents", eventLists);
var base = getSelected(that.get("availableEvents"), that.get("value"));
that.set("selectedBaseValue", base);
validateEventGoalField(that);
}

function getSelected(ele, uri) {
Expand All @@ -86,3 +100,18 @@ function getSelected(ele, uri) {
function setBase(uri, basePredicate, value) {
rdfGraph.setObject(uri, basePredicate, rdfFact.toNode(value));
}

function initErrorsList(comp) {
let node = getNode(comp);
if (node && !node.errors) {
getNode(comp).errors = new Array();
}
}

function validateEventGoalField(comp) {
comp.get("nodeProperties").validateEventGoalActionField(comp, "No Event is selected!");
}

function getNode(comp) {
return comp.get("nodeProperties").getNode(comp);
}
41 changes: 37 additions & 4 deletions app/components/behaviors/properties/parameter/event-goal-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,41 @@ let that;

export default Component.extend({
ajax: Ember.inject.service(),

nodeProperties: Ember.inject.service("behaviors/node-properties"),
availableEventsGoals: null,
selected: undefined,
validation: undefined,
value: null,
uri: null,

init() {
this._super(...arguments);
that = this;
initializeGlobals(this);
loadActionsRdfGraphData();
initErrorsList(this);
loadAvailableEventsRdfGraphData();
},

didInsertElement() {

},

didUpdateAttrs() {
initErrorsList(this);
validateEventGoalField(this);
},

selectedChanged: observer("selected", function () {
this.set("selected", this.selected);
setBase(this.get("uri"), this.get("structure.mapping"), this.selected);
let base = getSelected(that.get("availableEventsGoals"), this.selected);
this.set("selectedBaseValue", base);
initErrorsList(this);
validateEventGoalField(this);
}),

uriChange: observer("uri", function () {
that = this;
setAvailableEvents();
})
});
Expand All @@ -66,7 +83,7 @@ function initializeAjax() {
globals.ajax = ajax;
}

function loadActionsRdfGraphData() {
function loadAvailableEventsRdfGraphData() {
let repo = (localStorage.currentStore || "http://localhost:8090/rdf4j/repositories")
+ globals.agentsRepository;
actionsAgnt.getFromServer(ajax, repo).then(setAvailableEvents);
Expand All @@ -78,8 +95,9 @@ function setAvailableEvents() {
eventLists = eventLists.concat(actionsAgnt.getEvents());
eventLists = eventLists.concat(actionsAgnt.getGoals());
that.set("availableEventsGoals", eventLists);
var base = getSelected(that.get("availableEventsGoals"), that.get("value"));
let base = getSelected(that.get("availableEventsGoals"), that.get("value"));
that.set("selectedBaseValue", base);
validateEventGoalField(that);
}

function getSelected(ele, uri) {
Expand All @@ -89,3 +107,18 @@ function getSelected(ele, uri) {
function setBase(uri, basePredicate, value) {
rdfGraph.setObject(uri, basePredicate, rdfFact.toNode(value));
}

function initErrorsList(comp) {
let node = getNode(comp);
if (node && !node.errors) {
getNode(comp).errors = new Array();
}
}

function validateEventGoalField(comp) {
comp.get("nodeProperties").validateEventGoalActionField(comp, "No Event/Goal is selected!");
}

function getNode(comp) {
return comp.get("nodeProperties").getNode(comp);
}
35 changes: 31 additions & 4 deletions app/components/behaviors/properties/parameter/goal-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,36 @@ let that;

export default Component.extend({
ajax: Ember.inject.service(),

nodeProperties: Ember.inject.service("behaviors/node-properties"),
availableGoals: null,
selected: undefined,
validation: undefined,
uri: null,

didInsertElement() {
console.log("didInsertElement");
this._super(...arguments);
that = this;
initializeGlobals(this);
loadActionsRdfGraphData();
loadAvailableEventsRdfGraphData();
},

didUpdateAttrs() {
initErrorsList(this);
validateEventGoalField(this);
},


selectedChanged: observer("selected", function () {
this.set("selected", this.selected);
setBase(this.get("uri"), this.get("structure.mapping"), this.selected);
let base = getSelected(that.get("availableGoals"), this.selected);
this.set("selectedBaseValue", base);
initErrorsList(this);
validateEventGoalField(this);
}),

uriChange: observer("uri", function () {
that = this;
setAvailableGoals();
})
});
Expand All @@ -67,7 +78,7 @@ function initializeAjax() {
globals.ajax = ajax;
}

function loadActionsRdfGraphData() {
function loadAvailableEventsRdfGraphData() {
let repo = (localStorage.currentStore || "http://localhost:8090/rdf4j/repositories")
+ globals.agentsRepository;
actionsAgnt.getFromServer(ajax, repo).then(setAvailableGoals);
Expand All @@ -78,6 +89,7 @@ function setAvailableGoals() {
that.set("availableGoals", goalsLists);
var base = getSelected(that.get("availableGoals"), that.get("value"));
that.set("selectedBaseValue", base);
validateEventGoalField(that);
}

function getSelected(ele, uri) {
Expand All @@ -87,3 +99,18 @@ function getSelected(ele, uri) {
function setBase(uri, basePredicate, value) {
rdfGraph.setObject(uri, basePredicate, rdfFact.toNode(value));
}

function initErrorsList(comp) {
let node = getNode(comp);
if (node && !node.errors) {
getNode(comp).errors = new Array();
}
}

function validateEventGoalField(comp) {
comp.get("nodeProperties").validateEventGoalActionField(comp, "No Goal is selected!");
}

function getNode(comp) {
return comp.get("nodeProperties").getNode(comp);
}
Loading

0 comments on commit 4ff25f7

Please sign in to comment.