diff --git a/ClientSide/src/Application/Nadia.js b/ClientSide/src/Application/Nadia.js index 9fff360..0486d23 100644 --- a/ClientSide/src/Application/Nadia.js +++ b/ClientSide/src/Application/Nadia.js @@ -53,13 +53,6 @@ export default class Nadia { }) }, - editAnswer:(question, callback)=>{ - Bus.command('inference/editAnswer', {question:question}).done((res)=>{ - - callback(res); - }) - }, - updateHistory:(ruleName, callback)=>{ Bus.command('rule/updateHistory', {ruleName: ruleName, ruleText: ''}).done((res)=>{ if(res.update == 'done'){ diff --git a/ClientSide/src/Interface/Ui/RuleExecutionPage/RuleExecutionPage.js b/ClientSide/src/Interface/Ui/RuleExecutionPage/RuleExecutionPage.js index 84bd09d..474a4bb 100644 --- a/ClientSide/src/Interface/Ui/RuleExecutionPage/RuleExecutionPage.js +++ b/ClientSide/src/Interface/Ui/RuleExecutionPage/RuleExecutionPage.js @@ -166,35 +166,6 @@ class RuleExecutionPage extends React.Component { if(res.hasMoreQuestion == 'true'){ this._getNextQuestion(); } - else{ - let goalRuleData = {goalRuleName: res.goalRuleName, goalRuleValue: res.goalRuleValue, goalRuleType: res.goalRuleType}; - let goalRuleComponent = - let tempQuestionnaire = Clone(this.state.questionnaire); - tempQuestionnaire.unshift(goalRuleComponent); - - this.setState( - { - hasMoreQuestion: !this.state.hasMoreQuestion, - goalRule: goalRuleData, - questionnaire: tempQuestionnaire, - } - ); - } - }); - } - - _onEditAnswer=(question)=>{ - this.setState({questionnaire:[],questions:[]}); - Nadia.command.editAnswer(question,(res)=>{ - if(res.hasMoreQuestion == 'true'){ - res.workingMemory.map((item)=>{ - let answeredQuestion = ; - let tempQuestionnaire = Clone(this.state.questionnaire); - tempQuestionnaire.unshift(answeredQuestion); - }); - this.setState({questionnaire: tempQuestionnaire}); - this._getNextQuestion(); - } else{ let goalRuleData = {goalRuleName: res.goalRuleName, goalRuleValue: res.goalRuleValue, goalRuleType: res.goalRuleType}; let goalRuleComponent = @@ -214,7 +185,7 @@ class RuleExecutionPage extends React.Component { _createQuestionnaire=(questionData)=>{ - let nextQuestionComponent = ; + let nextQuestionComponent = ; let tempQuestionnaire = Clone(this.state.questionnaire); tempQuestionnaire.unshift(nextQuestionComponent); diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/AnsweredQuestionItem.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/AnsweredQuestionItem.js deleted file mode 100644 index 8ff71e3..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/AnsweredQuestionItem.js +++ /dev/null @@ -1,102 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import PropTypes from 'prop-types'; - -import {Segment } from 'semantic-ui-react'; - -//Application -import Nadia from 'src/Application/Nadia'; - -//component -import AnsweredQuestionIntType from './QuestionItems/QuestionIntType/AnsweredQuestionIntType'; -import AnsweredQuestionBoolType from './QuestionItems/QuestionBoolType/AnsweredQuestionBoolType'; -import AnsweredQuestionDateType from './QuestionItems/QuestionDateType/AnsweredQuestionDateType'; -import AnsweredQuestionStringType from './QuestionItems/QuestionStringType/AnsweredQuestionStringType'; -import AnsweredQuestionDoubleType from './QuestionItems/QuestionDoubleType/AnsweredQuestionDoubleType'; -import AnsweredQuestionHashType from './QuestionItems/QuestionHashType/AnsweredQuestionHashType'; -import AnsweredQuestionUrlType from './QuestionItems/QuestionUrlType/AnsweredQuestionUrlType'; -import AnsweredQuestionUuidType from './QuestionItems/QuestionUuidType/AnsweredQuestionUuidType'; - -export default class AnsweredQuestionItem extends React.Component { - constructor(props) { - super(props); - // initialise component state - this.state = { - - } - } - - componentDidMount = () => { - this.setState({questionData: this.props.questionData}); - - } - - - - - // prop types and default values - static propTypes = { - questionData: PropTypes.object, - enditAnswer: PropTypes.func, - } - - - _onEditAnswer=(question)=>{ - if(this.props.editAnswer){ - this.props.editAnswer(question) - } - } - - - - _createQuestionItem=()=>{ - let questionItem; - let questionText = this.props.questionData.questionText; - let answer = this.props.questionData.answer; - switch(this.props.questionData.answerValueType) - { - case 'integer': - questionItem = - break; - - case 'boolean': - questionItem = - break; - - case 'date': - questionItem = - break; - - case 'defistring': - case 'string': - questionItem = - break; - - case 'double': - questionItem = - break; - - case 'hash': - questionItem = - break; - - case 'url': - questionItem = - break; - - case 'uuid': - questionItem = - break; - } - return questionItem; - } - - // component render method - render() { - return ( - - {this._createQuestionItem()} - - ); - } -} diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItem.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItem.js index 415fd30..664bbcc 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItem.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItem.js @@ -12,10 +12,10 @@ import QuestionIntType from './QuestionItems/QuestionIntType/QuestionIntType'; import QuestionBoolType from './QuestionItems/QuestionBoolType/QuestionBoolType'; import QuestionDateType from './QuestionItems/QuestionDateType/QuestionDateType'; import QuestionStringType from './QuestionItems/QuestionStringType/QuestionStringType'; -import QuestionDoubleType from './QuestionItems/QuestionDoubleType/QuestionDoubleType'; -import QuestionHashType from './QuestionItems/QuestionHashType/QuestionHashType'; -import QuestionUrlType from './QuestionItems/QuestionUrlType/QuestionUrlType'; -import QuestionUuidType from './QuestionItems/QuestionUuidType/QuestionUuidType'; +import QuestionDoubleType from './QuestionItems/QuestionDoubleType'; +import QuestionHashType from './QuestionItems/QuestionHashType'; +import QuestionUrlType from './QuestionItems/QuestionUrlType'; +import QuestionUuidType from './QuestionItems/QuestionUuidType'; import GoalRuleBoolType from './GoalRuleItems/GoalRuleBoolType'; import GoalRuleDateType from './GoalRuleItems/GoalRuleDateType'; @@ -52,12 +52,6 @@ export default class QuestionItem extends React.Component { } } - _onEditAnswer=(question)=>{ - if(this.props.editAnswer){ - this.props.editAnswer(question) - } - } - _displayGoalRule=()=>{ let goalRuleText = this.props.goalRuleData.goalRuleName; let goalRuleValue = this.props.goalRuleData.goalRuleValue; @@ -93,36 +87,36 @@ export default class QuestionItem extends React.Component { switch(this.props.questionData.questionValueType) { case 'integer': - questionItem = + questionItem = break; case 'boolean': - questionItem = + questionItem = break; case 'date': - questionItem = + questionItem = break; case 'defistring': case 'string': - questionItem = + questionItem = break; case 'double': - questionItem = + questionItem = break; case 'hash': - questionItem = + questionItem = break; case 'url': - questionItem = + questionItem = break; case 'uuid': - questionItem = + questionItem = break; } return questionItem; diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionBoolType/AnsweredQuestionBoolType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionBoolType/AnsweredQuestionBoolType.js deleted file mode 100644 index 2be6d62..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionBoolType/AnsweredQuestionBoolType.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import {Button , Segment, Header, Message} from 'semantic-ui-react'; -import PropTypes from 'prop-types'; - -//style -import './QuestionBoolType.scss' - -export default class AnsweredQuestionBoolType extends React.Component { - constructor(props) { - super(props); - this.state ={ - - } - } - - - // prop types and default values - static propTypes = { - question: PropTypes.string.isRequired, - answer: PropTypes.string.isRequired, - } - - static defaultProps = { - - }; - - componentWillMount=()=>{ - this.setState({question: this.props.question, answer: this.props.answer}); - } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } - - // component render method - render() { - return ( - this.state.answer == 'true'? - - - -
{this.props.question}
- -
-
- : - - - -
{this.props.question}
- -
-
- ); - } -} diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionBoolType/QuestionBoolType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionBoolType/QuestionBoolType.js index fab57df..deeb7ca 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionBoolType/QuestionBoolType.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionBoolType/QuestionBoolType.js @@ -8,13 +8,12 @@ import './QuestionBoolType.scss' export default class QuestionBoolType extends React.Component { constructor(props) { - super(props); - this.state ={ - answered: false, - } + super(props); } - + state ={ + answered: false, + } // prop types and default values static propTypes = { question: PropTypes.string.isRequired, @@ -38,13 +37,6 @@ export default class QuestionBoolType extends React.Component { this.setState({answered: true, answer: false}); } } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } // component render method render() { @@ -55,7 +47,6 @@ export default class QuestionBoolType extends React.Component {
{this.props.question}
-
: @@ -63,7 +54,6 @@ export default class QuestionBoolType extends React.Component {
{this.props.question}
-
diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDateType/AnsweredQuestionDateType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDateType/AnsweredQuestionDateType.js deleted file mode 100644 index b6abf3f..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDateType/AnsweredQuestionDateType.js +++ /dev/null @@ -1,61 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import {Button , Segment, Message} from 'semantic-ui-react'; -import PropTypes from 'prop-types'; -import Moment from 'moment'; - -//component -import DateInputFields from './DateInputFields'; - -//style -import './QuestionDateType.scss'; - -export default class AnsweredQuestionDateType extends React.Component { - constructor(props) { - super(props); - this.state = { - - } - } - - - - // prop types and default values - static propTypes = { - question: PropTypes.string.isRequired, - answer: PropTypes.string.isRequired, - } - - componentWillMount=()=>{ - this.setState({question: this.props.question, answer: this.props.answer}); - } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } - - // component render method - render() { - let question = this.props.question+'?'; - let dateAnswerArray = this.state.answer.split('-'); - let dayInputValue = dateAnswerArray[2]; - let monthInputValue = dateAnswerArray[1]; - let yearInputValue = dateAnswerArray[0]; - return ( - - - - - - - - ); - } -} diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDateType/QuestionDateType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDateType/QuestionDateType.js index f8af4c6..7486630 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDateType/QuestionDateType.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDateType/QuestionDateType.js @@ -12,20 +12,19 @@ import './QuestionDateType.scss'; export default class QuestionDateType extends React.Component { constructor(props) { - super(props); - this.state = { - dayIsDirty: false, - dayInputValue: '', - monthIsDirty: false, - monthInputValue: '', - yearIsDirty: false, - yearInputValue: '', - dateInvalid: false, - answered: false, - } + super(props); } - + state = { + dayIsDirty: false, + dayInputValue: '', + monthIsDirty: false, + monthInputValue: '', + yearIsDirty: false, + yearInputValue: '', + dateInvalid: false, + answered: false, + } // prop types and default values static propTypes = { @@ -77,13 +76,6 @@ export default class QuestionDateType extends React.Component { answered: !this.state.answered}); } - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } - // component render method render() { let question = this.props.question+'?'; @@ -99,7 +91,6 @@ export default class QuestionDateType extends React.Component { yearInputValue= {this.state.yearInputValue} dateInvalid= {this.state.dateInvalid}/>
- : diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType/QuestionDoubleType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType.js similarity index 90% rename from ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType/QuestionDoubleType.js rename to ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType.js index 8c4aaad..8073ebe 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType/QuestionDoubleType.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType.js @@ -7,14 +7,13 @@ import PropTypes from 'prop-types'; export default class QuestionDoubleType extends React.Component { constructor(props) { - super(props); - this.state ={ - answered: false, - } + super(props); } - + state ={ + answered: false, + } // prop types and default values static propTypes = { @@ -44,13 +43,6 @@ export default class QuestionDoubleType extends React.Component { _onCancel=()=>{ this.setState({inputValue:{}, answered: !this.state.answered}); } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } // component render method render() { @@ -64,7 +56,6 @@ export default class QuestionDoubleType extends React.Component { - : diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType/AnsweredQuestionDoubleType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType/AnsweredQuestionDoubleType.js deleted file mode 100644 index 623ed4f..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionDoubleType/AnsweredQuestionDoubleType.js +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import {Input, Button, Icon , Segment, Message} from 'semantic-ui-react'; -import PropTypes from 'prop-types'; - - - -export default class AnsweredQuestionDoubleType extends React.Component { - constructor(props) { - super(props); - this.state ={ - - } - } - - - - - // prop types and default values - static propTypes = { - question: PropTypes.string.isRequired, - answer: PropTypes.string.isRequired, - - } - - componentWillMount=()=>{ - this.setState({question: this.props.question, answer: this.props.answer}); - } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.state.question); - } - } - - // component render method - render() { - let question = this.props.question+'?'; - return ( - - - - -
{this.state.answer}
-
- -
-
- ); - } -} diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType/QuestionHashType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType.js similarity index 90% rename from ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType/QuestionHashType.js rename to ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType.js index b2c29cf..aab0810 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType/QuestionHashType.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType.js @@ -8,14 +8,13 @@ import PropTypes from 'prop-types'; export default class QuestionHashType extends React.Component { constructor(props) { - super(props); - this.state ={ - answered: false, - } + super(props); } - + state ={ + answered: false, + } // prop types and default values static propTypes = { @@ -45,13 +44,6 @@ export default class QuestionHashType extends React.Component { _onCancel=()=>{ this.setState({inputValue:{}, answered: !this.state.answered}); } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } // component render method render() { @@ -65,7 +57,6 @@ export default class QuestionHashType extends React.Component { -
: diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType/AnsweredQuestionHashType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType/AnsweredQuestionHashType.js deleted file mode 100644 index c3e3f44..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionHashType/AnsweredQuestionHashType.js +++ /dev/null @@ -1,53 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import {Input, Button, Icon , Segment, Message} from 'semantic-ui-react'; -import PropTypes from 'prop-types'; - - - - -export default class AnsweredQuestionHashType extends React.Component { - constructor(props) { - super(props); - this.state ={ - - } - } - - - - // prop types and default values - static propTypes = { - question: PropTypes.string.isRequired, - answer: PropTypes.string.isRequired, - - } - - - - componentWillMount=()=>{ - this.setState({question: this.props.question, answer: this.props.answer}); - } - - _onEditAnswer=()=>{ - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } - - // component render method - render() { - let question = this.state.question+'?'; - return ( - - - - -
{this.state.answer}
-
- -
-
- ); - } -} diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionIntType/AnsweredQuestionIntType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionIntType/AnsweredQuestionIntType.js deleted file mode 100644 index 7ccaebd..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionIntType/AnsweredQuestionIntType.js +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import {Input, Button, Icon , Segment, Message, Header} from 'semantic-ui-react'; -import PropTypes from 'prop-types'; - -//style -import './QuestionIntType.scss'; - -export default class AnsweredQuestionIntType extends React.Component { - constructor(props) { - super(props); - this.state ={ - - } - } - - // prop types and default values - static propTypes = { - question: PropTypes.string.isRequired, - answer: PropTypes.string.isRequired, - } - - componentWillMount=()=>{ - this.setState({question: this.props.question, answer: this.props.answer}); - } - - _onEditAnswer=()=>{ - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } - - // component render method - render() { - let question = this.props.question+'?'; - return ( - - - -
{this.state.answer}
- -
-
- ); - } -} diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionIntType/QuestionIntType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionIntType/QuestionIntType.js index be670aa..8de4881 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionIntType/QuestionIntType.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionIntType/QuestionIntType.js @@ -8,11 +8,13 @@ import './QuestionIntType.scss'; export default class QuestionIntType extends React.Component { constructor(props) { - super(props); - this.state ={ - answered: false, - inputValue: '', - } + super(props); + } + + + state ={ + answered: false, + inputValue: '', } // prop types and default values @@ -44,13 +46,6 @@ export default class QuestionIntType extends React.Component { _onCancel=()=>{ this.setState({inputValue:{}, answered: !this.state.answered}); } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.props.question); - } - } // component render method render() { @@ -61,7 +56,6 @@ export default class QuestionIntType extends React.Component { {this.state.answered?
{this.state.inputValue}
-
: diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionStringType/AnsweredQuestionStringType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionStringType/AnsweredQuestionStringType.js deleted file mode 100644 index 5793ffb..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionStringType/AnsweredQuestionStringType.js +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import {Input, Button, Icon , Segment, Message, Header} from 'semantic-ui-react'; -import PropTypes from 'prop-types'; - - -//style -import './QuestionStringType.scss'; - -export default class AnsweredQuestionStringType extends React.Component { - constructor(props) { - super(props); - this.state ={ - - } - } - - // prop types and default values - static propTypes = { - question: PropTypes.string.isRequired, - answer: PropTypes.string.isRequired, - } - - componentWillMount=()=>{ - this.setState({question: this.props.question, answer: this.props.answer}); - } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.state.question); - } - } - - // component render method - render() { - let question = this.props.question+'?'; - return ( - - - -
{this.state.answer}
- -
-
- ); - } -} diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionStringType/QuestionStringType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionStringType/QuestionStringType.js index 3e7a14e..677ced8 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionStringType/QuestionStringType.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionStringType/QuestionStringType.js @@ -9,14 +9,15 @@ import './QuestionStringType.scss'; export default class QuestionStringType extends React.Component { constructor(props) { - super(props); - this.state ={ - answered: false, - inputValue:'', - } + super(props); } + state ={ + answered: false, + inputValue:'', + } + // prop types and default values static propTypes = { question: PropTypes.string.isRequired, @@ -37,13 +38,6 @@ export default class QuestionStringType extends React.Component { _onCancel=()=>{ this.setState({inputValue:{}, answered: !this.state.answered}); } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.state.question); - } - } // component render method render() { @@ -54,7 +48,6 @@ export default class QuestionStringType extends React.Component { {this.state.answered?
{this.state.inputValue}
-
: diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType/QuestionUrlType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType.js similarity index 83% rename from ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType/QuestionUrlType.js rename to ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType.js index ad1780c..81467f6 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType/QuestionUrlType.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType.js @@ -8,10 +8,13 @@ import PropTypes from 'prop-types'; export default class QuestionUrlType extends React.Component { constructor(props) { - super(props); - this.state ={ - answered: false, - } + super(props); + } + + + + state ={ + answered: false, } // prop types and default values @@ -42,14 +45,6 @@ export default class QuestionUrlType extends React.Component { _onCancel=()=>{ this.setState({inputValue:{}, answered: !this.state.answered}); } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.state.question); - } - } - // component render method render() { @@ -59,10 +54,10 @@ export default class QuestionUrlType extends React.Component { {this.state.answered? - -
{this.state.inputValue}
- -
+ + + +
: this.state.inputError? diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType/AnsweredQuestionUrlType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType/AnsweredQuestionUrlType.js deleted file mode 100644 index 1003c38..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUrlType/AnsweredQuestionUrlType.js +++ /dev/null @@ -1,53 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import {Input, Button, Icon , Segment, Message} from 'semantic-ui-react'; -import PropTypes from 'prop-types'; - - - - -export default class AnsweredQuestionUrlType extends React.Component { - constructor(props) { - super(props); - this.state ={ - - } - } - - - - - // prop types and default values - static propTypes = { - questionData: PropTypes.object, - enditAnswer: PropTypes.func, - } - - componentWillMount=()=>{ - this.setState({question: this.props.question, answer: this.props.answer}); - } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.state.question); - } - } - - - // component render method - render() { - let question = this.props.question+'?'; - return ( - - - - -
{this.state.answer}
- -
-
-
- ); - } -} diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType/QuestionUuidType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType.js similarity index 85% rename from ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType/QuestionUuidType.js rename to ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType.js index e91588b..45ffc33 100644 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType/QuestionUuidType.js +++ b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType.js @@ -9,7 +9,8 @@ import PropTypes from 'prop-types'; export default class QuestionUuidType extends React.Component { constructor(props) { super(props); - this.state = { + + state = { answered: false, } } @@ -43,12 +44,6 @@ export default class QuestionUuidType extends React.Component { _onCancel=()=>{ this.setState({inputValue:{}, answered: !this.state.answered}); } - - _onEditAnswer=()=>{ - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.state.question); - } - } // component render method render() { @@ -59,10 +54,10 @@ export default class QuestionUuidType extends React.Component { {this.state.answered? - -
{this.state.inputValue}
- -
+ + + +
: this.state.inputError? diff --git a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType/AnsweredQuestionUuidType.js b/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType/AnsweredQuestionUuidType.js deleted file mode 100644 index d454e29..0000000 --- a/ClientSide/src/Interface/Ui/RunRulesPage/Questions/QuestionItems/QuestionUuidType/AnsweredQuestionUuidType.js +++ /dev/null @@ -1,54 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import {Input, Button, Icon , Segment, Message} from 'semantic-ui-react'; -import PropTypes from 'prop-types'; - - - - -export default class QuestionUuidType extends React.Component { - constructor(props) { - super(props); - this.state ={ - - } - } - - - - - - // prop types and default values - static propTypes = { - questionData: PropTypes.object, - enditAnswer: PropTypes.func, - } - - componentWillMount=()=>{ - this.setState({question: this.props.question, answer: this.props.answer}); - } - - _onEditAnswer=()=>{ - debugger; - if(this.props.onEditAnswer){ - this.props.onEditAnswer(this.state.question); - } - } - - // component render method - render() { - let question = this.props.question+'?'; - return ( - - - - -
{this.state.answer}
- -
-
-
- ); - - } -} diff --git a/com.Nadia-R.S/bin/com/NadiaRS/InferenceEngine/inferencePackage/InferenceEngine.class b/com.Nadia-R.S/bin/com/NadiaRS/InferenceEngine/inferencePackage/InferenceEngine.class index 63614fa..e347fb6 100644 Binary files a/com.Nadia-R.S/bin/com/NadiaRS/InferenceEngine/inferencePackage/InferenceEngine.class and b/com.Nadia-R.S/bin/com/NadiaRS/InferenceEngine/inferencePackage/InferenceEngine.class differ diff --git a/com.Nadia-R.S/bin/com/NadiaRS/controller/InferenceController.class b/com.Nadia-R.S/bin/com/NadiaRS/controller/InferenceController.class index 5e5070d..1577b8f 100644 Binary files a/com.Nadia-R.S/bin/com/NadiaRS/controller/InferenceController.class and b/com.Nadia-R.S/bin/com/NadiaRS/controller/InferenceController.class differ diff --git a/com.Nadia-R.S/src/main/java/com/NadiaRS/InferenceEngine/inferencePackage/InferenceEngine.java b/com.Nadia-R.S/src/main/java/com/NadiaRS/InferenceEngine/inferencePackage/InferenceEngine.java index d4869c7..5fe7b30 100644 --- a/com.Nadia-R.S/src/main/java/com/NadiaRS/InferenceEngine/inferencePackage/InferenceEngine.java +++ b/com.Nadia-R.S/src/main/java/com/NadiaRS/InferenceEngine/inferencePackage/InferenceEngine.java @@ -1523,84 +1523,43 @@ public ObjectNode[] generateAssessmentSummary() return tempSummaryList.stream().toArray(ObjectNode[]::new); } - - public void editAnswer(String question) - { - List tempSummaryList = this.getAssessmentState().getSummaryList(); - int indexOfQuestionToBeEdited = tempSummaryList.indexOf(question); - HashMap tempWorkingMemory = this.getAssessmentState().getWorkingMemory(); - - /* - * following two lines are to reset 'exclusiveList' and 'inclusiveList' which are for tracking all relevant branches by cutting dependencies - */ - this.getAssessmentState().setExclusiveList(new ArrayList()); - this.getAssessmentState().setInclusiveList(new ArrayList()); - - tempWorkingMemory.remove(question); //need to remove values of 'question' key from workingMemory because it needs editing - - /* - * the reason of doing following lines is to re-establish 'inclusiveList' and 'exclusiveList' - * which manage cutting all irrelevant branches within the rule tree based on fed answers. - * all branches up to the point of 'to-be-edited-question' need re-establishment and other branches after the 'question' - * don't need to be re-established because those may not irrelevant to effect decision at the end unless they are appeared - * during the questionnaire after all re-establishment. - */ - IntStream.range(0, tempSummaryList.size()).forEachOrdered(index->{ - if(index < indexOfQuestionToBeEdited) { - Node node = this.getNextQuestion(this.getAssessment()); - if(ass.getNodeToBeAsked().getLineType().equals(LineType.ITERATE)) - { - ass.setAuxNodeToBeAsked(node); - } - List questionnaireFromNode = this.getQuestionsFromNodeToBeAsked(node); - questionnaireFromNode.stream().forEachOrdered(questionItem->{ - if(tempSummaryList.contains(questionItem)) - { - FactValue fv = tempWorkingMemory.get(questionItem); - this.feedAnswerToNode(node, questionItem, fv.getValue().toString(), fv.getType(), ass); - } - }); - } - }); - - } - + /* * this is to find a condition with a list of given keyword */ public List findCondition(String keyword) { - int initialSize = nodeSet.getNodeSortedList().size(); - List conditionList = new ArrayList<>(initialSize); - List questionList = new ArrayList<>(initialSize); - for(Node node: nodeSet.getNodeSortedList()) - { - if(nodeSet.getDependencyMatrix().getToChildDependencyList(node.getNodeId()).isEmpty()) - { - questionList.add(node.getNodeName()); - } - } - - String[] keywordArray = keyword.split("\\W+"); // split the keyword by none word character including whitespace. - int keywordArrayLength = keywordArray.length; - int numberOfMatched = 0; - for(String ruleName: questionList) - { - numberOfMatched = 0; - for(int i = 0; i < keywordArrayLength; i++) - { - if(ruleName.contains(keywordArray[i])) - { - numberOfMatched++; - } - } - if(numberOfMatched == keywordArrayLength) - { - conditionList.add(ruleName); - } - } - - return conditionList; + int initialSize = nodeSet.getNodeSortedList().size(); + List conditionList = new ArrayList<>(initialSize); + List questionList = new ArrayList<>(initialSize); + for(Node node: nodeSet.getNodeSortedList()) + { + if(nodeSet.getDependencyMatrix().getToChildDependencyList(node.getNodeId()).isEmpty()) + { + questionList.add(node.getNodeName()); + } + } + + String[] keywordArray = keyword.split("\\W+"); // split the keyword by none word character including whitespace. + int keywordArrayLength = keywordArray.length; + int numberOfMatched = 0; + for(String ruleName: questionList) + { + numberOfMatched = 0; + for(int i = 0; i < keywordArrayLength; i++) + { + if(ruleName.contains(keywordArray[i])) + { + numberOfMatched++; + } + } + if(numberOfMatched == keywordArrayLength) + { + conditionList.add(ruleName); + } + } + + return conditionList; } } diff --git a/com.Nadia-R.S/src/main/java/com/NadiaRS/controller/InferenceController.java b/com.Nadia-R.S/src/main/java/com/NadiaRS/controller/InferenceController.java index 607c972..8d48ca1 100644 --- a/com.Nadia-R.S/src/main/java/com/NadiaRS/controller/InferenceController.java +++ b/com.Nadia-R.S/src/main/java/com/NadiaRS/controller/InferenceController.java @@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; -import com.NadiaRS.InferenceEngine.factValuePackage.FactValue; import com.NadiaRS.InferenceEngine.factValuePackage.FactValueType; import com.NadiaRS.InferenceEngine.inferencePackage.Assessment; import com.NadiaRS.InferenceEngine.inferencePackage.InferenceEngine; @@ -30,7 +29,6 @@ import com.NadiaRS.domain.RuleHistory; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import jersey.repackaged.com.google.common.collect.Lists; @@ -50,71 +48,12 @@ public class InferenceController { public ObjectNode[] viewSummary(HttpServletRequest httpRequest) { InferenceEngine ie = (InferenceEngine)httpRequest.getSession().getAttribute("inferenceEngine"); - - List tempSummaryList = new ArrayList<>(); - HashMap tempWorkingMemory = ie.getAssessmentState().getWorkingMemory(); - ie.getAssessmentState().getSummaryList().stream().forEachOrdered((item)->{ - ObjectNode objectNode = new ObjectMapper().createObjectNode(); - objectNode.put("nodeText", item); - objectNode.put("nodeValue", tempWorkingMemory.get(item).getValue().toString()); - tempSummaryList.add(objectNode); - }); - - //following lines are to transfer all possible left over value from editing answers process from workingMemory to summary list in GUI - tempWorkingMemory.keySet().stream().forEach(key->{ - if(!ie.getAssessmentState().getSummaryList().contains(key)) - { - ObjectNode objectNode = new ObjectMapper().createObjectNode(); - objectNode.put("nodeText", key); - objectNode.put("nodeValue", tempWorkingMemory.get(key).getValue().toString()); - tempSummaryList.add(objectNode); - } - }); - - return tempSummaryList.stream().toArray(ObjectNode[]::new); - } - - @RequestMapping(value = "editAnswer", method = RequestMethod.POST) - public ObjectNode editAnswer(@RequestBody ObjectNode question, HttpServletRequest httpRequest) - { - InferenceEngine ie = (InferenceEngine)httpRequest.getSession().getAttribute("inferenceEngine"); - Assessment ass = (Assessment)httpRequest.getSession().getAttribute("assessment"); - - String questionName = question.get("question").asText(); - - ie.editAnswer(questionName); - - ObjectNode objectNode = new ObjectMapper().createObjectNode(); - ArrayNode questionsAndAnswers = objectNode.putArray("workingMemory"); - HashMap tempWorkingMemory = ie.getAssessmentState().getWorkingMemory(); - tempWorkingMemory.keySet().stream().forEach(key->{ - ObjectNode subObjectNode = new ObjectMapper().createObjectNode(); - subObjectNode.put("questionText", key); - subObjectNode.put("answer", tempWorkingMemory.get(key).getValue().toString()); - subObjectNode.put("answerValueType", tempWorkingMemory.get(key).getType().toString()); - questionsAndAnswers.add(subObjectNode); - }); - if(ie.getAssessmentState().getWorkingMemory().get(ass.getGoalNode().getNodeName())==null || !ie.getAssessmentState().allMandatoryNodeDetermined()) - { - objectNode.put("hasMoreQuestion", "true"); - } - else - { - String goalNodeName = ass.getGoalNode().getNodeName(); - objectNode.put("hasMoreQuestion", "false"); - objectNode.put("goalRuleName", goalNodeName); - objectNode.put("goalRuleValue", ie.getAssessmentState().getWorkingMemory().get(goalNodeName).getValue().toString()); - objectNode.put("goalRuleType", ie.findTypeOfElementToBeAsked(ass.getGoalNode()).get(goalNodeName).toString().toLowerCase()); - - } - - return objectNode; - + return ie.generateAssessmentSummary(); } @RequestMapping(value="feedAnswer", method = RequestMethod.POST) -// @ResponseBody + @ResponseBody public ObjectNode feedAnswer(@RequestBody ObjectNode answers, HttpServletRequest httpRequest) { InferenceEngine ie = (InferenceEngine)httpRequest.getSession().getAttribute("inferenceEngine");