PSP核心 - Row Set Transformation Toolkit 之方法简单例子与调试
准备:
上图简单描述PSP Engine的流程,本文只对Row Set Transformation Toolkit的方法做简单的例子,也就是上图虚线内的流程做模拟,其他信息请参照Bookself。
1, 数据在Table上,BC以上都是通过各种数据结构存在于内存中,经过转换预算,又写回到Table。
2, Variable Maps对数据的一种抽象,对于不用的数据来源(例如,来自Quote,Order Entry - Orders)都表现为一致性。可能坚固抽象性,导致Variable Maps没有层级结构。
在调试阶段我们可以XML来构造Property Set
XML2PropertySet 例子:
function GetPropertySet(fileName) { var rowSet = ""; try { var xmlReader = TheApplication().GetService("EAI XML Read from File"); var vInputs = TheApplication().NewPropertySet(); var vOutputs = TheApplication().NewPropertySet(); vInputs.SetProperty("FileName",fileName); xmlReader.InvokeMethod("ReadPropSet",vInputs,vOutputs); rowSet = vOutputs.GetChild(0); } catch(e) { throw e.message; } finally { xmlReader = null; vInputs = null; vOutputs = null; } return rowSet;
} |
Aggregate Transform 例子:
function TestAggregateSum() { try { var pspBS = TheApplication().GetService("Row Set Transformation Toolkit"); var vInputs = TheApplication().NewPropertySet(); var vOutputs = TheApplication().NewPropertySet();
var rowset:PropertySet = GetPropertySet("D:\\rowset_aggregate_sum.xml");
rowset.SetType("Row Set"); vInputs.AddChild(rowset);
var outputRowset:PropertySet = TheApplication().NewPropertySet();
outputRowset.SetType("Output Row Set"); vInputs.AddChild(outputRowset);
vInputs.SetProperty("Aggregate Field","Quantity"); vInputs.SetProperty("Aggregate Type","Sum"); vInputs.SetProperty("Group By","Product");
pspBS.InvokeMethod("Aggregate Transform",vInputs,vOutputs); } catch(e) { throw e.message; } finally { pspBS = null; vInputs = null; vOutputs = null; } } |
rowset_aggregate_sum.xml:
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage Mode="Quote" RowScope="All">Rowset <Line_spcItem Quantity="12" Quotation="100" Product="PD001" Currency_spcCode="USD">1-00001</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD001" Currency_spcCode="USD">1-00002</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD002" Currency_spcCode="USD">1-00003</Line_spcItem> </SiebelMessage> </PropertySet> |
Conditional Action Transform 例子:
function TestConditional() { try { var pspBS = TheApplication().GetService("Row Set Transformation Toolkit"); var vInputs = TheApplication().NewPropertySet(); var vOutputs = TheApplication().NewPropertySet();
var rowset:PropertySet = GetPropertySet("D:\\rowset_conditional.xml");
rowset.SetType("Row Set"); vInputs.AddChild(rowset);
var contextRowSet:PropertySet = GetPropertySet("D:\\context_conditional.xml");
contextRowSet.SetType("Context"); vInputs.AddChild(contextRowSet);
var ouputRowSet:PropertySet = TheApplication().NewPropertySet();
ouputRowSet.SetType("Ouput Row Set"); vInputs.AddChild(ouputRowSet);
vInputs.SetProperty("Condition 1","{Row.Currency Code} is null"); vInputs.SetProperty("On True 1_1","{Row.Currency Code} = {Context.Currency Code}");
pspBS.InvokeMethod("Conditional Action Transform",vInputs,vOutputs); } catch(e) { throw e.message; } finally { pspBS = null; vInputs = null; vOutputs = null; } } |
rowset_conditional.xml :
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage Mode="Quote" RowScope="All">Rowset <Line_spcItem Quantity="12" Quotation="100" Product="PD001" Currency_spcCode="CNY">1-00001</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD001" Currency_spcCode="">1-00002</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD002" Currency_spcCode="">1-00003</Line_spcItem> </SiebelMessage> </PropertySet> |
context_conditional.xml:
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage CPScope="Whole" Mode="Quote" RowScope="All">Context <Header Revision="1" Account="OTC Test Account" Currency_spcCode="USD" Header_spcId="1-2Z61FU" Mode="Quote" Exchange_spcDate="08/01/2012" Quotation_spcTotal_spcAmount="0" Price_spcList_spcId="1-Q2V-1" Account_spcType="Customer">1-2Z61FU </Header> </SiebelMessage> </PropertySet> |
Dynamic Look-Up Transform 例子:
function TestDynamicLookUp() { try { var pspBS = TheApplication().GetService("Row Set Transformation Toolkit"); var vInputs = TheApplication().NewPropertySet(); var vOutputs = TheApplication().NewPropertySet();
var rowset:PropertySet = GetPropertySet("D:\\rowset_DynamicLookUp.xml");
rowset.SetType("Row Set"); vInputs.AddChild(rowset);
var outputRowset:PropertySet = TheApplication().NewPropertySet();
outputRowset.SetType("Output Row Set"); vInputs.AddChild(outputRowset);
vInputs.SetProperty("Dynamic Matrix Name","Hand Tester Matrices"); vInputs.SetProperty("On First Match 1","{Row.Cal Quotation} = AdjustPrice({Row.Quotation},{Row.Currency Code},{Match.Adjustment Type},{Match.Adjustment Amount},{Match.Currency Code},{Match.Exchange Date})");
pspBS.InvokeMethod("Dynamic Look-Up Transform",vInputs,vOutputs); } catch(e) { throw e.message; } finally { pspBS = null; vInputs = null; vOutputs = null; } } |
rowset_DynamicLookUp.xml:
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage Mode="Quote" RowScope="All">Rowset <Line_spcItem Quantity="12" Quotation="100" Product="PD001" Product_spcType="Configurator" Cal_spcQuotation="" Currency_spcCode="USD">1-00001</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD001" Product_spcType="Component" Cal_spcQuotation="" Currency_spcCode="USD">1-00002</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD002" Product_spcType="Component" Cal_spcQuotation="" Currency_spcCode="USD">1-00003</Line_spcItem> </SiebelMessage> </PropertySet> |
注:该方法参数Dynamic Matrix Name 匹配 PSP Dynamic Matrix的Name 字段,所以要在以下界面维护数据。
Dynamic Subprocedure 例子:
Passed
Hierarchical Look-Up Transform 例子:
该例子使用了聚合计算,叠加父节点的计算。
function TestHierarchicalLookUp() { try { var pspBS = TheApplication().GetService("Row Set Transformation Toolkit"); var vInputs = TheApplication().NewPropertySet(); var vOutputs = TheApplication().NewPropertySet();
var rowset:PropertySet = GetPropertySet("D:\\rowset_HierarchicalLookUp.xml");
rowset.SetType("Row Set"); vInputs.AddChild(rowset);
var outputRowset:PropertySet = TheApplication().NewPropertySet();
outputRowset.SetType("Output Row Set"); vInputs.AddChild(outputRowset);
vInputs.SetProperty("Business Object","Adjustment Group"); vInputs.SetProperty("Business Component","Product-Based Adjustment"); vInputs.SetProperty("Hierarchy Business Object","Account"); vInputs.SetProperty("Hierarchy Business Component","Account"); vInputs.SetProperty("HBC Parent Field","Parent Account Id"); vInputs.SetProperty("HBC Id Field","Id"); vInputs.SetProperty("BC Id Field","Account Id"); vInputs.SetProperty("Row Id Field","Account Id"); vInputs.SetProperty("On Match 1","{Row.Quotation} = ToNumber({Row.Quotation})+ToNumber({Match.Adjustment Amount})"); pspBS.InvokeMethod("Hierarchical Look-Up Transform",vInputs,vOutputs); } catch(e) { throw e.message; } finally { pspBS = null; vInputs = null; vOutputs = null; } } |
rowset_HierarchicalLookUp.xml :
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage Mode="Quote" RowScope="All">Rowset <Line_spcItem Quantity="12" Quotation="100" Product="PD001" Currency_spcCode="USD" Account_spcId="9SIA-9US5O">1-00001</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD001" Currency_spcCode="USD" Account_spcId="9SIA-9US5I">1-00002</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD002" Currency_spcCode="USD" Account_spcId="9SIA-9US59">1-00003</Line_spcItem> </SiebelMessage> </PropertySet> |
Hierarchical Transform 例子:
function TestHierarchical() { try { var pspBS = TheApplication().GetService("Row Set Transformation Toolkit"); var vInputs = TheApplication().NewPropertySet(); var vOutputs = TheApplication().NewPropertySet();
var rowset:PropertySet = GetPropertySet("D:\\rowset_Hierarchical.xml");
rowset.SetType("Row Set"); vInputs.AddChild(rowset);
var outputRowset:PropertySet = TheApplication().NewPropertySet();
outputRowset.SetType("Output Row Set"); vInputs.AddChild(outputRowset);
vInputs.SetProperty("Row Id Field","Id"); vInputs.SetProperty("Parent Field","Parent Item Id"); vInputs.SetProperty("Direction","Up"); vInputs.SetProperty("On Leaf Row 1","{Row.Total Amount} = {Row.Quotation}"); vInputs.SetProperty("On Parent Row 1","{Row.Rollup Amount} = ToNumber(Sum({Children},'Total Amount'))"); vInputs.SetProperty("On Parent Row 2","{Row.Total Amount} = ToNumber({Row.Quotation}) +ToNumber({Row.Rollup Amount})");
pspBS.InvokeMethod("Hierarchical Transform",vInputs,vOutputs); } catch(e) { throw e.message; } finally { pspBS = null; vInputs = null; vOutputs = null; } } |
rowset_Hierarchical.xml :
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage Mode="Quote" RowScope="All">Rowset <Line_spcItem Id="1-00001" Quantity="12" Quotation="100" Product="PD001" Parent_spcItem_spcId="" Currency_spcCode="USD">1-00001</Line_spcItem> <Line_spcItem Id="1-00002" Quantity="13" Quotation="100" Product="PD001" Parent_spcItem_spcId="1-00001" Currency_spcCode="USD">1-00002</Line_spcItem> <Line_spcItem Id="1-00003" Quantity="13" Quotation="100" Product="PD002" Parent_spcItem_spcId="1-00001" Currency_spcCode="USD">1-00003</Line_spcItem> <Line_spcItem Id="1-00004" Quantity="13" Quotation="100" Product="PD002" Parent_spcItem_spcId="1-00002" Currency_spcCode="USD">1-00004</Line_spcItem> </SiebelMessage> </PropertySet> |
Merge Transform 例子:
Passed
Query Transform 例子:
Passed
Row Set Look-Up Transform 例子:
function TestRowsetLookup() { try { var pspBS = TheApplication().GetService("Row Set Transformation Toolkit"); var vInputs = TheApplication().NewPropertySet(); var vOutputs = TheApplication().NewPropertySet();
var rowset:PropertySet = GetPropertySet("D:\\rowset_RowsetLookup.xml");
rowset.SetType("Row Set"); vInputs.AddChild(rowset);
var lookupRowset:PropertySet = GetPropertySet("D:\\rowset_RowsetLookup_rowset.xml");
lookupRowset.SetType("Match Row Set"); vInputs.AddChild(lookupRowset);
vInputs.SetProperty("Search Specification","{Row.Product} = {Match.Product}"); vInputs.SetProperty("On Match 1","{Row.Quotation} = ToNumber({Row.Quotation}) +ToNumber({Match.Adjustment Amount})");
pspBS.InvokeMethod("Row Set Look-Up Transform",vInputs,vOutputs); } catch(e) { throw e.message; } finally { pspBS = null; vInputs = null; vOutputs = null; } } |
rowset_RowsetLookup.xml :
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage Mode="Quote" RowScope="All">Rowset <Line_spcItem Quantity="12" Quotation="100" Product="PD001" Currency_spcCode="CNY">1-00001</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD002" Currency_spcCode="">1-00002</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD003" Currency_spcCode="">1-00003</Line_spcItem> </SiebelMessage> </PropertySet> |
rowset_RowsetLookup_rowset.xml :
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage>Rowset <Line_spcItem Product="PD001" Adjustment_spcAmount="10"></Line_spcItem> <Line_spcItem Product="PD002" Adjustment_spcAmount="20"></Line_spcItem> <Line_spcItem Product="PD003" Adjustment_spcAmount="30"></Line_spcItem> <Line_spcItem Product="PD004" Adjustment_spcAmount="40"></Line_spcItem> <Line_spcItem Product="PD002" Adjustment_spcAmount="50"></Line_spcItem> </SiebelMessage> </PropertySet> |
Rule Set Look-Up Transform 例子:
Passed
Simple Look-Up Transform 例子:
Passed
Split Transform 例子:
function TestSplit() { try { var pspBS = TheApplication().GetService("Row Set Transformation Toolkit"); var vInputs = TheApplication().NewPropertySet(); var vOutputs = TheApplication().NewPropertySet();
var rowset:PropertySet = GetPropertySet("D:\\rowset_Split.xml");
rowset.SetType("Row Set"); vInputs.AddChild(rowset);
var onTrueRowset:PropertySet = TheApplication().NewPropertySet();
onTrueRowset.SetType("True Row Set"); vInputs.AddChild(onTrueRowset);
var onFalseRowset:PropertySet = TheApplication().NewPropertySet();
onFalseRowset.SetType("False Row Set"); vInputs.AddChild(onFalseRowset);
vInputs.SetProperty("Condition","{Row.Product Type} = 'Component'");
pspBS.InvokeMethod("Split Transform",vInputs,vOutputs); } catch(e) { throw e.message; } finally { pspBS = null; vInputs = null; vOutputs = null; } } |
rowset_Split.xml:
<?xml version="1.0" encoding="UTF-8"?> <?Siebel-Property-Set EscapeNames="true"?> <PropertySet> <SiebelMessage Mode="Quote" RowScope="All">Rowset <Line_spcItem Quantity="12" Quotation="100" Product="PD001" Product_spcType="Component" Currency_spcCode="USD">1-00001</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD001" Product_spcType="Configurator" Currency_spcCode="USD">1-00002</Line_spcItem> <Line_spcItem Quantity="13" Quotation="100" Product="PD002" Product_spcType="Configurator" Currency_spcCode="USD">1-00003</Line_spcItem> </SiebelMessage> </PropertySet> |