Skip to end of metadata
Go to start of metadata

API Description

Gateway Objects

All Model Gateway operations (import, export and synchronize) are accessible through the Gateway class which is part of the module arki.utils.modelgateway.gateway.

  • class Gateway( ruleSheets=None, checkMetamodel=True, viewList=None )

    Creates a new Gateway object with the following parameters:
    • ruleSheets: can either be a Rule Model file path or a RuleSheets object, if None the user is asked to select the file.
    • checkMetamodel: if_True_ then the Model Gateway performs several Type Diagram/Meta Model coherency check, setting it to False disables those checks.
    • viewList: list of the names of view filters to be used by the Model Gateway (None means that all filters are used). As the Model Gateway needs to work in an 'all' view, it tries to reconstruct it from the available view filters available. As processing multiple view filters takes time it is better to limit the Model Gateway to as few view filters as possible (the ideal being a unique 'all' view filter).
  • Gateway.Import( excelFile=None, reader=None, sheetMapper=None, macroDict=None )

    Warning: you must always pass optional arguments by keyword as the actual order in the code may be different.

    Icon
     

    Import data in the current project using the Model Gateway.

    • excelFile: path of the Excel file to be imported, if None the user will be asked to select the file.
    • reader: if None the Model Gateway will use the default excel file reader, otherwise reader must be an object deriving from the class arki.utils.modelgateway.datareader.DataReader.
    • sheetMapper: optional function which maps the sheets defined in the Rule Model with the tables/sheet of the input data. For example this mechanism allows to reuse the same Rule Model sheet for several tables in the input data.
    • macroDict: optional dictionary containing the identifier and value of user defined macros. Macro identifier found in the rule sheet columns default and filter values are replaced by the value found in macroDict.
  • Gateway.Export( writer=None, fullBranchMerge=False, template=None, macroDict=None, outFilename=None, readableRtf=False, embedRtf=False )

    Warning: you must always pass optional arguments by keyword as the actual order in the code may be different.

    Icon
     

    Exports the current project data using the Model Gateway.

    • writer: the writer to be used, if not specified it default to the Excel writer, otherwise must be an object deriving from arki.utils.modelgateway.datawriter.DataWriter.
    • fullBranchMerge: flag indicating if the 'branches' (tables resulting from branches in the Rule Model) should be completely merged or not. Complete merge means that the Model Gateway creates a row for each (item1,item2) couple where item1 is an element from one branch and item2 an element from the other branch. This feature can be very memory CPU consuming and for this reason is disabled by default.
    • template: specify the use of a template Excel file if it evaluates to True. If it is a string it indicates the path to the template file, otherwise the user is asked to select the template file.
    • macroDict: optional dictionary containing the identifier and value of user defined macros. Macro identifier found in the rule sheet columns default and filter values are replaced by the value found in macroDict.
    • outFilename: if set, and if writer is None, the file the Excel will be saved as.
    • embedRtf: if True, and if writer is None, save RTF data in separate files.
    • readableRtf: if True, and if writer is None, save RTF as plain text. Also ignored if embedRtf is True.
  • Gateway.Synchronize( excelFile=None, reader=None, sheetMapper=None, macroDict=None, exportDict=None )

    Warning: you must always pass optional arguments by keyword as the actual order in the code may be different.

    Icon
     

    Warning: 'exportDict' parameter is only available with arKItect 3.1 or a more recent version

    Icon
     

    Synchronizes the current project with the source file using the Model Gateway. Refer to the Import method for the arguments description. Note that, contrary to import, synchronize can delete arKItect objects, however the Model Gateway always asks for user confirmation before completely deleting any object (But he will not ask for confirmation before deleting a object locally under some parent).

    Use exportDict with Synchronize (available with 3.1. or more recent versions):

    When you synchronize an Excel file into your arKItect project, sometimes the file does not contain all the project data. In order to control the way MGW compares data at synchronize, you can pass him as parameter an 'exportDict' which will allow him to do an extract of the project data and use it to compare it with the synchronized Excel. He will then manage object deleting based on this filter of objects.

    exportDict should contain the following keys: 'ruleSheets' (mandatory), 'macroDict' (optional), 'viewList' (optional).
    example: gateway.Synchronize(exportDict={'ruleSheets':'myExport.rmgw', 'macroDict'=myExportMacroDict, 'viewList'=myExportViewList})

 

  • Gateway.SetDeletedRelationsHandlerhandler )

    No veto possible

    Icon

    The handler is called after all changes to the project have been applyed, and thus, cannot veto anything. It's typically used to remove still more arKItect objects, but it cannot cancel any deletion. The arguments are to be read-only and removing from them won't make the Gateway remove less arKItect objects.

    Overwrite

    Icon

    The call overwrites previous binding. To cancel the current handler binding, call with handler being None.


    Binds either None (the initial default) or a handler to the current object, having pseudo-code signature :

    Where unconnectedNodes is a set of ModelGraphNode that are no longer connected (last instance of arKItect object has been removed), and

    where removedRelations is a dict having

    • Key: the child ModelGraphNode who still has at least one parent

    • Values: list of parents whose child has been disconnected of

 

 

Import
Export
Synchronize
Synchronize with an extended deleter (simple)
Synchronize with an extended deleter (in a GUI application)
Import of specific file with specific rule maker
Export using a template file and with specific rule maker
Synchronize using specific file with specific rule maker

 

 

  • No labels