com.spss.psapi.task

Interface TaskRunner



  • public interface TaskRunner
    The TaskRunner provides a convenient way of creating and running tasks synchronously.
    Since:
    PSAPI 16.0
    Author:
    Julian Clinton
    • Method Detail

      • createStream

        ProcessorStream createStream(java.lang.String name,
                                   boolean autoConnect,
                                   boolean autoManage)
                                     throws ServerConnectionException
        Creates and returns a new ProcessorStream. Note that code that needs to create streams privately without having them made visible to the user should set the autoManage flag to false.
        Parameters:
        name - the object's name
        autoConnect - whether the stream should be auto-connected to the server
        autoManage - whether the stream should be added to the stream manager
        Returns:
        a new ProcessorStream
        Throws:
        ServerConnectionException - if the Session is already connected and the auto-connect flag is true but a new connection could not be created for the stream
      • openStreamFromFile

        ProcessorStream openStreamFromFile(java.lang.String filename,
                                         boolean autoManage)
                                           throws SessionException
        Reads and returns a stream from the specified file.
        Parameters:
        filename - the stream file path
        autoManage - whether the stream should be added to the stream manager
        Returns:
        the stream
        Throws:
        SessionException - if the stream cannot be loaded for some reason
      • saveStreamToFile

        void saveStreamToFile(ProcessorStream stream,
                            java.lang.String filename)
                              throws OwnerException,
                                     SessionException
        Saves the stream to the specified file location.
        Parameters:
        stream - the stream to be saved
        filename - the stream file path
        Throws:
        OwnerException - if the stream is not owned by the task runner session
        SessionException - if the stream cannot be saved for some reason
      • openModelFromFile

        ModelOutput openModelFromFile(java.lang.String filename,
                                    boolean autoManage)
                                      throws SessionException
        Reads and returns a model from the specified file.
        Parameters:
        filename - the model file path
        autoManage - whether the model should be added to the model manager
        Returns:
        the model
        Throws:
        SessionException - if the model cannot be loaded for some reason
      • saveModelToFile

        void saveModelToFile(ModelOutput modelOutput,
                           java.lang.String filename)
                             throws OwnerException,
                                    SessionException
        Saves the model to the specified file location.
        Parameters:
        modelOutput - the model to be saved
        filename - the model file path
        Throws:
        OwnerException - if the model is not owned by the task runner session
        SessionException - if the model cannot be saved for some reason
      • saveNodeToFile

        void saveNodeToFile(Processor node,
                          java.lang.String filename)
                            throws OwnerException,
                                   SessionException
        Saves the node to the specified file location.
        Parameters:
        node - the node to be saved
        filename - the node file path
        Throws:
        OwnerException - if the node is not owned by the task runner session
        SessionException - if the node cannot be saved for some reason
        Since:
        PSAPI 16.0.0.2
      • exportModelToFile

        void exportModelToFile(Processor node,
                             java.lang.String filename,
                             FileFormat fileFormat)
                               throws OwnerException,
                                      SessionException,
                                      ExportFormatException
        Exports the model in the supplied node to a file using the specified file format.
        Parameters:
        node - the model applier node to be exported
        filename - the exported file path
        fileFormat - the export file format
        Throws:
        OwnerException - if the model is not owned by the task runner session
        SessionException - if the model cannot be exported for some reason
        ExportFormatException - if the model does not support the export format
        Since:
        PSAPI 16.0.0.2
      • exportModelSummaryToFile

        void exportModelSummaryToFile(ModelOutput modelOutput,
                                    java.lang.String filename,
                                    FileFormat fileFormat)
                                      throws OwnerException,
                                             SessionException,
                                             ExportFormatException
        Exports the model summary to a file using the specified file format. Model summaries can only be exported as text or HTML.
        Parameters:
        modelOutput - the model to be exported
        filename - the exported file path
        fileFormat - the the export file format which is either FileFormat.PLAIN_TEXT or FileFormat.HTML
        Throws:
        OwnerException - if the model is not owned by the task runner session
        SessionException - if the model cannot be exported for some reason
        ExportFormatException - if the model does not support the export format
        Since:
        PSAPI 16.0.0.2
      • exportModelSummaryToFile

        void exportModelSummaryToFile(Processor node,
                                    java.lang.String filename,
                                    FileFormat fileFormat)
                                      throws OwnerException,
                                             SessionException,
                                             ExportFormatException
        Exports the model summary in the supplied node to a file using the specified file format. Model summaries can only be exported as text or HTML.
        Parameters:
        node - the model applier node to be exported
        filename - the exported file path
        fileFormat - the export file format which is either FileFormat.PLAIN_TEXT or FileFormat.HTML
        Throws:
        OwnerException - if the model is not owned by the task runner session
        SessionException - if the model cannot be exported for some reason
        ExportFormatException - if the model does not support the export format
        Since:
        PSAPI 16.0.0.2
      • openDocumentFromFile

        DocumentOutput openDocumentFromFile(java.lang.String filename,
                                          boolean autoManage)
                                            throws SessionException
        Reads and returns a document from the specified file.
        Parameters:
        filename - the document file path
        autoManage - whether the document should be added to the output manager
        Returns:
        the document
        Throws:
        SessionException - if the document cannot be loaded for some reason
      • saveDocumentToFile

        void saveDocumentToFile(DocumentOutput documentOutput,
                              java.lang.String filename)
                                throws OwnerException,
                                       SessionException
        Saves the document to the specified file location.
        Parameters:
        documentOutput - the document to be saved
        filename - the document file path
        Throws:
        OwnerException - if the document is not owned by the task runner session
        SessionException - if the document cannot be saved for some reason
      • insertNodeFromFile

        Processor insertNodeFromFile(java.lang.String filename,
                                   ProcessorDiagram diagram)
                                     throws OwnerException,
                                            SessionException,
                                            ObjectLockedException
        Reads and returns a node from the specified file, inserting it into the supplied diagram. Note that this can be used to read both Processor and CompositeProcessor objects.
        Parameters:
        filename - the file path
        diagram - the diagram that the node should be inserted into
        Returns:
        the Processor
        Throws:
        OwnerException - if the diagram is not owned by the task runner session
        SessionException - if the node cannot be loaded for some reason
        ObjectLockedException - if the stream that the node is being added to is locked
      • importPMMLModelFromFile

        ModelOutput importPMMLModelFromFile(java.lang.String filename,
                                          boolean autoManage)
                                            throws SessionException
        Reads PMML from the specified file and returns a model.
        Parameters:
        filename - the PMML file path
        autoManage - whether the model should be added to the model manager
        Returns:
        the model
        Throws:
        SessionException - if the model cannot be imported for some reason
        Since:
        PSAPI 16.0.2
      • publishModelToScoringAdapterTask

        java.lang.String publishModelToScoringAdapterTask(Processor node,
                                                        ServerDatabaseConnection dbConnection,
                                                        java.lang.String publishId)
                                                          throws PredictiveServerException
        Publishes the model from a model apply Processor to the specified database and optional ID. Returns a string representing an example of the SQL needed to call the model. The node needs to be connected to another node that provides all the columns necessary for applying the model. The stream that owns the node should be connected to a server that can access the database and the database connection must have been created via the stream that owns the supplied node.
        Parameters:
        node - the Processor containing the model
        dbConnection - the database connection associated with the node's stream
        publishId - (DB2 for z/OS databases only) an identifier for the model
        Returns:
        a string containing example SQL for calling the model
        Throws:
        PredictiveServerException - if the model cannot be published for some reason
        Since:
        PSAPI 16.0.2
        See Also:
        ProcessorStream.createServerDatabaseConnection(String, String, String, String)
      • exportOutputToFile

        void exportOutputToFile(PropertiedObject object,
                              java.lang.String filename,
                              FileFormat fileFormat,
                              java.util.Map<?,?> options)
                                throws OwnerException,
                                       SessionException,
                                       ExportFormatException
        Exports the output content from the supplied object to the specified file and format. The following document formats are supported:
        • FileFormat.PLAIN_TEXT
        • FileFormat.HTML
        • FileFormat.RTF
        • FileFormat.SPV
        • FileFormat.SPW
        • FileFormat.SPSS_WEB_REPORT
        • FileFormat.COGNOS_ACTIVE_REPORT
        • FileFormat.PDF
        • FileFormat.MS_EXCEL
        • FileFormat.MS_EXCEL2007
        • FileFormat.MS_EXCEL2007_M
        • FileFormat.MS_POWERPOINT
        The following image formats are also supported:
        • FileFormat.BITMAP
        • FileFormat.PNG
        • FileFormat.JPEG
        • FileFormat.TIFF

        If options are supplied, the value is a table of attribute/value pairs. For document exports, the options are:

        • alternate_log_file_location (string): the location of the log file if this is to be expored separately
        • custom_report_title (string): a custom title for a web report
        • excel_location_option ("AddColumns", "AddRows", "OverwriteAtCellRef"): where the content should be exported to in Excel
        • excel_operation_option ("CreateWorkbook", "CreateWorksheet", "ModifyWorksheet"): how the content should be exported to Excel
        • excel_sheetname (string): the Excel sheet name
        • excel_starting_cell_ref (string): the Excel starting cell references
        • export_html_headers (Boolean): whether to export HTML headers
        • export_image_maps (Boolean): whether to create image maps
        • export_images (Boolean): whether images should be exported separately for formats that don't support images
        • html_with_style (Boolean): whether style information should be saved
        • include_footnotes_and_captions (Boolean): whether footnotes and captions should be included
        • interactive_layer (Boolean): whether an interactive layer should be included in formats that support them
        • is_logs_excluded (Boolean): whether exclude logs
        • is_notes_excluded (Boolean): whether to exclude notes
        • is_text_excluded (Boolean): whether to exclude text content
        • javascript_file_name (string): for interactive output, the location of the JavaScript file if separate
        • model_view_option ("MVExportAll", "MVExportVisible", "MVPrintSetting"): which model views should be exported
        • page_break_between_table (Boolean): whether to create a page break between tables
        • page_setup (Map): the page setup settings (see below)
        • pdf_embed_bookmarks (Boolean): whether to embed bookmarks in PDF document
        • pdf_embed_fonts (Boolean): whether to embed fonts in the PDF document
        • pivot_table_option ("PTExportAllLayers", "PTExportVisibleLayers", "PTUsePrintLayerSetting"): how pivot tables should be handled
        • ppt_use_viewer_outlines (Boolean): whether to use viewer outlines in the PowerPoint
        • preserve_break_points (Boolean): whether to preserve break points
        • table_style (string): the name of the table style
        • text_encoding ("utf8", "utf16"): what text encoding to use in text files
        • text_doc_option ("TxtUseSpaces", "TxtUseTabs"): whether to uses spaces or tabs in text files
        • text_width_autofit (Boolean): whether to make table columns fit the content in text files
        • txt_column_width (integer): if table columns are not fitted to their content in text files, defines the column width
        • col_txt_border_character (character): the table column character when exporting to a text file
        • row_txt_border_character (character): the table column character when exporting to a text file
        • viewer_doc_name (string): the name of the document which should be displayed in the viewer
        • wide_tables_option ("WT_Extend", "WT_Shrink", "WT_Wrap"): defines how wide tables should be handled

        For graph exports, the options are:

        • bmp_compress_image (Boolean): whether to compress bitmap images
        • graph_image_size (integer): how much to scale the exported image as a percentage of the original
        • graph_invert_colors (Boolean): whether to invert the colors
        • graph_type ("BMP", "JPG", "PNG", "TIF"): defines the graph type to be used when exporting images separately from the non-image content
        • model_view_option ("MVExportAll", "MVExportVisible", "MVPrintSetting"): which model views should be exported
        • png_color_depth ("BlackWhite", "Grays", "SixteenColors", "TrueColor24", "TrueColor36", "TwoFiftySixColors"): the color depth when exporting to PNG
        • tiff_color_space ("CMYK", "RGB"): the color space when exporting to TIF
        • tiff_compress_image (Boolean): whether to compress TIF images

        For the page_setup, the options are:

        • height (Double): the page height
        • width (Double): the page width
        • bottom_margin (Double): the bottom margin
        • left_margin (Double): the left margin
        • right_margin (Double): the right margin
        • top_margin (Double): the top margin
        • orientation (Integer): 0 for portrait, 1 for landscape
        • units ("Centimeters", "Millimeters", "Inches", "PrintPoints"): the units that the margin and dimension values represent
        Parameters:
        object - the object with the output content
        filename - the file name where the output should be exported to
        fileFormat - the file format
        options - either null or a hash table of attribute values
        Throws:
        OwnerException - if the object is not owned by the current session
        ExportFormatException - if the export format is not supported
        SessionException - if some other error occurs
        Since:
        PSAPI 17.0

(C) Copyright IBM Corp. 1994, 2015. All Rights Reserved.