From ed53ca4686c0f0f57e0965d5188b0a09f9d30920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Mo=CC=88ser?= Date: Fri, 19 Dec 2014 10:29:52 +0100 Subject: [PATCH 1/3] Arbitrary number of actions, at least one ProcessChain. We still enforce them to be in blocks, i.e. we cannot mix actions with processChains. --- de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext b/de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext index abfa7cff..6ffb2815 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext @@ -729,8 +729,8 @@ WorkflowElement: initActions += Action '}') - ((actions += Action+) & - (processChain += ProcessChain)) + ((actions += Action*) & + (processChain += ProcessChain+)) '}' ; From 80869d1dbdc0b783ddf9e86d9968b8b6578526cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Mo=CC=88ser?= Date: Fri, 19 Dec 2014 10:32:18 +0100 Subject: [PATCH 2/3] Add test for empty processChain. Changed the warning message from "No processChain steps are defined for this processChain. Such processChains have no effect and should be omitted." to "No processChain steps are defined for this processChain. A processChain should have at least one step showing a view.". --- .../validator/EmptyProcessChain.md2 | 15 +++++++++++++++ .../controller/validator/ValidatorTests.xtend | 12 +++++++++++- .../framework/tests/utils/ModelProvider.java | 2 ++ .../validation/ControllerValidator.xtend | 19 +++++++++++++++++-- .../framework/validation/LegacyValidator.java | 12 ------------ 5 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/EmptyProcessChain.md2 diff --git a/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/EmptyProcessChain.md2 b/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/EmptyProcessChain.md2 new file mode 100644 index 00000000..8473b794 --- /dev/null +++ b/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/EmptyProcessChain.md2 @@ -0,0 +1,15 @@ +package TestProject.controllers + +WorkflowElement Test { + defaultProcessChain TestChain + + onInit { + action CustomAction init { + + } + } + + processChain TestChain { + + } +} diff --git a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend index 82202df7..ee9040ac 100644 --- a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend +++ b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend @@ -21,6 +21,9 @@ import de.wwu.md2.framework.mD2.Validator import java.util.List import de.wwu.md2.framework.mD2.CustomAction import de.wwu.md2.framework.mD2.ValidatorBindingTask +import de.wwu.md2.framework.mD2.MD2Package +import de.wwu.md2.framework.validation.ControllerValidator +import de.wwu.md2.framework.mD2.WorkflowElement @InjectWith(typeof(MD2InjectorProvider)) @RunWith(typeof(XtextRunner)) @@ -32,6 +35,7 @@ class ValidatorTests { MD2Model viewModel; MD2Model rootValidatorModel; MD2Model inputFieldValidatorModel; + MD2Model emptyProcessChainModel; ResourceSet rs; private EList elements; @@ -48,6 +52,7 @@ class ValidatorTests { mainModel = BASIC_CONTROLLER_M.load.parse(rs); rootValidatorModel = VALIDATOR_COMPONENT_C.load.parse(rs); inputFieldValidatorModel = INPUT_FIELD_VALIDATOR_COMPONENT_C.load.parse(rs); + emptyProcessChainModel = EMPTY_PROCESS_CHAIN_C.load.parse; elements = (rootValidatorModel.modelLayer as Controller).controllerElements; validators = elements.filter(typeof(Validator)).toList; @@ -101,7 +106,12 @@ class ValidatorTests { 1.assertEquals(tasks.get(1).validators.size); 1.assertEquals(tasks.get(2).validators.size); 1.assertEquals(tasks.get(3).validators.size); - } + } + + @Test + def checkForEmptyProcessChainsTest(){ + emptyProcessChainModel.assertWarning(MD2Package::eINSTANCE.processChain, ControllerValidator::EMPTYPROCESSCHAIN); + } } diff --git a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/utils/ModelProvider.java b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/utils/ModelProvider.java index 2ac4597d..98696ab6 100644 --- a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/utils/ModelProvider.java +++ b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/utils/ModelProvider.java @@ -51,6 +51,8 @@ public class ModelProvider { public static final String VALIDATOR_COMPONENT_C = "dsl/controller/validator/RootValidators.md2"; public static final String INPUT_FIELD_VALIDATOR_COMPONENT_C = "dsl/controller/validator/InputFieldValidators.md2"; + + public static final String EMPTY_PROCESS_CHAIN_C = "dsl/controller/validator/EmptyProcessChain.md2"; //********Validator*****// diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/ControllerValidator.xtend b/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/ControllerValidator.xtend index 58661230..9aea410b 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/ControllerValidator.xtend +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/ControllerValidator.xtend @@ -31,7 +31,9 @@ class ControllerValidator extends AbstractMD2JavaValidator { @Inject override register(EValidatorRegistrar registrar) { // nothing to do - } + } + + public static final String EMPTYPROCESSCHAIN = "emptyProcessChain"; ///////////////////////////////////////////////////////// /// Action Validators @@ -263,5 +265,18 @@ class ControllerValidator extends AbstractMD2JavaValidator { val error = '''No subsequent step! Cannot define 'proceed' operation on last processChain step.''' acceptError(error, next, null, -1, null); } - } + } + + /** + * Avoid empty processChains. + * @param processChain + */ + @Check + def checkForEmptyProcessChains(ProcessChain processChain) { + if(processChain.processChainSteps.empty) { + acceptWarning("No processChain steps are defined for this processChain. A processChain should have at least one step showing a view.", + processChain, null, -1, EMPTYPROCESSCHAIN); + } + } + } diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/LegacyValidator.java b/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/LegacyValidator.java index f0afbce6..2d6f32a9 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/LegacyValidator.java +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/LegacyValidator.java @@ -450,18 +450,6 @@ public void checkAbstractViewGUIElementRef_Path(AbstractViewGUIElementRef abstra } } - /** - * Avoid empty processChains. - * @param processChain - */ - @Check - public void checkForEmptyProcessChains(ProcessChain processChain) { - if(processChain.getProcessChainSteps().isEmpty()) { - acceptWarning("No processChain steps are defined for this processChain. Such processChains have no effect and should be omitted.", - processChain, null, -1, null); - } - } - /** * This validator avoids the assignment of none-toMany content providers (providing X[]) to ContentProviderAddActions. * @param addAction From bd70ec47c468a9d98429034584d7481f57f4355e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Mo=CC=88ser?= Date: Fri, 19 Dec 2014 10:32:38 +0100 Subject: [PATCH 3/3] Fix broken validator test due to new DSL structure. --- .../validator/InputFieldValidators.md2 | 23 +++++++++++++++---- .../controller/validator/RootValidators.md2 | 12 ---------- .../controller/validator/ValidatorTests.xtend | 5 ++-- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/InputFieldValidators.md2 b/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/InputFieldValidators.md2 index 5a5a63cc..e20d4359 100644 --- a/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/InputFieldValidators.md2 +++ b/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/InputFieldValidators.md2 @@ -1,10 +1,23 @@ package controllers -action CustomAction assignValidators { - bind validators NotNullValidator (message "ID must not be null!") NumberRangeValidator (message "ID must between 1 and 666!") on complaintView.complaintID - bind validator StringRangeValidator (maxLength 150, minLength 1, message "the string is too short or too long!") on complaintView.descriptionTxt - bind validator RegExValidator (regEx "[A-Za-Z]+@[a-z]{2,6}", message "that's not a valid email address") on complaintView.userEmail - bind validator DateRangeValidator (min 1900-01-01, message "the string is too short or too long!") on complaintView.submitDate +WorkflowElement Test { + defaultProcessChain MyProcessChain + onInit { + action CustomAction init{ + } + } + + processChain MyProcessChain { + step MediaCapturing: + view myView + } + + action CustomAction assignValidators { + bind validators NotNullValidator (message "ID must not be null!") NumberRangeValidator (message "ID must between 1 and 666!") on complaintView.complaintID + bind validator StringRangeValidator (maxLength 150, minLength 1, message "the string is too short or too long!") on complaintView.descriptionTxt + bind validator RegExValidator (regEx "[A-Za-Z]+@[a-z]{2,6}", message "that's not a valid email address") on complaintView.userEmail + bind validator DateRangeValidator (min 1900-01-01, message "the string is too short or too long!") on complaintView.submitDate + } } diff --git a/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/RootValidators.md2 b/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/RootValidators.md2 index 210b9e32..e8e17eba 100644 --- a/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/RootValidators.md2 +++ b/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/RootValidators.md2 @@ -47,15 +47,3 @@ remoteConnection myConnection { password "admin" user "admin" } - - -//assign Validators to input fields - -action CustomAction assignValidators { - bind validators NotNullValidator (message "ID must not be null!") NumberRangeValidator (message "ID must between 1 and 666!") on complaintView.complaintID - bind validator StringRangeValidator (maxLength 150, minLength 1, message "the string is too short or too long!") on complaintView.descriptionTxt - bind validator RegExValidator (regEx "[A-Za-Z]+@[a-z]{2,6}", message "that's not a valid email address") on complaintView.userEmail - bind validator DateRangeValidator (min 1900-01-01, message "the string is too short or too long!") on complaintView.submitDate -} - - diff --git a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend index ee9040ac..f395938c 100644 --- a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend +++ b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend @@ -58,7 +58,8 @@ class ValidatorTests { validators = elements.filter(typeof(Validator)).toList; ifv_elements = (inputFieldValidatorModel.modelLayer as Controller).controllerElements; - actions = ifv_elements.filter(typeof(CustomAction)).toList; + var workflowElement = ifv_elements.filter(typeof(WorkflowElement)).head as WorkflowElement; + actions = workflowElement.actions.filter(typeof(CustomAction)).toList; tasks = actions.get(0).codeFragments.filter(typeof(ValidatorBindingTask)).toList; } @@ -73,7 +74,7 @@ class ValidatorTests { @Test def validatorNamesTest(){ "validateComplaintID".assertEquals(validators.get(0).name); - "validateDesctription".assertEquals(validators.get(1).name); + "validateDescription".assertEquals(validators.get(1).name); "validateUserEmail".assertEquals(validators.get(2).name); "validateDate".assertEquals(validators.get(3).name); "myRemoteValidator".assertEquals(validators.get(4).name);