TWiki
>
WebXEO Web
>
XeoPrimer
>
XeoPrimerBOL
(revision 3) (raw view)
Edit
Attach
Tags:
tag this topic
create new tag
,
view all tags
-- Main.PedroRio - 21 Dec 2010 ---+ Business Object Language (BOL) The Business Object Language is a small expression language to help define conditions for the behavior in XEO Object Models. It allows to reference attribute values, compare them with other values as well as making small calculations. The following sections explain the various operators and statements that can be used in the language ---+++ Attributes Object Model attributes can be referenced in BOL expressions by their name, for example if you want to build the follwing: "If the value of attribute X is bigger than 5, return true" the bol expression would be "if (x > 5) return true". This syntax works for attributes that are not Collection nor Object. When dealing with an Object attribute you can refer to the values of its attributes by using the separator '.' ; Imagine a situation where we have a XEO Model to represent a Person a Car and a Car Brand, with the following (simplified) definition. *Person* ( Person ) | *Attribute Name* | *Attribute Type* | *Label* | *Description* | *Length* | *Required* | *Object Type* | | name | Text | Name | Person Name | 30 | - | N/A | | avg_km_car_year | Number | Average Km's | Average KM's per year with a car | 30 | - | N/A | | driver_license | Text | Driver License Number | The identifier of the driver license | 30 | - | N/A | | | | | | | | | *Car* ( Car ) | *Attribute Name* | *Attribute Type* | *Label* | *Description* | *Length* | *Required* | *Object Type* | | name | Text | Name | Name of the category | 30 | true | N/A | *Brand* ( Brand ) | *Attribute Name* | *Attribute Type* | *Label* | *Description* | *Length* | *Required* | *Object Type* | | name | Text | Name | Name of the category | 30 | true | N/A | T A ---+++ Boolean Values Boolean values can in BOL expressions, the folowing expressions represent the "true" value: * true * yes * y * YES In the same way, the following values represent the "false" value: * false * no * n * NO ---+++ Conditional Statements In BOL you can use conditional expressions in the form of if/else statements. The syntax is like the following: <verbatim>if ( CONDITION ) BOL EXPRESSION else BOL EXPRESSION</verbatim> If you need more conditions you use if/else with brackets <verbatim>if (CONDITION ){ //BOL EXPRESSIONS //BOL EXPRESSIONS } else { //BOL EXPRESSIONS //BOL EXPRESSIONS } </verbatim> _ ---+++ Operators aaa ---+++ Functions BOL includes a set of pre-defined functions which can be used inside every BOL Expression. __DATE FUNCTIONS__ Functions that return a date <strong><em><br /></em></strong> NOW - Devolve a data do tipo DD-MM-AAAA (21-12-2010 a 21 de Dezembro de 2010) TODAY - Devolve de hoje só com a data (ignora o tempo) NOW_HOURS - Devolve a data de hoje com as horas, (ignora minutos e segundos) NOW_MINUTES - Devolve a data de hoje com as horas e minutos (ignora os segundos) --- <em><strong> ROUND</strong></em> ROUND(Number) - Rounds to the nearest integer (0.4 -> 0; 0.5 -> 1) --- __CONCAT (Concatenates two values)__ <em><strong><br /></strong></em> * CONCAT(String,String) * CONCAT (Number,Number) - Number can be long/int value * CONCAT (Object,Object) - Converts each Object to string and concatenates --- __TO_DATE (Converts to a Date value)__ * TO_DATE(Date, Format) * TO_DATE (Object, Format), Object is converted to a String and * TO_DATE (long, Format) O <em>Format </em>tem de ser algo que o SimpleDateFormatter do java entenda, senão não devolve resultado (nem estoira) O primeiro argumento pode ser (NOW, TODAY, NOW_MINUTES, NOW_HOURS) --- __SUM__ * SUM ( Number , Number ) * SUM (Object , Object) - Converts the Object to String --- __SUBTRACT__ * SUBTRACT (Number, Number) * SUBTRACT (Object, Object) - Converts the Object to String --- __DIFF_IN_DAYS__ * <span style="white-space: pre;">DIFF_IN_DAYS</span> (Date, Date) * <span style="white-space: pre;">DIFF_IN_DAY</span> (Date, Long) * DIFF_IN_DAY (Long, Date) * DIFF_IN_DAY (Long, Long) Pode-se ter por exemplo DIFF_IN_DAYS (NOW, TO_DATE('DATA_FORMATADA','dd/MM/yyyy')) --- DIFF_IN_UTIL_DAYS __IS_NULL (Verifica se um dado valor é null)__ Funciona para todos os tipos de attributos excepto collection. addErrorMessage - Não funciona. aaa
Edit
|
Attach
|
P
rint version
|
H
istory
:
r12
|
r5
<
r4
<
r3
<
r2
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r3 - 2010-12-22
-
PedroRio
WebXEO
XEO Primer
-
Instalation
-
Introduction
-
Concepts
-
Architecture
-
XEO Library
-
Deploy to EAR
-
PreferenceStore
XEO - Core
-
XEO Model Reference
-
Security
-
Java API
-
BOL
-
XEOQL (BOQL)
-
Administrating
-
Background Tasks
-
boConfig.xml
-
Web.xml
-
Known Issues
-
XEO Flags
XEO - XWC
- Web Components
- Java Samples
- Custom Components
- Component Plugins
- Internationalization
- Viewer Events
- Value Change Listeners
- XUIServlet
- XeoLocalization
- XvwTemplates
Create New Topic
WebXEO Web
No permission to view
TWiki.WebTopBar
No permission to view
TWiki.WebBottomBar