Skip to content

Commit

Permalink
Merge pull request #11 from ps-md2/feature/actions-process-chain-in-wfe
Browse files Browse the repository at this point in the history
Each Workflow Element requires at least one Process Chain and accepts any number of actions
Merging branch "Feature/actions process chain in wfe"
  • Loading branch information
the-other-one committed Dec 19, 2014
2 parents fce05e8 + bd70ec4 commit a335f1b
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package TestProject.controllers

WorkflowElement Test {
defaultProcessChain TestChain

onInit {
action CustomAction init {

}
}

processChain TestChain {

}
}
Original file line number Diff line number Diff line change
@@ -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
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -32,6 +35,7 @@ class ValidatorTests {
MD2Model viewModel;
MD2Model rootValidatorModel;
MD2Model inputFieldValidatorModel;
MD2Model emptyProcessChainModel;
ResourceSet rs;

private EList<ControllerElement> elements;
Expand All @@ -48,12 +52,14 @@ 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;

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;

}
Expand All @@ -68,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);
Expand Down Expand Up @@ -101,7 +107,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);
}


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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*****//

Expand Down
4 changes: 2 additions & 2 deletions de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,8 @@ WorkflowElement:
initActions += Action
'}')

((actions += Action+) &
(processChain += ProcessChain))
((actions += Action*) &
(processChain += ProcessChain+))

'}'
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class ControllerValidator extends AbstractMD2JavaValidator {
@Inject
override register(EValidatorRegistrar registrar) {
// nothing to do
}
}

public static final String EMPTYPROCESSCHAIN = "emptyProcessChain";

/////////////////////////////////////////////////////////
/// Action Validators
Expand Down Expand Up @@ -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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,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
Expand Down

0 comments on commit a335f1b

Please sign in to comment.