Groovy Sample – PBCSBICSIntegration.groovy
package com.oracle.ceal
class PBCSBICSIntegration {
static main(args) {
def pbcsExportfiles
PbcsRestClient pbcsClient
BicsRestClient bicsClient
ApexRestClient apexClient
PBCSAutomationParameters pbcsParams=new PBCSAutomationParameters('PBCSBICSAutomation.properties')
if (pbcsParams.isConfigValid() == true) {
pbcsClient=new PbcsRestClient(pbcsParams.planningRestUrl,pbcsParams.interopRestUrl,pbcsParams.proxyHost,pbcsParams.proxyPort,pbcsParams.identityDomain,pbcsParams.username, pbcsParams.password, pbcsParams.ignoreSSLCertificationPathErrors)
pbcsClient.listFiles()
pbcsClient.deleteFile("ExportOliv.zip")
pbcsClient.deleteFile("ExportMetadataOliv.zip")
def response
//last parameter is server filename for export. If not set, this defaults to jobname as filename
response=pbcsClient.exportData("Vision","JobOliv","ExportOliv.zip")
String jobId = "";
jobId=pbcsClient.getJobIdFromJSONResponse(response)
if (jobId!="") println "Export running with jobid:"+jobId
// Looping to get jobId status while it s being processed on server
// In this example waiting 6 secs each time, and trying 100 times to get a valid status (not processing)
WaitForCode.retry(6000,100){
// second parameter is jobid (is obtained from json response from server)
def responseJobStatus
responseJobStatus=pbcsClient.getJobStatus("Vision",jobId)
if (responseJobStatus.contains("Processing")) throw new Exception("Job not finished"
}
//download server file name to local folder
pbcsClient.downloadFile("ExportOliv.zip","d:\\temp")
//last parameter is server filename for export. If not set, this defaults to jobname as filename
pbcsClient.exportMetaData("Vision","JobOlivMeta","ExportMetadataOliv.zip")
pbcsClient.downloadFile("ExportMetadataOliv.zip","d:\\temp")
pbcsExportfiles=pbcsClient.unZip("d:\\temp\\ExportOliv.zip","d:\\temp\\")
pbcsExportfiles.each { fileNameInZip ->
println "-->"+fileNameInZip
println "Nb of cols in csv:"+pbcsClient.findNbOfColsInCSV("d:\\temp\\", fileNameInZip, ",")
def headers
headers=pbcsClient.getHeadersInCSVAsList("d:\\temp\\", fileNameInZip, ",")
headers.each { header ->
println "header --"+header+"--"
}
println "<--"
}
} else {
println "Configuration for PBCS is invalid. Please check PBCSBICSAutomation.properties"
}
BICSAutomationParameters bicsParams=new BICSAutomationParameters('PBCSBICSAutomation.properties')
if (bicsParams.isConfigValid() == true) {
// load to bics
bicsClient=new BicsRestClient(bicsParams.bicsRestUrl,bicsParams.proxyHost,bicsParams.proxyPort,bicsParams.identityDomain,bicsParams.username, bicsParams.password, bicsParams.ignoreSSLCertificationPathErrors)
bicsClient.aboutBics()
bicsClient.listAllTables()
bicsClient.getTableInfo("ceal_4")
bicsClient.deleteTable("ceal_4")
// this creates a table with x columns MYCOL1 MYCOL2 MYCOL3
bicsClient.createTableToLoadCSV("ceal_4", 3 ,"MYCOL")
bicsClient.deleteDataFromTable("ceal_4")
//loadDataInTableUsingCSV(tableName, localCsvFilePath, localCsvFileName, delimiterInCsv,numberOfColumnsInCsv,numberOfLinesToSkip,columnPrefixInTable,isZipped)
bicsClient.loadDataInTableUsingCSV("ceal_4", "d:\\temp","export.csv",",",3,0,"MYCOL",false)
println "**Uploading each file from zip**"
pbcsExportfiles.each { fileNameInZip ->
println "-->"+fileNameInZip
def nbColsInCsv
nbColsInCsv=pbcsClient.findNbOfColsInCSV("d:\\temp\\", fileNameInZip, ",")
println "Nb of cols in csv:"+nbColsInCsv
def listHeaders
listHeaders=pbcsClient.getHeadersInCSVAsList("d:\\temp\\", fileNameInZip, ",")
listHeaders=bicsClient.truncateList(listHeaders, 30)
bicsClient.deleteTable("ceal_8")
bicsClient.createTableToLoadCSVWithHeaderNames("ceal_8", listHeaders )
//loadDataInTableUsingCSVAndHeader(tableName, localCsvFilePath, localCsvFileName, delimiterInCsv,numberOfLinesToSkip,listHeaders,isZipped)
bicsClient.loadDataInTableUsingCSVAndHeader("ceal_8", "d:\\temp",fileNameInZip,",",1,listHeaders,false)
println "<--"
}
println "****"
} else {
println "Configuration for BICS is invalid. Please check PBCSBICSAutomation.properties"
}
APEXAutomationParameters apexParams=new APEXAutomationParameters('PBCSBICSAutomation.properties')
if (apexParams.isConfigValid() == true) {
// load to bics
apexClient=new ApexRestClient(apexParams.apexRestUrl,apexParams.proxyHost,apexParams.proxyPort,apexParams.identityDomain,apexParams.username, apexParams.password, apexParams.ignoreSSLCertificationPathErrors)
// see ApexRestClient.groovy method def launchProcUsingGETAndParameterOnUrl(apexUri, parameter) for info on the rest configuration on server
apexClient.launchSQLQueryUsingGETAndVariableOnUrl("bics/test", "7839")
apexClient.launchProcUsingGET("bics/plsql/")
} else {
println "Configuration for Apex is invalid. Please check PBCSBICSAutomation.properties"
}
}
}
With PBCSBICSAutomation.properties
like the following:
pbcsPlanningRestUrl=https://<SERVER>/HyperionPlanning/rest/11.1.2.3.600
pbcsInteropRestUrl=https://<SERVER>/interop/rest/11.1.2.3.600
pbcsIdentityDomain=
pbcsUsername=
pbcsPassword=
proxyHost=
proxyPort=
ignoreSSLCertificationPathErrors=false
bicsRestUrl=https://bicsserver
bicsIdentityDomain=
bicsUsername=
bicsPassword=
apexRestUrl=https://dbserver/apex
apexIdentityDomain=
apexUsername=
apexPassword=