To implement a condition class you must extend psdi.common.condition.CustomCondition and override evaluateCondition and toWhereClause methods. Here is a sample class.
public class IsIssueProblem implements CustomCondition
{
public boolean evaluateCondition(MboRemote mbo, Object obj)
throws MXException, RemoteException
{
if (mbo.getString("ISSUETYPE").equalsIgnoreCase("PROBLEM"))
{
return false;
}
else
{
return false;
}
}
public String toWhereClause(Object obj, MboSetRemote mbs)
throws MXException, RemoteException
{
// ensure this method is not called by throwing an Exception
throw new MXApplicationException("", "");
}
}
The provided snippet works for all Conditional Expression usages except for QUALIFIED security restrictions. In this cases you have to implement the toWhereClause method to return a valid SQL clause.
The Maximo JavaDocs for the two methods better explain how the two methods should be implemented.
evaluateCondition
Evaluate the condition.
For data restrictions having a condition (SecurityRestrict other than object Qualified), the object framework will call this method for each Mbo and set the Mbo and MboValue flags appropriately.
Parameters:
- mbo - The mbo to be evaluated
- param - Any object of parameter that is understood by the condition class. For data restrictions, this param is not used. To use it, some of the framework logic must be overridden in the Mbo.
- The result of the evaluation. For data restrictions, True means the restriction will be applied.
toWhereClause
Convert the condition to a where clause. If the condition class will be used for "QUALIFIED" object security type, this method should return a where clause. If the condition should NOT be used for "QUALIFIED", it should throw an exception to indicate it is an error when attempted to be used. This method has to be thread safe. For qualified object data restrictions (SecurityRestrict) having a condition type of Class, the object framework (MboSet) will call this method to construct the Where clause.
Parameters:
- param - For data restrictions, this is not used by the object framework. To use param you must override some of the framework logic in your MboSet.
- msr - The MboSet whose Where clause is being constructed
Returns:
- The where clause that can be used to query the database
Source:http://maximodev.blogspot.com/2012/10/custom-condition-java-class-expression.html
Tidak ada komentar:
Posting Komentar