Creating the OnPlacement Method
In this step, choose the parameters for the GUI Node, starting with the
onPlacement() method.
As previously discussed in this tutorial, the
onPlacement() method defines the behavior of the operator when the user drags the operator from the sidebar onto the workflow canvas. During this step, think about what users see and can choose from the
TIBCO Data Science - Team Studio GUI when they run the operator.
Because the output dataset needs an integer for the number of rows to output, add a parameter for it here. Additionally, users need to be able to choose the format in which their result dataset is stored (in this case, TSV, Avro, or Parquet). Finally, because this job runs on Spark, add parameters so the user can customize the Spark job.
Before you beginCreating the GUI Node Class.
- Procedure
- Add the following code:
override def onPlacement( operatorDialog: OperatorDialog, operatorDataSourceManager: OperatorDataSourceManager, operatorSchemaManager: OperatorSchemaManager): Unit = { // add a parameter to the dialog so the user can enumerate the number of things (the // length of the dataset) to generate. operatorDialog.addIntegerBox( DatasetGeneratorUtils.numberRowsParamKey, // the constant we defined in DatasetGeneratorUtils, above "Number of things", // name of the parameter 0, // minimum accepted value 100,// maximum accepted value 10 // default value ) /* Use the HdfsParameterUtils class to add a dropdown list box, so the user can determine how the output data is stored (CSV, Avro, Parquet). Default to CSV. */ HdfsParameterUtils.addHdfsStorageFormatParameter(operatorDialog, HdfsStorageFormatType.CSV) /* * Use the HdfsParameterUtils class to add parameters about how/where to store the output * dataset. In particular: the output directory, the output name, and whether to overwrite * anything already stored at that location. */ HdfsParameterUtils.addStandardHdfsOutputParameters(operatorDialog) /* * Use the SparkParameterUtils class to add the some parameters to let the user configure the * Spark job. */ SparkParameterUtils.addStandardSparkOptions( operatorDialog, additionalSparkParameters = List() ) }
What to do nextCreate the onInputOrParameterChange method.