edu.sampleu.krms.impl
Class ContainsOperator

java.lang.Object
  extended by edu.sampleu.krms.impl.ContainsOperator
All Implemented Interfaces:
CustomOperator, FunctionTypeService

public class ContainsOperator
extends Object
implements CustomOperator, FunctionTypeService

An example CustomOperator to demonstrate this functionality in of the KRMS UI and engine.

This one also does the FunctionTypeService duties to produce the engine executable, though that responsibility could be extracted to a separate class if desired, though that would require more wiring and database configuration.

This implementation cheats a bit for easy configuration by persisting the FunctionDefinition on first access. The only prerequisite configuration to use it: 1) add a KRMS type with namespace "KR-SAP", name "contains operator", and the serviceName "sampleAppContainsOperatorService". 2) add a type relation of type 'A' (usage allowed) from your KRMS type to the context type you want to use it with.

This service implementation is wired up in Spring and exported to the service bus.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Constructor Summary
ContainsOperator()
           
 
Method Summary
 FunctionDefinition getOperatorFunctionDefinition()
          Returns the FunctionDefinition for the custom function the executable portion of this CustomOperator will call.
 Function loadFunction(FunctionDefinition functionDefinition)
          Loads the Function object that the KRMS engine can execute during rule evaluation
 List<RemotableAttributeError> validateOperandClasses(String lhsClassName, String rhsClassName)
          Validate the argument types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainsOperator

public ContainsOperator()
Method Detail

getOperatorFunctionDefinition

public FunctionDefinition getOperatorFunctionDefinition()
Returns the FunctionDefinition for the custom function the executable portion of this CustomOperator will call.

If the FunctionDefinition hasn't been persisted yet, this method will persist it and then return it.

Note that having the KRMS type for this

Specified by:
getOperatorFunctionDefinition in interface CustomOperator
Returns:

validateOperandClasses

public List<RemotableAttributeError> validateOperandClasses(String lhsClassName,
                                                            String rhsClassName)
Validate the argument types. This operator supports (String, String), and (Collection, Object). For other classes, errors will be produced. Note that at the current time (Rice 2.3.1), the rhsClassName will always be "java.lang.String" since the UI is constrained to set the second arg as a constant value.

Specified by:
validateOperandClasses in interface CustomOperator
Parameters:
lhsClassName - the class name for the left hand side operand
rhsClassName - the class name for the right hand side operand
Returns:
errors

loadFunction

public Function loadFunction(FunctionDefinition functionDefinition)
Loads the Function object that the KRMS engine can execute during rule evaluation

Specified by:
loadFunction in interface FunctionTypeService
Parameters:
functionDefinition - FunctionDefinition to create the Function from.
Returns:


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.