instruction
stringlengths 5
72
| input
stringclasses 1
value | output
stringlengths 22
8.46k
|
---|---|---|
How to Add a Custom Menu and Custom Processing | 15.2.2How to Add a Custom Menu and Custom Processing
The report provides a convenient GUI to manipulate a vast number of objects at one time. The window
can be extended by adding a menu with custom functionality to, for example, allow “manipulation”
rather than simply viewing of data.
Continuing with the Custom Object report example, this would be achieved by creating a class named
apps.reporting.CustomObjectReportWindowHandler that extends
com.calypso.apps.reporting.ReportWindowHandlerAdapter. These methods can be implemented:
• public void customizeReportWindow(ReportWindow reportWindow)
This is where the customization of the report can be done.
• public boolean callBeforeClose(ReportWindowDefinition definition)
This method returns true or false, true to authorize the report to be closed, or false to prevent
the report to be closed if additional processing must be done like publishing quotes, etc.
• public void customizeMenuBar(JMenuBar menuBar, RiskPresenterWorker worker)
This method provides the ability to customize the menu bar within the context of the given
RiskPresenterWorker.
• public void customizePopupMenu(JPopupMenu popup, RiskPresenterWorker worker)
This method provides the ability to customize the popup menu within the context of the given
RiskPresenterWorker.
• public void callAfterLoadAll(ReportWindow reportWindow)
Called at the end of ReportWindow.loadAll(), i.e., after the load process has been started for
each report in each tab.
• public boolean isValidLoad(ReportPanel panel)
Returns a true if the load was successful.
|
|
How to Create a Custom Aggregation Function | 15.2.3How to Create a Custom Aggregation Function
Create a class named tk.report.function.<function_name> that implements
com.calypso.tk.report.function.ReportFunction.
It will be invoked from com.calypso.tk.report.function.FunctionFactory.
Then add the function name to the “REPORT.Functions” domain. Out-of-the-box, Calypso provides the
following aggregation functions: Count, Sum, Average, Maximum, and Minimum.
|
|
How to Create a Custom Sorting Comparator | 15.2.4How to Create a Custom Sorting Comparator
Create a class named tk.report.<comparator_name>Comparator that implements
com.calypso.tk.report.RowComparator.
It will be invoked from com.calypso.tk.report.DefaultReportOutput.
|
|
How to Validate a Custom Report Filter | 15.2.5How to Validate a Custom Report Filter
Create a class named apps.reporting.<report_name>CustomReportFilter that implements the
interface com.calypso.apps.reporting.CustomReportFilter.
This is currently supported by the following reports: Audit, CRE, Message, Payment, Posting, Task
Station and Trade.
It is also supported by the report framework through com.calypso.apps.reporting.ReportPanel.
|
|
How to Customize the Transfer Report | 15.3 How to Customize the Transfer Report
After partitioning Trade and Inv_Sec tables, when querying with multiple ISIN codes in Transfer report,
you can provide custom SQL hint when loading the trades.
You can create a custom class named tk.report.trade.CustomSQLHintTradeLoader that implements
com.calypso.tk.report.trade.SQLHintTradeLoader to manage custom SQL Hint.
An example is provided in calypsox.tk.report.trade.CustomSQLHintTradeLoader.
|
|
How to Customize the Transfer Viewer | 15.4 How to Customize the Transfer Viewer
The Transfer Viewer is a utility that is only available if the environment property
USE_TRANSFER_VIEWER is true. When you right-click a transfer, choose Show > Transfer Viewer from
the popup menu to display all elements associated with the transfer.
The Transfer Viewer can be customized as follows:
− Adding panels.
− Displaying more data in the Main panel.
Create a class named apps.reporting.CustomTransferViewerWindow that implements
com.calypso.apps.reporting.TransferViewerInterface.
You can implement the following methods:
• getTransferMainPanel() — For customizing of the main panel.
• getTransferTabPanels() — For adding a panel.
• showTransfer() — For displaying additional transfer data.
|
|
How to Customize the Quick Search Window | 15.5 How to Customize the Quick Search Window
You can customize the search criteria, the searched objects, and the display of the objects.
Create a class named apps.reporting.<name>Interface that implements
com.calypso.apps.reporting.QuickSearchInterface.
|
|
Trade Bulk Entry API | 15.6 Trade Bulk Entry API
Knowledge of the Calypso Report API is necessary to utilize this API. Please refer to Report,
ReportStyle, ReportTemplate, ReportTemplatePanel, and ReportWindowHandler in this guide.
The viewable fields in the TradeBrowser are also available as fields in BulkEntryReport.
BulkEntryReport extends TradeReport. But instead of loading trades from database,
BulkEntryReport.load() loads trades from CSV file — a BulkEntryReportTemplate property.
BulkEntryReportStyle extends TradeReportStyle. The display is the same as that of the TradeBrowser,
using TradeReportStyle.getColumnValue() — an embedded ProductReportStyle.getColumnValue().
BulkEntryReportStyle.getPossibleColumnNames() overrides and restricts
TradeReportStyle.getPossibleColumnNames() to the editable columns provided by
<productType>BulkEntryItem.getPossibleColumnNames().
Adding Support for Additional Product Types
1. If it does not exist, add tk.report.<productType>ReportStyle.
2. Add tk.util.bulkentry.<productType>BulkEntryItem that extends TradeBulkEntryItem
and overrides:
− List<String> getPossibleColumnNames(): The editable column names (a subset of
TradeReportStyle.getPossibleColumnNames()).
The order of the returned column names is not relevant. In a CVS import, Trade/Product
fields are set in sequence following this order.
− SortedSet<String> getColumnChoices(String column): Use to restrict field values to a list of
choices. Also used for data validation.
− void setValue(Trade trade, String column, String value): Sets a Trade/Product attribute.
|
|
How to Enable Generic Comments for an Object | 15.7 How to Enable Generic Comments for an Object
To enable generic comments for an object, create a class named
tk.bo.sql.DefaultCommentableObjectSQL that implements tk.bo.sql.CommentableObjectSQL.
It will be invoked from the BackOffice RMI server.
This interface must implement the following methods:
public ObjectDescription getCommentableObject(int objectId, String objectClass,
Connection dbCon) throws PersistenceException;
objectClass: “Trade”, “Transfer”, “Message”, “Posting”, “YourObjectClass”, etc.
public GenericComment[ ] getObjectComments(ObjectDescription objectDesc, Int showType,
String whereClause, Connection dbCon) throws PersistenceException;
showType: GenericComment.SHOW_ALL, GenericComment.SHOW_PARENTS,
GenericComments.SHOW_CHILDREN, GenericComment.SHOW_ALL, GenericComment.SHOW_NONE
(no "Show" directive)
|
|
How to Limit the Number of Accounts Loaded in the Account Report | 15.8 How to Limit the Number of Accounts Loaded in the Account Report
When a user brings up an external account selector in the Account report, the system checks if there is
a custom class named tk.report.CustomReportPreviewMode that limits the number of accounts to be
loaded. The custom class needs to implement
com.calypso.tk.report.ReportPreviewModeInterface.
|
|
Risk Analysis | Section 16. Risk Analysis
16.1 Analysis
How Analyses are used
16.1.1How to Create a Custom Analysis
To add your own analysis, create a subclass of Analysis, for example XAnalysis (see illustration below),
that implements the run() method, and creates an AnalysisOutput class, XAnalysisOutput, that will
format the results of your analysis class.
To display your results, Calypso provides a standard viewer, DefaultAnalysisViewer, which can display
any report that is a spreadsheet-style table of values. If you wish to create a different type of display,
then you can create a class that implements the AnalysisViewer interface. Whatever viewer you choose,
you must register it in the Analysis Viewer Config window
Standard analysis parameters are specified in AnalysisParamStd. You may must subclass
AnalysisParamStd to add custom parameters, and create a custom parameters viewer that implements
AnalysisParamViewer for editing these parameters.
The following class diagram shows you the classes involved in creating a custom analysis.
Overview of Steps
• Step 1 — Create analysis parameters if applicable
• Step 2 — Create an analysis parameters viewer if applicable
• Step 3 — Create an AnalysisOutput
• Step 4 — Create an Analysis
• Step 5 — Register the new Analysis
Step 1 — Create Analysis Parameters.
This step is only necessary if your analysis requires custom parameters. Do the following for creating
the analysis parameters:
1. Create a class named tk.risk.<analysis_name>Param which extends
com.calypso.tk.risk.AnalysisParamStd.
This class will be invoked from your Analysis class.
2. To make the analysis parameters persistent, create a class named
tk.risk.sql.<analysis_name>Param which extends
com.calypso.tk.risk.sql.AnalysisParamStdSQL.
3. Register individual parameters using Configuration > System > Analysis Parameter Name
from the Calypso Navigator.
Sample Code in calypsox/tk/risk/
AnalysisParamStd samples:
DEMOParam.java
The DEMO analysis requires a frequency to generate time buckets and a number of threads for
multi-threading.
Step 2 — Create an Analysis Parameters Viewer.
This step is only necessary if your analysis requires custom parameters to be edited by the user.
Create a class named apps.risk.<analysis_name>ParamViewer which implements the interface
com.calypso.apps.risk.AnalysisParamViewer.
This class will be invoked from your Analysis Parameters class.
Step 3 — Create an AnalysisOutput.
Create a class named tk.risk.<analysis_name>Output that extends
com.calypso.tk.risk.AnalysisOutput.
Implement the following members and methods:
• A member to store the report. You can model the report as a Vector of TradeItem objects
(each TradeItem object represents a row in the report). Note that you can subclass TradeItem
as applicable.
• A method for building the report, for example addItem() to add rows to the report.
• Methods that will allow the AnalysisViewer to display, print, save, export, aggregate the report.
For example, when using the DefaultAnalysisViewer you will implement the following
methods:
− getNumberOfRows() to return the number of rows in the report
− getNumberOfColumns() to return the number of columns in the report
− getHeaderAt(int col) to return the heading text for a given column
− getColumnClassAt(int col) to return the datatype of the data for a given column
− getValueAt(int row, int col) to return the value for a given cell
− getAggregationSource() to return the aggregation criteria This class will be invoked from
your Analysis class.
Step 4 — Register the new Analysis.
Do the following to register a new analysis:
1. Add the analysis name to the riskAnalysis domain using the Add Risk Analysis Type window
as shown below. This window is accessed from the Risk Analysis window when you click the ...
button next to the Analysis Type field.
Save and click “Update Domains” in the Risk Analysis window.
2. Associate the Analysis with an AnalysisViewer using Configuration > System > Analysis
Viewer Configuration from the Calypso Navigator.
You can use the DefaultAnalysisViewer or create a custom AnalysisViewer as described in the following
section.
16.1.2How to Create a Custom AnalysisViewer
The default AnalysisViewer is com.calypso.apps.risk.DefaultAnalysisViewer.
Create a class named apps.risk.<viewer_class_name> which implements the interface
com.calypso.tk.risk.AnalysisViewer.
This class will be invoked from com.calypso.tk.risk.AnalysisViewerConfig.
You can associate the AnalysisViewer with a given Analysis using Configuration > System > Analysis
Viewer Configuration from the Calypso Navigator.
16.1.3How to Create a Custom Aggregation for an AnalysisViewer
Create a class named tk.util.CustomAggregation that implements the interface
com.calypso.tk.util.AggregationInterface.
This class will be invoked from com.calypso.tk.util.Aggregation.
16.1.4How to Create a Custom AnalysisHandler
Create a class named tk.risk.<analysis_name>Handler or tk.risk.DefaultAnalysisHandler that
implements com.calypso.tk.risk.AnalysisHandler.
This class will be invoked from com.calypso.tk.risk.AnalysisUtil for exporting AnalysisOutput
data to the AnalysisViewer.
16.1.5How to Create a Custom Analysis Input Verifier
Analysis performs calculations over an AnalysisInput that contains the trades, the PricingEnv, etc. You
can create a custom verifier of the input data.
Create a class named tk.risk.<analysis_name>Verifier or tk.risk.CustomAnalysisVerifier that
implements com.calypso.tk.risk.AnalysisVerifier.
This class will be invoked from com.calypso.tk.risk.AnalysisInput.
16.1.6How to Create Custom Template Keywords
Create a class named tk.risk.<analysis_name>RiskFormatter that implements
com.calypso.tk.risk.RiskFormatter.
Analysis names are available in the “riskAnalysis” domain. Implement a parse<keyword_name>()
method for each custom keyword.
This class will be invoked from com.calypso.tk.risk.AnalysisUtil.
|
|
How to Create a Custom Analysis | 16.1.1How to Create a Custom Analysis
To add your own analysis, create a subclass of Analysis, for example XAnalysis (see illustration below),
that implements the run() method, and creates an AnalysisOutput class, XAnalysisOutput, that will
format the results of your analysis class.
To display your results, Calypso provides a standard viewer, DefaultAnalysisViewer, which can display
any report that is a spreadsheet-style table of values. If you wish to create a different type of display,
then you can create a class that implements the AnalysisViewer interface. Whatever viewer you choose,
you must register it in the Analysis Viewer Config window
Standard analysis parameters are specified in AnalysisParamStd. You may must subclass
AnalysisParamStd to add custom parameters, and create a custom parameters viewer that implements
AnalysisParamViewer for editing these parameters.
The following class diagram shows you the classes involved in creating a custom analysis.
Overview of Steps
• Step 1 — Create analysis parameters if applicable
• Step 2 — Create an analysis parameters viewer if applicable
• Step 3 — Create an AnalysisOutput
• Step 4 — Create an Analysis
• Step 5 — Register the new Analysis
Step 1 — Create Analysis Parameters.
This step is only necessary if your analysis requires custom parameters. Do the following for creating
the analysis parameters:
1. Create a class named tk.risk.<analysis_name>Param which extends
com.calypso.tk.risk.AnalysisParamStd.
This class will be invoked from your Analysis class.
2. To make the analysis parameters persistent, create a class named
tk.risk.sql.<analysis_name>Param which extends
com.calypso.tk.risk.sql.AnalysisParamStdSQL.
3. Register individual parameters using Configuration > System > Analysis Parameter Name
from the Calypso Navigator.
Sample Code in calypsox/tk/risk/
AnalysisParamStd samples:
DEMOParam.java
The DEMO analysis requires a frequency to generate time buckets and a number of threads for
multi-threading.
Step 2 — Create an Analysis Parameters Viewer.
This step is only necessary if your analysis requires custom parameters to be edited by the user.
Create a class named apps.risk.<analysis_name>ParamViewer which implements the interface
com.calypso.apps.risk.AnalysisParamViewer.
This class will be invoked from your Analysis Parameters class.
Step 3 — Create an AnalysisOutput.
Create a class named tk.risk.<analysis_name>Output that extends
com.calypso.tk.risk.AnalysisOutput.
Implement the following members and methods:
• A member to store the report. You can model the report as a Vector of TradeItem objects
(each TradeItem object represents a row in the report). Note that you can subclass TradeItem
as applicable.
• A method for building the report, for example addItem() to add rows to the report.
• Methods that will allow the AnalysisViewer to display, print, save, export, aggregate the report.
For example, when using the DefaultAnalysisViewer you will implement the following
methods:
− getNumberOfRows() to return the number of rows in the report
− getNumberOfColumns() to return the number of columns in the report
− getHeaderAt(int col) to return the heading text for a given column
− getColumnClassAt(int col) to return the datatype of the data for a given column
− getValueAt(int row, int col) to return the value for a given cell
− getAggregationSource() to return the aggregation criteria This class will be invoked from
your Analysis class.
Step 4 — Register the new Analysis.
Do the following to register a new analysis:
1. Add the analysis name to the riskAnalysis domain using the Add Risk Analysis Type window
as shown below. This window is accessed from the Risk Analysis window when you click the ...
button next to the Analysis Type field.
Save and click “Update Domains” in the Risk Analysis window.
2. Associate the Analysis with an AnalysisViewer using Configuration > System > Analysis
Viewer Configuration from the Calypso Navigator.
You can use the DefaultAnalysisViewer or create a custom AnalysisViewer as described in the following
section.
|
|
How to Create a Custom AnalysisViewer | 16.1.2How to Create a Custom AnalysisViewer
The default AnalysisViewer is com.calypso.apps.risk.DefaultAnalysisViewer.
Create a class named apps.risk.<viewer_class_name> which implements the interface
com.calypso.tk.risk.AnalysisViewer.
This class will be invoked from com.calypso.tk.risk.AnalysisViewerConfig.
You can associate the AnalysisViewer with a given Analysis using Configuration > System > Analysis
Viewer Configuration from the Calypso Navigator.
|
|
How to Create a Custom Aggregation for an AnalysisViewer | 16.1.3How to Create a Custom Aggregation for an AnalysisViewer
Create a class named tk.util.CustomAggregation that implements the interface
com.calypso.tk.util.AggregationInterface.
This class will be invoked from com.calypso.tk.util.Aggregation.
|
|
How to Create a Custom AnalysisHandler | 16.1.4How to Create a Custom AnalysisHandler
Create a class named tk.risk.<analysis_name>Handler or tk.risk.DefaultAnalysisHandler that
implements com.calypso.tk.risk.AnalysisHandler.
This class will be invoked from com.calypso.tk.risk.AnalysisUtil for exporting AnalysisOutput
data to the AnalysisViewer.
|
|
How to Create a Custom Analysis Input Verifier | 16.1.5How to Create a Custom Analysis Input Verifier
Analysis performs calculations over an AnalysisInput that contains the trades, the PricingEnv, etc. You
can create a custom verifier of the input data.
Create a class named tk.risk.<analysis_name>Verifier or tk.risk.CustomAnalysisVerifier that
implements com.calypso.tk.risk.AnalysisVerifier.
This class will be invoked from com.calypso.tk.risk.AnalysisInput.
|
|
How to Create Custom Template Keywords | 16.1.6How to Create Custom Template Keywords
Create a class named tk.risk.<analysis_name>RiskFormatter that implements
com.calypso.tk.risk.RiskFormatter.
Analysis names are available in the “riskAnalysis” domain. Implement a parse<keyword_name>()
method for each custom keyword.
This class will be invoked from com.calypso.tk.risk.AnalysisUtil.
|
|
How to Create a Custom Risk Analysis in the Middle-Tier Servers | 16.1.7How to Create a Custom Risk Analysis in the Middle-Tier Servers
The analysis type must be added to the “riskPresenter” domain using the Domain Values window. For
example, if the implemented analysis name is MyCustomAnalysis, then you would add “MyCustom” to
the riskPresenter domain.
Implementation Requirements
AnalysisOutput must implement PresentableAnaysisOutput and Externalizable. In this case
calypsox.tk.risk.XXXCustomAnalysisOutput must implement the following methods.
• Implementation of the getRiskPresenterHeader(String user) method is required — This provides
the header information used by the risk presenter. The method should construct
RiskPresenterHeaderResult with the following collections:
− All headers — Map of headers that comprises of BASE_CURRENCY and ELAPSED_TIME.
− All columns list — All column names. In XXXCustomAnalysisOutput, it is the all headers
string array transformed to a collection as a value tagged to the key “Default.”
− All aggregation lists — The entire collection of column names tagged to “Default” key.
− All Column Meta Data collection — For each column, there is a ColumnMetaData
constructed from default_obj_key that is dimensional, is a key column, is part of the source,
is not additive, is not editable, is not numeric, and is not visible. Next, each column
depending upon which category it belongs to (from the following bulleted categories), is
dimensional, distinct, keyed, numeric (if it is a pricer measure value), and additive. The
numeric columns are primarily measure columns and not dimensional. For the sake of the
RiskAnalysisOutputModel object creation, it is necessary that there is at least one measure
column. Therefore it is a collection of all the columns that is transformed to equivalent
ColumnMetaData objects.
Metadata for the columns of the analysis must be correctly defined (minimally, the following):
− setNumeric(true/false) — Whether or not the column is numeric.
Example: Trade Id, NPV.
− setDimension(true/false) — A dimension is a column that you can aggregate.
Example: Book, Currency.
Measure columns such as NPV are non-dimensional
− setName(String) — The column name.
− setColumnClass(Class) — The column’s class.
The Supported Data types in Middle Tier are: String, Tenor, Boolean, JDate, JDatetime,
DisplayPeriodization, Integer, Double, and DisplayValue (Amount, Rate, Spread,
BondPrice, Price)
− setSource(true/false) — Is the column is the source identifier.
If not defined, default_obj_id is set as the source.
− Must implement the readExternal(ObjectInput) and writeExternal(ObjectOutput) methods
with all member attributes that must be serialized.
• Must populate the values for metadata columns, which includes the following columns. This
can be done by using a utility method on AnalysisOutput.populateMetaData(TradeArray array)
− default_obj
− default_obj_id
− default_obj_le
− default_obj_version
− default_obj_book_id
− default_obj_product_i
− default_statu
− default_obj_key
− default_obj_settle_date)
− At a minimum, the column default_obj_book_id, which is used for access permission in
presentation server, must be populated.
Implement a translator for the analysis output. The translator should extend
com.calypso.tk.risk.translator.AbstractTranslator. The naming convention is (XXXTranslator)
where XXX is the analysis name. The translator should:
• Define an overridable LOG string of “XXXTranslator.”
• Implement the abstract method getData(AnalysisOutput, List<String> columnNames) which
will:
− Return the collection of rows or items in an analysis output with each element in the
collection being a map that consist of keys as column names and values
− For each row, create a collection of cell values for each column as key. This provides an
entire 2D data array.
Supported Middle-Tier Data Types
• String
• Tenor
• Boolean
• JDate
• JDatetime
• DisplayPeriodization
• Integer
• Double
• DisplayValue
− Amount
− Rate
− Spread
− BondPrice
− Price
|
|
Customizing Official P&L | 16.2 Customizing Official P&L
|
|
P&L Component Calculator | 16.2.1P&L Component Calculator
Added calypso.tk.plcalculator.PLComponentCalculatorCustom to show how to extend Calypso's
PLComponentCalculatorBase, and use a custom pricer to fill the desired PLComponentMeasures.
Added calypso.tk.risk.pl.Customizer to show how to register the custom OPL calculator with the
OPL framework.
|
|
Product P&L Calculator | 16.2.2Product P&L Calculator
You can customize the product P&L calculator by creating a class named tk.risk.pl.Customizer.
In the non-argument constructor, or in the static block, register the custom calculator for the products
you wish to customize. The calculator must implement the interface
com.calypso.tk.plcalculator.OfficialPLMarkCalculator.
Sample Code
{
package calypsox.tk.risk.pl;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import com.calypso.tk.core.Log;
import com.calypso.tk.marketdata.OfficialPLMarkFactory;
import com.calypso.tk.marketdata.OfficialPLMarkI;
import com.calypso.tk.marketdata.QuoteValue;
import com.calypso.tk.plcalculator.OfficialPLMarkCalculator;
import com.calypso.tk.plcalculator.OfficialPLMarkCalculatorContext;
import com.calypso.tk.plcalculator.OfficialPLMarkCalculatorFactory;
import com.calypso.tk.plcalculator.PLComponentMeasureException;
import com.calypso.tk.plcalculator.PLComponentMeasureName;
import com.calypso.tk.risk.pl.PLMethodologyConfig.PLMethodology;
import com.calypso.tk.service.DSConnection;
import com.calypso.tk.service.LocalCache;
public class Customizer {
static {
//FormulaFactory.register(new CustomAccrualPnL());
//FormulaFactory.register(new CustomTotalPnL());
//Overide a UnrealizedOther for Swap
//Register a calculator for custom product and Swap
OfficialPLMarkCalculatorFactory.register(new PLComponentCalcualatorOverride());
Log.system("Customizer", "Regsitered custom calculator for DEMO_1 and Swap");
}
static public class PLComponentCalcualatorOverride implements
OfficialPLMarkCalculator{
@Override
public Set<OfficialPLMarkI> calculate(
OfficialPLMarkCalculatorContext context,
List<PLComponentMeasureException> exceptions) {
Set<OfficialPLMarkI> components = new HashSet<OfficialPLMarkI>();
OfficialPLMarkI component = OfficialPLMarkFactory.getInstance(context,
context.getPricingEnv().getBaseCurrency(),
null); //So we never need to convert.
components.add(component);
component.addMeasureValue(PLComponentMeasureName.UnrealizedMTM, 1);
component.addMeasureValue(PLComponentMeasureName.UnrealizedAccrual, 2);
component.addMeasureValue(PLComponentMeasureName.UnrealizedAccretion, 3);
component.addMeasureValue(PLComponentMeasureName.UnrealizedOther, 4);
component.addMeasureValue(PLComponentMeasureName.RealizedMTM, 5);
component.addMeasureValue(PLComponentMeasureName.RealizedAccrual, 6);
component.addMeasureValue(PLComponentMeasureName.RealizedAccretion, 7);
component.addMeasureValue(PLComponentMeasureName.RealizedOther, 8);
component.addMeasureValue(PLComponentMeasureName.CA_COST, 9);
component.addMeasureValue(PLComponentMeasureName.CA_NOTIONAL, 10);
component.addMeasureValue(PLComponentMeasureName.CA_PV, 11);
return components;
}
@Override
public Set<String> getSupportedProductTypes() {
Vector types = LocalCache.getDomainValues(DSConnection.getDefault(),
"productType");
return new HashSet<String>(types);
}
@Override
public Set<PLMethodology> getSupportedMethodologies(String productType,
String subType, String extendedType) {
HashSet<PLMethodology> methods = new HashSet<PLMethodology>();
methods.add(PLMethodology.MTM);
return methods;
}
@Override
public Set<Integer> getMarketDataItemIds(OfficialPLMarkCalculatorContext
context) {
return new HashSet<Integer>();
}
@Override
public Set<QuoteValue> getQuotes(OfficialPLMarkCalculatorContext context) {
return new HashSet<QuoteValue>();
}
@Override
public PLMethodology getDefaultMethodology(String productType,
String subType, String extendedType) {
return PLMethodology.MTM;
}
@Override
public Set<String> getMissingMarketDataItems(
OfficialPLMarkCalculatorContext context) {
// TODO Auto-generated method stub
return null;
}
}
}
|
|
Custom OfficialPLMarkTransformer | 16.2.3Custom OfficialPLMarkTransformer
Create a class named tk.risk.pl.Customizer. In this class call
OfficialPLMarkTransformerFactory.register(transformer class) to register the custom transformer in the
transformer factory.
Custom transformer class: Create a class named tk.plcalculator.<transformer> that implements
com.calypso.tk.plcalculator.api.OfficialPLMarkTransformer.
|
|
Fee Computation | 16.2.4Fee Computation
You can create a class named tk.plcalculator.CustomDiscountLookup which implements
com.calypso.tk.plcalculator.DefaultDiscountLookup.
CustomDiscountLookup is invoked by com.calypso.tk.plcalculator.PLCashflowUtility to obtain
discount factors for fee flows in Official PL.
|
|
Historical Rate Measure Calculator | 16.2.5Historical Rate Measure Calculator
You need to create a class that implements
com.calypso.tk.risk.pl.api.PLComponentHistoRateMeasureCalculator, for example
tk.risk.pl.PLComponentCustomHistoRateMeasureCalculator.
The only method that must be written is:
PLComponentHistoRateMeasureCalculator(IIPnLPLComponentBaseMeasureCalculatorContext
context, Collection<Exception> errors);
The custom class must be registered in the environment property:
OFFICIALPL_CUSTOM_HISTO_RATE_MEASURE_CALC_CLASSNAME.
For example, OFFICIALPL_CUSTOM_HISTO_RATE_MEASURE_CALC_CLASSNAME =
tk.risk.pl.PLComponentCustomHistoRateMeasureCalculator.
|
|
Custom Pricer Measures | 16.2.6Custom Pricer Measures
You can create a class that extends OfficialPLMarkMeasureExtender. It only supports 10 custom pricer
measures for Bonds. These custom pricer measures are only displayed in the Official P&L report and
are not stored.
You can also create a class that implements OfficialPLMarkMeasureExtenderMetaData to implement
the display of the custom pricer measures.
OfficialPLMarkMeasureExtender.
OfficialPLMarkMeasureExtender allows adding custom pricer measures. It has following methods:
• getSupportedProductAndMethodologyList() - An extender is tied to a particular productType
and P&L methodology. This method should return a list of productType/P&L methodology in
the form of OfficialPLMarkMeasureExtenderKey wrapper. It is called a “key” because when
extender is registered to the extender factory OfficialPLMarkMeasureExtenderFactory, the
extender will be registered with this key.
• getInternalMeasureNames() - This method should return list of PricerMeasure names. Ex. “NPV”
• getExtended2InternalMeasureMapping() - User may want to name report header different from
the PricerMeasure name. For example, user may want to see “Custom NPV” on the header for
PricerMeasure NPV. To do this we need a level of abstraction, so internally the columns are
named MEASURE01, MEASURE02, …, MEASURE10. This method will provide PricerMeasure
name to MEASUREXX mapping. MEASUREXX to column display header will be specified
separately in OfficialPLMarkMeasureExtenderMetaData.getMetaDataMap().
Sample Code
package calypsox.tk.risk.pl;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.calypso.tk.core.PricerMeasure;
import com.calypso.tk.core.Product;
import com.calypso.tk.risk.pl.OfficialPLMarkMeasureExtenderBase;
import com.calypso.tk.risk.pl.OfficialPLMarkMeasureExtenderKey;
public class CustomOfficialPLMarkMeasureExtender extends
OfficialPLMarkMeasureExtenderBase {
@Override
public Set<OfficialPLMarkMeasureExtenderKey>
getSupportedProductAndMethodologyList() {
Set<OfficialPLMarkMeasureExtenderKey> supportedList = new
HashSet<OfficialPLMarkMeasureExtenderKey>();
supportedList.add(new
OfficialPLMarkMeasureExtenderKey(Product.BOND,null));
return supportedList;
}
@Override
public Set<String> getInternalMeasureNames() {
Set<String> supportedList = new HashSet<String>();
supportedList.add(PricerMeasure.S_NPV);
supportedList.add(PricerMeasure.S_ACCRUAL_BO);
supportedList.add(PricerMeasure.S_AVG_YIELD);
return supportedList;
}
@Override
public Map<String,EXTENDED_COLUMN> getExtended2InternalMeasureMapping() {
Map<String,EXTENDED_COLUMN> map = new HashMap<String,EXTENDED_COLUMN>();
map.put(PricerMeasure.S_NPV,EXTENDED_COLUMN.MEASURE01);
map.put(PricerMeasure.S_ACCRUAL_BO,EXTENDED_COLUMN.MEASURE02);
map.put(PricerMeasure.S_AVG_YIELD,EXTENDED_COLUMN.MEASURE03);
return map;
}
}
Extender Factory Registration
package calypsox.tk.risk.pl;
import com.calypso.tk.risk.pl.OfficialPLMarkMeasureExtenderFactory;
public class Customizer {
static {
OfficialPLMarkMeasureExtenderFactory.registerExtender(new
CustomOfficialPLMarkMeasureExtender());
OfficialPLMarkMeasureExtenderFactory.registerColumnMetaData(new
CustomOfficialPLMarkMeasureExtenderMetaData());
}
}
OfficialPLMarkMeasureExtenderMetaData
MetaData will tell the framework how to display the PricerMeasures. It has following method:
• getMetaDataMap() - See getExtended2InternalMeasureMapping() above.
Sample Code
package calypsox.tk.risk.pl;
import java.util.EnumMap;
import com.calypso.tk.core.Amount;
import com.calypso.tk.presentation.risk.ColumnMetaData;
import
com.calypso.tk.risk.pl.OfficialPLMarkMeasureExtenderColumnHeader.EXTENDED_COLUMN;
import com.calypso.tk.risk.pl.OfficialPLMarkMeasureExtenderMetaData;
public class CustomOfficialPLMarkMeasureExtenderMetaData implements
OfficialPLMarkMeasureExtenderMetaData {
@Override
public EnumMap<EXTENDED_COLUMN, ColumnMetaData> getMetaDataMap() {
EnumMap<EXTENDED_COLUMN,ColumnMetaData> map = new
EnumMap<EXTENDED_COLUMN,ColumnMetaData>(EXTENDED_COLUMN.class);
map.put(EXTENDED_COLUMN.MEASURE01,createAddtiveDisplayValue("Custom
NPV"));
map.put(EXTENDED_COLUMN.MEASURE02,createAddtiveDisplayValue("Custom
ACCRUAL_BO"));
map.put(EXTENDED_COLUMN.MEASURE03,createAddtiveDisplayValue("Custom
AVG_YIELD" ));
return map;
}
private ColumnMetaData createAddtiveDisplayValue(String name){
ColumnMetaData metaData = new ColumnMetaData();
metaData.setName(name);
metaData.setDimension(false);
metaData.setAdditive(true);
metaData.setNumeric(true);
metaData.setDistinct(false);
metaData.setColumnClass(Amount.class);
return metaData;
}
}
Other Considerations
Currently all the measures in one P&L line are all in same currency which is the P&L Currency. To keep
things consistent, PricerMeasures will be displayed on the P&L line with matching P&L Currency only. If
a matching P&L Currency line does not exist, a new line will be created just for this PricerMeasure.
|
|
Custom Shift Type and Shift Amount | 16.2.7Custom Shift Type and Shift Amount
To implement a custom shift type or shift amount in Official P&L Explain by Greeks and Live P&L for FX
Spot or Equity, create a class named tk.risk.<class name> that implements
com.calypso.tk.risk.OfficialPLGreeksShiftAmountCustomizer.
For FX Spot, override the method setFXShiftAmountType() and getFXShiftAmount() for shift amount.
For Equity, override the method setEquityShiftAmountType() for shift type and getEquityShiftAmount()
for shift amount.
|
|
Custom Official P&L Export | 16.2.8Custom Official P&L Export
The sample scheduled task calypsox.tk.util.ScheduledTaskCUSTOM_OFFICIALPLEXPORT shows how
to produce custom Official P&L files.
|
|
How to Customize ScenarioAnalysis | 16.3 How to Customize ScenarioAnalysis
ScenarioAnalysis allows defining market data scenarios to be applied to a set of trades, and calculates
risk measures for those scenarios. You can create custom scenario market data, custom scenario rules,
custom report viewers, and custom report viewer converters.
|
|
Creating a Custom Scenario Rule | 16.3.1Creating a Custom Scenario Rule
Create a class named tk.risk.ScenarioRule<name> that implements
com.calypso.tk.risk.ScenarioRule.
This class will be invoked from com.calypso.apps.risk.ScenarioRulePanel.
You must register the custom rule name with the “customScenarioRule” domain.
|
|
Creating a Custom Scenario Market Data | 16.3.2Creating a Custom Scenario Market Data
Create a class named tk.risk.CustomScenarioMarketData that implements
com.calypso.tk.risk.CustomScenarioMarketDataInterface.
This class will be invoked from com.calypso.tk.risk.ScenarioMarketData.
|
|
Creating a Custom Report Viewer | 16.3.3Creating a Custom Report Viewer
Create a class named tk.risk.<viewer> that implements
com.calypso.tk.risk.ScenarioReportViewInterface.
This class will be invoked from com.calypso.tk.risk.ScenarioReportView and
com.calypso.apps.risk.ScenarioReportViewWindow.
The custom viewers must be registered in the domain “ScenarioViewerClassNames”.
|
|
Creating a Custom Report Viewer Converter | 16.3.4Creating a Custom Report Viewer Converter
Create a class named tk.risk.<viewer converter> that implements
com.calypso.tk.risk.ScenarioReportViewConverterInterface.
This class will be invoked from com.calypso.tk.risk.ScenarioReportView to convert the standard
columns names to user-defined column names.
|
|
Creating a Custom Notifcation Before/After Pricing a Trade | 16.3.5Creating a Custom Notifcation Before/After Pricing a Trade
The interface CustomScenarioAnalysisInterface has the following methods: beforeApplyingAllRules()
and afterApplyingAllRules().
Create a class named tk.risk.DefaultCustomScenarioAnalysisInterface that implements
com.tk.risk.CustomScenarioAnalysisInterface.
This class will be invoked from ScenarioAnalysis.
16.4 Distributed Processing
How Distributed Procesing is used
16.4.1How to Apply Distributed Processing to a Client Application
A client application will instantiate a DispatcherUser that connects to the Dispatcher for sending jobs
and receiving the results.
For applying distributed processing to a risk analysis, see “How to Apply Distributed Processing to a
Risk Analysis”.
Overview of Steps
• Step 1 — Create a DispatcherJob
• Step 2 — Create a DispatcherJobOutput
• Step 3 — Implement DispatcherUserListener and instantiate DispatcherUser
Step 1 — Creating a DispatcherJob.
A DispatcherJob is an individual job sent to the Dispatcher for calculation.
Create a class named apps.distproc.<name>Job or tk.distproc.<name>Job that extends
com.calypso.tk.distproc.DispatcherJob.
Implement the process() method. The process() method will return its results as a
DispatcherJobOutput.
Step 2 — Creating a DispatcherJobOutput.
DispatcherJobOutput contains the results of DispatcherJob. Create a class named
apps.distproc.<name>JobOutput or tk.distproc.<name>JobOutput that extends
com.calypso.tk.distproc.DispatcherJobOutput.
Implement get() and set() methods in your DispatcherJobOutput class that allow the calculation
routine in your DispatcherJob to set the calculated result values. Usually, these result values are
PricerMeasures.
This class will be invoked from DispatcherJob.
Step 3 — Implementing DispatcherUserListener and Instantiating DispatcherUser.
Your client application must implement com.calypso.tk.distproc.DispatcherUserListener. Any
client of the distributed processing system must be able to:
• Receive a large task from the user and divide that task into smaller jobs
• Send the jobs (using a DispatcherUser)
• Receive and relay the results
• Assess completion of the jobs
• Handle errors
Receiving and Dividing the Task
For example, you can use a Trade Filter to collect the trades that you want to process and create a
DispatcherJob for every ten trades in the Trade Filter.
Also, a table of ratio by product type allows splitting the jobs through the classes,
tk.distproc.SwaptionProductRatio and tk.distproc.CancellableSwapRatio.
Currently, for a European swaption, the ratio is set to 5, and for a Bermudan swaption, the ratio is set to
10. Those settings can be modified in the above-mentioned classes.
Suppose the number of trades per job is set to 10:
• Each swap is counted for 1 trade. For 50 swaps in a portfolio, it will take 5 jobs to complete the
task.
• Each European swaption is counted for 5 trades. For 50 swaptions in a portfolio, it will take 25
jobs to complete the task.
• Each Bermudan swaption is counted for 10 trades. For 50 swaptions in a portfolio, it will take
50 jobs to complete the task.
Sending Jobs
Your client application will create a DispatcherUser to send jobs to the Dispatcher. Your application
will need a DispatcherConfig in order to specify the location of the running Dispatcher process, so that
it can create the DispatcherUser as a client of the Dispatcher. In the line below, c is our
DispatcherConfig object:
DispatcherUser d= new DispatcherUser(c);
The DispatcherUser can exist for the life of the client application, sending many DispatcherJobs via its
send() method:
DispatcherUser.send(DispatcherJob);
When sending jobs, you can set the COMPRESS_DISPATCHER_JOBS environment property to true to
compress the jobs, or to false otherwise. The default value is true. Note that on large jobs over a fast
network, it may be faster to send the jobs uncompressed.
Receiving Results
The method for receiving results is established in the DispatcherUserListener interface:
public void jobFinished(DispatcherJobOutput out);
The jobFinished() method will receive and relay the results of the calculation when a job is finished.
Inside jobFinished(), you should implement the work necessary to relay the results using a
DispatcherJobOutput.
Assessing Completion
Most client applications will use a counter to count results as they arrive. Once the number of results
equals the number of jobs sent, the client application can exit or proceed to other work.
Handling Errors
The method for handling errors is established in the DispatcherUserListener interface:
public void onDisconnect();
The onDisconnect() method is called if your connection to the Dispatcher is dropped. In this method
you should implement error reporting, informing the user that the calculation has failed due to the lost
connection.
16.4.2How to Create a Custom Ratio Dispatcher by Product
Create a class named tk.distproc.<product_type>ProductRatio that implements the interface
tk.distproc.ProductRatio.
This class will be invoked from com.calypso.tk.distproc.ProductRatioUtil.
|
|
How to Apply Distributed Processing to a Client Application | 16.4.1How to Apply Distributed Processing to a Client Application
A client application will instantiate a DispatcherUser that connects to the Dispatcher for sending jobs
and receiving the results.
For applying distributed processing to a risk analysis, see “How to Apply Distributed Processing to a
Risk Analysis”.
Overview of Steps
• Step 1 — Create a DispatcherJob
• Step 2 — Create a DispatcherJobOutput
• Step 3 — Implement DispatcherUserListener and instantiate DispatcherUser
Step 1 — Creating a DispatcherJob.
A DispatcherJob is an individual job sent to the Dispatcher for calculation.
Create a class named apps.distproc.<name>Job or tk.distproc.<name>Job that extends
com.calypso.tk.distproc.DispatcherJob.
Implement the process() method. The process() method will return its results as a
DispatcherJobOutput.
Step 2 — Creating a DispatcherJobOutput.
DispatcherJobOutput contains the results of DispatcherJob. Create a class named
apps.distproc.<name>JobOutput or tk.distproc.<name>JobOutput that extends
com.calypso.tk.distproc.DispatcherJobOutput.
Implement get() and set() methods in your DispatcherJobOutput class that allow the calculation
routine in your DispatcherJob to set the calculated result values. Usually, these result values are
PricerMeasures.
This class will be invoked from DispatcherJob.
Step 3 — Implementing DispatcherUserListener and Instantiating DispatcherUser.
Your client application must implement com.calypso.tk.distproc.DispatcherUserListener. Any
client of the distributed processing system must be able to:
• Receive a large task from the user and divide that task into smaller jobs
• Send the jobs (using a DispatcherUser)
• Receive and relay the results
• Assess completion of the jobs
• Handle errors
Receiving and Dividing the Task
For example, you can use a Trade Filter to collect the trades that you want to process and create a
DispatcherJob for every ten trades in the Trade Filter.
Also, a table of ratio by product type allows splitting the jobs through the classes,
tk.distproc.SwaptionProductRatio and tk.distproc.CancellableSwapRatio.
Currently, for a European swaption, the ratio is set to 5, and for a Bermudan swaption, the ratio is set to
10. Those settings can be modified in the above-mentioned classes.
Suppose the number of trades per job is set to 10:
• Each swap is counted for 1 trade. For 50 swaps in a portfolio, it will take 5 jobs to complete the
task.
• Each European swaption is counted for 5 trades. For 50 swaptions in a portfolio, it will take 25
jobs to complete the task.
• Each Bermudan swaption is counted for 10 trades. For 50 swaptions in a portfolio, it will take
50 jobs to complete the task.
Sending Jobs
Your client application will create a DispatcherUser to send jobs to the Dispatcher. Your application
will need a DispatcherConfig in order to specify the location of the running Dispatcher process, so that
it can create the DispatcherUser as a client of the Dispatcher. In the line below, c is our
DispatcherConfig object:
DispatcherUser d= new DispatcherUser(c);
The DispatcherUser can exist for the life of the client application, sending many DispatcherJobs via its
send() method:
DispatcherUser.send(DispatcherJob);
When sending jobs, you can set the COMPRESS_DISPATCHER_JOBS environment property to true to
compress the jobs, or to false otherwise. The default value is true. Note that on large jobs over a fast
network, it may be faster to send the jobs uncompressed.
Receiving Results
The method for receiving results is established in the DispatcherUserListener interface:
public void jobFinished(DispatcherJobOutput out);
The jobFinished() method will receive and relay the results of the calculation when a job is finished.
Inside jobFinished(), you should implement the work necessary to relay the results using a
DispatcherJobOutput.
Assessing Completion
Most client applications will use a counter to count results as they arrive. Once the number of results
equals the number of jobs sent, the client application can exit or proceed to other work.
Handling Errors
The method for handling errors is established in the DispatcherUserListener interface:
public void onDisconnect();
The onDisconnect() method is called if your connection to the Dispatcher is dropped. In this method
you should implement error reporting, informing the user that the calculation has failed due to the lost
connection.
|
|
How to Create a Custom Ratio Dispatcher by Product | 16.4.2How to Create a Custom Ratio Dispatcher by Product
Create a class named tk.distproc.<product_type>ProductRatio that implements the interface
tk.distproc.ProductRatio.
This class will be invoked from com.calypso.tk.distproc.ProductRatioUtil.
|
|
How to Apply Distributed Processing to a Risk Analysis | 16.4.3How to Apply Distributed Processing to a Risk Analysis
Create a class named tk.distproc.<analysis_name>AnalysisDispatcher which implements
com.calypso.tk.distproc.AnalysisDispatcher.
In order to detect errors returned by individual jobs that will make any further calculation meaningless,
and to terminate the entire dispatch job, call the DistAnalysis.stopAll() method from
AnalysisDispatcher.taskFinished().
This class will be invoked from com.calypso.tk.distproc.AnalysisDispatcher.
|
|
How to Create a Custom Error Notification | 16.4.4How to Create a Custom Error Notification
The default error notification is an email when the dispatcher or the calculator are disconnected from
the system. Email server host and port come from calpyso_mail.properties. This means that such a file
should exist in a directory that is in the classpath on all hosts involved: client host, dispatcher host, and
all calculator hosts. The DispatcherConfig provides the “from” and “to” email addresses.
To use this email-on-errors feature, the Calculators must know what DispatcherConfig to use. That
means that either:
• The Calculators are started with "-config <DispatcherConfig_name>" at the command line,
or
• The Calculators are started in GUI mode, and the DispatcherConfig is chosen from the drop-
down list.
To create a custom error notification, create a class named tk.distproc.CustomErrorNotifier that
implements com.calypso.tk.distproc.ErrorNotifier.
This class will be invoked from com.calypso.apps.distproc.DispatcherConfigWindow,
com.calypso.tk.distproc.Calculator, and com.calypso.tk.distproc.Dispatcher.
|
|
Reference Data | Section 17. Reference Data
17.1 Legal Entities
|
|
How to Create Custom Attributes on Legal Entities | 17.1.1How to Create Custom Attributes on Legal Entities
You can build a custom input window. Your custom window can contain the fields you need in order to
record the additional attributes. Users can then launch the window by clicking the custom button in the
legal entity window.
Create a class named apps.refdata.LegalEntityCustomInputWindow which implements the interface
com.calypso.apps.refdata.LegalEntityCustomInput.
You must define the following methods in your LegalEntityCustomInputWindow class:
• input() — Applies the display for your window.
• allowAttributeWindow() — Specifies if you still allow Calypso’s Legal Entity Attribute window to
be launched.
This class will be invoked from com.calypso.apps.refdata.BOLegalEntityWindow.
|
|
How to Apply Custom Validation to a LegalEntity | 17.1.2How to Apply Custom Validation to a LegalEntity
Create a class named apps.refdata.CustomLegalEntityValidator which implements the interface
com.calypso.apps.refdata.LegalEntityValidator.
This class will be invoked from com.calypso.apps.refdata.BOLegalEntityWindow.
|
|
How to Apply Custom Validation to a Legal Agreement | 17.1.3How to Apply Custom Validation to a Legal Agreement
Create a class named apps.refdata.CustomLegalAgreementValidator that implements
com.calypso.apps.refdata.LegalAgreementValidator.
This class will be invoked from com.calypso.apps.refdata.BOLegalAgreementWindow.
|
|
How to Apply Custom Validation to a LegalEntity Contact | 17.1.4How to Apply Custom Validation to a LegalEntity Contact
Create a class named apps.refdata.CustomLEContactValidator which implements the interface
com.calypso.apps.refdata.LEContactValidator.
This class will be invoked from com.calypso.apps.refdata.BOLEContactWindow.
|
|
How to Apply Custom Validation to LegalEntity Attributes | 17.1.5How to Apply Custom Validation to LegalEntity Attributes
Create a class named apps.refdata.CustomLEAttributeValidator which implements the interface
com.calypso.apps.refdata.LEAttributeValidator.
This class will be invoked from com.calypso.apps.refdata.BOLegalEntityAttributeWindow.
To check the validity of the LEI (Legal Entity Identifier) attribute, you can create a class that implements
com.calypso.tk.refdata.LEIValidator. This validator must be used in the custom attribute validator
for the LEI attribute.
|
|
How to Apply Custom Validation to LegalEntity Registrations | 17.1.6How to Apply Custom Validation to LegalEntity Registrations
Create a class named apps.refdata.CustomRegistrValidator which implements the interface
com.calypso.apps.refdata.RegistrValidator.
This class will be invoked from com.calypso.apps.refdata.BOLERegistrationWindow.
|
|
Applying Custom Validation to a Margin Call Config | 17.2 Applying Custom Validation to a Margin Call Config
Create a class named apps.refdata.CustomMarginCallConfigValidator which implements the
interface com.calypso.apps.refdata.MarginCallConfigValidator.
This class will be invoked from com.calypso.apps.refdata.BOMarginCallConfigWindow.
|
|
Settlement and Delivery Instructions (SDI) | 17.3 Settlement and Delivery Instructions (SDI)
|
|
How to Create a Custom SDI Selector | 17.3.1How to Create a Custom SDI Selector
Refer to the Calypso Settlements documentation for the methodology used by Calypso for selecting
settlement and delivery instructions for trades.
Create a class named tk.bo.<product_type>SDISelector which implements the interface
com.calypso.tk.bo.SDISelector.
This class will be invoked from com.calypso.tk.bo.SDISelectorUtil. SDISelector contains the
following methods:
• validSDIList() — Returns a list of Valid SDI List.
• validate() — Checks whether Static Data is still valid.
• checkSettleDate() — Rejects any SDI record that uses an agent or intermediary that is not open
for business on the transfer settlement date.
• getSettlementMethod() — Returns the Settlement Method applicable for the Trade. The
purpose is to restrict the search of Settlement Instruction based on specific information set on
the Trade. If the settlement Method returns null, the standard SDI search logic is applied.
• getSettlementMethods() — Checks multiple transfer rules for ensuring that both pay and
receive legs are using the same settlement method.
• setTradeTransferRule() — Overrides, if necessary TradeTransferRule created by each
BOProductHandler.
• getValidManualSDIList() — Returns the first valid manual SDI or null if none found.
• isBridgePossible() — Checks whether two Settle and Delivery Instructions are compatible.
Compares the Settlement Methods of the Processing Organization and the Counterparty and
returns whether Settlement Instructions are compatible.
• matchSDIList() — Compares the two lists of Settle and Delivery Instructions and removes the
incompatible SDI from the List. Both lists must be sorted by preference.
• matchManualSDIList() — Same as above for Manual SDI.
|
|
How to Create a Custom SDI Sort Order | 17.3.2How to Create a Custom SDI Sort Order
Create a class named tk.refdata.CustomComparatorSDI which implements the interface
java.util.Comparator.
This class will be invoked from com.calypso.tk.util.ComparatorFactory.
|
|
How to Create a Custom SDI Description | 17.3.3How to Create a Custom SDI Description
Since users will be using the description to choose the proper instruction for making manual
assignments of settlement and delivery instructions, you may wish to use custom descriptions.
Create a class named tk.refdata.CustomSDIDescription which implements the interface
com.calypso.tk.refdata.SDIDescription.
This class will be invoked from com.calypso.tk.refdata.SettleDeliveryInstruction and
com.calypso.apps.refdata.BOSettlDeliveryWindow.
|
|
How to Apply a Custom Validation to an SDI | 17.3.4How to Apply a Custom Validation to an SDI
Create class named apps.refdata.CustomSDIValidator which implements the interface
com.calypso.apps.refdata.SDIValidator.
This class will be invoked from com.calypso.apps.refdata.BOSettlDeliveryWindow.
|
|
How to add a Custom Menu Item to the SDI Window | 17.3.5How to add a Custom Menu Item to the SDI Window
Create a class named apps.refdata.CustomSDIMenu which implements the interface
com.calypso.apps.refdata.SDIMenu.
This class will be invoked from com.calypso.apps.refdata.BOSettlDeliveryWindow for any utility
function.
|
|
How to Create a Custom Summary Panel on the SDI Window | 17.3.6How to Create a Custom Summary Panel on the SDI Window
Create a class named apps.refdata.CustomSDISummaryPanel which implements the interface
com.calypso.apps.refdata.SDISummaryPanel.
This class will be invoked from com.calypso.apps.refdata.BOSettlDeliveryWindow.
|
|
How to Apply Custom Validation to an SDI Relationship | 17.3.7How to Apply Custom Validation to an SDI Relationship
Create a class named apps.refdata.CustomSDIRelationShipValidator which implements the
interface com.calypso.apps.refdata.SDIRelationShipValidator.
This class will be invoked from com.calypso.apps.refdata.SDIRelationShipWindow.
|
|
How to Apply Custom Validation to a Manual SDI | 17.3.8How to Apply Custom Validation to a Manual SDI
Create a class named apps.refdata.ManualSDIValidator which implements the interface
com.calypso.apps.refdataCustomManual.SDIValidator.
This class will be invoked from com.calypso.apps.refdata.ManualSDIWindow.
|
|
How to Apply Custom Validation to a Book | 17.4 How to Apply Custom Validation to a Book
Create a class named apps.refdata.CustomBookValidator which implements the interface
com.calypso.apps.refdata.BookValidator.
This class will be invoked from com.calypso.apps.refdata.BookWindow.
17.5 Static Data Filter
How to use statis data filters
17.5.1Creating a Custom StaticDataFilter Attribute
You can implement tk.refdata.sdfilter.SDFilterCriterion for a single attribute, or
tk.refdata.sdfilter.SDFilterCriterionFactory for a set of attributes for the same object.
SDFilterCriterion is the Java interface defining one criterion.
SDFilter attribute is the display name of an SDFilterCriterion in the Static Data Filter window.
tk.refdata.StaticDataFilterElement is the persisted value object holding the user selected
criterion name, operator type, possibly a list of choices.
tk.refdata.sdfilter.SDFilterCriterion
SDFilterCriterion is an interface defining one single SDFilter criterion (or attribute).
Do the following for create a custom StaticDataFilter attribute:
1. Create a class named tk.refdata.sdfilter.criterionimpl.<name>SDFilterCriterion
that implements tk.refdata.sdfilter.SDFilterCriterion.
2. Register the attribute name in domain “sdFilterCriterion”. The attribute will be made
available in the Static Data Filter window.
The SDFilterCriterion implementation encapsulates the logic to evaluate SDFilter.accept() arguments,
collected into a tk.refdata.sdfilter.SDFilterInput, for one given StaticDataFilterElement.
SDFilterCriterion is typed: it accesses fields returning value of a given type: String, JDate, etc.
Sample SDFilterCriterion
public class NettingTypeSDFilterCriterion extends AbstractSDFilterCriterion<String> {
@Override
public boolean hasDomainValues() {
return true;
}
@Override
public List<String> getDomainValues() {
return LocalCache.getDomainValues(DSConnection.getDefault(), "nettingType");
}
@Override
public String getValue(SDFilterInput input) {
String nettingType = NettingConfig.NT_NONE;
BOTransfer transfer = input.getTransfer();
if (transfer != null) {
nettingType = transfer.getNettingType();
} else if (input.getTrade() != null) {
List<TradeTransferRule> rules =
BOProductHandler.buildTransferRules(input.getTrade(),
new Vector<BOException>(), DSConnection.getDefault());
if (rules != null) {
for (TradeTransferRule rule: rules) {
if (rule.getNettingType() != null
&& !NettingConfig.NT_NONE.equals(rule.getNettingType())) {
nettingType = rule.getNettingType();
break;
}
}
}
}
return nettingType;
}
@Override
public Class<String> getValueType() {
return String.class;
}
}
Domain: Add NettingType to domain “sdFilterCriterion”
tk.refdata.sdfilter.AbstractSDFilterCriterion
AbstractSDFilterCriterion is a base implementation of SDFilterCriterion, defining default
SDFilterOperatorType for common types. Say if SDFilterCriterion.getValueType() returns an Integer,
default SDFilterOperatorType are INT_RANGE, INT_ENUM, NOT_IN_INT_ENUM.
tk.refdata.sdfilter.SDFilterCriterionFactory
SDFilterCriterionFactory creates a set of SDFilterCriterion for a common category. For example,
LegalAgreementSDFilterCriterionFactory creates SDFilterCriterion accessing
tk.refdata.LegalAgreement fields.
Do the following for create a custom set of StaticDataFilter attributes:
1. Create a class named
tk.refdata.sdfilter.criterionimpl.<name>SDFilterCriterionFactory that implements
tk.refdata.sdfilter.SDFilterCriterionFactory.
2. Register the factory name in domain “sdFilterCriterion.Factory”. All the attributes defined in
the corresponding class will be made available in the Static Data Filter window.
Sample SDFilterCriterionFactory
public class CustomSDFilterCriterionFactory implements SDFilterCriterionFactory {
@Override
public Set<String> getSDFilterCriterionNames() {
return new HashSet<String>(Arrays.asList("FirstCriterion", "SecondCriterion"));
}
@Override
public SDFilterCriterion<?> createSDFilterCriterion(final String criterionName) {
return new AbstractSDFilterCriterion<String>() {
@Override
public String getName() {
return criterionName;
}
@Override
public Class<String> getValueType() {
return String.class;
}
@Override
public String getValue(SDFilterInput input) {
// return the [Trade] field value this SDFilterCriterion is accessing
String value = null;
if ("FirstCriterion".equals(getName())) {
// value = get field value from input.getTrade(), or ...
} else if ("SecondCriterion".equals(getName())) {
// value = get field value from input.getTransfer(), or ...
}
return value;
}
@Override
public SDFilterCategory getCategory() {
return SDFilterCategory.CUSTOM;
}
};
}
}
Domain: Add Custom to domain “sdFilterCriterion.Factory”.
tk.refdata.sdfilter.SDFilterInput
SDFilterInput collects and holds all arguments passed to StaticDataFilter.accept(Object...) or
StaticDataFilter.simulate(Object...).
SDFilterInput may contain com.calypso.tk.core.Trade, com.calypso.tk.bo.BOTransfer, etc. Most
commonly used business Objects have direct accessors, say:
• SDFilterInput.getTrade()
• SDFilterInput.getTransfer()
• SDFilterInput.getStaticDataFiltrElement()
Any type held by SDFilterInput can be accessed using: public <T> T get(Class<?extends T>
type);
For example: SDFilterInput.get(com.calypso.tk.bo.Task.class) returns a Task if a Task was passed as
argument to StaticDataFilter.accept(Object...).
The number and types of SDFilter input - SDFilterInput.accept(Object...) arguments – is unlimited. It
depends on when and why the SDFilterInput is built.
17.5.2Creating a Custom Attribute Panel
Create a class named apps.refdata.<attribute_name>CustomAttributePanel that implements the
interface com.calypso.apps.refdata.CustomAttributePanel.
This class will be invoked from com.calypso.apps.refdata.StaticDataFilterWindow.
|
|
Creating a Custom StaticDataFilter Attribute | 17.5.1Creating a Custom StaticDataFilter Attribute
You can implement tk.refdata.sdfilter.SDFilterCriterion for a single attribute, or
tk.refdata.sdfilter.SDFilterCriterionFactory for a set of attributes for the same object.
SDFilterCriterion is the Java interface defining one criterion.
SDFilter attribute is the display name of an SDFilterCriterion in the Static Data Filter window.
tk.refdata.StaticDataFilterElement is the persisted value object holding the user selected
criterion name, operator type, possibly a list of choices.
tk.refdata.sdfilter.SDFilterCriterion
SDFilterCriterion is an interface defining one single SDFilter criterion (or attribute).
Do the following for create a custom StaticDataFilter attribute:
1. Create a class named tk.refdata.sdfilter.criterionimpl.<name>SDFilterCriterion
that implements tk.refdata.sdfilter.SDFilterCriterion.
2. Register the attribute name in domain “sdFilterCriterion”. The attribute will be made
available in the Static Data Filter window.
The SDFilterCriterion implementation encapsulates the logic to evaluate SDFilter.accept() arguments,
collected into a tk.refdata.sdfilter.SDFilterInput, for one given StaticDataFilterElement.
SDFilterCriterion is typed: it accesses fields returning value of a given type: String, JDate, etc.
Sample SDFilterCriterion
public class NettingTypeSDFilterCriterion extends AbstractSDFilterCriterion<String> {
@Override
public boolean hasDomainValues() {
return true;
}
@Override
public List<String> getDomainValues() {
return LocalCache.getDomainValues(DSConnection.getDefault(), "nettingType");
}
@Override
public String getValue(SDFilterInput input) {
String nettingType = NettingConfig.NT_NONE;
BOTransfer transfer = input.getTransfer();
if (transfer != null) {
nettingType = transfer.getNettingType();
} else if (input.getTrade() != null) {
List<TradeTransferRule> rules =
BOProductHandler.buildTransferRules(input.getTrade(),
new Vector<BOException>(), DSConnection.getDefault());
if (rules != null) {
for (TradeTransferRule rule: rules) {
if (rule.getNettingType() != null
&& !NettingConfig.NT_NONE.equals(rule.getNettingType())) {
nettingType = rule.getNettingType();
break;
}
}
}
}
return nettingType;
}
@Override
public Class<String> getValueType() {
return String.class;
}
}
Domain: Add NettingType to domain “sdFilterCriterion”
tk.refdata.sdfilter.AbstractSDFilterCriterion
AbstractSDFilterCriterion is a base implementation of SDFilterCriterion, defining default
SDFilterOperatorType for common types. Say if SDFilterCriterion.getValueType() returns an Integer,
default SDFilterOperatorType are INT_RANGE, INT_ENUM, NOT_IN_INT_ENUM.
tk.refdata.sdfilter.SDFilterCriterionFactory
SDFilterCriterionFactory creates a set of SDFilterCriterion for a common category. For example,
LegalAgreementSDFilterCriterionFactory creates SDFilterCriterion accessing
tk.refdata.LegalAgreement fields.
Do the following for create a custom set of StaticDataFilter attributes:
1. Create a class named
tk.refdata.sdfilter.criterionimpl.<name>SDFilterCriterionFactory that implements
tk.refdata.sdfilter.SDFilterCriterionFactory.
2. Register the factory name in domain “sdFilterCriterion.Factory”. All the attributes defined in
the corresponding class will be made available in the Static Data Filter window.
Sample SDFilterCriterionFactory
public class CustomSDFilterCriterionFactory implements SDFilterCriterionFactory {
@Override
public Set<String> getSDFilterCriterionNames() {
return new HashSet<String>(Arrays.asList("FirstCriterion", "SecondCriterion"));
}
@Override
public SDFilterCriterion<?> createSDFilterCriterion(final String criterionName) {
return new AbstractSDFilterCriterion<String>() {
@Override
public String getName() {
return criterionName;
}
@Override
public Class<String> getValueType() {
return String.class;
}
@Override
public String getValue(SDFilterInput input) {
// return the [Trade] field value this SDFilterCriterion is accessing
String value = null;
if ("FirstCriterion".equals(getName())) {
// value = get field value from input.getTrade(), or ...
} else if ("SecondCriterion".equals(getName())) {
// value = get field value from input.getTransfer(), or ...
}
return value;
}
@Override
public SDFilterCategory getCategory() {
return SDFilterCategory.CUSTOM;
}
};
}
}
Domain: Add Custom to domain “sdFilterCriterion.Factory”.
tk.refdata.sdfilter.SDFilterInput
SDFilterInput collects and holds all arguments passed to StaticDataFilter.accept(Object...) or
StaticDataFilter.simulate(Object...).
SDFilterInput may contain com.calypso.tk.core.Trade, com.calypso.tk.bo.BOTransfer, etc. Most
commonly used business Objects have direct accessors, say:
• SDFilterInput.getTrade()
• SDFilterInput.getTransfer()
• SDFilterInput.getStaticDataFiltrElement()
Any type held by SDFilterInput can be accessed using: public <T> T get(Class<?extends T>
type);
For example: SDFilterInput.get(com.calypso.tk.bo.Task.class) returns a Task if a Task was passed as
argument to StaticDataFilter.accept(Object...).
The number and types of SDFilter input - SDFilterInput.accept(Object...) arguments – is unlimited. It
depends on when and why the SDFilterInput is built.
|
|
Creating a Custom Attribute Panel | 17.5.2Creating a Custom Attribute Panel
Create a class named apps.refdata.<attribute_name>CustomAttributePanel that implements the
interface com.calypso.apps.refdata.CustomAttributePanel.
This class will be invoked from com.calypso.apps.refdata.StaticDataFilterWindow.
|
|
Applying Custom Validation to a Static Data Filter | 17.5.3Applying Custom Validation to a Static Data Filter
To perform custom validation on a Static Data Filter, create a class named
tk.refdata.CustomStaticDataFilterValidator that implements
com.calypso.tk.refdata.StaticDataFilterValidator.
17.6 Trade Filter
How Trade Filters are used
17.6.1Position Based Products
The domain “PositionBasedProducts” contains a list of products that return true in their
implementation of isPositionBased(). This list is used internally for excluding the trades whose products
are position based from trade filters with that criteria.
This list is not to be modified, and should include at most all products that are position based
products. Including products which return false from their isPositionBased() implementations will result
in incorrect behavior when loaded through trade filters with the property setIncludePositionBased to
false.
Not including all position based products in this list will only result in lower performance and higher
memory requirements when loading trade filters with the property setIncludePositionBased to false.
17.6.1Extending the Trade Filter Mechanism
This is the recommended approach to extend trade filters.
To extend the trade filter mechanism, you need to:
• Provide a factory class in charge of this specific filtering extension
• Declare this factory via a domain value so that it will be automatically instanciated when
building the trade filters
• Implement the various classes this factory will have to instantiate and to handle.
Trade Filter Factory
Create a class named tk.mo.<extension_name>TradeFilterFactory that implements
com.calypso.tk.mo.ITradeFilterFactory.
Register the <extension name> in the domain “TradeFilterFactories”.
Example: tk.mo.TRTradeFilterFactory.
The ITradeFilterFactory interface has the following APIs:
• String getName() - This function returns the name of the current trade factory filter. In the
above example, it would return "TR".
• List<ExtendedTradeFilterCriteriaPanel> createCriteriaPanels() - This function creates the panels
that edit the criteria related to the current factory. It is called by the trade filter window:
afterwards, the related panels will show up on the window. A factory can supply one or several
panels for editing the various criteria it handles.
• List<ExtendedTradeFilterCriterion> load(String trade_filter_name) throws PersistenceException
- This function loads from the database all the criteria provided by the current trade filter
factory and associated to trade_filter_name.
• void delete(String trade_filter_name) throws PersistenceException - This function deletes from
database all the criteria provided by the current trade filter factory and associated to
trade_filter_name.
This API introduces 2 classes: ExtendedTradeFilterCriterion and ExtendTradeFilterCriteriaPanel, which
are detailed in the following section.
Classes for Extended Criteria
When extending a trade filter that targets specific tables (such as Trade Repository tables, Hedge
Accounting tables and so long), you need to provide:
− The additional criteria for filtering the trades against those specific tables: each of these criteria
must extend the superclass ExtendedTradeFilterCriterion
− The panel(s) in charge of editing those additional criteria within the trade filter window: each of
these panel must extend the abstract class ExtendedTradeFilterCriteriaPanel
The abstract class ExtendedTradeFilterCriterion provides a single abstract function which should be
implemented by any kinds of additional trade filter criterion customers wish to supply with their
factory.
This function is:
• void save() throws PersistenceException - This function saves the current criterion into the
database. It should throw a PersistenceException instance in case of failure.
The abstract class ExtendedTradeFilterCriteriaPanel provides the 2 following abstract functions which
should be implemented by any additional panels provided by the factory:
• boolean show(ExtendedTradeFilterCriterion criterion) - This function displays and edits the
given criterion whenever possible: it should return false if it is not intended for the given
criterion and true if it accepts and displays the criterion. A single panel might be able to edit
several criteria.
The broad picture of the role of this function is the following. A trade filter might be including
several extended criteria implementing ExtendedTradeFilterCriterion. Each of these criterion
via its name must relate to a given criteria factory. This factory comes up with a set of panels
implementing ExtendedTradeFilterCriteriaPanel: the factory will display the criterion by finding
the panel that accepts the criterion. A failure to find the factory or a failure of the factory to
display the criterion (no accepting panel found) will generate an error in the log and an
exception in the back-office task window.
• List<ExtendedTradeFilterCriterion> generateCriteria(String filter_name) - Generates and
returns all the extended criteria presently edited by the panel. The trade filter name is
provided so that the panel does not need to record it. This function is called when saving a
trade filter from the trade window. When the panel is not editing any criteria, it should return
an empty list.
17.6.2Creating a Custom Trade Filter Attribute
Follow the steps below to create a custom Trade Filter attribute:
1. Create a class named tk.mo.CustomCriterion<name> that implements
com.calypso.tk.mo.CustomCriterion.
When implementing a custom attribute, you can decide whether to generate the SQL clause or
not. The SQL clause will be appended to the Trade Filter SQL statement for loading trades.
Generating the SQL clause allows loading trades more efficiently. However, in cases where
generating the SQL clause is not feasible, you can let the accept() method in TradeFilter doing
the filtering on the loaded trades.
This class will be invoked from com.calypso.tk.mo.CustomCriterion.
2. Register the new attribute in the “customCriterion” domain.
3. Create a custom panel for the new attribute as described in the following section.
17.6.3Creating a Custom Attribute Panel
Create a class named apps.refdata.<attribute_name>Panel that implements the interface
com.calypso.apps.refdata.CustomCriterionPanelInterface.
<attribute_name>Panel is invoked from com.calypso.apps.refdata.TradeFilterWindow.
|
|
Position Based Products | 17.6.1Position Based Products
The domain “PositionBasedProducts” contains a list of products that return true in their
implementation of isPositionBased(). This list is used internally for excluding the trades whose products
are position based from trade filters with that criteria.
This list is not to be modified, and should include at most all products that are position based
products. Including products which return false from their isPositionBased() implementations will result
in incorrect behavior when loaded through trade filters with the property setIncludePositionBased to
false.
Not including all position based products in this list will only result in lower performance and higher
memory requirements when loading trade filters with the property setIncludePositionBased to false.
|
|
Extending the Trade Filter Mechanism | 17.6.1Extending the Trade Filter Mechanism
This is the recommended approach to extend trade filters.
To extend the trade filter mechanism, you need to:
• Provide a factory class in charge of this specific filtering extension
• Declare this factory via a domain value so that it will be automatically instanciated when
building the trade filters
• Implement the various classes this factory will have to instantiate and to handle.
Trade Filter Factory
Create a class named tk.mo.<extension_name>TradeFilterFactory that implements
com.calypso.tk.mo.ITradeFilterFactory.
Register the <extension name> in the domain “TradeFilterFactories”.
Example: tk.mo.TRTradeFilterFactory.
The ITradeFilterFactory interface has the following APIs:
• String getName() - This function returns the name of the current trade factory filter. In the
above example, it would return "TR".
• List<ExtendedTradeFilterCriteriaPanel> createCriteriaPanels() - This function creates the panels
that edit the criteria related to the current factory. It is called by the trade filter window:
afterwards, the related panels will show up on the window. A factory can supply one or several
panels for editing the various criteria it handles.
• List<ExtendedTradeFilterCriterion> load(String trade_filter_name) throws PersistenceException
- This function loads from the database all the criteria provided by the current trade filter
factory and associated to trade_filter_name.
• void delete(String trade_filter_name) throws PersistenceException - This function deletes from
database all the criteria provided by the current trade filter factory and associated to
trade_filter_name.
This API introduces 2 classes: ExtendedTradeFilterCriterion and ExtendTradeFilterCriteriaPanel, which
are detailed in the following section.
Classes for Extended Criteria
When extending a trade filter that targets specific tables (such as Trade Repository tables, Hedge
Accounting tables and so long), you need to provide:
− The additional criteria for filtering the trades against those specific tables: each of these criteria
must extend the superclass ExtendedTradeFilterCriterion
− The panel(s) in charge of editing those additional criteria within the trade filter window: each of
these panel must extend the abstract class ExtendedTradeFilterCriteriaPanel
The abstract class ExtendedTradeFilterCriterion provides a single abstract function which should be
implemented by any kinds of additional trade filter criterion customers wish to supply with their
factory.
This function is:
• void save() throws PersistenceException - This function saves the current criterion into the
database. It should throw a PersistenceException instance in case of failure.
The abstract class ExtendedTradeFilterCriteriaPanel provides the 2 following abstract functions which
should be implemented by any additional panels provided by the factory:
• boolean show(ExtendedTradeFilterCriterion criterion) - This function displays and edits the
given criterion whenever possible: it should return false if it is not intended for the given
criterion and true if it accepts and displays the criterion. A single panel might be able to edit
several criteria.
The broad picture of the role of this function is the following. A trade filter might be including
several extended criteria implementing ExtendedTradeFilterCriterion. Each of these criterion
via its name must relate to a given criteria factory. This factory comes up with a set of panels
implementing ExtendedTradeFilterCriteriaPanel: the factory will display the criterion by finding
the panel that accepts the criterion. A failure to find the factory or a failure of the factory to
display the criterion (no accepting panel found) will generate an error in the log and an
exception in the back-office task window.
• List<ExtendedTradeFilterCriterion> generateCriteria(String filter_name) - Generates and
returns all the extended criteria presently edited by the panel. The trade filter name is
provided so that the panel does not need to record it. This function is called when saving a
trade filter from the trade window. When the panel is not editing any criteria, it should return
an empty list.
|
|
Creating a Custom Trade Filter Attribute | 17.6.2Creating a Custom Trade Filter Attribute
Follow the steps below to create a custom Trade Filter attribute:
1. Create a class named tk.mo.CustomCriterion<name> that implements
com.calypso.tk.mo.CustomCriterion.
When implementing a custom attribute, you can decide whether to generate the SQL clause or
not. The SQL clause will be appended to the Trade Filter SQL statement for loading trades.
Generating the SQL clause allows loading trades more efficiently. However, in cases where
generating the SQL clause is not feasible, you can let the accept() method in TradeFilter doing
the filtering on the loaded trades.
This class will be invoked from com.calypso.tk.mo.CustomCriterion.
2. Register the new attribute in the “customCriterion” domain.
3. Create a custom panel for the new attribute as described in the following section.
|
|
Creating a Custom Attribute Panel | 17.6.3Creating a Custom Attribute Panel
Create a class named apps.refdata.<attribute_name>Panel that implements the interface
com.calypso.apps.refdata.CustomCriterionPanelInterface.
<attribute_name>Panel is invoked from com.calypso.apps.refdata.TradeFilterWindow.
|
|
Creating a Custom Trade Filter Validator | 17.6.4Creating a Custom Trade Filter Validator
To validate the contents of a Trade Filter prior to saving it, create a class named
apps.refdata.CustomTradeFilterValidator that implements the interface
com.calypso.apps.refdata.CustomTradeFilterValidator.
• Method – isValidInput performs validation of Trade Filter fields.
• Parameters:
− TradeFilter tradefilter — The name of the Trade Filter.
− Frame w — The Trade Filter window handle to use for editing.
− Vector messages — A Vector of string messages that the method can attach messages for
the user.
• Returns:
− False — Save not permitted.
− True — Save premitted
CustomTradeFilterValidator is invoked from com.calypso.apps.refdata.TradeFilterWindow.
Sample Code in calypsox/apps/refdata/
CustomTradeFilterValidator.java
|
|
Applying Custom Validation to a Fee Grid | 17.7 Applying Custom Validation to a Fee Grid
Create a class named apps.refdata.CustomFeeGridValidator that implements
com.calypso.apps.refdata.FeeGridValidator.
CustomFeeGridValidator is invoked from com.calypso.apps.refdata.FeeGridWindow.
17.8 CFD
How CFDs are used
17.8.1How to Apply Custom Validation to a CFDContractDefinition
Create a class named apps.refdata.CustomCFDContractValidator which implements the interface
com.calypso.apps.refdata.CFDContractValidator.
This class will be invoked from com.calypso.apps.refdata.CFDContractWindow.
|
|
How to Apply Custom Validation to a CFDContractDefinition | 17.8.1How to Apply Custom Validation to a CFDContractDefinition
Create a class named apps.refdata.CustomCFDContractValidator which implements the interface
com.calypso.apps.refdata.CFDContractValidator.
This class will be invoked from com.calypso.apps.refdata.CFDContractWindow.
|
|
How to Apply Custom Validation to a CFDCountryGrid | 17.8.2How to Apply Custom Validation to a CFDCountryGrid
Create a class named apps.refdata.CustomCFDCountryGridValidator which implements the
interface com.calypso.apps.refdata.CFDCountryGridValidator.
This class will be invoked from com.calypso.apps.refdata.CFDCountryGridWindow.
|
|
Audit and Authorization | 17.9 Audit and Authorization
|
|
How to make a Class Auditable and Authorizable | 17.9.1How to make a Class Auditable and Authorizable
Auditable means that all changes to an object such as INSERT, AMEND and REMOVE are recorded
with the following information:
• What has changed in the object
• When was the object changed
• Who made the changes
Authorizable means that when an object is changed, another user has to authorize the changes.
The Audit mode is activated by default. The activation of the Authorization mode is done in the start
script of the Data Server. Refer to the Calypso System Guide for details.
Overview of Steps
• Step 1 — Create a class that implements Auditable or Authorizable (which in turn extends
Auditable)
• Step 2 — Make the class persistent
• Step 3 —Register the class for audit and authorization
Step 1 — Create a class that implements Auditable or Authorizable.
Create a class that implements com.calypso.tk.core.Auditable for audit only, or
com.calypso.tk.core.Authorizable for both audit and authorization.
Audit
Implement the following methods on Auditable:
• doAudit()
• undo()
• clone()
• getVersion()
• setVersion()
• getUser()
• setUser()
The following variables must be defined:
• int version
• String user
Authorization
Implement the following methods on Authorizable:
• getId()
• setId()
• diff()
• apply()
• getAuthName()
The following variable must be defined:
• int id
Step 2 — Make the class persistent.
To make the class persistent, create a class that extends com.calypso.tk.core.sql.AuditSQL for
audit only, or com.calypso.tk.core.sql.AuthorizableSQL for both audit and authorization.
The following methods must be overloaded in your SQL class:
• save()
• remove()
• find()
The database table does not need any field to store audit information. This is all taken care of by
Calypso using bo_audit. However the table needs the following:
• A unique identifier, preferably an integer
• A version number (Calypso will control the versioning for you)
Database scripts:
samples/cookbook/le_limit.sql (Sybase)
samples/cookbook/le_limit_Oracle.sql (Oracle)
Step 3 — Registering the Class for Audit and Authorization
The class name should be registered in the classAuditMode domain for audit, and in the
classAuthMode domain for authorization.
|
|
How to Create a Custom Authorization Window | 17.9.2How to Create a Custom Authorization Window
The default Authorization Window is com.calypso.apps.refdata.AuthorizationWindow.
Create a class named apps.refdata.<name>AuthViewer that implements
com.calypso.apps.refdata.AuthViewer.
This class will be invoked from com.calypso.apps.refdata.AuthViewerUtil.
|
|
How to Customize the Pending Modifications Window | 17.9.3How to Customize the Pending Modifications Window
To customize a given entity display of the pending modifications, create a class named
apps.refdata.<entity>PendingModificationWindow that extends extends JPanel and implements
the interface com.calypso.apps.refdata.IPendingModificationWindow.
You can customize the display inside the build() method, and use the following methods to get the
modified fields:
PendingModificationUtil.getOldDisplayValue()
PendingModificationUtil.getNewDisplayValue()
Example: You can create a class named LegalEntityPendingModificationWindow to customize the
display of pending modifications for legal entities.
|
|
How to add Custom Authorization to a Class | 17.9.4How to add Custom Authorization to a Class
Create a class named apps.util.<class_name>CheckAuthorization that implements
com.calypso.apps.util.CheckAuthorization.
This class will be invoked from com.calypso.tk.refdata.AccessUtil.
|
|
How to Create Custom Authorization Behavior | 17.9.5How to Create Custom Authorization Behavior
You can implement a custom authorization behavior that will be invoked when clicking the Accept
button in the Authorization window.
Create a class named tk.refdata.CustomPreAuthorize that implements
CustomPreAuthorizeInterface.
17.10 Authentication
The Calypso application leverages the authentication mechanism provided by the application server.
All standalone Java clients continue to use the ConnectionUtil.connect(String user, String password,
String appName, String envName) API to authenticate and connect to the Data Server.
The authentication mechanism is configured by specifying properties in the env file.
Please refer to the Calypso Installation Guide for details.
|
|
How to add Custom Authentication | 17.10.1 How to add Custom Authentication
Custom authentication is supported as of 17 April 22 MR. Customers can implement the custom
Authentication logic into the calypso stack by following the below process.
Step 1 - Create CustomAuthenticationProvider class which has the logic. See sample code below.
Place the custom jar inside $CALYPSO_HOME/client/lib.
Step 2 - Add the fully qualified class name of CustomAuthenticationProvider in the JVM argument of
the Auth server in the deploylocalConfig.properties file. Multiple values can be provided as comma
separated.
authServer.jvmArgs.0=-Dcalypso.custom.auth.providers =
com.calypso.springboot.security.CustomAuthenticationProvider
Step 3 – Deploy the system and start the servers
Guidelines:
CustomAuthenticationProvider implements AuthenticationProvider for supporting custom auth.
• If the authentication logic is successful, then return Authentication Object or a subclass of it
populated with Username, password, and Authorities.
• If the authentication logic is Unsuccessful, then
− If the provider is mandatory throw InternalAuthenticationServiceException so that no
further AuthenticationProviders are tried.
− If the provider is optional throw AuthenticationServiceException so that other
AuthenticationProviders can be tried down the stack.
An order indicates at which position the authentication provider should be injected. Lower order
indicates higher priority. Inbuilt AuthenticationProviders with their respective position are mentioned
below. This CustomAuthenticationProvider with Order 15 will be first to authenticate.
There are empty slots in between AuthenticationProviders so that CustomAuthentication can be
injected in between the inbuilt ones if need arise.
ldapAuthenticationProvider : Order [25] {This is injected only if LDAP is enabled.}
CalypsoDefaultAuthenticationProvider256 : Order [30]
CalypsoDefaultAuthenticationProvider : Order [35]
Sample Code
package com.calypso.springboot.security;
import java.util.ArrayList;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.AuthenticationServiceException;
import
org.springframework.security.authentication.InternalAuthenticationServiceException;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
/**
@Order(15)
public class CustomAuthenticationProvider implements AuthenticationProvider {
private boolean isMandatory = false; // Set to true if this Provider is mandatory
for the users to login. Default false.
public Authentication authenticate(Authentication authentication) throws
AuthenticationException {
String name = authentication.getName();
if (supports(authentication.getClass())) {
/*
* Add the authentication Logic here. Once the custom logic validation is
* complete and the authentication is good,
* This Class should return an Authentication Object or subclass of it. In this
* example we return
*/
if (name.equals(authentication.getCredentials())) //dummy condition. Should
be replaced with actual authentication status
{
// Authentication is successful, Create the
UsernamePasswordAuthenticationToken with the name and roles.
ArrayList<GrantedAuthority> authorities = new ArrayList<>(); //Roles can
be added here as list.
return new UsernamePasswordAuthenticationToken(name,
authentication.getCredentials(), authorities);
}
if (isMandatory) {
throw new InternalAuthenticationServiceException("Authentication Failed,
Unable to process the request.");
}
else {
throw new AuthenticationServiceException("Authentication Failed");
}
}
return null;
}
public boolean supports(Class<?> authentication) {
return authentication.equals(UsernamePasswordAuthenticationToken.class);
}
}
17.11 Access Permissions
Access Permissions are checked on server side at API level for certain objects.
Please refer to Calypso Access Permissions documentation for details.
17.11.1 How to add Custom Access Permission Functions
To add a new function, add the function name to the “function” domain. If it is a restriction, add it to
the “restriction” domain instead.
For example, we add MyCheck to the “function” domain. Then in your custom code, you can check the
function using:
If AccessUtil.isAuthorized(‘MyCheck’)
17.11.2 How to Add Custom Access Permissions to a Class
Create a class named apps.util.<class_name>CheckAccess which implements the interface
com.calypso.tk.refdata.CheckAccess.
17.11.3 How to Create Custom Trade Access Permissions
Create a class named tk.refdata.CustomTradeAccess that implements the interface
com.calypso.tk.refdata.TradeAccess.
17.11.4 How to Create a Custom User Setup
To control which GUI and config properties for a given “reference user” should be duplicated when
adding a new user or changing a user’s group in the User Access Permission window.
Create a class named apps.refdata.UserSetup which implements the interface
com.calypso.apps.refdata.CustomUserSetup.
|
|
How to add Custom Access Permission Functions | 17.11.1 How to add Custom Access Permission Functions
To add a new function, add the function name to the “function” domain. If it is a restriction, add it to
the “restriction” domain instead.
For example, we add MyCheck to the “function” domain. Then in your custom code, you can check the
function using:
If AccessUtil.isAuthorized(‘MyCheck’)
|
|
How to Add Custom Access Permissions to a Class | 17.11.2 How to Add Custom Access Permissions to a Class
Create a class named apps.util.<class_name>CheckAccess which implements the interface
com.calypso.tk.refdata.CheckAccess.
|
|
How to Create Custom Trade Access Permissions | 17.11.3 How to Create Custom Trade Access Permissions
Create a class named tk.refdata.CustomTradeAccess that implements the interface
com.calypso.tk.refdata.TradeAccess.
|
|
How to Create a Custom User Setup | 17.11.4 How to Create a Custom User Setup
To control which GUI and config properties for a given “reference user” should be duplicated when
adding a new user or changing a user’s group in the User Access Permission window.
Create a class named apps.refdata.UserSetup which implements the interface
com.calypso.apps.refdata.CustomUserSetup.
|
|
How to Apply Custom Validation to User Access Permissions | 17.11.5 How to Apply Custom Validation to User Access Permissions
Create a class named tk.refdata.DefaultCustomProfileValidator which implements the interface
com.calypso.tk.refdata.CustomProfileValidator.
|
|
Scheduled Tasks | 17.12 Scheduled Tasks
Scheduled Tasks can be used to run tasks on a regular basis, such as exporting data and importing
data on a regular basis.
Out-of-the-box, Calypso provides a number of scheduled tasks described in the Calypso Scheduled
Tasks User Guide.
|
|
How to Create a Custom Scheduled Task | 17.12.1 How to Create a Custom Scheduled Task
Create a class named tk.util.ScheduledTask<name> which extends the class
com.calypso.tk.util.ScheduledTask.
Note that a scheduled task cannot be executed inside the Data Server.
[NOTES: It is not recommended to audit every data member encapsulated within a custom
ScheduledTask implementation. You should consider the following alternatives:
If you are extending ScheduledTask, override doAudit:void. In this operation you can pick and
choose the data members you wish audited.
If you want simply exclude a data member from the audit process, rename the data member
by pre-appending a double underscore to its moniker (for example, change class variable foo
to __foo)]
This class will be invoked from com.calypso.tk.util.ScheduledTask.
|
|
Adding a Custom Attribute | 17.12.2 Adding a Custom Attribute
Override the buildAttributeDefinition method, which returns a list of Attribute objects created using
the ScheduledTask.attribute static method. For example:
@Override
protected List<AttributeDefinition> buildAttributeDefinition() {
List<AttributeDefinition> attributeList =
new ArrayList<AttributeDefinition>();
attributeList.add(attribute("Test 1"));
}
The above example adds the new attribute, “Test 1.” Test 1 is then available in the Task Attributes
section:
The attributes are treated as AttributeDefinition objects and do not require “if” clauses to manipulate
the domain and most validations, and the type and domain are defined when creating the attribute
object.
The example below demontrates the creation of five test attributes, one of each data type: Plain String,
Domain Value, Boolean, Integer, Date.
@Override
protected List<AttributeDefinition> buildAttributeDefinition() {
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
List<AttributeDefinition> attributeList = new
ArrayList<AttributeDefinition>();
attributeList.add(attribute("Test String"));
attributeList.add(attribute("Test Domain").domainName("productType"));
attributeList.add(attribute("Test Boolean").booleanType());
attributeList.add(attribute("Test Int").integer());
attributeList.add(attribute("Test Date").dateFormat(dateFormat));
return attributeList;
}
The attributes appear in the Task Attributes section:
You can retrieve attribute values using the standard getAttribute method. Best practice necessitates
the use of constants for ease of use.
|
|
Customizing a Scheduled Task | 17.12.3 Customizing a Scheduled Task
How to Customize the MESSAGE_MATCHING Scheduled Task
The MESSAGE_MATCHING Scheduled Task can be used for matching external SWIFT messages. It
can be customized in the following manner.
• com.calypso.tk.util.SwiftMessageInput — Write a class called CustomSwiftMessageInput
which implements SwiftMessageInput.
• If you do not write CustomSwiftMessageInput the scheduled task reads the text file
Incomingswift.txt where the messages are separated by the separator specified in the
scheduled task attributes.
• com.calypso.tk.util.swiftparser.TagParser — For parsing YYY tag you must write
TagYYParser which implements TagParser.
• com.calypso.tk.util.swiftparser.MessageMatcher — For matching the “MT000” type of
message you will need MessageMT000Matcher which implements MessageMatcher.
• com.calypso.tk.util.swiftparser.MessageProcessor — For processing the message
MT000 (matched/unmatched) you must write MT000MessageProcessor which implements
MessageProcessor. This class gets the BOMessage created using swift, and if matched then a
BOMessage which is matched. Here you can do the final processing for that message.
How to Customize the INVENTORY_SNAPSHOT Scheduled Task
The INVENTORY_SNAPSHOT scheduled task has been modified to allow customization of the
snapshot name and to allow generating a snapshot by currency.
The constraint on the name of the customized snapshot is that the 4th character must be an
underscore (_). The following methods are now protected:
• getChangedPositionClass() — This is the method that generates the name of the snapshot.
• getDateFromSnapshot() — This method decodes the date of the snapshot from its name.
• getLatestSnapshot() — This method returns the latest snapshot name which needs to be
retained for the purge. It is called from purgeSnapshot() method. It has to be done for each
position class (Internal, client, External).
The methods getExtraCashSQL() and getExtraSecuritySQL() can also be used for adding an SQL where
clause.
|
|
Workflow Process | 18.1 Workflow Process
|
|
How to Create a Custom Exception Handler | 18.1.1How to Create a Custom Exception Handler
Create a class named tk.bo.workflow.exhandler.<exception_type>ExceptionHandler which
implements the interface com.calypso.tk.bo.workflow.ExceptionHandler.
This class will be invoked from com.calypso.tk.bo.workflow.ExceptionHandlerUtil.
|
|
How to Create a Custom KickOffDate, CutOffDate | 18.1.2How to Create a Custom KickOffDate, CutOffDate
Create a class named tk.bo.workflow.KickOffCalculator<config_name> which implements the
interface com.calypso.tk.bo.workflow.KickOffCalculator.
This class will be invoked from com.calypso.tk.bo.workflow.KickOffCalculatorUtil to override
the KickOffDate and/or CutOffDate calculation for a particular KickOffCutOffConfig.
[NOTE: For performance reasons, workflow rules are executed within the Data Server. Be very
careful to clone any objects retrieved from the Data Server prior to modifying them]
|
|
How to Create Custom Data for a Task | 18.1.3How to Create Custom Data for a Task
Create a class named tk.bo.CustomTaskInfo which implements the interface
com.calypso.tk.bo.TaskFillInfo.
This class will be invoked from com.calypso.tk.bo.TaskFillInfoUtil.
|
|
How to Create Custom Rules, Actions, and Statuses | 18.1.4How to Create Custom Rules, Actions, and Statuses
Do the following to create custom Rules, Actions, and Statuses for any workflow type:
1. Create a class named tk.bo.workflow.rule.<component_name><workflow_type>Rule that
implements the interface com.calypso.tk.bo.workflow.WfRule.
This class will be invoked from com.calypso.tk.bo.workflow.WorkflowRuleUtil.
2. Register the new workflow type in the “workflowType” domain.
3. Add the new statuses, actions, and rules to this workflow type using Configuration >
Workflow > Workflow Configuration > Domains > Entity from the Calypso Navigator as
applicable.
|
|
How to Create a Custom Workflow Rule | 18.1.5How to Create a Custom Workflow Rule
To create a custom Trade Workflow Rule, create a class named
tk.bo.workflow.rule.<rule_name>TradeRule which implements the interface
com.calypso.tk.bo.workflow.WfTradeRule.
To create a custom Message Workflow Rule, create a class named
tk.bo.workflow.rule.<rule_name>MessageRule which implements the interface
com.calypso.tk.bo.workflow.WfMessageRule.
To create a custom Transfer Workflow Rule, create a class named
tk.bo.workflow.rule.<rule_name>TransferRule which implements the interface
com.calypso.tk.bo.workflow.WfTransferRule.
[NOTE: The rule names must be registered with the appropriate workflow rule domains:
workflowRuleMessage, workflowRuleTrade, and workflowRuleTransfer]
The following methods must be implemented on the interfaces WfTradeRule, WfTransferRule and
WfMessageRule:
• check() — This method should only contain tests, and no object should be modified in this
method. The reason is that if a given transition has more than one rule, the system will first call
all the check() methods, and if all of them return true, it will call the update() methods, and then
save any object as applicable.
This method can be run on both client and data server sides. When applying a transition for
saving/updating objects, the workflow will run on the server, but if a user wants to simulate a
transition, the workflow runs on the client side.
− When loading static data, you should use BOCache, LocalCache, and the remote services
when possible. The workflow will know by itself on which side the code runs. The following
code for example, can be run on both sides.
LegalEntity po = BOCache.getLegalEntity(dsCon, transfer.getProcessingOrg());
− When loading active data, you should first check if you are running on the client or server
side to know if you must test for dbCon being null.
If dbCon is not null, you are running on the server side and you must use the SQL class.
Otherwise, you must use the remote services. Note that a DSConnection is never null, even
on the server side. Therefore, the code should be similar to :
if (dbCon != null) {
trade = TradeSQL.getTrade(id, (Connection)dbCon);
} else {
trade = dsCon.getRemoteTrade().getTrade(id);
}
• getDescription() — This method will be called from the Workflow Config window to display
information about the rule.
• update() — This method will be called by the system when all rules return true from the check()
methods. You can modify object in this method. Note that this method will always be run on
the server side. Therefore, only the dbCon can be used. For example, you can do:
TaskSQL.save(newTask, (Connection)dbCon);
Moreover, if you want to save and publish new events inside a workflow rule, that must be
done in the update() method. You must create the event and add it to the events vector that is
one of the arguments of the method. For example, you can do:
TaskSQL.save(newTask, (Connection)dbCon);
PSEventTask taskEvent = new PSEventTask();
taskEvent.setTask(newTask);
events.addElement(taskEvent);
If you want to create exception tasks, it is recommended to create BOException objects and
add them to the excps vector that is one of the arguments of the method. For example, you
can do:
BOException boExcp = new BOException(tradeId, this.getClass().getName(),
"Exception Message", BOException.INFORMATION); excps.addElement(boExcp);
These classes will be invoked from com.calypso.tk.bo.workflow.WorkflowRuleUtil.
|
|
How to Customize UpdateSettleDateTransferRule | 18.1.6How to Customize UpdateSettleDateTransferRule
You can create a class named tk.bo.workflow.rule.BOMessageValueDateControlHandler that
implements com.calypso.tk.bo.workflow.rule.IValueDateControl to customize
ValueDateControl.
This class is invoked from com.calypso.tk.bo.workflow.rule.UpdateSettleDateTransferRule.
|
|
How to Implement a Custom Workflow | 18.2 How to Implement a Custom Workflow
Calypso offers the ability to implement a workflow for any entity. We will use the LegalEntity object to
illustrate the implementation of a custom workflow.
An implementation using the Book class was also successfully implemented and tested. Note however
that the current implementation stores the entity id as an integer. This raises some issues as to the
feasibility to use classes which use a String identifier.
|
|
Entity | 18.2.1Entity
The object for which you want to implement a custom workflow must be identified as an Entity.
Implementing EntityObject
The object for which you want to implement a generic workflow must implement
com.calypso.tk.core.EntityObject.
For example, the following code was added to the class com.calypso.tk.core.LegalEntity to
become an EntityObject. New imports are needed:
import java.sql.Connection;
import com.calypso.tk.core.sql.LegalEntitySQL;
The following methods provide a simple yet sufficient implementation of EntityObject interface:
/**
New class field keeps a reference to EntityState
@see com.calypso.tk.core.EntityState
*/
protected EntityState _entityState = new EntityState();
/**
Returns a unique id for this EntityObject. Note that together with
the value returned by <code>getEntityType()</code>, the ID-type pair
must uniquely identify this Entity Object in the system.<br>
It is possible, however, for 2 or more EntityObjects to have the same
id if they have different Entity Types.
<p>
*/
public int getEntityId() { return getId(); }
/**
Returns a type that uniquely identifies this EntityObject "type".
Typically, the simplest way to implement this method is simply to
return getClass().toString(). However, this is left as an implementation
detail to permit more customization control.
*/
public String getEntityType() { return "LegalEntity"; }
/**
Returns an object that encapsulates the Workflow State for this
<code>EntityObject</code>.
*
@return the state associated to this entity object
@see com.calypso.tk.core.EntityState
*/
public EntityState getEntityState() { return _entityState; }
/**
Sets the object which encapsulates the Workflow State for this
<code>EntityObject</code>
*
@param state the workflow state to associate to this entity object.
@see com.calypso.tk.core.EntityState
*/
public void setEntityState(EntityState state) { _entityState = state; }
/**
Returns the Processing Org associated with this entity. Note
that if not applicable, the method should return "ALL", preferably.
*
*/
public String getProcessingOrg() { return “ALL”; }
It is also important to remember to update the clone(), readExternal(…), and
writeExternal(…) methods. It is straightforward but quite important to pass the
information through RMI:
public void writeExternal(ObjectOutput out) throws IOException {
...
boolean v=_entityState != null; out.writeBoolean(v);
if(v) _entityState.writeExternal(out);
}
public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
...
if(in.readBoolean()) {
entityState = new EntityState();
try {_entityState.readExternal(in);}
catch(Exception e) {
Log.error(this, e);
throw new IOException(e.getMessage());
}
}
}
Lastly, you must adjust the serialVersionUID field.
Implementing EntityPersistence
When an object goes through the workflow, the actual saving to the database is done via the
EntityObject interface. The object goes through the workflow and, if no error is raised, the object and
its state are saved to persistent data by calling EntityObjectSQL.save(EntityObject, Connection). To
properly persist your object at this point, you must implement the appropriate persistence class. For
example, if you have the following class tk.mypackage.MyObject which implements EntityObject, then
you must create tk.mypackage.sql.MyObjectSQL that implements
com.calypso.tk.core.sql.EntityPersistence. In doing so, you ensure that EntityObjectSQL is able
to save, retrieve, remove your objects properly as the object goes through the workflow.
The changes to EntityObjectSQL are minimal. For this example, the changes are made to
com.calypso.tk.core.sql.LegalEntitySQL. The idea is for the object’s associated EntityState to be
saved/removed/retrieved as needed. Hence, all methods which retrieve the LegalEntity object from
the database make a call as follows:
EntityObjectSQL.setEntityState(legalEntity, con);
Similarly, the following calls are used in the save and remove methods, respectively:
EntityObjectSQL.saveEntityState(legalEntity, con);
EntityObjectSQL.removeEntityState(legalEntity, con);
We have established an association between the LegalEntity, an entity object, and its associated
EntityState, its state. To ensure data integrity we must be sure that the memory image for the object
matches that in the database.
Modifying ReferenceDataServerImpl
You must change the API for saving the object.
For this example, we change the save(LegalEntity) method. Currently, the save operation is invoked as
follows:
int lid = LegalEntitySQL.save(legalEntity);
By changing this to the following, everything is handled in the workflow, including the actual “save”
operation:
saveEntityObject(legalEntity); int lid = legalEntity.getId();
Adding Workflow Rules
On occasion you may need to add workflow rules for triggering the workflow.
In this example, we have created a simple class
com.calypso.tk.bo.workflow.rule.CheckValidLegalEntityRule that checks various properties of a
Legal Entity to determine whether or not it is valid.
The workflow can have the following status: NONE, PENDING, or VERIFIED. The Action NEW creates
the transition from NONE to PENDING. The Action AMEND, with STP flag on, links PENDING to
VERIFIED with a call to this rule. Lastly, there is a link back from VERIFIED to PENDING, also on AMEND,
so that any changes to the LegalEntity are validated back through the rule.
|
|
Domain Data | 18.2.2Domain Data
The following domain values should be added:
• Add the entity to the “workflowType” domain. In our example, we add LegalEntity.
• Create the domain “workflowRule<entity>”. In our example, it is “workflowRuleLegalEntity”.
• Add the workflow rules that you have created to the “workflowRule<entity>” domain. In our
example, we add CheckValid to the “workflowRuleLegalEntity” domain.
|
|
Workflow | 18.2.3Workflow
Once the domain values have been set, the workflow can be configured using Configuration >
Workflow > Workflow Configuration from the Calypso Navigator.
Make sure to add the actions, rules, and status codes as applicable using the menu items under
Domain > Entity. You will be prompted to enter the entity (LegalEntity in our example).
We provide a sample configuration of the LegalEntity workflow. You must start with a clean database
and apply Demonstration Data in order to load the sample configuration.
|
|
Task Station | 18.3 Task Station
You can add custom menu items to the New Task Station by creating a class named
apps.reporting.CustomTaskMenuActions that extends
com.calypso.apps.reporting.DefaultTaskMenuActions.
To add custom columns, please refer to Calypso New Task Station documentation for information on
adding task enrichment fields.
|
|
Extension Point Factory Framework | Section 19. Extension Point Factory Framework
The Extension Point Factory provides a common mechanism to load classes that are extension points
to Calypso. Extension points in Calypso are classes that provide additional functionality. For example,
the FilterSet class can be extended to handle additional conditions by providing an implementation of
the CustomFilterInterface.
Prior to the Extension Point Factory, the approach was to simply attempt loading a well known class
name. If the class loaded, then obviously the extension is available. However, if an extension did not
load and run, there was no means to determine the cause. The application returned a Null in both
cases, when the load failed or if the class was missing.
Using the Extension Point Factory, it is possible to determine an exact cause of failure. In the event of a
failure, a log entry is made with detailing the problem. An incorrect assignable type, a failure to load,
or a missing class file all result in a throwable RuntimeException and a log entry to that effect.
public Object getExtensionPoint(Class theType, String extensionName, String
defaultExtensionClassname)
Where:
• theType - The type expected for the extension class.
• extensionName - The name of the extension point without the package prefix.
• defaultExtensionClassname – To be set with or without backward compatibility.
− No Backward compatibility:
Set to Null. This forces users to specify the extension point’s classname (either fully
qualified or without the package prefix) in a property name having the form:
extensionName_EXTENSION_CLASSNAME where extensionName is the class name
without the package prefix.
On failure, a Null is returned and a RuntimeException is thrown and a log entry is made
(wrong assignable type or extension point not found).
On success, ExtensionPointFactory returns an instance of the extension type associated
with the extensionName.
− Support Backward Compatibility:
Set to the extension point’s classname (either fully qualified or with the package prefix). For
example, CustomFilter, tk.marketdata.CustomFilter, or
client.tk.marketdata.CustomFilter.
If ExtensionPointFactory does not find an explicitly named in the application’s properties
file, it then attempts to load the classname specified by defaultExtensionClassname.
On failure, a Null is returned and a “failed to load” log entry is made.
On success, ExtensionPointFactory returns an instance of the extension type associated
with the extensionName.
|
|
How to Customize the Login Dialog | 20.1 How to Customize the Login Dialog
The following section allows you to add custom panels to the login dialog. These panels are for display
use only, and do not modify the form inputs.
Create a class named tk.util.ClientVersion that implements
com.calypso.tk.util.ClientVersionInterface.
This class will be invoked from com.calypso.apps.util.CalypsoLoginDialog.
|
|
How to Customize Password Encryption – Login | 20.2 How to Customize Password Encryption – Login
Login passwords are encrypted and stored in the database. A salt hashing encryption mechanism is
used for those users who have created or reset their password in v15.1 or higher, otherwise a non-salt
mechanism is used.
For salt hashing only, you can create a custom DigestCallback implementation from
org.jboss.crypto.digest.DigestCallback interface.
Compile the custom code and include the custom jars in the custom-shared-lib.
Then specify it in the DIGEST_CALLBACK environment property.
|
|
How to Customize Password Encryption – Environment Files | 20.3 How to Customize Password Encryption – Environment Files
Passwords stored in the Calypso environment property files can be encrypted. The encryption
mechanism to use can be customized.
Create a class that implements com.calypso.tk.core.CalypsoEncrypter and specify the class name
in the environment property ENCRYPTION_CLASS.
|
|
How to Customize Password Validation | 20.4 How to Customize Password Validation
You can create a class named tk.refdata.CustomPasswordValidator that extends
com.calypso.tk.refdata.PasswordValidator.
|
|
How to Create Custom Version Information | 20.5 How to Create Custom Version Information
Create a class named tk.util.ClientVersion that implements
com.calypso.tk.util.ClientVersionInterface.
This class will be invoked from com.calypso.apps.util.CalypsoLoginDialog.
|
Subsets and Splits