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>
Default implementation of
ImportExportDelegate that provides standard import/export
behavior for resource types:
- Parse: Reads resource files via
ResourceReader.readResource(ResourcePath, String), decodes configs using theResourceCodecfrom the owningResourceTypeMeta. - Export: Writes each resource's standard files to the
.gwexviaResourceWriter.writeResourceFiles(Resource, String). - Import: Returns the resource list unchanged. The manager handles
ChangeOperationconstruction and pushing. - Post-import: No-op (inherited from
ImportExportDelegate.afterImport(List, ImportContext, ResourceReader)).
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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ImportExportDelegate
ImportExportDelegate.ResourceEntry<R>, ImportExportDelegate.ResourceImportPath -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonExport(List<ImportExportDelegate.ResourceEntry<R>> resources, ResourceWriter writer) Called during export with all resources of this type selected for export.parseImport(List<ImportExportDelegate.ResourceImportPath> resourcePaths, ResourceReader reader) Parse resources of this type from the.gwexZIP.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ImportExportDelegate
afterImport, prepareImport
-
Constructor Details
-
DefaultImportExportDelegate
-
-
Method Details
-
parseImport
public List<ImportExportDelegate.ResourceEntry<R>> parseImport(List<ImportExportDelegate.ResourceImportPath> resourcePaths, ResourceReader reader) throws IOException Description copied from interface:ImportExportDelegateParse resources of this type from the.gwexZIP. 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:
parseImportin interfaceImportExportDelegate<R>- Parameters:
resourcePaths- the resource paths identified in the.gwexZIP for this type, paired with their collection namesreader- 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:ImportExportDelegateCalled during export with all resources of this type selected for export. The delegate writes all necessary data for these resources into the.gwexfile.- Specified by:
onExportin interfaceImportExportDelegate<R>- Parameters:
resources- all resources of this type selected for export, with decoded configs and collection nameswriter- provides methods for writing resource files and additional data to the.gwexZIP- Throws:
IOException
-