Public/Get-SolveID.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
function Get-SolveID {
  <#
    .SYNOPSIS
    Get solve ID
 
    .DESCRIPTION
    Wrapper function to retrieve the unique identifier of an analysi using the RiskPro batch client
 
    .PARAMETER JavaPath
    The optional java path parameter corresponds to the path to the Java executable file. If not specified, please ensure that the path contains the Java home.
 
    .PARAMETER RiskProBatchClient
    The RiskPro batch client parameter corresponds to the path to the RiskPro batch client JAR file.
 
    .PARAMETER ServerURI
    The server URI parameter corresponds to the Uniform Resource Identifier (URI) of the RiskPro server.
 
    .PARAMETER Credentials
    The credentials parameter corresponds to the credentials of the RiskPro account to use for the operation.
 
    .PARAMETER JavaOptions
    The optional Java options parameter corresponds to the additional Java options to pass to the Java client.
 
    .PARAMETER Model
    The model parameter corresponds to the name model containing the analysis to check.
 
    .PARAMETER Solve
    The solve parameter corresponds to the name of the analysis to check.
 
    .PARAMETER Kind
    The kind parameter corresponds to the kind of the analysis to check.
    The available values are the following (see technical reference):
    - BACKTESTING: VaR Backtesting
    - CLEAN_ROLLUP: Cleaning of rollup results
    - CONTRACT_AGGREGATION: Contract aggregation
    - CONTRACT_SELECTION: Contract selection
    - COVARIANCE_MATRIX_GENERATION: Covariance matrix generation
    - CREDIT_SCORING_DATA_LOADER: Credit score data loading
    - DYNAMIC_MC: Dynamic Monte-Carlo analysis
    - DYNAMIC: Dynamic analysis
    - FINANCIAL_STUDIO_LOADER: FDA loading
    - FLAT_FILE_LOADER: V2.6 flat file loading
    - GENESIS_LOADER: DataFoundation loading
    - INCREMENTAL_RESULT_AGGREGATION: Incremental analysis aggregation
    - MC_SCENARIO: Monte-Carlo scenario generation
    - MODEL_EXPORT: Model export
    - MODEL_IMPORT: Model import
    - PDF_REPORT: PDF report export
    - PROSPECTIVE_HEDGE_TEST: Prospective hedge testing
    - RESULT_AGGREGATION: Analysis aggregation
    - RETROSPECTIVE_HEDGE_TEST: Retrospective hedge testing
    - RISK_METRICS: RiskMetric matrix loading
    - ROLLUP: Rollup
    - SCENARIO_REPORT: Scenario report
    - SELECTION_REPORT: Selection report
    - STATIC_SCENARIO: Static scenario generation
    - STATIC_VAR_SCENARIO: Static VaR scenario generation
    - STATIC: Static analysis
    - WHATIF_SCENARIO: What-if scenario generation
    - XL_IMPORT: Excel import
    - XL_REPORT: Excel report export
    - XL_TEMPLATE_REPORT: Excel template reporting
 
    .PARAMETER Synchronous
    The synchonous switch defines if the operation should be run in synchronous mode.
 
    .NOTES
    File name: Get-SolveID.ps1
    Author: Florian CARRIER
    Creation date: 23/10/2019
    Last modified: 21/01/2020
    TODO Add parameter validation
                    Parse output and retrieve model ID
  #>

  [CmdletBinding (
    SupportsShouldProcess = $true
  )]
  Param(
    [Parameter (
      Position    = 1,
      Mandatory   = $false,
      HelpMessage = "Java path"
    )]
    [ValidateNotNullOrEmpty ()]
    [String]
    $JavaPath,
    [Parameter (
      Position    = 2,
      Mandatory   = $true,
      HelpMessage = "RiskPro batch client path"
    )]
    [ValidateNotNullOrEmpty ()]
    [Alias ("Path", "RiskProPath")]
    [String]
    $RiskProBatchClient,
    [Parameter (
      Position    = 3,
      Mandatory   = $true,
      HelpMessage = "RiskPro server URI"
    )]
    [ValidateNotNullOrEmpty ()]
    [String]
    $ServerURI,
    [Parameter (
      Position    = 4,
      Mandatory   = $true,
      HelpMessage = "Credentials of the user"
    )]
    [ValidateNotNullOrEmpty ()]
    [System.Management.Automation.PSCredential]
    $Credentials,
    [Parameter (
      Position    = 5,
      Mandatory   = $false,
      HelpMessage = "Java options"
    )]
    [ValidateNotNullOrEmpty ()]
    [String[]]
    $JavaOptions,
    [Parameter (
      Position    = 6,
      Mandatory   = $true,
      HelpMessage = "Name of the model"
    )]
    [ValidateNotNullOrEmpty ()]
    [String]
    $Model,
    [Parameter (
      Position    = 7,
      Mandatory   = $true,
      HelpMessage = "Name of the analysis"
    )]
    [ValidateNotNullOrEmpty ()]
    [String]
    $Solve,
    [Parameter (
      Position    = 8,
      Mandatory   = $true,
      HelpMessage = "Solve kind"
    )]
    [ValidateSet (
      "BACKTESTING",
      "CLEAN_ROLLUP",
      "CONTRACT_AGGREGATION",
      "CONTRACT_SELECTION",
      "COVARIANCE_MATRIX_GENERATION",
      "CREDIT_SCORING_DATA_LOADER",
      "DYNAMIC_MC",
      "DYNAMIC",
      "FINANCIAL_STUDIO_LOADER",
      "FLAT_FILE_LOADER",
      "GENESIS_LOADER",
      "INCREMENTAL_RESULT_AGGREGATION",
      "MC_SCENARIO",
      "MODEL_EXPORT",
      "MODEL_IMPORT",
      "PDF_REPORT",
      "PROSPECTIVE_HEDGE_TEST",
      "RESULT_AGGREGATION",
      "RETROSPECTIVE_HEDGE_TEST",
      "RISK_METRICS",
      "ROLLUP",
      "SCENARIO_REPORT",
      "SELECTION_REPORT",
      "STATIC_SCENARIO",
      "STATIC_VAR_SCENARIO",
      "STATIC",
      "WHATIF_SCENARIO",
      "XL_IMPORT",
      "XL_REPORT",
      "XL_TEMPLATE_REPORT"
    )]
    [String]
    $Kind,
    [Parameter (
      HelpMessage = "Define if the synchronous mode should be enabled"
    )]
    [Switch]
    $SynchronousMode
  )
  Begin {
    # Get global preference variables
    Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState
    # Get administration Java class
    $JavaClass = Get-JavaClass -Name "Utilities"
  }
  Process {
    # Define operation parameters
    $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary"
    $OperationParameters.Add("ut.modelName", $Model)
    $OperationParameters.Add("ut.solveName", $Solve)
    $OperationParameters.Add("ut.solveKind", $Kind)
    # Configure synchronous mode
    $OperationParameters.Add("ws.sync", $SynchronousMode)
    # Format Java parameters
    $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters
    # Query solve ID
      Invoke-RiskProBatchClient -Properties $Properties -Credentials $Credentials -Operation "getSolveId" -Parameters $Parameters -Class $JavaClass
  }
}