Class DefaultImportExportDelegate<R>

java.lang.Object
com.inductiveautomation.ignition.gateway.importexport.DefaultImportExportDelegate<R>
Type Parameters:
R - The resource config type
All Implemented Interfaces:
ImportExportDelegate<R>

public class DefaultImportExportDelegate<R> extends Object implements ImportExportDelegate<R>
Default implementation of ImportExportDelegate that provides standard import/export behavior for resource types:

This is the default delegate returned by ResourceTypeMeta.getImportExportDelegate(). Most resource types don't need to override it.

Module authors who need to contribute additional data alongside the standard resource files (e.g., persisted memory tag values) should extend this class:

public class TagDefinitionDelegate extends DefaultImportExportDelegate<TagDefConfig> {

    public TagDefinitionDelegate(ResourceCodec<TagDefConfig> codec) {
        super(codec);
    }

    @Override
    public void onExport(List<ResourceEntry<TagDefConfig>> resources,
                         ResourceWriter writer) throws IOException {
        super.onExport(resources, writer);
        // Write additional data as a stream
        byte[] values = serializeAllTagValues(resources);
        writer.writeAdditionalData("tag-values.json",
            new ByteArrayInputStream(values));
    }

    @Override
    public List<ResourceEntry<TagDefConfig>> prepareImport(
            List<ResourceEntry<TagDefConfig>> resources,
            ImportContext context, ResourceReader reader) throws IOException {
        // Read the batch file as a stream and seed values before push
        reader.readAdditionalData("tag-values.json")
            .ifPresent(stream -> seedTagValues(resources, stream));
        return resources;
    }
}
See Also:
  • Constructor Details

    • DefaultImportExportDelegate

      public DefaultImportExportDelegate(ResourceCodec<R> codec)
  • Method Details

    • parseImport

      Description copied from interface: ImportExportDelegate
      Parse resources of this type from the .gwex ZIP. Called at upload time (before any user interaction). The delegate owns all decoding — it reads the raw resource files from the ZIP via the reader and decodes them using whatever codec or logic it needs.

      The returned ImportExportDelegate.ResourceEntrys are used by the manager to build the interactive manifest (parseability status, conflict detection, dependency warnings). If a resource cannot be parsed, the delegate should not include it in the returned list — the manager will mark it as non-importable.

      Specified by:
      parseImport in interface ImportExportDelegate<R>
      Parameters:
      resourcePaths - the resource paths identified in the .gwex ZIP for this type, paired with their collection names
      reader - provides methods for reading resource files from the ZIP
      Returns:
      the parsed resource entries with decoded configs
      Throws:
      IOException
    • onExport

      public void onExport(List<ImportExportDelegate.ResourceEntry<R>> resources, ResourceWriter writer) throws IOException
      Description copied from interface: ImportExportDelegate
      Called during export with all resources of this type selected for export. The delegate writes all necessary data for these resources into the .gwex file.
      Specified by:
      onExport in interface ImportExportDelegate<R>
      Parameters:
      resources - all resources of this type selected for export, with decoded configs and collection names
      writer - provides methods for writing resource files and additional data to the .gwex ZIP
      Throws:
      IOException