Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/controllers/cbr_cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ module.exports.setDefault = async (req, res) => {
selected_intent.strategies.forEach(function(strat){
if(strat.id == req.params.strategyId){
strat.selected = true;
selected_intent.strategy_selected = true;
selected_intent.strategy_selected = strat.tree;
}
})

Expand Down
16 changes: 12 additions & 4 deletions src/controllers/usecase.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Usecase = require("../models/usecase");
const Tree = require("../models/tree");
const axios = require('axios');

module.exports.create = async (req, res) => {
Expand Down Expand Up @@ -112,8 +113,9 @@ module.exports.getCaseStructure = async (req, res) => {
var all_cases = []
// console.log(build_json);
// Now do persona by persona
data.personas.forEach(function(persona){
persona.intents.forEach(intent => {
Promise.all(
await data.personas.map(async function(persona){
await Promise.all(await persona.intents.map(async intent => {
// console.log(intent);
var new_case = JSON.stringify(build_json)

Expand All @@ -123,6 +125,10 @@ module.exports.getCaseStructure = async (req, res) => {
new_case = new_case.replaceAll('<DomainKnowledgeLevel>', persona.details.domain_knowledge_level);
new_case = JSON.parse(new_case);

const selected_tree = await Tree.findById(intent.strategy_selected);

new_case["http://www.w3id.org/iSeeOnto/explanationexperience#hasSolution"] = selected_tree.data

var asks = []
intent.questions.forEach(question => {
var ask = {...new_case["http://www.w3id.org/iSeeOnto/explanationexperience#hasDescription"]["http://www.w3id.org/iSeeOnto/explanationexperience#hasUserGroup"]["https://purl.org/heals/eo#asks"][0]};
Expand Down Expand Up @@ -172,9 +178,11 @@ module.exports.getCaseStructure = async (req, res) => {
});
new_case["http://www.w3id.org/iSeeOnto/explanationexperience#hasOutcome"]["http://linkedu.eu/dedalo/explanationPattern.owl#isBasedOn"] = evals;
all_cases.push(new_case);
});
}));
})).then(function(){
res.json(all_cases);
});
res.json(all_cases);

} catch (error) {
res.status(500).json({ message: error });
}
Expand Down