From 058d0434aa993048e360ade863064762bf5e3ead Mon Sep 17 00:00:00 2001 From: Jason Fischer <65784505+jason-fischer-flashparking@users.noreply.github.com> Date: Tue, 25 May 2021 17:54:01 -0500 Subject: [PATCH 1/2] flip arg order for comparator functions (inputValue, choiceValue) --- src/stateTasks/executors/ChoiceExecutor.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stateTasks/executors/ChoiceExecutor.ts b/src/stateTasks/executors/ChoiceExecutor.ts index 6993d982..66b425bd 100644 --- a/src/stateTasks/executors/ChoiceExecutor.ts +++ b/src/stateTasks/executors/ChoiceExecutor.ts @@ -107,23 +107,23 @@ export class ChoiceExecutor extends StateTypeExecutor { case 'NumericEquals': case 'StringEquals': case 'TimestampEquals': - return this.checkEquals(choiceValue, inputValue); + return this.checkEquals(inputValue, choiceValue); case 'NumericGreaterThan': case 'StringGreaterThan': case 'TimestampGreaterThan': - return this.checkGreaterThan(choiceValue, inputValue); + return this.checkGreaterThan(inputValue, choiceValue); case 'NumericGreaterThanEquals': case 'StringGreaterThanEquals': case 'TimestampGreaterThanEquals': - return this.checkGreaterThanEquals(choiceValue, inputValue); + return this.checkGreaterThanEquals(inputValue, choiceValue); case 'NumericLessThan': case 'StringLessThan': case 'TimestampLessThan': - return this.checkLowerThan(choiceValue, inputValue); + return this.checkLowerThan(inputValue, choiceValue); case 'NumericLessThanEquals': case 'StringLessThanEquals': case 'TimestampLessThanEquals': - return this.checkLowerThanEquals(choiceValue, inputValue); + return this.checkLowerThanEquals(inputValue, choiceValue); default: throw new Error(); } From 26299ef370b2bd165437c5665c8e11ae7fa98fda Mon Sep 17 00:00:00 2001 From: Jason Fischer <65784505+jason-fischer-flashparking@users.noreply.github.com> Date: Wed, 2 Jun 2021 14:50:11 -0500 Subject: [PATCH 2/2] support IsPresent --- src/stateTasks/executors/ChoiceExecutor.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stateTasks/executors/ChoiceExecutor.ts b/src/stateTasks/executors/ChoiceExecutor.ts index 66b425bd..d4e14564 100644 --- a/src/stateTasks/executors/ChoiceExecutor.ts +++ b/src/stateTasks/executors/ChoiceExecutor.ts @@ -103,6 +103,8 @@ export class ChoiceExecutor extends StateTypeExecutor { // TODO: Find a better way to map the comparators with the methods without using factories or strategy switch (comparator) { + case "IsPresent": + return choiceValue ? inputValue !== undefined : inputValue === undefined; case 'BooleanEquals': case 'NumericEquals': case 'StringEquals': @@ -125,7 +127,7 @@ export class ChoiceExecutor extends StateTypeExecutor { case 'TimestampLessThanEquals': return this.checkLowerThanEquals(inputValue, choiceValue); default: - throw new Error(); + throw new Error(`Comparator ${comparator} not implemented`); } }