Versions Compared
Version | Old Version 7 | New Version 8 |
---|---|---|
Changes made by | Former user |
Former user |
Saved on |
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Selector Built-in Functions
These functions are available via the object's namespace, e.g. Person:{function}
.
They can be used to read sets of data from the persistence layer. The final four in the table below (union
, diff
, intersect
, and and
) can be used to build up a complex selector using a combination of other selector BIFs as parameters. The other selectors all take an object's attribute as first parameter, and one or more values as the next parameter(s).
Function | Syntax | Description | Example | ||||
---|---|---|---|---|---|---|---|
all | Obj:all() | returns Returns all records from the table. | Person[] plist = Person:all(); | ||||
equals | Obj:equals(a,b) | returns Returns records with value of obj. | Person[] plist = Person:equals(deleted, false); | ||||
notEquals | Obj:notEquals(a,b) | returns Returns records with value of obj. a not equal to b . | Person[] plist = Person:notEquals(deleted, true); | ||||
empty | Obj:empty(a) | returns Returns records with obj.a a equal to null . | Person[] plist = Person:empty(mobileNum); | ||||
notEmpty | Obj:notEmpty(a) | Returns records with a not equal to null . | Person[] plist = Person:emptynotEmpty(mobileNum); | ||||
between | Obj:between(a,x,y) | returns Returns records with value of obj.a of a within the range of values between x and y . | Person[] plist = Person:between(dob, date1, date2); | ||||
notBetween | Obj:notBetween(a,x,y) | Returns records with value of a not within the range of values between x and y . | Person[] plist = Person:betweennotBetween(dob, date1, date2); | ||||
lessThanOrEqual | Obj:lessThanOrEqual(a,b) | returns Returns records with value of obj. a less than or equal to b . | Person[] plist = Person:lessThanOrEqual(age, num); | ||||
lessThan | Obj:lessThan(a,b) | returns Returns records with value of obj. a less than b . | Person[] plist = Person:lessThan(age, num); | ||||
greaterThan | Obj:greaterThan(a,b) | Check if value is greater than the value being compared toReturns records with value of a greater than b . | Person[] plist = Person:greaterThan(age, num); | ||||
attributeIn | Obj:attributeIn(a,"x,y,z") | Attribute InReturns records with value of a matching any of the values x ,y ,z (replace x ,y ,z with any number of values). | Person[] plist = Person:attributeIn(state, "Any, One, Of, These"); | ||||
notAttributeIn | Obj: relationshipInnotAttributeIn(a, b) | Relationship In"x,y,z") | Returns records with value of a not matching any of the values x ,y ,z (replace x ,y ,z with any number of values). | Person[] plist = Person:relationshipIn(reportsTo, personnotAttributeIn(state, "Any, One, Of, These"); | |||
contains relationshipIn | Obj: containsrelationshipIn(a,b) | Check is collection has element(s)Returns records with a relationship/link between a and b , with attribute a being annotated as @OneToMany , @ManyToOne , etc. and b a persistent object instance. Attribute a can be likened to a foreign key. | Person[] plist = Person:containsrelationshipIn(namereportsTo, "a"person); | beginsWith | |||
notRelationshipIn | Obj:notRelationshipIn(a,b) | Returns records without a relationship/link between a and b , with attribute a being annotated as @OneToMany , @ManyToOne , etc. and b a persistent object instance. Attribute a can be likened to a foreign key. | Person[] plist = Person:beginsWithnotRelationshipIn(namereportsTo, "a"person); | ||||
endsWith | End withcontains | Obj:contains(a,b) | Returns records with substring b found anywhere within value of a . | Person[] plist = Person:endsWithcontains(name, "a"); | notEmpty | ||
Not emptybeginsWith | Obj:beginsWith(a,b) | Returns records with substring b found at the beginning of the value of a . | Person[] plist = Person:notEmpty(mobileNumbeginsWith(name, "a"); | ||||
notBetween | Not between the data or elementsendsWith | Obj:endsWith(a,b) | Returns records with substring b found at the end of the value of a . | Person[] plist = Person:notBetweenendsWith(dob, date1, date2name, "a"); | |||
notContains | Collection does not contain element(s) | Obj:notContains(a,b) | Returns records with substring b found nowhere within value of a . | Person[] plist = Person:notContains(name, "a"); | |||
notBeginWith | Not begin with | Obj:notBeginWith(a,) | Returns records with substring b not found at the beginning of the value of a . | Person[] plist = Person:notBeginWith(name, "a"); | |||
notEndsWith | Check if value does not end with value being compared to | Obj:notEndsWith(a,b) | Returns records with substring b not found at the end of the value of a . | Person[] plist = Person:notEndsWith(name, "a"); | |||
notAttributeIn | Attribute not in the given domain | Person[] plist = Person:notAttributeIn(state, "Any, One, Of, These"); | |||||
notRelationshipIn | Use to check for relationship | Person[] plist = Person:notRelationshipIn(reportsTo, person); | |||||
union | Union | union | Obj:union(selector1(a,b), selector2(x,y)) | Combines the results of two or more selectors. Does not return the same record twice. | Person[] plist = Person:union(equals(rating, "good"), equals(rating, "excellent")); | ||
diff | Use to check for differences | Obj:diff(selector1(a,b), selector2(x,y)) | Compares the results of two or more selectors and returns only the difference. | Person[] plist = Person:diff(equals(), equals()); | |||
intersect | Intersect | Obj:intersect(selector1(a,b), selector2(x,y)) | Returns records for which all the selectors are true. | Person[] plist = Person:intersect(equals(deleted, false), equals(active, true)); | |||
and | And (in most cases, use this rather than intersect) | Obj:and(selector1(a,b), selector2(x,y)) | Returns records for which all the selectors are true. | Person[] plist = Person:and(equals(deleted, false), equals(active, true)); |
Data Subsets
Having populated a collection with a selector BIF, you can further refine your selection by assigning a subset of said collection to a new collection by using the select
BIF. This BIF is available via the collection variable and takes one or a combination of the above selector BIFs as parameter. See the Collections for details.
Excerpt | ||
---|---|---|
| ||
all, equals, notEquals, etc. | select |