java.lang.Object
com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
com.inductiveautomation.perspective.gateway.model.PageModel
All Implemented Interfaces:
AuditingContext, LoggingContext, Page, PerspectiveElement, PropertyTreeOwner
Direct Known Subclasses:
DesignerPageModel

public class PageModel extends AbstractLifecycle implements Page
A page contains a number of views all running within the same web page, or tab. A given session may contain multiple pages running concurrently when the user has opened multiple tabs for the same project.
  • Field Details

  • Constructor Details

    • PageModel

      public PageModel(@Nonnull InternalSession session, @Nonnull com.inductiveautomation.ignition.common.gson.Gson gson, @Nonnull LoggerEx log, @Nonnull String pageId)
  • Method Details

    • getPage

      @Nullable public Page getPage()
      Specified by:
      getPage in interface PerspectiveElement
      Returns:
      The Page that this element is part of. Will return null if this is the Session
    • getView

      @Nullable public View getView()
      Specified by:
      getView in interface PerspectiveElement
      Returns:
      The view within which this element exists, or null if this is a Page or Session
    • getName

      @Nonnull public String getName()
      Specified by:
      getName in interface PerspectiveElement
      Returns:
      The name of the element. If this is a component, it will be the name of the component. If this is a View, the name will be "view". If this is a Page, the name will be "page". If this is the session, the name will be "session".
    • getSession

      @Nonnull public InternalSession getSession()
      Specified by:
      getSession in interface PerspectiveElement
      Returns:
      The session that this element is a part of.
    • createPropertyReference

      @Nonnull public PropertyReference createPropertyReference(String referencePath, Consumer<PropertyTreeChangeEvent> subscriber, Set<Origin> acceptableOrigins)
      Description copied from interface: PerspectiveElement
      Create a PropertyReference with this PerspectiveElement as the target.
      Specified by:
      createPropertyReference in interface PerspectiveElement
      Parameters:
      referencePath - the path to the property
      subscriber - the subscriber - a Consumer of PropertyTreeChangeEvents
      acceptableOrigins - the Set of Origins in which the subscriber is interested
      Returns:
      the PropertyReference
    • getPropertyTreeOf

      @Nullable public PropertyTree getPropertyTreeOf(@Nullable PropertyType propertyType)
      Description copied from interface: PropertyTreeOwner
      Fetch the PropertyTree associated with the given PropertyType
      Specified by:
      getPropertyTreeOf in interface PropertyTreeOwner
      Parameters:
      propertyType - The PropertyType of the PropertyTree we want to fetch
      Returns:
      The PropertyTree or null if this PropertyTreeOwner does not manage a PropertyTree for the given PropertyType or if a null PropertyType is given
    • getPageEventBus

      public com.google.common.eventbus.EventBus getPageEventBus()
      Specified by:
      getPageEventBus in interface Page
    • getPageEventManager

      public EventManager getPageEventManager()
      Specified by:
      getPageEventManager in interface Page
    • createViewConfigLoader

      protected Function<String,CompletableFuture<Optional<ViewConfig>>> createViewConfigLoader()
    • createHandlers

      protected PageModel.Handlers createHandlers(com.inductiveautomation.ignition.common.gson.Gson gson, LoggerEx log)
    • getId

      public String getId()
      Specified by:
      getId in interface Page
    • getCreated

      public long getCreated()
      Specified by:
      getCreated in interface Page
    • getViews

      public List<ViewModel> getViews()
      Specified by:
      getViews in interface Page
    • getViewCount

      public int getViewCount()
    • getComponentCount

      public int getComponentCount()
    • getBindingCount

      public int getBindingCount()
    • getLogger

      public LoggerEx getLogger()
      Specified by:
      getLogger in interface LoggingContext
    • getMdcParent

      @Nullable public LoggingContext getMdcParent()
      Specified by:
      getMdcParent in interface LoggingContext
    • mdcSetup

      public void mdcSetup()
      Description copied from interface: LoggingContext
      Set up the MDC keys for this context
      Specified by:
      mdcSetup in interface LoggingContext
    • mdcTeardown

      public void mdcTeardown()
      Description copied from interface: LoggingContext
      Tear down the MDC keys that are added in #mdcSetup
      Specified by:
      mdcTeardown in interface LoggingContext
    • notifyProjectUpdated

      public void notifyProjectUpdated()
    • send

      public void send(String protocol, com.inductiveautomation.ignition.common.gson.JsonElement payload) throws IOException
      Throws:
      IOException
    • send

      public void send(String protocol, String payload) throws IOException
      Specified by:
      send in interface Page
      Throws:
      IOException
    • receive

      public void receive(MessageChannel channel, String protocol, Reader payload)
    • isConnected

      public boolean isConnected()
      Specified by:
      isConnected in interface Page
    • notifyConnected

      public void notifyConnected(MessageChannel channel)
    • notifyDisconnected

      public void notifyDisconnected(MessageChannel channel)
    • setPageTimeout

      public void setPageTimeout(ScheduledFuture<?> pageTimeout)
    • onSessionPropertyChange

      public void onSessionPropertyChange(PropertyType propertyType, PropertyTreeChangeEvent changeEvent)
      Called from the session when the session properties change. Puts the changes into the accumulator inside the sync manager.
      Parameters:
      propertyType - The PropertyType of the session's PropertyTree which fired the PropertyTreeChangeEvent
      changeEvent - The PropertyTreeChangeEvent fired from the session's PropertyTree
    • report

      public com.inductiveautomation.ignition.common.gson.JsonObject report()
      Generates a full report of the current views and their values.
      Returns:
      a json object containing the full property tree for the current executing project/session
    • briefReport

      public com.inductiveautomation.ignition.common.gson.JsonObject briefReport()
      Generates a brief report of the current views and their values for status pages.
      Returns:
      a json array containing brief info on the current executing project/session
    • sendKeepalive

      public void sendKeepalive()
      Sends a keepalive message down the websocket channel. This will provoke the page's frontend code to HTTP GET the route at /data/perspective/keepalive
    • sendGatewayLastActiveTime

      public void sendGatewayLastActiveTime(long timestamp, long idleTime, long lastActiveServerTimestamp)
    • onKeepaliveReceived

      public void onKeepaliveReceived(long timestamp)
      When the route /data/perspective/keepalive is fetched, it will route back to here
    • isViewAuthorized

      protected boolean isViewAuthorized(@Nonnull ViewInstanceId viewInstanceId, @Nonnull ViewConfig viewConfig)
    • updateModulesInfo

      public void updateModulesInfo(List<GatewayModule> modules)
    • onStartup

      protected void onStartup()
      Specified by:
      onStartup in class AbstractLifecycle
    • onShutdown

      protected void onShutdown()
      Specified by:
      onShutdown in class AbstractLifecycle
    • disconnect

      public void disconnect()
    • close

      public void close(@Nullable String message)
      Specified by:
      close in interface Page
    • newAuthChallenge

      public void newAuthChallenge(AuthChallengeRequest authChallengeRequest) throws Exception
      Description copied from interface: Page
      Trigger a new authentication challenge. Sends a message to the client to open the authentication challenge workflow using whatever framing option was specified in the auth challenge request.
      Specified by:
      newAuthChallenge in interface Page
      Parameters:
      authChallengeRequest - the AuthChallengeRequest
      Throws:
      Exception - if the client identifier associated with the auth challenge request is blank, or if the message channel between the Gateway and the Client is not currently open
    • newAuthChallengeInternal

      public void newAuthChallengeInternal(AuthChallengeRequest authChallengeRequest) throws Exception
      Throws:
      Exception
    • getAuditSnapshot

      @Nonnull public AuditContext.Builder getAuditSnapshot()
      Specified by:
      getAuditSnapshot in interface AuditingContext
      Returns:
      A new, or extended, AuditContext.Builder, with qualified information about the current scope.