| |
|
| com.metaboss.sdlctools.domains.enterprisemodel.BOSelector
All known Subclasses: com.metaboss.sdlctools.domains.enterprisemodel.impl.BOSelectorImpl,
BOSelector | public interface BOSelector extends BOObject(Code) | | Selector is the definition of the sub-query available on the
entity collection. Such sub-query allows to further narrow collection
of entities obtained via association navigation. Selector is different to association.
Each association results in 'Foreign Key' type of relationship between entities.
Selector results in just an extra method on the entity collection and has
no impact on the database structure. Lets look at the example :
- Client entity is associated with Order entity via ClientPlacesOrder
association. This means that the Client will have the method :
// Returns all orders owned by the client regardless of their current state
public BOOrderCollection getOrders()
By calling this method program can obtain the collection of all orders ever given by the client
- At the same time Order entity has following selectors defined : MostRecentOrder (returning zero or one Order),
ActiveOrders (returning zero or more Orders) and CancelledOrders (again returning zero or more Orders).
In this case Order Collection will have following methods :
// Returns last placed order ot null if this collection is empty
public BOOrder selectMostRecentOrder()
// Returns collection of zero or more active orders
public BOOrderCollection selectActiveOrders()
// Returns collection of zero or more cancelled orders
public BOOrderCollection selectCancelledOrders()
By calling this methods program can select single
entity or sub-collection of entities satisfying particular criteria.
- Using both facilities above, calling program can, for example, obtain
desired orders for the client in one stroke as follows :
BOOrderCollection lActiveOrders = null;
BOOrderCollection lLastCancelledOrder = null;
// Get client's active orders
lActiveOrders = lClient.getOrders().selectActiveOrders();
// Now get most recent cancelled order
lLastCancelledOrder = lClient.getOrders().selectCancelledOrders().selectMostRecentOrder();
- This feature is even more powerful when combined with collection association methods.
To further above example, suppose Order entity is associated with Product
(many Orders can refer to one Product). In this case to get all products client is waiting on :
BOProductCollection lDesiredProducts = null;
// Get all distinct products from client's active orders
lDesiredProducts = lClient.getOrders().selectActiveOrders().getDistinctProducts();
Note that underlying implementation of collections and selectors ensures that the
actual selection and loading is deferred to database, all subqueries are combined in one
and actual query only executed when actual data is about to be used.
This ensures maximum possible speed without compromising reuse.
Selector Name must be unique within particular entity. Selector definition contains
list of input parameters. Any number of parameters of any valid datatype can be specified.
Selector definition specifies selector cardinality. This controls the patterns of how selector method is named
(i.e. whether to use singular or plural name).
At the storage interface level, the details of any number of selectors are
carried in the array of com.metaboss.enterprise.ps.STSelectorDetails[] structures
it contains 'history' of all selectors and associations invoked. Array of these structures
is passed to majority of all get methods.
|
getEntity | public BOEntity getEntity() throws BOException(Code) | | Returns entity, which owns this selector. Together with the selector name
forms the unique selector identifier
|
getJavaSelector | public String getJavaSelector() throws BOException(Code) | | Retrieves text of java implementation template of the selector
|
getName | public String getName() throws BOException(Code) | | Retrieves selector name. Consists of the prefix and suffix
This name is always present
|
getSQLSelector | public String getSQLSelector() throws BOException(Code) | | Retrieves text of SQL implementation template of the selector
|
isImplicit | public boolean isImplicit() throws BOException(Code) | | Returns boolean flag indicating if this selector is an implicit selector
|
setIsImplicit | public void setIsImplicit(boolean isImplicit) throws BOException(Code) | | Sets boolean flag indicating if this selector is an implicit selector
|
setJavaSelector | public void setJavaSelector(String pJavaSelector) throws BOException(Code) | | Sets text of java implementation template of the selector
|
setSQLSelector | public void setSQLSelector(String pSQLSelector) throws BOException(Code) | | Sets text of SQL implementation template of the selector
|
|
|
|