public abstract class EpmScript
extends groovy.lang.Script
By default, parameters are case insensitive and may not be null or empty unless otherwise specified.
Constructor and Description |
---|
EpmScript()
Constructs an instance of this class with default parameters.
|
Modifier and Type | Method and Description |
---|---|
Connection |
connection(java.lang.String url,
java.lang.String userName,
java.lang.String password)
Returns a new connection to the resource identified by the sepcified URL.
|
oracle.epm.api.model.DataExportCsvWriter |
createEpmCellCsvWriter(java.io.Writer writer,
java.util.Collection<Dimension> rowDimensions,
java.util.Collection<Member> columnMembers)
Creates and returns a new cell based CSV writer.
|
oracle.epm.api.model.DataExportCsvWriter |
createEpmCellCsvWriter(java.io.Writer writer,
java.util.Collection<Dimension> rowDimensions,
java.util.Collection<Member> columnMembers,
char delimiter)
Creates and returns a new cell based CSV writer.
|
oracle.epm.api.model.DataExportCsvWriter |
createEpmColumnCsvWriter(java.io.Writer writer,
java.util.Collection<Dimension> rowDimensions,
java.util.Collection<Member> columnMembers)
Creates and returns a new column based CSV writer.
|
oracle.epm.api.model.DataExportCsvWriter |
createEpmColumnCsvWriter(java.io.Writer writer,
java.util.Collection<Dimension> rowDimensions,
java.util.Collection<Member> columnMembers,
char delimiter)
Creates and returns a new column based CSV writer.
|
java.io.PrintWriter |
createFilePrintWriter(java.lang.String fileName)
Creates and returns a new file PrintWriter.
|
java.io.PrintWriter |
createFilePrintWriter(java.lang.String fileName,
java.lang.String charsetName,
boolean forceBomIfPossible)
Creates and returns a new file PrintWriter.
|
java.io.Writer |
createFileWriter(java.lang.String fileName)
Creates and returns a new file writer.
|
java.io.Writer |
createFileWriter(java.lang.String fileName,
java.lang.String charsetName,
boolean forceBomIfPossible)
Creates and returns a new file writer.
|
RowData |
createRowData(Tuple rowMembersTuple,
java.util.Collection<Member> columnMembers,
java.util.Map<java.lang.String,java.lang.String> columnMemberNamesToValues)
Returns the newly created RowData with the specified members and data.
|
RowData |
createRowData(Tuple rowMembersTuple,
java.util.Map<java.lang.String,java.lang.String> columnMemberNamesToValues)
Returns the newly created RowData with the specified members and data.
|
RowData |
createRowData(Tuple rowMembersTuple,
java.util.Set<Member> columnMembers,
java.util.Map<java.lang.String,java.lang.String> columnMemberNamesToValues)
Returns the newly created RowData with the specified members and data.
|
java.io.Writer |
createZipFileWriter(java.lang.String zipFileName,
java.lang.String innerFileName)
Creates and returns a new zip file writer.
|
java.lang.String |
cscParams(java.util.Collection<?> items)
Returns a string value with each of the specified items flattened, quoted
and seperated by a comma.
|
java.lang.String |
cscParams(java.lang.Object... items)
Returns a string value with each of the specified items flattened, quoted
and seperated by a comma.
|
CloseableIterator<java.lang.String[]> |
csvIterator(java.lang.String inputFileName)
Returns an iterator to iterate over the rows of a CSV file.
|
CloseableIterator<java.lang.String[]> |
csvIterator(java.lang.String inputFileName,
char separator)
Returns an iterator to iterate over the rows of a CSV file.
|
CloseableIterator<java.lang.String[]> |
csvIterator(java.lang.String inputFileName,
java.lang.String separator)
Returns an iterator to iterate over the rows of a CSV file.
|
CsvWriter |
csvWriter(java.lang.String outputFileName)
Returns a CsvWriter to write values to a CSV file using a comma for the
separator and quoting only values that are required to be quoted.
|
CsvWriter |
csvWriter(java.lang.String outputFileName,
boolean quoteAllValues)
Returns a CsvWriter to write values to a CSV file using a comma for the
separator and quoting based on the option provided.
|
CsvWriter |
csvWriter(java.lang.String outputFileName,
char separator)
Returns a CsvWriter to write values to a CSV file using using a comma for
the separator and quoting only values that are required to be quoted.
|
CsvWriter |
csvWriter(java.lang.String outputFileName,
char separator,
boolean quoteAllValues)
Returns a CsvWriter to write values to a CSV file using the separator
and quoting based on the options provided.
|
CsvWriter |
csvWriter(java.lang.String outputFileName,
java.lang.String separator)
Returns a CsvWriter to write values to a CSV file using the separator
provided and quoting only values that are required to be quoted.
|
CsvWriter |
csvWriter(java.lang.String outputFileName,
java.lang.String separator,
boolean quoteAllValues)
Returns a CsvWriter to write values to a CSV file using the separator
and quoting based on the options provided.
|
long |
currentTimeMillis()
Returns the current time in milliseconds.
|
Job |
executeJob(JobDefinition jobDef)
Executes the job with the specified job definition and returns the
job once it has completed or failed.
|
java.lang.String |
fixValues(EssbaseCompatible... objects)
Returns a string value for the specified objects that can be plugged into
a Essbase calc script FIX command.
|
Rule |
getCurrentRule()
Returns the current rule being executed.
|
long |
getEntryId(java.lang.String smartListName,
java.lang.String smartListEntryName)
Returns the smart list entry id for the specified smart list name
and entry name.
|
oracle.epm.api.epmctl.EpmAutomate |
getEpmAutomate()
Returns an EpmAutomate instance class.
|
java.util.Map<java.lang.String,RtpValue> |
getRtps()
Returns an unmodifiable map of RtpValue objects for the run time prompts
used in this script.
|
Rule |
getRule()
Returns the current rule being executed.
|
int |
getTextCellId(java.lang.String textVal,
boolean createIfNotFound)
Returns the text cell id for the specified text value or 0 if the text
value is not found and createIfNotFound is false.
|
java.lang.String |
json(java.util.Map<java.lang.String,?> input)
Returns a JSON string for the specified input map.
|
java.lang.String |
mdxParams(java.lang.Object... items)
Returns a string value with each of the specified items flattened,
evaluated and converted to MDX delimited identifiers and separated by a
comma.
|
GroovyMessageBundle |
messageBundle(java.util.Map<java.lang.String,java.lang.String> resourceMap)
Returns a new in memory resource bundle that contains locale-specific
resources provided to it.
|
GroovyResourceBundleLoader |
messageBundleLoader(java.util.Map<java.lang.String,GroovyMessageBundle> messageBundleMap)
Returns a resource bundle loader that manages message bundles by locale.
|
long |
nanoTime()
Returns the current value of the running Java Virtual Machine's
high-resolution time source, in nanoseconds.
|
void |
print(java.lang.Object value)
Prints the value to the current operation's job details, which can be
viewed from the job console.
|
void |
printf(java.lang.String format,
java.lang.Object value)
Prints a formatted string using the specified format string and argument
to the current operation's job details, which can be viewed from the job
console.
|
void |
printf(java.lang.String format,
java.lang.Object[] values)
Prints a formatted string using the specified format string and arguments
to the current operation's job details, which can be viewed from the job
console.
|
void |
println()
Prints a newline to the current operation's job details, which can be
viewed from the job console.
|
void |
println(java.lang.Object value)
Prints the value and a newline to the current operation's job details,
which can be viewed from the job console.
|
java.lang.String |
stripQuotes(java.lang.String text)
Return the specified text with double quotation removed.
|
void |
throwVetoException(GroovyResourceBundleLoader rbl,
java.lang.String resourceKey,
java.lang.Object... parameters)
Throws an exception indicating that the operation in progress must be
vetoed.
|
void |
throwVetoException(com.hyperion.planning.HspDynamicLocalizedException cause)
Throws an exception indicating that the operation in progress must be
vetoed.
|
void |
throwVetoException(com.hyperion.planning.HspLocalizedException cause)
Throws an exception indicating that the operation in progress must be
vetoed.
|
void |
throwVetoException(java.lang.String message)
Throws an exception indicating that the operation in progress must be
vetoed.
|
void |
validateRtp(RtpValue rtp,
oracle.epm.api.model.Predicate<RtpValue> predicate,
GroovyResourceBundleLoader rbl,
java.lang.String resourceKey,
java.lang.Object... parameters)
Validates the run time prompt value against the specified predicate.
|
void |
validateRtp(RtpValue rtpValue,
java.lang.String pattern,
GroovyResourceBundleLoader rbl,
java.lang.String resourceKey,
java.lang.Object... parameters)
Validates the run time prompt value against the specified regular
expression pattern.
|
public EpmScript()
public Connection connection(java.lang.String url, java.lang.String userName, java.lang.String password)
url
- resource URLuserName
- name of the userpassword
- password for the userpublic oracle.epm.api.model.DataExportCsvWriter createEpmCellCsvWriter(java.io.Writer writer, java.util.Collection<Dimension> rowDimensions, java.util.Collection<Member> columnMembers)
Example data file for cell Format:
"Years","Scenario","Version","Currency","Entity","Grades","Employee","Account","Period"
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Price","Jan",5
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Price","Feb",5
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Price","Mar",4
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Discount Percentage","Jan",0.1
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Discount Percentage","Feb",0.5
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Discount Percentage","Mar",0.15
writer
- writer write torowDimensions
- names of dimenisons for row memberscolumnMembers
- names of cloumn memberspublic oracle.epm.api.model.DataExportCsvWriter createEpmCellCsvWriter(java.io.Writer writer, java.util.Collection<Dimension> rowDimensions, java.util.Collection<Member> columnMembers, char delimiter)
Example data file for cell Format:
"Years","Scenario","Version","Currency","Entity","Grades","Employee","Account","Period"
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Price","Jan",5
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Price","Feb",5
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Price","Mar",4
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Discount Percentage","Jan",0.1
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Discount Percentage","Feb",0.5
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Discount Percentage","Mar",0.15
writer
- writer write torowDimensions
- names of dimenisons for row memberscolumnMembers
- names of cloumn membersdelimiter
- delimiter to use, defaults to ','public oracle.epm.api.model.DataExportCsvWriter createEpmColumnCsvWriter(java.io.Writer writer, java.util.Collection<Dimension> rowDimensions, java.util.Collection<Member> columnMembers)
Example data file for Column Format:
"Years","Scenario","Version","Currency","Entity","Grades","Employee","Account","Period"
"Jan","Feb","Dec"
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Price",5,5,4
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Discount Percentage",0.1,0.5,0.15
writer
- writer write torowDimensions
- names of dimenisons for row memberscolumnMembers
- names of cloumn memberspublic oracle.epm.api.model.DataExportCsvWriter createEpmColumnCsvWriter(java.io.Writer writer, java.util.Collection<Dimension> rowDimensions, java.util.Collection<Member> columnMembers, char delimiter)
Example data file for Column Format:
"Years","Scenario","Version","Currency","Entity","Grades","Employee","Account","Period"
"Jan","Feb","Dec"
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Price",5,5,4
"FY19","Current","BU Version_1","EUR","CA","Grade 1","Employee 1","Discount Percentage",0.1,0.5,0.15
writer
- writer write torowDimensions
- names of dimenisons for row memberscolumnMembers
- names of cloumn membersdelimiter
- delimiter to use, defaults to ','public java.io.PrintWriter createFilePrintWriter(java.lang.String fileName) throws java.io.UnsupportedEncodingException, java.io.FileNotFoundException
The file will be available in the Outbox when the writer is closed.
Example call from Groovy:
/*RTPS: */ createFilePrintWriter('test.log').withCloseable() { out -> out.println 'Hello World!' }
fileName
- name of the file to createjava.io.UnsupportedEncodingException
- if the UTF-8 charset is not
supportedjava.io.FileNotFoundException
- if an exception occurs when opening or
creating a new file with the specified name, possibly due to an invalid
file name or illegal characterspublic java.io.PrintWriter createFilePrintWriter(java.lang.String fileName, java.lang.String charsetName, boolean forceBomIfPossible) throws java.io.FileNotFoundException, java.io.IOException
The file will be available in the Outbox when the writer is closed.
Example call from Groovy:
/*RTPS: */ createFilePrintWriter('test.log').withCloseable() { out -> out.println 'Hello World!' }
fileName
- name of the file to createcharsetName
- name of the requested charsetforceBomIfPossible
- if true, the byte order mark will be added to
the writer for the following charsets: UTF_8, UTF_16, UTF_16LE, UTF_16BEjava.io.FileNotFoundException
- if an exception occurs when opening or
creating a new file with the specified name, possibly due to an invalid
file name or illegal charactersjava.io.IOException
- if an I/O error occursjava.nio.charset.IllegalCharsetNameException
- - If the given charset name is illegaljava.lang.IllegalArgumentException
- - If the given charsetName is nulljava.nio.charset.UnsupportedCharsetException
- - If the specified charset is not supportedpublic java.io.Writer createFileWriter(java.lang.String fileName) throws java.io.UnsupportedEncodingException, java.io.FileNotFoundException
The file will be available in the Outbox when the writer is closed.
fileName
- name of the file to createjava.io.UnsupportedEncodingException
- if the UTF-8 charset is not
supportedjava.io.FileNotFoundException
- if an exception occurs when opening or
creating a new file with the specified name, possibly due to an invalid
file name or illegal characterspublic java.io.Writer createFileWriter(java.lang.String fileName, java.lang.String charsetName, boolean forceBomIfPossible) throws java.io.FileNotFoundException, java.io.IOException
The file will be available in the Outbox when the writer is closed.
fileName
- name of the file to createcharsetName
- name of the requested charsetforceBomIfPossible
- if true, the byte order mark will be added to
the writer for the following charsets: UTF_8, UTF_16, UTF_16LE, UTF_16BEjava.io.FileNotFoundException
- if an exception occurs when opening or
creating a new file with the specified name, possibly due to an invalid
file name or illegal charactersjava.io.IOException
- if an I/O error occursjava.nio.charset.IllegalCharsetNameException
- if the given charset name is illegaljava.lang.IllegalArgumentException
- if the given charsetName is nulljava.nio.charset.UnsupportedCharsetException
- if the specified charset is not supportedpublic RowData createRowData(Tuple rowMembersTuple, java.util.Collection<Member> columnMembers, java.util.Map<java.lang.String,java.lang.String> columnMemberNamesToValues)
rowMembersTuple
- row dimension to members mapcolumnMembers
- column memberscolumnMemberNamesToValues
- column member names to values mappublic RowData createRowData(Tuple rowMembersTuple, java.util.Map<java.lang.String,java.lang.String> columnMemberNamesToValues)
The column members from the first RowData of the current data export will be used.
rowMembersTuple
- row dimension to members mapcolumnMemberNamesToValues
- column member names to values mappublic RowData createRowData(Tuple rowMembersTuple, java.util.Set<Member> columnMembers, java.util.Map<java.lang.String,java.lang.String> columnMemberNamesToValues)
rowMembersTuple
- row dimension to members mapcolumnMembers
- column memberscolumnMemberNamesToValues
- column member names to values mappublic java.io.Writer createZipFileWriter(java.lang.String zipFileName, java.lang.String innerFileName) throws java.io.UnsupportedEncodingException, java.io.FileNotFoundException, java.io.IOException
The zip file will be available in the Outbox when the writer is closed.
zipFileName
- name of the zip file to createinnerFileName
- name of the file the content will be written to
and zipppedjava.io.UnsupportedEncodingException
- if the UTF-8 charset is not
supportedjava.io.FileNotFoundException
- if an exception occurs when opening or
creating a new file with the specified name, possibly due to invalid
file name or illegal charactersjava.io.IOException
- if an I/O error occurspublic java.lang.String cscParams(java.util.Collection<?> items)
The string returned by this method can be plugged into a Essbase calc script command as parameters.
This method accepts primitive arrays, Object arrays, Iterable objects and Maps which are flattened before quoting them. Maps are converted into map.values() as they are flattened.
This method supports objects that are references to a member (see section Member References)
Example call from Groovy to demonstrate calling this method with a list of HeaderCell, RtpValue and Member type of objects as parameters.
/*RTPS: {Periods}*/ Application app = operation.application Cube cube = app.getCube("OEP_FS") println operation.grid.pov*.mbrName List<DataGrid.HeaderCell> povMemberCells = operation.grid.pov*.findAll { DataGrid.HeaderCell it -> it.dimName != "Plan Element" } as List<DataGrid.HeaderCell> List<Member> products = app.getDimension("Product").getEvaluatedMembers("ILvl0Descendants(Product)", cube) String calcScript = """ Fix(${cscParams([povMemberCells, rtps.periods, products])}) "OFS_Calculated" ( "OFS_Product Revenue" = "OFS_Volume" * "OFS_Avg Selling Price"; ) EndFix;""" println("The following calc script was executed by $operation.user.fullName: \n $calcScript") return calcScript
items
- collection of one or more objectsoracle.epm.api.model.IllegalScriptArgumentException
- if null items were found in the
flattened list.public java.lang.String cscParams(java.lang.Object... items)
The string returned by this method can be plugged into a Essbase calc script command as parameters.
This method accepts primitive arrays, Object arrays, Iterable objects and Maps which are flattened before quoting them. Maps are converted into map.values() as they are flattened.
This method supports objects that are references to a member (see section Member References)
Example call from Groovy to demonstrate calling this method with an array of HeaderCell, RtpValue and Member type of objects as parameters.
/*RTPS: {Periods}*/ Application app = operation.application Cube cube = app.getCube("OEP_FS") println operation.grid.pov*.mbrName List<DataGrid.HeaderCell> povMemberCells = operation.grid.pov*.findAll { DataGrid.HeaderCell it -> it.dimName != "Plan Element" } as List<DataGrid.HeaderCell> List<Member> products = app.getDimension("Product").getEvaluatedMembers("ILvl0Descendants(Product)", cube) String calcScript = """ Fix(${cscParams(povMemberCells, rtps.periods, products)}) "OFS_Calculated" ( "OFS_Product Revenue" = "OFS_Volume" * "OFS_Avg Selling Price"; ) EndFix;""" println("The following calc script was executed by $operation.user.fullName: \n $calcScript") return calcScript
items
- one or more objectsoracle.epm.api.model.IllegalScriptArgumentException
- if null items were found in the
flattened list.public CloseableIterator<java.lang.String[]> csvIterator(java.lang.String inputFileName) throws java.io.IOException
Example call from Groovy:
/*RTPS: */ csvIterator('test.csv').withCloseable() { reader -> reader.each { String[] values -> println(Arrays.toString(values)) } }
inputFileName
- name of the file to read and iterate over. The file
name can contain only alphabets, digits, '_', '-' or a space.java.io.IOException
- if an I/O error occurspublic CloseableIterator<java.lang.String[]> csvIterator(java.lang.String inputFileName, char separator) throws java.io.IOException
Example call from Groovy:
/*RTPS: */ csvIterator('test.csv', (char)'\t').withCloseable() { reader -> reader.each { String[] values -> println(Arrays.toString(values)) } }
inputFileName
- name of the file to read and iterate over. The file
name can contain only alphabets, digits, '_', '-' or a space.separator
- separator used in the input filejava.io.IOException
- if an I/O error occurspublic CloseableIterator<java.lang.String[]> csvIterator(java.lang.String inputFileName, java.lang.String separator) throws java.io.IOException
Example call from Groovy:
/*RTPS: */ csvIterator('test.csv', '\t').withCloseable() { reader -> reader.each { String[] values -> println(Arrays.toString(values)) } }
inputFileName
- name of the file to read and iterate over. The file
name can contain only alphabets, digits, '_', '-' or a space.separator
- separator used in the input file(first char will be
used as the separator)java.io.IOException
- if an I/O error occurspublic CsvWriter csvWriter(java.lang.String outputFileName)
Example call from Groovy:
/*RTPS: */ csvWriter('test.csv').withCloseable() { out -> out.writeNext 'Scenario', 'Data Storage', 'Start Year', 'End Year', 'Start Period', 'End Period' out.writeNext 'Current', 'Store', 'FY16', 'FY24', 'Jan', 'Dec' out.writeNext 'Variance', 'Never Share', 'FY12', 'FY20', 'Jan', 'Dec' out.writeNext 'Variance Comments', 'Store', 'FY12', 'FY24', 'Apr', 'Aug' out.writeNext 'Act vs Plan %', 'Dynamic Calc', 'FY10', 'FY18', 'Jan', 'Dec' }
outputFileName
- file where values are written. The file
name can contain only alphabets, digits, '_', '-' or a space.
The file name cannot point to an existing directory. The file will be
overwritten if it exists.public CsvWriter csvWriter(java.lang.String outputFileName, boolean quoteAllValues)
Example call from Groovy:
/*RTPS: */ csvWriter('test.csv', true).withCloseable() { out -> out.writeNext 'Scenario', 'Data Storage', 'Start Year', 'End Year', 'Start Period', 'End Period' out.writeNext 'Current', 'Store', 'FY16', 'FY24', 'Jan', 'Dec' out.writeNext 'Variance', 'Never Share', 'FY12', 'FY20', 'Jan', 'Dec' out.writeNext 'Variance Comments', 'Store', 'FY12', 'FY24', 'Apr', 'Aug' out.writeNext 'Act vs Plan %', 'Dynamic Calc', 'FY10', 'FY18', 'Jan', 'Dec' }
outputFileName
- file where values are written. The file
name can contain only alphabets, digits, '_', '-' or a space.
The file name cannot point to an existing directory. The file will be
overwritten if it exists.quoteAllValues
- true if all values are to be quoted, false
to quote only values that are required to be quotedpublic CsvWriter csvWriter(java.lang.String outputFileName, char separator)
Example call from Groovy:
/*RTPS: */ csvWriter('test.csv', (char)'\t').withCloseable() { out -> out.writeNext 'Scenario', 'Data Storage', 'Start Year', 'End Year', 'Start Period', 'End Period' out.writeNext 'Current', 'Store', 'FY16', 'FY24', 'Jan', 'Dec' out.writeNext 'Variance', 'Never Share', 'FY12', 'FY20', 'Jan', 'Dec' out.writeNext 'Variance Comments', 'Store', 'FY12', 'FY24', 'Apr', 'Aug' out.writeNext 'Act vs Plan %', 'Dynamic Calc', 'FY10', 'FY18', 'Jan', 'Dec' }
outputFileName
- file where values are written. The file
name can contain only alphabets, digits, '_', '-' or a space.
The file name cannot point to an existing directory. The file will be
overwritten if it exists.separator
- separator to be usedpublic CsvWriter csvWriter(java.lang.String outputFileName, char separator, boolean quoteAllValues)
Example call from Groovy:
/*RTPS: */ csvWriter('test.csv', (char)',', true).withCloseable() { out -> out.writeNext 'Scenario', 'Data Storage', 'Start Year', 'End Year', 'Start Period', 'End Period' out.writeNext 'Current', 'Store', 'FY16', 'FY24', 'Jan', 'Dec' out.writeNext 'Variance', 'Never Share', 'FY12', 'FY20', 'Jan', 'Dec' out.writeNext 'Variance Comments', 'Store', 'FY12', 'FY24', 'Apr', 'Aug' out.writeNext 'Act vs Plan %', 'Dynamic Calc', 'FY10', 'FY18', 'Jan', 'Dec' }
outputFileName
- file where values are written. The file
name can contain only alphabets, digits, '_', '-' or a space.
The file name cannot point to an existing directory. The file will be
overwritten if it exists.separator
- separator to be usedquoteAllValues
- true if all values are to be quoted, false
to quote only values that are required to be quotedpublic CsvWriter csvWriter(java.lang.String outputFileName, java.lang.String separator)
Example call from Groovy:
/*RTPS: */ csvWriter('test.csv', '\t').withCloseable() { out -> out.writeNext 'Scenario', 'Data Storage', 'Start Year', 'End Year', 'Start Period', 'End Period' out.writeNext 'Current', 'Store', 'FY16', 'FY24', 'Jan', 'Dec' out.writeNext 'Variance', 'Never Share', 'FY12', 'FY20', 'Jan', 'Dec' out.writeNext 'Variance Comments', 'Store', 'FY12', 'FY24', 'Apr', 'Aug' out.writeNext 'Act vs Plan %', 'Dynamic Calc', 'FY10', 'FY18', 'Jan', 'Dec' }
outputFileName
- file where values are written. The file
name can contain only alphabets, digits, '_', '-' or a space.
The file name cannot point to an existing directory. The file will be
overwritten if it exists.separator
- separator to be used, first char will be
used as the separatorpublic CsvWriter csvWriter(java.lang.String outputFileName, java.lang.String separator, boolean quoteAllValues)
Example call from Groovy:
/*RTPS: */ csvWriter('test.csv', '\t').withCloseable() { out -> out.writeNext 'Scenario', 'Data Storage', 'Start Year', 'End Year', 'Start Period', 'End Period' out.writeNext 'Current', 'Store', 'FY16', 'FY24', 'Jan', 'Dec' out.writeNext 'Variance', 'Never Share', 'FY12', 'FY20', 'Jan', 'Dec' out.writeNext 'Variance Comments', 'Store', 'FY12', 'FY24', 'Apr', 'Aug' out.writeNext 'Act vs Plan %', 'Dynamic Calc', 'FY10', 'FY18', 'Jan', 'Dec' }
outputFileName
- file where values are written. The file
name can contain only alphabets, digits, '_', '-' or a space.
The file name cannot point to an existing directory. The file will be
overwritten if it exists.separator
- separator to be used(first char will be
used as the separator)quoteAllValues
- true if all values are to be quoted, false
to quote only values that are required to be quotedpublic long currentTimeMillis()
Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.
public Job executeJob(JobDefinition jobDef) throws java.lang.Exception
This will execute the job synchronously and will return only when the job execution either completes successfully or fails.
This job instance will get created as a child job of the current Groovy rule being executed.
Supported job types are Rules, Ruleset and Template. Parameter values for Member, Members, Member Range and Cross Dimension type of rtps being passed to this job should be valid in the cube the current Groovy rule is being executed against.
Note: At this time, rtp evaluations are indetermined if a rule executing against one cube executes a rule directly or indirectly in a different cube. In most cases this should be avoided as behavior in this area is subject to change.
jobDef
- job definitionjava.lang.Exception
- if an unexpected fault occurspublic java.lang.String fixValues(EssbaseCompatible... objects)
An EssbaseCompatible object can be a variety of objects such as a Member, Dimension, RtpValue, etc.
objects
- one or more EssbaseCompatible objectspublic Rule getCurrentRule()
public long getEntryId(java.lang.String smartListName, java.lang.String smartListEntryName)
The entry name can be the name of the entry such as Active or the label resource key of the entry such as LABEL_ACTIVE.
smartListName
- smart list namesmartListEntryName
- smart list entry name or non localized labeloracle.epm.api.model.IllegalScriptArgumentException
- if smartListName is null or emptypublic oracle.epm.api.epmctl.EpmAutomate getEpmAutomate()
This is a privileged method. A user with administrator privileges can automate many repeatable tasks by executing various EPM Automate commands via the returned EpmAutomate instance.
For examples on how to call EPM Automate commands from Groovy, see Running Commands without Installing EPM Automate.
public java.util.Map<java.lang.String,RtpValue> getRtps()
public Rule getRule()
getCurrentRule()
public int getTextCellId(java.lang.String textVal, boolean createIfNotFound) throws java.lang.Exception
textVal
- text valuecreateIfNotFound
- if true a new text id is created if one
does not exist for the specified text valuejava.lang.Exception
- if an unexpected error occurrsoracle.epm.api.model.IllegalScriptArgumentException
- if textVal is null or emptypublic java.lang.String json(java.util.Map<java.lang.String,?> input)
input
- input mappublic java.lang.String mdxParams(java.lang.Object... items)
The string returned by this method can be plugged into an ASO custom calc or allocation script command as parameters.
This method accepts Object arrays, Iterable objects and Maps which are flattened before converting them. Maps are converted into map.values() as they are flattened.
This method supports objects that are references to a member (see section Member References) or objects that evaluate to Member objects.
Example call from Groovy to demonstrate calling this method with an RtpValue type of object as parameters.
/*RTPS: {Month}*/ AllocationParameters allocationParameters = new AllocationParameters() allocationParameters.pov = "Crossjoin(Crossjoin(Crossjoin(Crossjoin( Crossjoin(Crossjoin({[No Currency]},{[No Entity]}),{[No Manager]}), {${mdxParams(rtps.Month)}}),{[BU Version_1]}),{[FY15]}),{[Bonus]})" allocationParameters.amount = '([No Employee], [Actual])' allocationParameters.zeroAmountOption = ZeroAmountOption.ABORT allocationParameters.targetTimeSpanOption = TargetTimeSpanOption.DIVIDE_AMOUNT allocationParameters.range = '{Descendants([Total Employees], [Total Employees].dimension.Levels(0))}' allocationParameters.target = '([Current])' allocationParameters.basis = '([Salary], [Actual])' allocationParameters.basisTimeSpanOption = BasisTimeSpanOption.COMBINE_BASIS allocationParameters.zeroBasisOption = ZeroBasisOption.NEXT_AMOUNT; allocationParameters.negativeBasisOption = NegativeBasisOption.DEFAULT allocationParameters.allocationMethod = AllocationMethod.SHARE allocationParameters.roundDigits = 2 allocationParameters.roundMethod = RoundingMethod.ERRORS_TO_HIGHEST Application app = operation.application Cube cube = app.getCube("OEP_FS") cube.executeAsoAllocation(allocationParameters)
items
- one or more objectsoracle.epm.api.model.IllegalScriptArgumentException
- if null items were found in the
flattened list.public GroovyMessageBundle messageBundle(java.util.Map<java.lang.String,java.lang.String> resourceMap)
Example call from Groovy:
def mbUs = messageBundle(["validation.invalidemail":"Email address is invalid: {0}"], ["validation.invalidphone":"Phone number is invalid: {0}"], ["validation.memberexists":"The member you have specified already exists and cannot be created: {0}."], ["validation.invalidnamelength":"Employee name must be 5 to 40 characters: {0}"])
resourceMap
- a map of locale-specific resource key/value pairspublic GroovyResourceBundleLoader messageBundleLoader(java.util.Map<java.lang.String,GroovyMessageBundle> messageBundleMap)
messageBundleMap
- a map of locale to resource bundlepublic long nanoTime()
System.nanoTime()
public void print(java.lang.Object value)
print
in class groovy.lang.Script
value
- the value to printpublic void printf(java.lang.String format, java.lang.Object value)
printf
in class groovy.lang.Script
format
- the format to followvalue
- the value to formatpublic void printf(java.lang.String format, java.lang.Object[] values)
printf
in class groovy.lang.Script
format
- the format to followvalues
- the value to be formattedpublic void println()
println
in class groovy.lang.Script
public void println(java.lang.Object value)
println
in class groovy.lang.Script
value
- the value to printpublic java.lang.String stripQuotes(java.lang.String text)
text
- the stringpublic void throwVetoException(GroovyResourceBundleLoader rbl, java.lang.String resourceKey, java.lang.Object... parameters)
rbl
- a resource bundle loader with resource bundles containing the
specified resourceKeyresourceKey
- resource key present in the resource bundleparameters
- parameters for the message or nullVetoOperationException
- that vetoes the current operation and is
shown to the end useroracle.epm.api.model.IllegalScriptArgumentException
- if rbl is null or resourceKey is
null or emptypublic void throwVetoException(com.hyperion.planning.HspDynamicLocalizedException cause) throws java.lang.Exception
cause
- the cause for this exceptionjava.lang.Exception
- if an unexpected fault occurspublic void throwVetoException(com.hyperion.planning.HspLocalizedException cause) throws java.lang.Exception
cause
- the cause for this exceptionjava.lang.Exception
- if an unexpected fault occurspublic void throwVetoException(java.lang.String message) throws java.lang.Exception
message
- detailed localized message indicating the reason for the
vetojava.lang.Exception
- if an unexpected fault occurspublic void validateRtp(RtpValue rtp, oracle.epm.api.model.Predicate<RtpValue> predicate, GroovyResourceBundleLoader rbl, java.lang.String resourceKey, java.lang.Object... parameters)
If the value does not match the predicate, a veto exception is thrown indicating that the operation in progress must be vetoed.
Example call from Groovy that validates the length of the employee name:
/*RTPS: {EmployeeName}*/ def mbUs = messageBundle(["validation.invalid.name.length":"Employee name must be 5 to 40 characters: {0}"]) def mbl = messageBundleLoader(["en" : mbUs]); validateRtp(rtps.EmployeeName, {(5..40).contains(it.enteredValue.size()) }, mbl, "validation.invalid.name.length", rtps.EmployeeName);
rtp
- an RtpValue that should be validatedpredicate
- the predicate to validate the rtp value againstrbl
- a resource bundle loader with resource bundles containing the
specified resourceKeyresourceKey
- resource key present in the resource bundleparameters
- parameters for the message or nullVetoOperationException
- that vetoes the current operation and is
shown to the end useroracle.epm.api.model.IllegalScriptArgumentException
- if rbl is null or resourceKey is
null or emptypublic void validateRtp(RtpValue rtpValue, java.lang.String pattern, GroovyResourceBundleLoader rbl, java.lang.String resourceKey, java.lang.Object... parameters)
If the value does not match the pattern, a veto exception is thrown indicating that the operation in progress must be vetoed.
Example call from Groovy that validates the employee email:
/*RTPS: {EmployeeEmail}*/ def mbUs = messageBundle(["validation.invalid.email":"Email address is invalid: {0}"]) def mbl = messageBundleLoader(["en" : mbUs]); validateRtp(rtps.EmployeeEmail, /^.+@.+/, mbl, "validation.invalid.email", rtps.EmployeeEmail.enteredValue);
rtpValue
- an RtpValue that should be validatedpattern
- the regular expression to validate the rtp value againstrbl
- a resource bundle loader with resource bundles containing the
specified resourceKeyresourceKey
- resource key present in the resource bundleparameters
- parameters for the message or nullVetoOperationException
- that vetoes the current operation and is
shown to the end useroracle.epm.api.model.IllegalScriptArgumentException
- if rbl is null or resourceKey is
null or emptyCopyright © 2017, 2024, Oracle and/or its affiliates. All rights reserved.