Skip to content
Snippets Groups Projects
jython-master-data-scripts.md 7.21 KiB
Newer Older
  • Learn to ignore specific revisions
  • Marco Del Tufo's avatar
    .
    Marco Del Tufo committed
    [Log
    in](https://unlimited.ethz.ch/login.action?os_destination=%2Fdisplay%2FopenBISDoc2010%2FJython%2BMaster%2BData%2BScripts)
    
    Linked Applications
    
    Loading…
    
    [![Confluence](/download/attachments/327682/atl.site.logo?version=1&modificationDate=1563454119905&api=v2)](/)
    
    -   [Spaces](/spacedirectory/view.action "Spaces")
    -   [Create ](# "Create from template")
    
    -   Hit enter to search
    
    -   [Help](# "Help")
        -   [Online
            Help](https://docs.atlassian.com/confluence/docs-82/ "Visit the Confluence documentation home")
        -   [Keyboard Shortcuts](# "View available keyboard shortcuts")
        -   [Feed
            Builder](/dashboard/configurerssfeed.action "Create your custom RSS feed.")
        -   [What’s
            new](https://confluence.atlassian.com/display/DOC/Confluence+8.2+Release+Notes)
        -   [Available Gadgets](# "Browse gadgets provided by Confluence")
        -   [About
            Confluence](/aboutconfluencepage.action "Get more information about Confluence")
    
    -   
    
    -   
    
    -   
    
    -   [Log
        in](/login.action?os_destination=%2Fdisplay%2FopenBISDoc2010%2FJython%2BMaster%2BData%2BScripts)
    
      
    
    [![openBIS Documentation Rel.
    20.10](/images/logo/default-space-logo.svg)](/display/openBISDoc2010/openBIS+Documentation+Rel.+20.10+Home "openBIS Documentation Rel. 20.10")
    
    [openBIS Documentation Rel.
    20.10](/display/openBISDoc2010/openBIS+Documentation+Rel.+20.10+Home "openBIS Documentation Rel. 20.10")
    
    -   [Pages](/collector/pages.action?key=openBISDoc2010)
    -   [Blog](/pages/viewrecentblogposts.action?key=openBISDoc2010)
    
    ### Page tree
    
    [](/collector/pages.action?key=openBISDoc2010)
    
    Browse pages
    
    ConfigureSpace tools
    
    [](#)
    
    -   [ ](#)
        -   [ Attachments (0)
            ](/pages/viewpageattachments.action?pageId=53746018 "View Attachments")
        -   [ Page History
            ](/pages/viewpreviousversions.action?pageId=53746018)
    
        -   [ Page Information ](/pages/viewinfo.action?pageId=53746018)
        -   [ Resolved comments ](#)
        -   [ View in Hierarchy
            ](/pages/reorderpages.action?key=openBISDoc2010&openId=53746018#selectedPageInHierarchy)
        -   [ View Source
            ](/plugins/viewsource/viewpagesrc.action?pageId=53746018)
        -   [ Export to PDF
            ](/spaces/flyingpdf/pdfpageexport.action?pageId=53746018)
        -   [ Export to Word ](/exportword?pageId=53746018)
        -   [ View Visio File
            ](/plugins/lucidchart/selectVisio.action?contentId=53746018)
    
        -   [ Copy
            ](/pages/copypage.action?idOfPageToCopy=53746018&spaceKey=openBISDoc2010)
    
    1.  [Pages](/collector/pages.action?key=openBISDoc2010)
    2.  **…**
    3.  [openBIS Documentation Rel. 20.10
        Home](/display/openBISDoc2010/openBIS+Documentation+Rel.+20.10+Home)
    4.  [openBIS 20.10
        Documentation](/display/openBISDoc2010/openBIS+20.10+Documentation)
    5.  [Guides](/display/openBISDoc2010/Guides)
    
    -   []( "Unrestricted")
    -   [Jira links]()
    
    [Jython Master Data Scripts](/display/openBISDoc2010/Jython+Master+Data+Scripts)
    --------------------------------------------------------------------------------
    
    -   Created by [Fuentes Serna Juan Mariano
        (ID)](%20%20%20%20/display/~juanf%0A), last modified by [Kovtun
        Viktor (ID)](%20%20%20%20/display/~vkovtun%0A) on [Mar 10,
        2023](/pages/diffpagesbyversion.action?pageId=53746018&selectedPageVersions=1&selectedPageVersions=2 "Show changes")
    
    Introduction
    ------------
    
    openBIS defines as "Master data" all metadata configurations needed
    before the import of the real raw data. Master data includes
    experiment/sample/data set/property/file types, vocabularies and
    property assignments.
    
    ### API Basics
    
    Similarly to the [Jython Dropbox
    API](/pages/viewpage.action?pageId=53746029) the script can access a
    global variable named `service`, which can be used to create
    transactions.
    
        transaction = service.transaction()
    
    The transactions are a focal API concept offering to create new types
    (e.g. `createNewSampleType`, `createNewDataSetType`) and new property
    assignments (e.g. `assignPropertyType`).
    
    The complete Javadoc for the API is available at
    
    [TABLE]
    
    ### Simple example
    
        import ch.systemsx.cisd.openbis.generic.client.jython.api.v1.DataType as DataType
    
        tr = service.transaction()
    
        expType = tr.createNewExperimentType('EXPERIMENT-TYPE')
        expType.setDescription('Experiment type description.')
    
        sampleType = tr.createNewSampleType('SAMPLE-TYPE')
        sampleType.setDescription('Sample type description.')
        sampleType.setSubcodeUnique(True)
        sampleType.setAutoGeneratedCode(True)
        sampleType.setGeneratedCodePrefix("G_");
    
        dataSetType = tr.createNewDataSetType('DATA-SET-TYPE')
        dataSetType.setContainerType(True)
        dataSetType.setDescription('Data set type description.')
    
        materialType = tr.createNewMaterialType('MATERIAL-TYPE')
        materialType.setDescription('Material type description.')
    
        stringPropertyType = tr.createNewPropertyType('VARCHAR-PROPERTY-TYPE', DataType.VARCHAR)
        stringPropertyType.setDescription('Varchar property type description.')
        stringPropertyType.setLabel('STRING')
    
        materialPropertyType = tr.createNewPropertyType('MATERIAL-PROPERTY-TYPE', DataType.MATERIAL)
        materialPropertyType.setDescription('Material property type description.')
        materialPropertyType.setLabel('MATERIAL')
        materialPropertyType.setMaterialType(materialType)
        materialPropertyType.setManagedInternally(False)
    
        # assigns the newly created property 'MATERIAL-PROPERTY-TYPE'
        # as a mandatory property for 'SAMPLE-TYPE'
        materialAssignment = tr.assignPropertyType(sampleType, materialPropertyType)
        materialAssignment.setMandatory(True)
    
        # assigns the newly created property 'VARCHAR-PROPERTY-TYPE'
        # as an optional property for 'EXPERIMENT-TYPE' with default value 'FOO_BAR'
        stringAssignement = tr.assignPropertyType(expType, stringPropertyType)
        stringAssignement.setMandatory(False)
        stringAssignement.setDefaultValue('FOO_BAR')
    
    ### Command line tools
    
    #### Executing master data scripts
    
    Make sure openBIS AS is up and running prior script execution. Go to the
    openBIS AS installation folder. Assuming your script is
    `/local/master-data-script.py` and openBIS AS is started on the URL
    `     http://localhost:8888/openbis   ` execute the command
    
        > cd /local0/openbis/servers/openBIS-server/jetty/bin
        > /register-master-data.sh -s http://localhost:8888/openbis/openbis -f /local/master-data-script.py
    
    You will be prompted for username/password before the script execution.
    Please note that the second 'openbis' is needed in the server address,
    so that you connect via the API.
    
    #### Exporting master data
    
    You can export the master data from a running openBIS system as script
    by running the command
    
        > cd /local0/openbis/servers/openBIS-server/jetty/bin
        > /export-master-data.sh -s http://localhost:8888/openbis/openbis
    
    This command will create a folder `exported-master-data-DATE` which will
    contain the exported master data script - `master-data.py`
    
    -   No labels
    
    Overview
    
    Content Tools
    
    Apps
    
    -   Powered by [Atlassian
        Confluence](https://www.atlassian.com/software/confluence) 8.2.0
    -   Printed by Atlassian Confluence 8.2.0
    -   [Report a bug](https://support.atlassian.com/confluence-server/)
    -   [Atlassian News](https://www.atlassian.com/company)
    
    [Atlassian](https://www.atlassian.com/)
    
    {"serverDuration": 132, "requestCorrelationId": "dd6427c828fba420"}