Methods in conditions

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Methods in conditions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:35 pm

by Fargs >> Thu, 10 Jun 2004 0:41:03 GMT

Hi
I was wondering if there is anyway to use a method in a condition. Here's my problem, I have a company with a collection of people, each person can play different roles in the company, such as customer, or employee, or manager, etc. So, i have a person object that has a collection of role objects. But the company needs to find all the customers so wrote a method in the RoleByDescripDict class called includesType that returns a boolean:

includesType(class : Class) : Boolean;

Here's my condition in the person class:

isCustomer():Boolean condition;
begin
return allRoles.includesType(Customer);
end;

Or if there is some type of support for an SQL type language, that would help. Thanks for your help and suggestions.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Methods in conditions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:35 pm

by Jade Support >> Fri, 11 Jun 2004 1:20:04 GMT

This is a documented restriction when using Conditions. The following rules apply when using Conditions or Constraints, (See point 3):

- A class can define a number of conditions. Only if and return instructions can be used in condition
methods.
- A returned boolean-expression can contain only references to the properties of the class and calls to
other conditional expressions of the class or its superclasses.
- Conditions are declarative in nature rather than procedural and they have a restricted scope because
they could be executed in different places and in different contexts, so they need to be able to be
evaluated in isolation (for example, no app or global system variable may be present and no methods
can be called).
- Any parameters that you specify can be constant parameters only. You cannot reimplement a
condition inherited from a superschema or superclass. Methods can call conditions.
- The Object class sendMsg and sendMsgWithParams methods can now call conditions as well as
methods.
- Changing and recompiling a constraint may require a reorganization if the inverse has instances.

A returned boolean-expression can contain only references to the properties of the class and calls to other conditional expressions.

It looks like you might be using the Condition in the wrong context. It's designed to return a Boolean value based on a simple condtional statement, which is used in maintaing inverse references when the specified conditions are met. This Constraint is then used on the Define Reference dialog. Essentially acting as a filter, letting those objects that meet the criteria into the collection and blocking those that don't.

You should be able to use an ordinay JADE method that returns a value of type Boolean for what you're after. Or subclass the person dictionary with Manager, Employee and Customer dictionaries. Then use Constraints to populate these dictionaries. You need only to iterate the existing collection of Customers then and not every instance of Person.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 32 guests