From 73d102e8d24a94fd6b53586c0777f3a2c8e86c76 Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Tue, 4 Feb 2020 14:31:07 +0000 Subject: [PATCH 1/8] Rename write utility function --- ...md.ps1 => Write-RiskProBatchClientCmd.ps1} | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) rename Private/{Write-RiskProBatchCmd.ps1 => Write-RiskProBatchClientCmd.ps1} (80%) diff --git a/Private/Write-RiskProBatchCmd.ps1 b/Private/Write-RiskProBatchClientCmd.ps1 similarity index 80% rename from Private/Write-RiskProBatchCmd.ps1 rename to Private/Write-RiskProBatchClientCmd.ps1 index 6fd31aa..32a6337 100644 --- a/Private/Write-RiskProBatchCmd.ps1 +++ b/Private/Write-RiskProBatchClientCmd.ps1 @@ -1,4 +1,4 @@ -function Write-RiskProBatchCmd { +function Write-RiskProBatchClientCmd { <# .SYNOPSIS Write RiskPro batch client command @@ -25,16 +25,16 @@ function Write-RiskProBatchCmd { The operation parameter corresponds to the command to execute. .PARAMETER Parameters - The parameters parameter corresponds to the list of parameters to use for the operation. + The optional parameters parameter corresponds to the list of parameters to use for the operation. .PARAMETER Class The class parameter corresponds to the Java class to use for the operation. .NOTES - File name: Write-RiskProBatchCmd.ps1 + File name: Write-RiskProBatchClientCmd.ps1 Author: Florian CARRIER Creation date: 27/11/2018 - Last modified: 21/01/2020 + Last modified: 24/01/2020 #> [CmdletBinding()] Param ( @@ -89,7 +89,7 @@ function Write-RiskProBatchCmd { $Operation, [Parameter ( Position = 7, - Mandatory = $true, + Mandatory = $false, HelpMessage = "Parameters of the operation" )] [ValidateNotNullOrEmpty ()] @@ -120,7 +120,19 @@ function Write-RiskProBatchCmd { # Format Java parameters $BaseParameters = ConvertTo-JavaProperty -Properties $CommandParameters # Construct command - $Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $Parameters $JavaOptions $Class" + if ($PSBoundParameters.ContainsKey("JavaOptions")) { + if ($PSBoundParameters.ContainsKey("Parameters")) { + $Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $Parameters $JavaOptions $Class" + } else { + $Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $JavaOptions $Class" + } + } else { + if ($PSBoundParameters.ContainsKey("Parameters")) { + $Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $Parameters $Class" + } else { + $Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $Class" + } + } # Debugging with obfuscation Write-Log -Type "DEBUG" -Object $Command -Obfuscate $Credentials.GetNetworkCredential().Password # Return RiskPro batch client command From 2b5ae0b4e476e2cf85084415139d285a970851bd Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Tue, 4 Feb 2020 14:31:23 +0000 Subject: [PATCH 2/8] Enable command without operation parameters --- Public/Invoke-RiskProBatchClient.ps1 | 32 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Public/Invoke-RiskProBatchClient.ps1 b/Public/Invoke-RiskProBatchClient.ps1 index b905829..840573a 100644 --- a/Public/Invoke-RiskProBatchClient.ps1 +++ b/Public/Invoke-RiskProBatchClient.ps1 @@ -25,7 +25,7 @@ function Invoke-RiskProBatchClient { The operation parameter corresponds to the command to execute. .PARAMETER Parameters - The parameters parameter corresponds to the list of parameters to use for the operation. + The optional parameters parameter corresponds to the list of parameters to use for the operation. .PARAMETER Class The class parameter corresponds to the Java class to use for the operation. @@ -34,7 +34,7 @@ function Invoke-RiskProBatchClient { File name: Invoke-RiskProBatchClient.ps1 Author: Florian CARRIER Creation date: 27/11/2018 - Last modified: 21/01/2020 + Last modified: 24/01/2020 #> [CmdletBinding ( SupportsShouldProcess = $true @@ -91,7 +91,7 @@ function Invoke-RiskProBatchClient { $Operation, [Parameter ( Position = 7, - Mandatory = $true, + Mandatory = $false, HelpMessage = "Parameters of the operation" )] [ValidateNotNullOrEmpty ()] @@ -111,18 +111,34 @@ function Invoke-RiskProBatchClient { Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState } Process { - # Build command + # Check parameters and build command if ($PSBoundParameters.ContainsKey("JavaPath") -And ($JavaPath -ne "") -And ($JavaPath -ne $null)) { if ($PSBoundParameters.ContainsKey("JavaOptions") -And ($JavaOptions -ne "") -And ($JavaOptions -ne $null)) { - $CommandLine = Write-RiskProBatchCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Parameters $Parameters -Class $Class + if ($PSBoundParameters.ContainsKey("Parameters")) { + $CommandLine = Write-RiskProBatchClientCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Parameters $Parameters -Class $Class + } else { + $CommandLine = Write-RiskProBatchClientCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Class $Class + } } else { - $CommandLine = Write-RiskProBatchCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Parameters $Parameters -Class $Class + if ($PSBoundParameters.ContainsKey("Parameters")) { + $CommandLine = Write-RiskProBatchClientCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Parameters $Parameters -Class $Class + } else { + $CommandLine = Write-RiskProBatchClientCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Class $Class + } } } else { if ($PSBoundParameters.ContainsKey("JavaOptions") -And ($JavaOptions -ne "") -And ($JavaOptions -ne $null)) { - $CommandLine = Write-RiskProBatchCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Parameters $Parameters -Class $Class + if ($PSBoundParameters.ContainsKey("Parameters")) { + $CommandLine = Write-RiskProBatchClientCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Parameters $Parameters -Class $Class + } else { + $CommandLine = Write-RiskProBatchClientCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Class $Class + } } else { - $CommandLine = Write-RiskProBatchCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Parameters $Parameters -Class $Class + if ($PSBoundParameters.ContainsKey("Parameters")) { + $CommandLine = Write-RiskProBatchClientCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Parameters $Parameters -Class $Class + } else { + $CommandLine = Write-RiskProBatchClientCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Class $Class + } } } # Execute command From a0ed1f867dd6a596b68dbdb693a30d9e9756ca73 Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Tue, 4 Feb 2020 14:31:30 +0000 Subject: [PATCH 3/8] Create Start-Maintenance.ps1 --- Public/Start-Maintenance.ps1 | 92 ++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Public/Start-Maintenance.ps1 diff --git a/Public/Start-Maintenance.ps1 b/Public/Start-Maintenance.ps1 new file mode 100644 index 0000000..3e473a2 --- /dev/null +++ b/Public/Start-Maintenance.ps1 @@ -0,0 +1,92 @@ +function Start-Maintenance { + <# + .SYNOPSIS + Start maintenance + + .DESCRIPTION + Wrapper function to start maintenance 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. + + .NOTES + File name: Start-Maintenance.ps1 + Author: Florian CARRIER + Creation date: 24/01/2020 + Last modified: 24/01/2020 + #> + [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 + ) + Begin { + # Get global preference variables + Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState + # Get utilities Java class + $JavaClass = Get-JavaClass -Name "Administration" + } + Process { + # Define operation + $Operation = "startMaintenance" + # Call RiskPro batch client + if ($PSBoundParameters.ContainsKey("JavaPath")) { + Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Class $JavaClass + } else { + Invoke-RiskProBatchClient -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Class $JavaClass + } + } +} From 42453c8a62886479691fe9125971d73377d56421 Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Tue, 4 Feb 2020 14:31:35 +0000 Subject: [PATCH 4/8] Create Start-ExportToExcel.ps1 --- Public/Start-ExportToExcel.ps1 | 351 +++++++++++++++++++++++++++++++++ 1 file changed, 351 insertions(+) create mode 100644 Public/Start-ExportToExcel.ps1 diff --git a/Public/Start-ExportToExcel.ps1 b/Public/Start-ExportToExcel.ps1 new file mode 100644 index 0000000..c195279 --- /dev/null +++ b/Public/Start-ExportToExcel.ps1 @@ -0,0 +1,351 @@ +function Start-ExportToExcel { + <# + .SYNOPSIS + Start export to Excel + + .DESCRIPTION + Wrapper function to export a report to Excel 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. + + .NOTES + File name: Start-ExportToExcel.ps1 + Author: Florian CARRIER + Creation date: 24/01/2020 + Last modified: 24/01/2020 + #> + [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] + $ModelName, + [Parameter ( + Position = 7, + Mandatory = $true, + HelpMessage = "Name of the export process job" + )] + [ValidateNotNullOrEmpty ()] + [String] + $SolveJobName, + [Parameter ( + Position = 8, + Mandatory = $true, + HelpMessage = "Name of the calculation job to export" + )] + [ValidateNotNullOrEmpty ()] + [String] + $ReportedSolveJobName, + [Parameter ( + Position = 9, + Mandatory = $true, + HelpMessage = "Type of the solve to export" + )] + [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] + $ReportedSolveJobKind, + [Parameter ( + Position = 10, + Mandatory = $false, + HelpMessage = "Name of the report to export" + )] + [ValidateNotNullOrEmpty ()] + [String] + $ReportName, + [Parameter ( + Position = 11, + Mandatory = $true, + HelpMessage = "Type of the report (see Java documentation for OlapStandardReportType class)" + )] + [ValidateSet ( + "BACKTESTED_VAR", + "CAD_FRTB_CONSO", + "CAD_FRTB_JTD", + "CAD_FRTB_MR", + "CAD_FRTB_MR_FLAT", + "CAD_IRB_ADVANCED", + "CAD_IRB_FOUNDATION", + "CAD_MR_COM", + "CAD_MR_COM_OVER_TIME", + "CAD_MR_EQ", + "CAD_MR_EQ_OVER_TIME", + "CAD_MR_FX", + "CAD_MR_FX_OVER_TIME", + "CAD_MR_IR_GEN", + "CAD_MR_IR_GEN_OVER_TIME", + "CAD_MR_IR_SPE", + "CAD_MR_IR_SPE_OVER_TIME", + "CAD_MR_OPTIONS", + "CAD_MR_OPTIONS_OVER_TIME", + "CAD_PARTIAL_USE", + "CAD_STANDARD", + "DEFAULT_REPORT", + "DYN_MC_STORED_VAR", + "DYN_MC_STORED_VAR_TAIL", + "DYNAMIC_BOOK_VALUE", + "DYNAMIC_FTP", + "DYNAMIC_FTP_SPREAD", + "DYNAMIC_IFRS_BOOK_VALUE", + "DYNAMIC_LIQUIDITY_GAP", + "DYNAMIC_NPV", + "DYNAMIC_REPO_POSITIONS", + "DYNAMIC_REPRICING_GAP", + "DYNAMIC_SECURITIES_IN_REPOS", + "DYNAMIC_STOCKFLOW", + "ECL_ALLOCATION_DETAILS", + "EXPECTED_CREDIT_LOS_OVER_TIME", + "EXT_LCR", + "EXT_LCR_CONSO", + "EXT_LCR_CONSO_OVER_TIME", + "EXT_LCR_OVER_TIME", + "FAKE", + "FIXING_DATE_GAP", + "FIXING_DATE_GAP_INTERNAL_VIEW", + "FIXING_DATE_GAP_OVER_TIME", + "FIXING_DATE_GAP_OVER_TIME_INTERNAL_VIEW", + "HEDGE_EFFECTIVENESS_PROSPECTIVE_TEST", + "HEDGE_RATIO_PROSPECTIVE_TEST", + "HISTO_PROFIT_AND_LOSS_REPORT", + "HISTO_VAR_NPV_PURE", + "HISTO_VAR_NPV_TREAS", + "HISTORICAL_VAR", + "HISTORIZED_CONTRACT_RESULTS", + "HISTORIZED_HEDGE_EFFECTIVENESS_RETROSPECTIVE_TEST", + "KEY_RATE_OVER_TIME", + "LCR_LIQUIDITY_GAP_OVER_TIME", + "LCR_SPECIFIC_LIQUIDITY_GAP", + "LIQUIDITY_AT_RISK", + "LIQUIDITY_GAP_OVER_TIME", + "MC_PROFIT_AND_LOSS_REPORT", + "MC_VAR_NPV_PURE", + "MC_VAR_NPV_TREAS", + "PARAM_VAR_RISK_FACTOR_CATEGORY_DECOMPOSITION", + "PARAM_VAR_RISK_FACTOR_FULL_DECOMPOSITION", + "REPO_POSITIONS", + "REPRICING_GAP_OVER_TIME", + "SECURITIES_IN_REPOS", + "SENSITIVITY_GAP_OVER_TIME", + "SENSITIVTY_GAP", + "SPREAD_EXPOSURE", + "SPREAD_EXPOSURE_OVER_TIME", + "SPREAD_EXPOSURE_OVER_TIME_TYPE_DECOMPOSITION", + "SPREAD_EXPOSURE_TYPE_DECOMPOSITION", + "STATIC_BOOK_VALUE", + "STATIC_COM_EXPOSURE", + "STATIC_CONTINGENT_GAP", + "STATIC_CPI_EXPOSURE", + "STATIC_CREDIT_VALUE_ADJUSTEMENT", + "STATIC_CRPLUS", + "STATIC_CURRENT_EXPOSURE", + "STATIC_EXPECTED_CREDIT_LOSS", + "STATIC_FTP", + "STATIC_FX_EXPOSURE", + "STATIC_IFRS_BOOK_VALUE", + "STATIC_INCOME_BOOK_VALUE", + "STATIC_INCOME_FTP", + "STATIC_INCOME_FTP_SPREAD", + "STATIC_INCOME_IFRS_BOOK_VALUE", + "STATIC_INDEX_EXPOSURE", + "STATIC_KEY_RATE", + "STATIC_LIQUIDITY_GAP", + "STATIC_MC_STORED_VAR", + "STATIC_MC_STORED_VAR_TAIL", + "STATIC_MONTECARLO", + "STATIC_NPV", + "STATIC_REPRICING_GAP", + "STATIC_VOL_EXPOSURE", + "STOCHASTIC_PFE", + "STOCKFLOW", + "STOCKFLOW_OVER_TIME", + "STORED_VAR" + )] + [String] + $ReportType, + [Parameter ( + Position = 12, + Mandatory = $true, + HelpMessage = "Name of the generated Excel file" + )] + [ValidateNotNullOrEmpty ()] + [String] + $OutputFileName, + [Parameter ( + Position = 13, + Mandatory = $false, + HelpMessage = "Name of the cube definition" + )] + [ValidateNotNullOrEmpty ()] + [String] + $CubeDefinitionName, + [Parameter ( + Position = 14, + Mandatory = $false, + HelpMessage = "MDX query" + )] + [ValidateNotNullOrEmpty ()] + [String] + $MDXQuery, + [Parameter ( + Position = 15, + Mandatory = $false, + HelpMessage = "Path to a file containing a MDX query" + )] + [ValidateNotNullOrEmpty ()] + [String] + $MDXFileName, + [Parameter ( + Position = 16, + Mandatory = $false, + HelpMessage = "Full mnemonic of the account to export" + )] + [ValidateNotNullOrEmpty ()] + [String] + $AccountMnemonic, + [Parameter ( + Position = 17, + Mandatory = $false, + HelpMessage = "Free form footer string to append to the report(s)" + )] + [ValidateNotNullOrEmpty ()] + [String] + $ExtraCopyrightInfo, + [Parameter ( + Position = 18, + Mandatory = $false, + HelpMessage = "Title of the report" + )] + [ValidateNotNullOrEmpty ()] + [String] + $Title, + [Parameter ( + HelpMessage = "Define if numerical figures should be exported with full precision" + )] + [Switch] + $FullPrecision + ) + Begin { + # Get global preference variables + Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState + # Get Java class + $JavaClass = Get-JavaClass -Name "Results" + # Define operation + $Operation = "startExportToExcel" + } + Process { + # Define operation parameters + $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" + $OperationParameters.Add("rs.modelName", $ModelName) + $OperationParameters.Add("rs.solveJobName", $SolveJobName) + $OperationParameters.Add("rs.reportedSolveJobName", $ReportedSolveJobName) + $OperationParameters.Add("rs.reportedSolveJobKind", $ReportedSolveJobKind) + if ($PSBoundParameters.ContainsKey("ReportName")) { $OperationParameters.Add("rs.reportName", $ReportName) } + $OperationParameters.Add("rs.reportType", $ReportType) + $OperationParameters.Add("rs.outputFileName", $OutputFileName) + if ($PSBoundParameters.ContainsKey("CubeDefinitionName")) { $OperationParameters.Add("rs.cubeDefinitionName", $CubeDefinitionName) } + $OperationParameters.Add("rs.fullPrecision", $FullPrecision) + if ($PSBoundParameters.ContainsKey("MDXQuery")) { $OperationParameters.Add("rs.mdx", $MDXQuery) } + if ($PSBoundParameters.ContainsKey("MDXFileName")) { $OperationParameters.Add("rs.mdxFileName", $MDXFileName) } + if ($PSBoundParameters.ContainsKey("AccountMnemonic")) { $OperationParameters.Add("rs.accountMnemonic", $AccountMnemonic) } + if ($PSBoundParameters.ContainsKey("ExtraCopyrightInfo")) { $OperationParameters.Add("rs.extraCopyrightInfo", $ExtraCopyrightInfo) } + if ($PSBoundParameters.ContainsKey("Title")) { $OperationParameters.Add("rs.title", $Title) } + # Format Java parameters + $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters + # Call RiskPro batch client + if ($PSBoundParameters.ContainsKey("JavaPath")) { + Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Class $JavaClass + } else { + Invoke-RiskProBatchClient -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Class $JavaClass + } + } +} From f11020f6e8b40b197f2ad7254336cb00a12b1ed3 Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Tue, 4 Feb 2020 14:31:53 +0000 Subject: [PATCH 5/8] Explicit parameter naming --- Public/Get-ModelID.ps1 | 10 +++++----- Public/Start-Solve.ps1 | 18 +++++++++--------- Public/Test-Model.ps1 | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Public/Get-ModelID.ps1 b/Public/Get-ModelID.ps1 index d771ced..e8832b9 100644 --- a/Public/Get-ModelID.ps1 +++ b/Public/Get-ModelID.ps1 @@ -21,14 +21,14 @@ function Get-ModelID { .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 of the model to check. + .PARAMETER ModelName + The model name parameter corresponds to the name of the model to check. .NOTES File name: Get-ModelID.ps1 Author: Florian CARRIER Creation date: 23/10/2019 - Last modified: 21/01/2020 + Last modified: 28/01/2020 TODO Add parameter validation Parse output and retrieve model ID WARNING Synchronous mode not supported for operation 'getModelId'! @@ -86,7 +86,7 @@ function Get-ModelID { [ValidateNotNullOrEmpty ()] [Alias ("Name")] [String] - $Model + $ModelName ) Begin { # Get global preference variables @@ -97,7 +97,7 @@ function Get-ModelID { Process { # Define operation parameters $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" - $OperationParameters.Add("ut.modelName", $Model) + $OperationParameters.Add("ut.modelName", $ModelName) # Format Java parameters $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters # Query model ID diff --git a/Public/Start-Solve.ps1 b/Public/Start-Solve.ps1 index cc00c26..e139e1e 100644 --- a/Public/Start-Solve.ps1 +++ b/Public/Start-Solve.ps1 @@ -21,8 +21,8 @@ function Start-Solve { .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 of the model. + .PARAMETER ModelName + The model name parameter corresponds to the name of the model. .PARAMETER ResultSelection The result selection parameter corresponds to the name of the analysis to run. @@ -30,8 +30,8 @@ function Start-Solve { .PARAMETER AccountStructure The account structure parameter corresponds to the name of the financial institution. - .PARAMETER Solve - The solve parameter corresponds to the label of the process. + .PARAMETER SolveName + The solve name parameter corresponds to the label of the process. .PARAMETER AnalysisDate The optional analysis date parameter corresponds to the date of the analysis. It must be in the following format: dd/MM/YYYY AM/PM. @@ -76,7 +76,7 @@ function Start-Solve { File name: Start-Solve.ps1 Author: Florian CARRIER Creation date: 22/10/2019 - Last modified: 21/01/2020 + Last modified: 28/01/2020 TODO Add parameter validation .LINK @@ -140,7 +140,7 @@ function Start-Solve { )] [ValidateNotNullOrEmpty ()] [String] - $Model, + $ModelName, [Parameter ( Position = 7, Mandatory = $true, @@ -164,7 +164,7 @@ function Start-Solve { )] [ValidateNotNullOrEmpty ()] [String] - $Solve, + $SolveName, [Parameter ( Position = 10, Mandatory = $false, @@ -268,14 +268,14 @@ function Start-Solve { Process { # Define operation parameters $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" - $OperationParameters.Add("sv.modelName", $Model) + $OperationParameters.Add("sv.modelName", $ModelName) $OperationParameters.Add("sv.resultSelectionName", $ResultSelection) # Add accout structure (financial institution) if ($PSBoundParameters.ContainsKey("AccountStructure")) { $OperationParameters.Add("sv.accountStructureName", $AccountStructure) } # Add solve name - $OperationParameters.Add("sv.solveName", $Solve) + $OperationParameters.Add("sv.solveName", $SolveName) if ($PSBoundParameters.ContainsKey("AnalysisDate")) { $OperationParameters.Add("sv.analysisDate", $AnalysisDate) } diff --git a/Public/Test-Model.ps1 b/Public/Test-Model.ps1 index 7b61949..b3d18a1 100644 --- a/Public/Test-Model.ps1 +++ b/Public/Test-Model.ps1 @@ -28,7 +28,7 @@ function Test-Model { File name: Test-Model.ps1 Author: Florian CARRIER Creation date: 23/10/2019 - Last modified: 22/01/2020 + Last modified: 28/01/2020 #> [CmdletBinding ( SupportsShouldProcess = $true @@ -83,7 +83,7 @@ function Test-Model { [ValidateNotNullOrEmpty ()] [Alias ("Name")] [String] - $Model + $ModelName ) Begin { # Get global preference variables @@ -91,7 +91,7 @@ function Test-Model { } Process { # Query model - $GetModelID = Get-ModelID -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Model $Model + $GetModelID = Get-ModelID -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -ModelName $ModelName # Return outcome return (Test-RiskProBatchClientOutcome -Log $GetModelID) } From 3847557b4454b5941c69fa2248011aceb5fac1fb Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Fri, 21 Feb 2020 11:46:10 +0000 Subject: [PATCH 6/8] Add file system functions --- Public/Invoke-List.ps1 | 109 +++++++++++++++++++++++++++++++++ Public/Invoke-MakeDir.ps1 | 109 +++++++++++++++++++++++++++++++++ Public/Invoke-Upload.ps1 | 124 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 342 insertions(+) create mode 100644 Public/Invoke-List.ps1 create mode 100644 Public/Invoke-MakeDir.ps1 create mode 100644 Public/Invoke-Upload.ps1 diff --git a/Public/Invoke-List.ps1 b/Public/Invoke-List.ps1 new file mode 100644 index 0000000..ab92d28 --- /dev/null +++ b/Public/Invoke-List.ps1 @@ -0,0 +1,109 @@ +function Invoke-List { + <# + .SYNOPSIS + List files + + .DESCRIPTION + Wrapper function to list files on the server 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 Directory + The directory parameter corresponds to the path to the directory to inspect. + + .NOTES + File name: Invoke-List.ps1 + Author: Florian CARRIER + Creation date: 17/02/2020 + Last modified: 17/02/2020 + #> + [CmdletBinding ( + SupportsShouldProcess = $true + )] + Param ( + [Parameter ( + Position = 1, + Mandatory = $false, + HelpMessage = "Java path" + )] + [ValidateNotNullOrEmpty ()] + [System.String] + $JavaPath, + [Parameter ( + Position = 2, + Mandatory = $true, + HelpMessage = "RiskPro batch client path" + )] + [ValidateNotNullOrEmpty ()] + [Alias ("Path", "RiskProPath")] + [System.String] + $RiskProBatchClient, + [Parameter ( + Position = 3, + Mandatory = $true, + HelpMessage = "RiskPro server URI" + )] + [ValidateNotNullOrEmpty ()] + [System.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 ()] + [System.String[]] + $JavaOptions, + [Parameter ( + Position = 6, + Mandatory = $true, + HelpMessage = "Path to the directory to inspect" + )] + [ValidateNotNullOrEmpty ()] + [Alias ("File")] + [System.String] + $Directory + ) + Begin { + # Get global preference variables + Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState + # Get utilities Java class + $JavaClass = Get-JavaClass -Name "FileSystem" + # Prefix directory path with expected scheme (if required) + if ($Directory -NotMatch '(riskpro\:\/\/).*') { + $Directory = [System.String]::Concat("riskpro://", $Directory) + } + # Encode URI + $DirectoryURI = Resolve-URI -URI $Directory -RestrictedOnly + } + Process { + # Define operation parameters + $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" + $OperationParameters.Add("fs.file", $DirectoryURI) + # Format Java parameters + $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters + # List files + Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation "list" -Parameters $Parameters -Class $JavaClass + } +} diff --git a/Public/Invoke-MakeDir.ps1 b/Public/Invoke-MakeDir.ps1 new file mode 100644 index 0000000..396fbc4 --- /dev/null +++ b/Public/Invoke-MakeDir.ps1 @@ -0,0 +1,109 @@ +function Invoke-MakeDir { + <# + .SYNOPSIS + Make directory + + .DESCRIPTION + Wrapper function to create a directory on the server 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 Directory + The directory parameter corresponds to the path to the directory to create. + + .NOTES + File name: Invoke-MakeDir.ps1 + Author: Florian CARRIER + Creation date: 17/02/2020 + Last modified: 17/02/2020 + #> + [CmdletBinding ( + SupportsShouldProcess = $true + )] + Param ( + [Parameter ( + Position = 1, + Mandatory = $false, + HelpMessage = "Java path" + )] + [ValidateNotNullOrEmpty ()] + [System.String] + $JavaPath, + [Parameter ( + Position = 2, + Mandatory = $true, + HelpMessage = "RiskPro batch client path" + )] + [ValidateNotNullOrEmpty ()] + [Alias ("Path", "RiskProPath")] + [System.String] + $RiskProBatchClient, + [Parameter ( + Position = 3, + Mandatory = $true, + HelpMessage = "RiskPro server URI" + )] + [ValidateNotNullOrEmpty ()] + [System.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 ()] + [System.String[]] + $JavaOptions, + [Parameter ( + Position = 6, + Mandatory = $true, + HelpMessage = "Path to the directory to create" + )] + [ValidateNotNullOrEmpty ()] + [Alias ("File")] + [System.String] + $Directory + ) + Begin { + # Get global preference variables + Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState + # Get utilities Java class + $JavaClass = Get-JavaClass -Name "FileSystem" + # Prefix directory path with expected scheme (if required) + if ($Directory -NotMatch '(riskpro\:\/\/).*') { + $Directory = [System.String]::Concat("riskpro://", $Directory) + } + # Encode URI + $DirectoryURI = Resolve-URI -URI $Directory -RestrictedOnly + } + Process { + # Define operation parameters + $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" + $OperationParameters.Add("fs.file", $DirectoryURI) + # Format Java parameters + $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters + # Create directory + Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation "makeDir" -Parameters $Parameters -Class $JavaClass + } +} diff --git a/Public/Invoke-Upload.ps1 b/Public/Invoke-Upload.ps1 new file mode 100644 index 0000000..fe64823 --- /dev/null +++ b/Public/Invoke-Upload.ps1 @@ -0,0 +1,124 @@ +function Invoke-Upload { + <# + .SYNOPSIS + Publish file + + .DESCRIPTION + Wrapper function to upload a file on the server 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 FilePath + The file path parameter corresponds to the path to the file to upload. + + .PARAMETER DestinationPath + The destination path parameter corresponds to the server-side destination path of the file. + + .NOTES + File name: Invoke-Upload.ps1 + Author: Florian CARRIER + Creation date: 17/02/2020 + Last modified: 17/02/2020 + #> + [CmdletBinding ( + SupportsShouldProcess = $true + )] + Param ( + [Parameter ( + Position = 1, + Mandatory = $false, + HelpMessage = "Java path" + )] + [ValidateNotNullOrEmpty ()] + [System.String] + $JavaPath, + [Parameter ( + Position = 2, + Mandatory = $true, + HelpMessage = "RiskPro batch client path" + )] + [ValidateNotNullOrEmpty ()] + [Alias ("Path", "RiskProPath")] + [System.String] + $RiskProBatchClient, + [Parameter ( + Position = 3, + Mandatory = $true, + HelpMessage = "RiskPro server URI" + )] + [ValidateNotNullOrEmpty ()] + [System.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 ()] + [System.String[]] + $JavaOptions, + [Parameter ( + Position = 6, + Mandatory = $true, + HelpMessage = "Path to the file" + )] + [ValidateNotNullOrEmpty ()] + [System.String] + $FilePath, + [Parameter ( + Position = 7, + Mandatory = $true, + HelpMessage = "Destination path of the file" + )] + [ValidateNotNullOrEmpty ()] + [System.String] + $DestinationPath + ) + Begin { + # Get global preference variables + Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState + # Get utilities Java class + $JavaClass = Get-JavaClass -Name "FileSystem" + # Prefix file paths with expected scheme (if required) + if ($FilePath -NotMatch '(file\:\/\/\/).*') { + $FilePath = [System.String]::Concat("file:///", $FilePath) + } + if ($DestinationPath -NotMatch '(riskpro\:\/\/).*') { + $DestinationPath = [System.String]::Concat("riskpro://", $DestinationPath) + } + # Encode URIs + $FileURI = Resolve-URI -URI $FilePath -RestrictedOnly + $DestinationURI = Resolve-URI -URI $DestinationPath -RestrictedOnly + } + Process { + # Define operation parameters + $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" + $OperationParameters.Add("fs.sourceFile", $FileURI) + $OperationParameters.Add("fs.destFile" , $DestinationURI) + # Format Java parameters + $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters + # Upload file + Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation "upload" -Parameters $Parameters -Class $JavaClass + } +} From 7507f2291b81c7e02e769c0864946e8338ab9d2f Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Fri, 21 Feb 2020 11:46:26 +0000 Subject: [PATCH 7/8] Update Start-ImportXML.ps1 --- Public/Start-ImportXML.ps1 | 201 ++++++++++++++++++++++++++++--------- 1 file changed, 152 insertions(+), 49 deletions(-) diff --git a/Public/Start-ImportXML.ps1 b/Public/Start-ImportXML.ps1 index 200e99b..76dc134 100644 --- a/Public/Start-ImportXML.ps1 +++ b/Public/Start-ImportXML.ps1 @@ -1,35 +1,147 @@ function Start-ImportXML { - # TODO + <# + .SYNOPSIS + Import XML file + + .DESCRIPTION + Wrapper function to import data 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 ModelName + The model name parameter corresponds to the name of the model in which to import data. + + .PARAMETER SolveName + The SOLVE name parameter corresponds to the name of the solve to create. + + .PARAMETER FileName + The file name parameter corresponds to the path to the file to import. + + .PARAMETER ModelElements + The model elements parameter corresponds to the import configuration for model elements. + + .PARAMETER Observations + The observations parameter corresponds to the import configuration for observations. + + .PARAMETER Contracts + The contracts parameter corresponds to the import configuration for contracts. + + .PARAMETER Counterparties + The counterparties parameter corresponds to the import configuration for counterparties. + + .PARAMETER BusinessAudits + The business audits parameter corresponds to the import configuration for business audits. + + .PARAMETER Libraries + The libraries parameter corresponds to the import configuration for Java libraries. + + .PARAMETER LogLevel + The log level parameter corresponds to the level of logging desired. + + .PARAMETER ForcedDataGroupName + The forced data group name corresponds to the name of the data group in which the data should be imported. + + .PARAMETER NewModel + The new model switch specifies if a new model should be created. + + .PARAMETER CompileAllExpressions + The compile all expressions switch specifies if all expressions should be compiled. + + .PARAMETER SynchronousMode + The synchronous mode switch specifies if the synchronous mode should be enabled. + + .NOTES + File name: Start-ImportXML.ps1 + Author: Florian CARRIER + Creation date: 15/10/2019 + Last modified: 17/02/2020 + TODO Add unmanaged objects parameters + + #> [CmdletBinding ( SupportsShouldProcess = $true )] Param( [Parameter ( Position = 1, + Mandatory = $false, + HelpMessage = "Java path" + )] + [ValidateNotNullOrEmpty ()] + [System.String] + $JavaPath, + [Parameter ( + Position = 2, + Mandatory = $true, + HelpMessage = "RiskPro batch client path" + )] + [ValidateNotNullOrEmpty ()] + [Alias ("Path", "RiskProPath")] + [System.String] + $RiskProBatchClient, + [Parameter ( + Position = 3, + Mandatory = $true, + HelpMessage = "RiskPro server URI" + )] + [ValidateNotNullOrEmpty ()] + [System.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 ()] + [System.String[]] + $JavaOptions, + [Parameter ( + Position = 6, Mandatory = $true, HelpMessage = "Name of the model to import" )] [ValidateNotNullOrEmpty ()] [String] - $Model, + $ModelName, [Parameter ( - Position = 2, + Position = 7, Mandatory = $true, - HelpMessage = "Name of the process" + HelpMessage = "Name of the solve" )] [ValidateNotNullOrEmpty ()] [String] - $Solve, + $SolveName, [Parameter ( - Position = 2, + Position = 8, Mandatory = $true, HelpMessage = "Path to the file to import" )] [ValidateNotNullOrEmpty ()] [String] - $File, + $FileName, [Parameter ( - Position = 3, + Position = 9, Mandatory = $false, HelpMessage = "Action to perform for model elements" )] @@ -37,7 +149,7 @@ function Start-ImportXML { [String] $ModelElements = "NONE", [Parameter ( - Position = 4, + Position = 10, Mandatory = $false, HelpMessage = "Action to perform for observations" )] @@ -45,7 +157,7 @@ function Start-ImportXML { [String] $Observations = "NONE", [Parameter ( - Position = 5, + Position = 11, Mandatory = $false, HelpMessage = "Action to perform for contracts" )] @@ -53,7 +165,7 @@ function Start-ImportXML { [String] $Contracts = "NONE", [Parameter ( - Position = 6, + Position = 12, Mandatory = $false, HelpMessage = "Action to perform for conterparties" )] @@ -61,7 +173,7 @@ function Start-ImportXML { [String] $Counterparties = "NONE", [Parameter ( - Position = 7, + Position = 13, Mandatory = $false, HelpMessage = "Action to perform for business audits" )] @@ -69,7 +181,7 @@ function Start-ImportXML { [String] $BusinessAudits = "NONE", [Parameter ( - Position = 8, + Position = 14, Mandatory = $false, HelpMessage = "Action to perform for libraries" )] @@ -77,7 +189,7 @@ function Start-ImportXML { [String] $Libraries = "NONE", [Parameter ( - Position = 9, + Position = 15, Mandatory = $false, HelpMessage = "Define level of detail for logs" )] @@ -85,13 +197,13 @@ function Start-ImportXML { [String] $LogLevel = "INFO", [Parameter ( - Position = 10, + Position = 16, Mandatory = $false, - HelpMessage = "Define level of detail for logs" + HelpMessage = "Name of the target data group" )] [ValidateNotNullOrEmpty ()] [String] - $ForcedDataGroup, + $ForcedDataGroupName, [Parameter ( HelpMessage = "Define if a new model should be created" )] @@ -101,51 +213,42 @@ function Start-ImportXML { HelpMessage = "Define if all expressions should be compiled" )] [Switch] - $CompileExpressions, + $CompileAllExpressions, [Parameter ( HelpMessage = "Define if the synchronous mode should be enabled" )] [Switch] - $SyncMode = $true + $SynchronousMode ) Begin { # Get global preference variables Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState # Get Java class - $JavaClass = Get-JavaClass -Name "Interface" + $JavaClass = Get-JavaClass -Name "Interfacing" + # Prefix file paths with expected scheme (if required) + if (($FileName -NotMatch '(riskpro\:\/\/).*') -And ($FileName -NotMatch '(file\:\/\/\/).*')) { + $FileName = [System.String]::Concat("file:///", $FileName) + } + # Encode URI + $FileURI = Resolve-URI -URI $FileName -RestrictedOnly } Process { - # # Variables - # $URI = Resolve-URI -URI $Path - # if ($Remote) { - # $URI = "file:///$URI" - # } else { - # # TODO add check if URI is not relative - # $URI = "riskpro://$URI" - # } - # $ISOTime = Get-Date -Format "yyyy-MM-dd_HHmmss" - # # Set solve name - # if ($ForcedDataGroup -ne "") { - # $SolveName = "Import_${ForcedDataGroup}_${ISOTime}" - # } else { - # $SolveName = "Import_${Model}_${ISOTime}" - # } # Define operation parameters $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" - $OperationParameters.Add("ic.createNew", $NewModel) - $OperationParameters.Add("ic.modelName", $Model) - $OperationParameters.Add("ic.solveName", $SolveName) - $OperationParameters.Add("ic.fileName", $URI) - $OperationParameters.Add("ic.modelElements", $ModelElements) - $OperationParameters.Add("ic.observations", $Observations) - $OperationParameters.Add("ic.contracts", $Contracts) - $OperationParameters.Add("ic.counterparties", $Counterparties) - $OperationParameters.Add("ic.businessAudits", $BusinessAudits) - $OperationParameters.Add("ic.libraries", $Libraries) - $OperationParameters.Add("ic.logLevel", $LogLevel) - $OperationParameters.Add("ic.compileAllExpressions", $CompileExpressions) - $OperationParameters.Add("ic.forcedDataGroupName", $ForcedDataGroup) - $OperationParameters.Add("ws.sync", $SyncMode) + $OperationParameters.Add("ic.createNew" , $NewModel) + $OperationParameters.Add("ic.modelName" , $ModelName) + $OperationParameters.Add("ic.solveName" , $SolveName) + $OperationParameters.Add("ic.fileName" , $FileURI) + $OperationParameters.Add("ic.modelElements" , $ModelElements) + $OperationParameters.Add("ic.observations" , $Observations) + $OperationParameters.Add("ic.contracts" , $Contracts) + $OperationParameters.Add("ic.counterparties" , $Counterparties) + $OperationParameters.Add("ic.businessAudits" , $BusinessAudits) + $OperationParameters.Add("ic.libraries" , $Libraries) + $OperationParameters.Add("ic.logLevel" , $LogLevel) + $OperationParameters.Add("ic.compileAllExpressions" , $CompileAllExpressions) + $OperationParameters.Add("ic.forcedDataGroupName" , $ForcedDataGroupName) + $OperationParameters.Add("ws.sync" , $SynchronousMode) # Format Java parameters $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters # Import XML file From 254308cf1f789d32b4685d3a208ef58c5ed16f97 Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Fri, 21 Feb 2020 17:04:02 +0000 Subject: [PATCH 8/8] Explicit parameter name definition --- Public/Start-CleanRollupSolve.ps1 | 177 ++++++++++++++++++++++++++++++ Public/Start-RollupSolve.ps1 | 164 +++++++++++++++++++++++++++ Public/Start-Solve.ps1 | 2 +- 3 files changed, 342 insertions(+), 1 deletion(-) create mode 100644 Public/Start-CleanRollupSolve.ps1 create mode 100644 Public/Start-RollupSolve.ps1 diff --git a/Public/Start-CleanRollupSolve.ps1 b/Public/Start-CleanRollupSolve.ps1 new file mode 100644 index 0000000..0278526 --- /dev/null +++ b/Public/Start-CleanRollupSolve.ps1 @@ -0,0 +1,177 @@ +function Start-CleanRollupSolve { + <# + .SYNOPSIS + Start roll-up solve + + .DESCRIPTION + Wrapper function to start a clean-roll-up solve 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 ModelName + The model name parameter corresponds to the name of the model. + + .PARAMETER ResultSelectionName + The optional result selection name parameter corresponds to the name of the analysis to run. + + .PARAMETER SolveName + The solve name parameter corresponds to the label of the process. + + .PARAMETER TechnicalConfiguration + The optional technical configuration parameter corresponds to the name of the technical parameter definition. + + .PARAMETER BeginDate + The begin date parameter corresponds to the begin date for the purge operation. + + .PARAMETER EndDate + The end date parameter corresponds to the end date for the purge operation. + + .PARAMETER SynchronousMode + The synchonous mode switch defines if the operation should be run in synchronous mode. + + .NOTES + File name: Start-CleanRollupSolve.ps1 + Author: Florian CARRIER + Creation date: 21/02/2020 + Last modified: 21/02/2020 + + .LINK + Invoke-RiskProBatchClient + #> + [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] + $ModelName, + [Parameter ( + Position = 7, + Mandatory = $false, + HelpMessage = "Name of the result selection" + )] + [ValidateNotNullOrEmpty ()] + [String] + $ResultSelectionName, + [Parameter ( + Position = 9, + Mandatory = $true, + HelpMessage = "Name of the solve" + )] + [ValidateNotNullOrEmpty ()] + [String] + $SolveName, + [Parameter ( + Position = 9, + Mandatory = $false, + HelpMessage = "Name of the technical configuration" + )] + [ValidateNotNullOrEmpty ()] + [String] + $TechnicalConfiguration, + [Parameter ( + Position = 10, + Mandatory = $true, + HelpMessage = "Begin date" + )] + # TODO validate format DD/MM/YYYY [AM | PM] + [ValidateNotNullOrEmpty ()] + [String] + $BeginDate, + [Parameter ( + Position = 11, + Mandatory = $true, + HelpMessage = "End date" + )] + # TODO validate format DD/MM/YYYY [AM | PM] + [ValidateNotNullOrEmpty ()] + [String] + $EndDate, + [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 "Solve" + } + Process { + # Define operation parameters + $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" + $OperationParameters.Add("sv.modelName", $ModelName) + if ($PSBoundParameters.ContainsKey("ResultSelectionName")) { $OperationParameters.Add("sv.resultSelectionName", $ResultSelectionName) } + $OperationParameters.Add("sv.solveName", $SolveName) + if ($PSBoundParameters.ContainsKey("TechnicalConfiguration")) { $OperationParameters.Add("sv.technicalConfiguration", $TechnicalConfiguration) } + $OperationParameters.Add("sv.beginDate", $BeginDate) + $OperationParameters.Add("sv.endDate", $EndDate) + # Configure syncrhonous mode + $OperationParameters.Add("ws.sync", $SynchronousMode) + # Format Java parameters + $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters + # Run solve + Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation "startCleanRollupSolve" -Parameters $Parameters -Class $JavaClass + } +} diff --git a/Public/Start-RollupSolve.ps1 b/Public/Start-RollupSolve.ps1 new file mode 100644 index 0000000..138fd7a --- /dev/null +++ b/Public/Start-RollupSolve.ps1 @@ -0,0 +1,164 @@ +function Start-RollupSolve { + <# + .SYNOPSIS + Start roll-up solve + + .DESCRIPTION + Wrapper function to start a roll-up solve 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 ModelName + The model name parameter corresponds to the name of the model. + + .PARAMETER ResultSelectionName + The optional result selection name parameter corresponds to the name of the analysis to run. + + .PARAMETER SolveName + The solve name parameter corresponds to the label of the process. + + .PARAMETER TechnicalConfiguration + The optional technical configuration parameter corresponds to the name of the technical parameter definition. + + .PARAMETER AnalysisDate + The optional analysis date parameter corresponds to the date of the analysis. It must be in the following format: dd/MM/YYYY AM/PM. + + .PARAMETER SynchronousMode + The synchonous mode switch defines if the operation should be run in synchronous mode. + + .NOTES + File name: Start-RollupSolve.ps1 + Author: Florian CARRIER + Creation date: 21/02/2020 + Last modified: 21/02/2020 + + .LINK + Invoke-RiskProBatchClient + #> + [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] + $ModelName, + [Parameter ( + Position = 7, + Mandatory = $false, + HelpMessage = "Name of the result selection" + )] + [ValidateNotNullOrEmpty ()] + [String] + $ResultSelectionName, + [Parameter ( + Position = 9, + Mandatory = $true, + HelpMessage = "Name of the solve" + )] + [ValidateNotNullOrEmpty ()] + [String] + $SolveName, + [Parameter ( + Position = 9, + Mandatory = $false, + HelpMessage = "Name of the technical configuration" + )] + [ValidateNotNullOrEmpty ()] + [String] + $TechnicalConfiguration, + [Parameter ( + Position = 10, + Mandatory = $true, + HelpMessage = "Date of analysis" + )] + # TODO validate format DD/MM/YYYY [AM | PM] + [ValidateNotNullOrEmpty ()] + [String] + $AnalysisDate, + [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 "Solve" + } + Process { + # Define operation parameters + $OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary" + $OperationParameters.Add("sv.modelName", $ModelName) + if ($PSBoundParameters.ContainsKey("ResultSelectionName")) { $OperationParameters.Add("sv.resultSelectionName", $ResultSelectionName) } + $OperationParameters.Add("sv.solveName", $SolveName) + if ($PSBoundParameters.ContainsKey("TechnicalConfiguration")) { $OperationParameters.Add("sv.technicalConfiguration", $TechnicalConfiguration) } + $OperationParameters.Add("sv.analysisDate", $AnalysisDate) + # Configure syncrhonous mode + $OperationParameters.Add("ws.sync", $SynchronousMode) + # Format Java parameters + $Parameters = ConvertTo-JavaProperty -Properties $OperationParameters + # Run solve + Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation "startRollupSolve" -Parameters $Parameters -Class $JavaClass + } +} diff --git a/Public/Start-Solve.ps1 b/Public/Start-Solve.ps1 index e139e1e..2c3e6f8 100644 --- a/Public/Start-Solve.ps1 +++ b/Public/Start-Solve.ps1 @@ -24,7 +24,7 @@ function Start-Solve { .PARAMETER ModelName The model name parameter corresponds to the name of the model. - .PARAMETER ResultSelection + .PARAMETER ResultSelectionName The result selection parameter corresponds to the name of the analysis to run. .PARAMETER AccountStructure