java.lang.Object
com.inductiveautomation.ignition.common.resourcecollection.EffectiveResource
All Implemented Interfaces:
Resource

public class EffectiveResource extends Object implements Resource
Delegate resource implementation that overrides the collection name, so that all resources, inherited or otherwise, share the same resource id.
  • Constructor Details

    • EffectiveResource

      public EffectiveResource(String collectionName, Resource delegateResource)
    • EffectiveResource

      public EffectiveResource(String collectionName, Resource delegateResource, List<String> definingCollectionNames)
  • Method Details

    • getCollectionName

      public String getCollectionName()
      Description copied from interface: Resource
      Get the name of the ResourceCollection this resource belongs to. Note that if this resource was inherited, this collection name will be the name of the collection that was loaded up, not necessarily the collection that actually holds the definition of this resource.
      Specified by:
      getCollectionName in interface Resource
    • getDefiningCollectionName

      public String getDefiningCollectionName()
      Specified by:
      getDefiningCollectionName in interface Resource
      Returns:
      The name of the resource collection that holds the definition of this resource. By comparing this to getCollectionName, you can determine if this resource is inherited or not.
    • getDefiningCollectionNames

      public List<String> getDefiningCollectionNames()
      Specified by:
      getDefiningCollectionNames in interface Resource
      Returns:
      All collections in the inheritance chain that define this resource.
    • getResourceId

      public ResourceId getResourceId()
      Specified by:
      getResourceId in interface Resource
    • getContentDigest

      public ImmutableBytes getContentDigest()
      Description copied from interface: Resource
      Get the SHA-256 digest of the content of this resource. This does not include the project name or any part of the path to this resource, but rather, it's a representation of the contents of the folder on disk.

      Any changes to any of the resource contents of that folder shall result in a change to the content digest.

      Specified by:
      getContentDigest in interface Resource
      Returns:
      the SHA-256 digest of the content of this resource.
      See Also:
    • getResourceSignature

      public ResourceSignature getResourceSignature()
      Description copied from interface: Resource
      Get the ResourceSignature for this resource.
      Specified by:
      getResourceSignature in interface Resource
      Returns:
      the ResourceSignature for this resource.
    • getResourceName

      public String getResourceName()
      Specified by:
      getResourceName in interface Resource
    • getResourceType

      public ResourceType getResourceType()
      Specified by:
      getResourceType in interface Resource
    • getResourcePath

      public ResourcePath getResourcePath()
      Specified by:
      getResourcePath in interface Resource
    • getDocumentation

      @Nullable public String getDocumentation()
      Specified by:
      getDocumentation in interface Resource
    • getApplicationScope

      public int getApplicationScope()
      Description copied from interface: Resource
      Get the application scope of this resource.
      Specified by:
      getApplicationScope in interface Resource
      Returns:
      the application scope of this resource.
      See Also:
    • getVersion

      public int getVersion()
      Description copied from interface: Resource
      Get the version of this resource.

      The version number is not intended to track mutations to the resource like the legacy edit count, but rather, its interpretation and use is for the entities this resource type belongs to and so it can be used to reason about the contents of the resource, e.g. to distinguish between serialization formats.

      Specified by:
      getVersion in interface Resource
      Returns:
      the version of this resource.
    • isFolder

      public boolean isFolder()
      Specified by:
      isFolder in interface Resource
      Returns:
      true if this resource is a folder.
    • isUnary

      public boolean isUnary()
      Specified by:
      isUnary in interface Resource
    • isRestricted

      public boolean isRestricted()
      Specified by:
      isRestricted in interface Resource
      Returns:
      true if this resource is restricted to users of a certain role. Formerly known as "protected".
    • isOverridable

      public boolean isOverridable()
      Specified by:
      isOverridable in interface Resource
      Returns:
      true if this resource can be overridden by child projects.
    • getData

      @Nonnull public Optional<ImmutableBytes> getData()
      Description copied from interface: Resource
      Returns the data for the legacy "default" file. Equivalent to calling:
           getData("data.bin");
       
      Specified by:
      getData in interface Resource
    • getData

      @Nonnull public Optional<ImmutableBytes> getData(String key)
      Description copied from interface: Resource
      Retrieve the data for the given key (filename) as an ImmutableBytes. Consider using Resource.getDataStream(String) instead.
      Specified by:
      getData in interface Resource
    • getDataStream

      public Optional<InputStream> getDataStream(String key)
      Description copied from interface: Resource
      Retrieve the data for the given key (filename) as an input stream. Depending on the Resource implementation, this may be more memory efficient than Resource.getData(String).
      Specified by:
      getDataStream in interface Resource
    • getDataReader

      public Optional<Reader> getDataReader(String key)
      Description copied from interface: Resource
      Retrieve the data for the given key (filename) as a reader. Reader will be opened with UTF-8 encoding. This may be more memory efficient than using Resource.getData(String), especially for parsing large JSON files, for example.
      Specified by:
      getDataReader in interface Resource
    • getDataDigest

      public Optional<String> getDataDigest(String key)
      Description copied from interface: Resource
      The "digest" is a unique fingerprint for the data file. Calculated as a sha-256 hash and then encoded to a string as hex. Reference implementation looks like:
           getData(key).map(bytes -> DigestBuilder.sha256().update(bytes).buildHexString());
       
      Specified by:
      getDataDigest in interface Resource
    • getDataKeys

      @Nonnull public com.google.common.collect.ImmutableSet<String> getDataKeys()
      Description copied from interface: Resource
      Get an immutable view of the data key set.
      Specified by:
      getDataKeys in interface Resource
      Returns:
      an immutable view of the data key set.
    • getAttributes

      @Nonnull public Map<String,com.inductiveautomation.ignition.common.gson.JsonElement> getAttributes()
      Description copied from interface: Resource
      Get an immutable view of the attributes map.
      Specified by:
      getAttributes in interface Resource
      Returns:
      an immutable view of the attributes map.
    • getAttribute

      public Optional<com.inductiveautomation.ignition.common.gson.JsonElement> getAttribute(String key)
      Specified by:
      getAttribute in interface Resource
    • getDelegateResource

      public Resource getDelegateResource()