Article
Evgeny Shvarov · Jan 24 2m read

Deploying InterSystems IRIS Data Using ZPM Package Manager

Hi developers!

Often we need to deploy some data along with code pieces of the application.

And for InterSystems IRIS developers the question could sound: "How can I deploy the data I have in globals?"

InterSystems IRIS Globals Model QuickStart | InterSystems

Here I want to suggest to you one of the approaches - deploying global data using the ZPM package manager.

Exporting Globals Data

Suppose you have the IRIS database server where you have the global which you want to deploy. The ZPM package manager can deploy files so you need to export the global into a file and build the package with this file.

ZPM can deploy globals in XML format, so we need to export a global in an XML file first.

E.g. if the global you need to export has the name "DataD" the following command in the IRIS terminal will export the global DataD in XML file:

d $System.OBJ.Export("DataD.GBL","/irisrun/repo/data/DataD.xml")

How the Resource Looks Like

To build the package with a global we should introduce certain resource element in module XML like:

<Resource Name="DataD.GBL"/>

See the example in documentation.

Notice this resource element will look for the DataD.XML file, not DataD.GBL as you could expect.

And ZPM will look for the DataD.XML file in the /gbl folder inside the folder listed in <SourceRoot> element.

Example

Here is a sample repository iris-dataset-countries which contains a package that deploys global with the data on different countries.

Here is the module XML:

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
  <Document name="dataset-countries.ZPM">
    <Module>
      <Name>dataset-countries</Name>
      <Description>Module imports the data of Country passengers in dc.data.Tinanic class</Description>
      <Version>1.0.0</Version>
      <Packaging>module</Packaging>
      <SourcesRoot>src</SourcesRoot>
      <Resource Name="dc.data.Country.CLS"/>
      <Resource Name="dc.data.CountryD.GBL"/>
    </Module>
  </Document>
</Export>

And we could see the resource:

<Resource Name="dc.data.CountryD.GBL"/>

Which is located in /src/gbl/dc.data.CountryD.XML file in the repository:

So when ZPM loads the module into IRIS it imports the global according to the module.xml.

You can test install the global (and the class for it to make queries) with:

USER>zpm "install dataset-countries"

Or you are welcome to play with global packaging with the Countries or Titanic datasets.

10
1 0 0 188
Log in or sign up to continue