Skip to content

Commit

Permalink
Merge pull request #6 from ps-md2/feature/dsl-validator
Browse files Browse the repository at this point in the history
Feature/dsl validator
  • Loading branch information
the-other-one committed Dec 18, 2014
2 parents b7dcae4 + 7f34ca4 commit 057bd85
Show file tree
Hide file tree
Showing 12 changed files with 537 additions and 278 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ WorkflowElement LocationDetection{
action CustomAction next {
bind action FireEvent(LocationDetectionEvent) on LocationDetectionView.Next.onClick
}
}

processChain LocationProcessChain{
step LocationDetection:
view LocationDetectionView
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ entity Complaint {
entity Location {
myStreet: string
myCity: string
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ GridLayoutPane LocationDetectionView (columns 1, rows 6) {
TextInput cityLbl {tooltip "city"}
Spacer
Button Next {text "Next"}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ App CurrentStateProjectApp {
LocationDetection (startable: "Start Controller 1")
}
appName "functionTestApp"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package CurrentStateProject.controllers

main {
appVersion "1.0"
modelVersion "1.0"
}
remoteConnection CitizenAppRemoteConnection {
uri "http://localhost:8081/Backend/"
}
contentProvider Complaint localComplaintProvider {
providerType CitizenAppRemoteConnection
}

WorkflowElement LocationDetection{
onInit {
action CustomAction init{

}
}
action CustomAction next {
bind action FireEvent(LocationEvent) on LocationVerifyView.Next2.onClick
}
processChain LocationProcessChain{
step LocationDetection:
view LocationDetectionView
}
}

WorkflowElement SubmitComplaint {
onInit {
action CustomAction init {
}
}
action CustomAction next {
bind action FireEvent(LocationEvent) on LocationVerifyView.Next2.onClick
}
processChain ComplaintProcessChain {
step SubmitComplaint:
view SubmitComplaintView
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package CurrentStateProject.models

entity Complaint {
loc: Location // use current MD2 location instead!--> No, current MD2 location is a content provider, not an entity!
descriptions : string
feedback : string
status : ComplaintStatus
}

entity Location {
myStreet: string
myStreetNo: string
myPostalCode: integer
myCity: string
myCountry: string
myLatitude: float
myLongitude: float
}

enum ComplaintStatus {
"User is filling out complaint",
"Complaint is sent to administration",
"Complaint is in process",
"Complaint has been handled by the administration"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package CurrentStateProject.views

GridLayoutPane LocationDetectionView (columns 2, rows 9) {
Label TitleLbl ("Enter your location") // better: As Title of Activity
Spacer
TextInput streetLbl {tooltip "street"}
TextInput streetNoLbl {tooltip "no"}
IntegerInput zipLbl {tooltip "zip" }
TextInput cityLbl {tooltip "city"}
TextInput countryLbl {tooltip "country" width 100%}
Spacer {width 1%}
Label latitudeLbl ("Latitude:")
Label latitudeValueLbl ("")
Label longitudeLbl ("Longitude:")
Label longitudeValueLbl ("")
Spacer {width 1%}
Button DetectLocationBtn {text "My Location"}
Button Cancel {text "Cancel"}
Button Next {text "Next"}
//NavigationBar(Cancel, next)
Spacer {width 1%}
}

FlowLayoutPane LocationVerifyView (vertical) {
Label TitleLbl ("Verify Location") // better: As Title of Activity

FlowLayoutPane StreetView (horizontal) {
LocationDetectionView.streetLbl -> streetLbl2
LocationDetectionView.streetNoLbl -> streetNoLbl2
}
FlowLayoutPane CityView (horizontal) {
LocationDetectionView.zipLbl -> zipLbl2
LocationDetectionView.cityLbl -> cityLbl2
}

LocationDetectionView.countryLbl -> countryLbl2
Spacer {width 1%}
LocationDetectionView.latitudeLbl -> latitudeLbl2
LocationDetectionView.longitudeLbl -> longitudeLbl2

//NavigationBar(Cancel, previous, next)
LocationDetectionView.Cancel -> Cancel2
LocationDetectionView.Next -> Next2
Button Previous {text "Previous"}
}

FlowLayoutPane SubmitComplaintView (vertical) {
Label TitleLbl ("Submit Complaint") // better: As Title of Activity
Image UploadImg {
src "uploadedImage.png"
}
FlowLayoutPane StreetView (horizontal) {
LocationDetectionView.streetLbl -> streetLbl3
LocationDetectionView.streetNoLbl -> streetNoLbl3
}
FlowLayoutPane CityView (horizontal) {
LocationDetectionView.zipLbl -> zipLbl3
LocationDetectionView.cityLbl -> cityLbl3
}

LocationDetectionView.countryLbl -> countryLbl3
Spacer {width 1%}
LocationDetectionView.latitudeLbl -> latitudeLbl3
LocationDetectionView.longitudeLbl -> longitudeLbl3

TextInput DescriptionTxt {
label "Additional Description"
type textarea
}
//NavigationBar(Cancel, next "Submit complaint")
LocationDetectionView.Cancel -> Cancel3
Button submitComplaint {text "Submit complaint"}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package CurrentStateProject.workflows

/*
* Implement the workflow here
*/

WorkflowElement LocationDetection
fires LocationEvent {
start LocationDetection
}

WorkflowElement SubmitComplaint
fires SubmitEvent {
start LocationDetection
}
fires anotherEvent {
start LocationDetection
}

App Citizenapp {
WorkflowElements {
LocationDetection (startable: "Start Controller 1"),
SubmitComplaint
}
appName "currentStateApp"
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ class functionTest {
controllerModel.assertNoErrors;
viewModel.assertNoErrors;
modelModel.assertNoErrors;
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package de.wwu.md2.framework.tests.dsl.workflow.functionTest

import org.eclipse.xtext.junit4.InjectWith
import de.wwu.md2.framework.MD2InjectorProvider
import org.junit.runner.RunWith
import org.eclipse.xtext.junit4.XtextRunner
import javax.inject.Inject
import org.eclipse.xtext.junit4.util.ParseHelper
import de.wwu.md2.framework.mD2.MD2Model
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.junit.Before
import static extension de.wwu.md2.framework.tests.utils.ModelProvider.*

import org.junit.Test
import org.eclipse.xtext.junit4.validation.ValidationTestHelper
import de.wwu.md2.framework.validation.ControllerValidator
import de.wwu.md2.framework.mD2.MD2Package

@InjectWith(typeof(MD2InjectorProvider))
@RunWith(typeof(XtextRunner))
class validatorTest {

@Inject extension ParseHelper<MD2Model>
@Inject extension ValidationTestHelper
MD2Model workflowModel;
MD2Model controllerModel;
MD2Model viewModel;
MD2Model modelModel;
ResourceSet rs;

@Before
def void setUp() {
rs = new ResourceSetImpl();
workflowModel = WORKFLOW_VALIDATOR_W.load.parse(rs);
controllerModel = WORKFLOW_VALIDATOR_C.load.parse(rs);
viewModel = WORKFLOW_VALIDATOR_V.load.parse(rs);
modelModel = WORKFLOW_VALIDATOR_M.load.parse(rs);
}

@Test
def checkIfSpecifiedEventsAreFiredInControllerTest(){
workflowModel.assertNoErrors();
workflowModel.assertWarning(MD2Package::eINSTANCE.workflowEvent,ControllerValidator::FIREEVENT)
}

@Test
def checkEventExistsInCorrectWorkflowElementTest(){
controllerModel.assertError(MD2Package::eINSTANCE.fireEventAction,ControllerValidator::EVENTREFERENCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ public class ModelProvider {

public static String VALIDATOR_MODEL_M = "dsl/model/validator/Model.md2";


//***Workflow***//

public static String WORKFLOW_FUNCTION_W = "dsl/workflow/functionTest/workflow.md2";
public static String WORKFLOW_FUNCTION_C = "dsl/workflow/functionTest/controller.md2";
public static String WORKFLOW_FUNCTION_V = "dsl/workflow/functionTest/view.md2";
public static String WORKFLOW_FUNCTION_M = "dsl/workflow/functionTest/model.md2";

public static String WORKFLOW_VALIDATOR_W = "dsl/workflow/validator/workflow.md2";
public static String WORKFLOW_VALIDATOR_C = "dsl/workflow/validator/controller.md2";
public static String WORKFLOW_VALIDATOR_V = "dsl/workflow/validator/view.md2";
public static String WORKFLOW_VALIDATOR_M = "dsl/workflow/validator/model.md2";
//***Controller***//

public static final String BASIC_CONTROLLER_M = "dsl/controller/Model.md2";
Expand Down
Loading

0 comments on commit 057bd85

Please sign in to comment.