TWiki> WebXEO Web>XeoPrimer>XeoPrimerBOL (revision 3)EditAttach
Tags:
create new tag
, view all tags
-- 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:

if ( CONDITION )
   BOL EXPRESSION
else
   BOL EXPRESSION

If you need more conditions you use if/else with brackets

if (CONDITION ){
//BOL EXPRESSIONS
//BOL EXPRESSIONS
} else {
  //BOL EXPRESSIONS
  //BOL EXPRESSIONS 
}

_

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

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)


ROUND

ROUND(Number) - Rounds to the nearest integer (0.4 -> 0; 0.5 -> 1)


CONCAT (Concatenates two values)


  • 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 Format 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

  • DIFF_IN_DAYS (Date, Date)
  • DIFF_IN_DAY (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 | Print version | History: r12 | r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r3 - 2010-12-22 - PedroRio
 

No permission to view TWiki.WebTopBar

This site is powered by the TWiki collaboration platform Powered by Perl

No permission to view TWiki.WebBottomBar