Package com.orchestranetworks.schema
Interface ValueFunction
public interface ValueFunction
Computes a value when this value is not persisted by EBX® repository.
Examples of uses
- to retrieve data persisted in a third-party database;
- to compute a value (the computation may depend on other values in the same dataset or record).
Definition in the data model
The specific function must be declared under the element
xs:annotation/xs:appinfo
(see Computed Values):
where<osd:function class="com.foo.MyFunction"/>
com.foo.MyFunction is the fully qualified name of the class implementing
this interface. It is also possible to set additional JavaBean properties:
<osd:function class="com.foo.MyFunction">
<param1>...</param1>
<param2>...</param2>
</osd:function>
where param1 and param2 are JavaBean properties of the class specified.
For more information, see the JavaBean specification.
Life cycle
- When the data model is loaded:
- the class specified is instantiated through its default constructor and the setters of the JavaBean properties
are called (in the example above,
setParam1(...)andsetParam2(...)); - the method
setup(ValueFunctionContext)is called on the new instance.
- the class specified is instantiated through its default constructor and the setters of the JavaBean properties
are called (in the example above,
- During the operational phase: the method
getValue(Adaptation)is called each time this is needed (for example when the record is displayed or exported).
Performance warning
See getValue(Adaptation).
-
Method Summary
Modifier and TypeMethodDescriptiongetValue(Adaptation aDataSetOrRecord) Returns the value in the context of the specified record or dataset.voidsetup(ValueFunctionContext aContext) This method is called when the data model is loaded, for checking that this function is consistent with the data model that defines it.
-
Method Details
-
getValue
Returns the value in the context of the specified record or dataset.The value returned must conform to the associated data model declaration (that is, the type, cardinality, facets).
Performance warning
If the function is attached to a table with N records, some operations will call this method N times. This is the case for:
- an external export (but the method
ExportSpec.setIncludesComputedValues(boolean)will deactivate the call to the function); - a filter, when the filter depends on this node;
- full dataset validation, when the node is used by some dynamic constraints.
It is however possible to avoid this call if the
validation is disabled on the associated node by specifying in the data model
the attribute
osd:disableValidation = "true".
Thus, for a table with large volumes of records, it may be necessary to optimize the implementation (for example, by caching). See also performance guidelines chapter.
Multi-threading
For a single instance of this interface, this method may be called concurrently by several threads.
- See Also:
- an external export (but the method
-
setup
This method is called when the data model is loaded, for checking that this function is consistent with the data model that defines it.
-