外部调出 API 示例
1.
使用以下内容创建一个名为 GetCreditScore.java 的文件。此文件假定具有一个用于从建模应用程序中访存分数且名为 ScoreQueryUtility 的类。
import java.util.Map;
import com.unicacorp.interact.session.AudienceId;
import com.unicacorp.interact.flowchart.macrolang.storedobjs.IAffiniumExternalCallout;
import com.unicacorp.interact.flowchart.macrolang.storedobjs.CalloutException;
import java.util.Random;

public class GetCreditScore implements IAffiniumExternalCallout
{
// the class that has the logic to query an external system for a customer’s credit score
private static ScoreQueryUtility scoreQueryUtility;
public void initialize(Map<String, String> configurationData) throws CalloutException
{
// configurationData has the key- value pairs specific to the environment the server is running in
// initialize scoreQueryUtility here
}

public void shutdown(Map<String, String> configurationData) throws CalloutException
{
// shutdown scoreQueryUtility here
}

public int getNumberOfArguments()
{
// do not expect any additional arguments other than the customer’s id
return 0;
}

public List<String> getValue(AudienceId audienceId, Map<String, String> configurationData,
Object... arguments) throws CalloutException
{
Long customerId = (Long) audienceId.getComponentValue("Customer");
// now query scoreQueryUtility for the credit score of customerId
Double score = scoreQueryUtility.query(customerId);
String str = Double.toString(score);
List<String> list = new LinkedList<String>();
list.add(str);
return list;
}
}
2.
GetCreditScore.java 编译为 GetCreditScore.class
3.
创建一个名为 creditscore.jar 的文件,其中包含 GetCreditScore.class 及其使用的其他类文件。
4.
5.
在“管理配置”页面上的 externalCallouts 类别中,创建一个名称为 GetCreditScore 并且类路径为 /data/interact/creditscore.jar 的外部调出。
6.
在交互式流程图中,调出可以用作 EXTERNALCALLOUT(‘GetCreditScore’)