Page tree
Skip to end of metadata
Go to start of metadata

Cantor scripts contain program code statements written in Cantor (a Domain-Specific Language built on Groovy). They can be used in conjunction with Groovy scripts, and even Java classes and interfaces.  Scripts can be written for any custom programming, practical processing purposes.  The syntax is similar to Visual Basic.  A number of supporting component libraries are also available.

Creating a Cantor script

Scripts are generated in the Project Explorer. Context menu → New → e. g. Cantor Script.

Then the directory and the file name have to be entered.

Create a script name, using the required extension .cantor, in the selected directory.

Press Finish: an empty Editor window opens.

Example cantor script

The following script reads data from an Excel spreadseet, adds an index to the business object that was created during the Extract, and writes the resulting data out to a database table.

 

' 1) read Excel spreadsheet - 2) add an index - 3) write data to a table
MappingHelper.setMapping(FromExcelToTable, "fromProspectsExcel")  ' Extract from Excel spreadsheet into BO
Dim recordsInList As BusinessObjectList = Query From FromExcelToTable
MappingHelper.setMapping(FromExcelToTable, "toDatabaseTable")  ' Load from BO into DB table
Dim recordsOutList As BusinessObjectList = Query From FromExcelToTable Writable
Dim counter = 0
Dim logger As LoggerUtil.Logger = LoggerUtil.getLogger(this)
Try
     recordsOutList.clear() ' empty out list of BOs to restart each time from scratch
Catch ex As Exception
     notice ("Error while clearing the output list: " + ex.getMessage() + ": Ok to ignore!")
End Try
Try
     If fernbach.cantor.script.Sql.execute ("drop table SAMPLE_EXCEL_SOURCE;") Then
     logger.notice ("Dropped table SAMPLE_EXCEL_SOURCE")
Else
     logger.notice ("Table not dropped, but no error!")
End If
Catch ex As Exception
     logger.notice ("Error dropping table: " + ex.getMessage())
End Try
Try
     If recordsInList.isEmpty() Then
          logger.notice ("Error: empty input list!")
          Return
     End If
Catch ex As Exception
     logger.notice ("Error while testing inputList: " + ex.getMessage())
End Try

Dim recordsIn As Iterator = recordsInList.iterator()
Do While recordsIn.hasNext() ' read each line with Do While
     Dim bo As BusinessObject = recordsIn.next()
     counter += 1
     bo.index = counter
     recordsOutList.addNew(bo)
     logger.notice ("Name for record " + bo.index + ": " + bo.firstName + " " + bo.lastName)
Loop
try
     recordsOutList.store()
Catch ex As Exception
     logger.notice ("Could not write to db table: " + ex.getMessage())
     Return
End Try
logger.notice ("--- Extracted records stored in table ---")

Cantor scripts configurations

For a Jabatix Script or a Process Flow one or more preconfigured settings for the model parameters can be defined and stored in the Jabatix Workbench. 

By  using this feature, it is possible to run a Process Flow on the Jabatix EE server with an individual setting for the model parameters. 

  • Select Cantor Scripts Configurations… in the drop down menu of the Run icon. 

 

  • On the context menu of Remote Processflow select New. If a configuration for a single Jabatix Script is needed, use the context menu of the Cantor Script for a local or Cantor Remote Script for the server execution.
  • Type in a name for the individual configuration
  • Select in the tab Process Flow a Jabatix Model and a Process Flow 



  • Switch to the tab Parameters and select Customize model parameters
  • An individual configuration of the model parameters can be captured in the column Customized values:

 

 

  • Click Apply to save the configuration.
  • By clicking Run, the Process Flow with the individual parameter settings is executed on the Jabatix EE server. 
  • A stored Cantor Scripts Configuration can be restarted on the Jabatix EE server by selecting the corresponding Processflow in the selection box of the Run icon. 


 

  • No labels