Within a XUI rule one can define their own condition implementation. A condition gets checked if an event occurs and will fire a set of actions if the condition is true (ECA, Event-Condition-Action).
Instead of using the built in formula engine to define a condition, you can use your own condition implementation. If you define a formula engine condition in combination with an own condition implementation, both conditions will be checked and have to return true to fire the actions.



The class need to implement the com.jaxfront.core.rule.Condition interface. If you click on the button next to the text field ( ), JAXFront will try to load the class (through the specified classpath) and check if the Condition interface is implemented. A red bullet indicates that the class can not be loaded or it does not implement the Condition interface.
com.jaxfront.core.rule.Condition

Name

Description

doesConcern(Type)

Returns true if the passed type does concern this condition. This may be important if the scope of the event definition is not just 'sourceOnly'. In this case just check if the passed type equals the source of the condition or is derrived from it.

isTrue()

Returns true if the condition is true. Check any status based on the underlying source type.

setSourceType(Type)

Sets holder of the condition.

See class com.jaxfront.demo.api.OwnCondition


This Condition just checks if the source of the defined rule holds a future date.
 

public class OwnCondition extends Object implements Condition {
    
    Type _sourceType;
    
    public boolean isTrue() throws FormulaException {
        SimpleType simpleType = (SimpleType)_sourceType;
        String dateString = simpleType.getValue();
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            Date inputDate = format.parse(dateString);
            Date currentDate = new Date();
            return inputDate.compareTo(currentDate) > 0;
        }
        catch (ParseException ex) {
            //do nothing
        }
        return false;
    }
    
    public boolean doesConcern(Type checkType) {
        return checkType == _sourceType;
    }
    
    public void setSourceType(Type sourceType) {
        _sourceType = sourceType;
    }
} 
  • Keine Stichwörter