Difference between revisions of "Action DSL"

From OS.bee documentation
Jump to: navigation, search
(Created page with "==Introduction== ===CRUD for toolbar=== Editing data is nice but data must be persisted otherwise all effort invested in editing data would be lost. For this reason, OS.bee...")
 
(ActionDSl)
Line 35: Line 35:
 
==ActionDSl==
 
==ActionDSl==
  
The actionDSL works for Os.bee models, it defines the toolbar actions for task, select workload, dialog, report, chart, workflow, datainterchange, ect..
+
The ActionDSL works for Os.bee models, it defines the toolbar actions for task, select workload, dialog, report, chart, workflow, datainterchange, ect..
  
 
The main semantic elements of the ActionDSL are:
 
The main semantic elements of the ActionDSL are:

Revision as of 14:47, 25 July 2017

Introduction

CRUD for toolbar

Editing data is nice but data must be persisted otherwise all effort invested in editing data would be lost. For this reason, OS.bee apps come with a set of create, read, update and delete functionality (CRUD) to manipulate data in a database. OS.bee can be operated with different database products.

Create

Create or add new entries.

If you want to create new data entry, please press the “new data” action button, after the action has been executed, a new unique id must be created.

ActionDSL 01.png

Read

Read, retrieve, search or view existing entries.

Existed data can be read from the database. If you request existed data to be displayed in the UI, you must either retrieved a unique id to the database so it can select the requested data, or you can search and select one.

In Os.bee web site, for example the perspective of “Persons”, you can click one row from the table on the left, then the detail data will be read from database and shown in the dialog on the right.

ActionDSL 02.png

Update

Update or edit existing entries.

After editing your data, please press the “save” button and the data will be saved in the underlying database.

ActionDSL 03.png

Delete

Delete, deactivate or remove existing entries.

If you don’t need an existing entry, please select it and press the “delete” button, then this data will be remove from the underlying database.



ActionDSL 04.png

ActionDSl

The ActionDSL works for Os.bee models, it defines the toolbar actions for task, select workload, dialog, report, chart, workflow, datainterchange, ect..

The main semantic elements of the ActionDSL are:

  • “package” - the root element that contains all the other elements. A model can contain multiple packages.
  • “toolbar” - define the action details, e.g. toolbar name, description and items…
  • “items” – define the items for this action.
  • “item” - define the function and action type for the item …

Syntax

package defintion

Syntax:

package <package name>[{
toolbar <toolbar name> [described by <description>]
		[items { . . .}]
. . .
} ]

For each toolbar, one .java file named <toolbar name>+Action.java will be generated in folder ./src-gen/<package name>/.

  • One or more toolbars can be defined in the same package.
  • Keyword descrbied by is optional; you can use this keyword to define the description of this toolbar
  • One or more item can be defined in the same items block.

Example:

package net.osbee.sample.foodmart.actions {
	toolbar StartTask described by "Toolbar for tables showing tasks" 
items { . . . }
	toolbar Dialog described by "Toolbar for Dialogs" items { . . . }
	toolbar HandleTask described by "Toolbar for BPM oriented perspectives" 
items { . . . }
toolbar Report described by "Toolbar for reports" items { . . . }
toolbar WorkloadSelect described by "Toolbar for Workload Selects" 
items { . . . }
}

In this example, 5 toolbars are defined in the same package; they are StartTask, Dialog, HandleTask, Report and WorkloadSelect.

Items&item

This is the main part of this model. All the action details can be defined here. For each item, a java file named <toolbar name>+<action rule>+Action.java will be generated in folder ./src-gen/<package name>/. <action rule> is defined in ActionType and it will be introduced in the next section.

Syntax:

items { 
item <item name> [described by <description>]
		[icon <URI string>]
		[group <func.FunctionLibraryGroup name>	
  [canExecute <func.FunctionLibraryFunction name>]
& [executeParameter <func.FunctionLibraryFunction name>]
]
		ActionType
		[message <msg.MessageItem name |QualifiedName>]
. . .
}]
. . .
} ]
  • Keyword icon is optional, it define the identifier for a resource, e.g. icon file
  • Keyword group, canExecute & executeParameter are used to define the predefined function which this item could use from FunctionlibraryDSL.

Example:

toolbar HandleTask described by "Toolbar for BPM oriented perspectives" items {
   item stop icon "task_action_stop" group PerspectiveToolbar
     canExecute stopCanExecute executeParameter getTaskId taskAction Stop
   . . .
}

In this example, the following code will be generated in the java file of item stop:

@CanExecute
public boolean canExecute() {
return net.osbee.sample.foodmart.functionlibraries.PerspectiveToolbar
.stopCanExecute(getContent());
}

@Execute
public void execute(final IEventBroker eventBroker) {
    log.debug("action execute called for stop");
    String uuid = (String)eclipseContext.get("HandleTask_TOOLBAR_ID");
eventBroker.send(
EventBrokerMsg.ACTION_BUTTON_EXECUTE_PREFIX+ "HandleTaskAction"+uuid, 
new EventBrokerMsg(-1, 
"Stop", 
net.osbee.sample.foodmart.functionlibraries
.PerspectiveToolbar.getTaskId(getContent())
)
);
}
  • Keyword message is used to define the action message using predefined message from messageDSL.

Example:

toolbar Dialog described by "Toolbar for Dialogs" items { 
	item newItem icon "dsnew" dialogAction New
item saveItem icon "dssave" dialogAction Save message  net.osbee.sample.foodmart.messages.FoodMartErrors.DtoService.SaveMsg
item deleteItem icon "dsdelete" dialogAction Delete message net.osbee.sample.foodmart.messages.FoodMartErrors.DtoService.DeleteMsg
	item cancelItem icon "dscancel" dialogAction Cancel
}

The message SavMsg and DeleteMsg are defined in messageDSL as following:

package net.osbee.sample.foodmart.messages{
	category FoodMartErrors {
		group DtoService { 
			message DeleteMsg{ 
				parameter{
					Exception ex
					String stackTrace
				}
				automatic{}
				format {
					log "%%ex.simpleName%%: Delete not allowed! – 
%%stackTrace%%"
					show "%%ex.simpleName%% - %%ex.localizedMessage%% 
- Delete not allowed!"
				}
			}
			message SaveMsg{
				parameter{
					Exception ex
					String stackTrace
				}
				automatic{}
				format {
					log "%%ex.simpleName%%: Save not allowed! – 
%%stackTrace%%"
					show "%%ex.simpleName%% - %%ex.localizedMessage%% 
- Delete not allowed!"
				}
			}
		}
	}
}

The dialog Employee uses this toolbar Dialog in dialogDSL as following:

package net.osbee.sample.foodmart.dialogs {
	dialog Employee described by "Employee data" autobinding MemployeeDto toolbar Dialog
	. . .
}

There will be no code generated in the related toolbar java files. But in the EmployeeDialog.java, where this toolbar will be used, the following code generated for the message:

public void showSaveErrorMessage(final Exception ex) {
    org.eclipse.osbp.xtext.messagedsl.common.Message errorMsg = net.osbee.sample.foodmart.messages.FoodMartErrorsMessage.DtoService_SaveMsg(ex, ex.getMessage());
    Notification.show(errorMsg.getShowMessage());
    log.error(errorMsg.getLogMessage());
  }
  
  public void showDeleteErrorMessage(final Exception ex) {
    org.eclipse.osbp.xtext.messagedsl.common.Message errorMsg = net.osbee.sample.foodmart.messages.FoodMartErrorsMessage.DtoService_DeleteMsg(ex, ex.getMessage());
    Notification.show(errorMsg.getShowMessage());
    log.error(errorMsg.getLogMessage());
  }
  • ActionType will be introduced in the next section.

ActionType

ActionType sets the type of action for the item.

There are 8 kinds of action types:

taskAction

taskAction is used to define the action of task for bpm.

Syntax:

taskAction <taskAction rule>
  • taskAction rule includes 15 rules, and its <action rule> is the same as the following rule:
Claim, Start, Stop, Release, Suspend, Resume, Skip, Complete, Delegate, Forward, Fail, Register, Remove, Activate, Exit

Example:

toolbar StartTask described by "Toolbar for tables showing tasks" items {
	item claim icon "task_action_claim" group TaskToolbar 
 canExecute claimCanExecute executeParameter getTaskId taskAction Claim
	item start icon "task_action_start" group TaskToolbar 
 canExecute startCanExecute executeParameter getTaskId taskAction Start
	item start icon "task_action_resume" group TaskToolbar 
 canExecute resumeCanExecute executeParameter getTaskId taskAction Resume
}
selectWorkloadAction

selectWorkloadAction is used to define the action of select workload.

Syntax:

selectWorkloadAction <selectWorkloadAction rule>
  • selectWorkloadAction rule includes the 2 rules, and its <action rule> is as same as the following rule: RemoveAll, AddAll.

Example:

toolbar WorkloadSelect described by "Toolbar for Workload Selects" items {
item removeAllWorkloadItems icon "task_status_obsolete" selectWorkloadAction  RemoveAll
item addAllSelectedItemsToTheWorkload icon "import"            selectWorkloadAction AddAll
}
dialogAction

DialogAction is used to define the actions for dialog.

Syntax:

dialogAction <dialogAction rule>
  • dialogAction rule includes the 4 rules, and its <action rule> is as same as the following rule: New, Save, Delete, Cancel

Example:

toolbar Dialog described by "Toolbar for Dialogs" items { 
	item newItem icon "dsnew" dialogAction New
item saveItem icon "dssave" dialogAction Save message  net.osbee.sample.foodmart.messages.FoodMartErrors.DtoService.SaveMsg
item deleteItem icon "dsdelete" dialogAction Delete message net.osbee.sample.foodmart.messages.FoodMartErrors.DtoService.DeleteMsg
	item cancelItem icon "dscancel" dialogAction Cancel
}
  • “new” means create a new entry.
  • “save” means save the changing.
  • “delete” means delete the selected entry.
  • “cancel” means ignore the changing.

Here is the dialog view in perspective, in which the 4 buttons do the actions by clicking them:

ActionDSL 05.png

reportAction

ReportAction is used to define the actions for report.

Syntax:

reportAction <reportAction rule>
  • reportAction rule includes the 2 rules: PrintOnServer, Download.
  • Its <action rule> is PrintOnServer and ReportDownload.

Example:

toolbar Report described by "Toolbar for reports" items {
	item print icon "print" reportAction Download
	item print icon "xml" reportAction PrintOnServer
}
chartAction

chartAction is used to define the actions for chart.

Syntax:

chartAction Download
  • Its <action rule> is ChartDownload.
workflowAction

workflowAction is used to define the actions for workflow.

Syntax:

workflowAction Start
  • Its <action rule> is start.
genericAction

genericAction is used to define the actions for yourself. You can define it as you will.

Syntax:

genericAction <STRING>
  • Its <action rule> is the string.
datainterchangeAction

datainterchangeAction is used to define the actions for data interchange

Syntax:

datainterchangeAction <datainterchangeAction rule> <data.DataInterchange name>
  • datainterchangeAction type includes the following types, and its <action rule> is as same as the following rule: Import, Export.
  • The data interchange should be predefined in datainterchangeDSL.

The following code will be generated in the java file of item:

@Execute
  public void execute(final IEventBroker eventBroker) {
    <datainterchange qualified name> <datainerchange name> = new <datainterchange qualified name>();
    <datainerchange name>.setFileURL(<file path URL String>
    <datainerchange name>.setPersistenceService(persistenceService);
    <datainerchange name>.setDirection(WorkerThreadRunnable.Direction.IMPORT);
    <datainerchange name>.setEventBroker(eventBroker);
    <datainerchange name>.setEventDispatcher(eventDispatcher);
    executorService.execute(<datainerchange name>);
  }

Copyright Notice

All rights are reserved by Compex Systemhaus GmbH. In particular, duplications, translations, microfilming, saving and processing in electronic systems are protected by copyright. Use of this manual is only authorized with the permission of Compex Systemhaus GmbH. Infringements of the law shall be punished in accordance with civil and penal laws. We have taken utmost care in putting together texts and images. Nevertheless, the possibility of errors cannot be completely ruled out. The Figures and information in this manual are only given as approximations unless expressly indicated as binding. Amendments to the manual due to amendments to the standard software remain reserved. Please note that the latest amendments to the manual can be accessed through our helpdesk at any time. The contractually agreed regulations of the licensing and maintenance of the standard software shall apply with regard to liability for any errors in the documentation. Guarantees, particularly guarantees of quality or durability can only be assumed for the manual insofar as its quality or durability are expressly stipulated as guaranteed. If you would like to make a suggestion, the Compex Team would be very pleased to hear from you.

(c) 2019 Compex Systemhaus GmbH