New Posts New Posts RSS Feed: Example of TriggerTargetNavigator
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Example of TriggerTargetNavigator

 Post Reply Post Reply
Author
Customer View Drop Down
Senior Member
Senior Member
Avatar
User Submitted Questions to Support

Joined: 30-May-2007
Location: United States
Posts: 260
Post Options Post Options   Quote Customer Quote  Post ReplyReply Direct Link To This Post Topic: Example of TriggerTargetNavigator
    Posted: 03-Aug-2007 at 11:53am
Do you have an example of how the TriggerTargetNavigator is used? I'm trying to implement cross object verification but can't seem to get it to work.
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 03-Aug-2007 at 12:05pm

The TriggerTargetNavigator represents a delegate for navigating from the trigger object to the object being verified. The navigator can either be a path (PropertyDescriptor) or a custom method capable of bridging the two object types.

Here’s an example taken from the sample app accompanying the Verification Tutorial videos on the website, where the navigator is a path:

///<summary>Get the OrderDateAfterHired Verifier.</summary>
private static Verifier GetOrderDateAfterHiredVerifier() {
  string description = "OrderDate must be after the sales rep's HireDate.";
  DelegateVerifier<Order> v =
    new DelegateVerifier<Order>(description, OrderDateAfterHiredCondition);
  v.ExecutionModes = VerifierExecutionModes.InstanceAndOnPostsetTriggers;
  v.AddTrigger(EntityPropertyDescriptors.Order.OrderDate);
  v.AddTrigger(new TriggerLink(
    EntityPropertyDescriptors.Employee.HireDate, // Triggered by Employee.HireDate
    EntityPropertyDescriptors.Employee.Orders, // Path from trigger (Employee) to Order
    true)); // True = that path returns multiple orders
  return v;
} 

Here’s an example where the navigator is a custom method:

private static Verifier GetOrderDateDiscontinuedProductVerifier() {

  string description = "No orders allowed for discontinued products after 1/1/1998";
  DelegateVerifier<Order> v =
    new DelegateVerifier<Order>(description, GetOrderDateDiscontinuedProductCondition);
  v.ExecutionModes = VerifierExecutionModes.All;
  v.AddTrigger(EntityPropertyDescriptors.Order.OrderDate);
  v.AddTrigger(new TriggerLink(
    EntityPropertyDescriptors.Product.Discontinued, // Triggered by Product.Discontinued
    GetOrdersAssociatedWithProduct, // Method bridging orders and products
    true); // True = that method returns multiple orders
  return v;
}
private static EntityList<Order> GetOrdersAssociatedWithProduct(Object pProduct) {
  Product aProduct = (Product)pProduct;
  OrderDetail[] details = aProduct.GetChildren<OrderDetail>(
    EntityRelations.Product_OrderDetail,
    QueryStrategy.Normal);
  EntityList<Order> orders = aProduct.PersistenceManager.GetParents<Order>(
    details, EntityRelations.Order_OrderDetail, QueryStrategy.Normal);
  return orders;
}
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down