Class PageModel
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
PageModel.Handlers
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicReference<MessageChannel>
channel
protected long
created
com.inductiveautomation.ignition.common.gson.Gson
gson
protected PageModel.Handlers
handlers
protected java.lang.String
id
identifier of this view group.protected long
lastKeepalive
LoggerEx
log
static java.lang.ThreadLocal<PageModel>
PAGE
protected PropertyTree
props
protected long
roundtrip
InternalSession
session
protected com.inductiveautomation.perspective.gateway.model.PropertySyncManager
syncManager
protected java.util.function.Function<java.lang.String,java.util.concurrent.CompletableFuture<java.util.Optional<ViewConfig>>>
viewConfigLoader
protected java.util.Map<ViewInstanceId,ViewModel>
views
-
Constructor Summary
Constructors Constructor Description PageModel(InternalSession session, com.inductiveautomation.ignition.common.gson.Gson gson, LoggerEx log, java.lang.String pageId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.inductiveautomation.ignition.common.gson.JsonObject
briefReport()
Generates a brief report of the current views and their values for status pages.void
close(java.lang.String message)
protected PageModel.Handlers
createHandlers(com.inductiveautomation.ignition.common.gson.Gson gson, LoggerEx log)
PropertyReference
createPropertyReference(java.lang.String referencePath, java.util.function.Consumer<PropertyTreeChangeEvent> subscriber, java.util.Set<Origin> acceptableOrigins)
Create aPropertyReference
with thisPerspectiveElement
as the target.protected java.util.function.Function<java.lang.String,java.util.concurrent.CompletableFuture<java.util.Optional<ViewConfig>>>
createViewConfigLoader()
void
disconnect()
AuditContext.Builder
getAuditSnapshot()
int
getBindingCount()
int
getComponentCount()
long
getCreated()
java.lang.String
getId()
LoggerEx
getLogger()
LoggingContext
getMdcParent()
java.lang.String
getName()
Page
getPage()
com.google.common.eventbus.EventBus
getPageEventBus()
EventManager
getPageEventManager()
PropertyTree
getPropertyTreeOf(PropertyType propertyType)
Fetch thePropertyTree
associated with the givenPropertyType
InternalSession
getSession()
View
getView()
int
getViewCount()
java.util.List<ViewModel>
getViews()
boolean
isConnected()
protected boolean
isViewAuthorized(ViewInstanceId viewInstanceId, ViewConfig viewConfig)
void
mdcSetup()
Set up the MDC keys for this contextvoid
mdcTeardown()
Tear down the MDC keys that are added in #mdcSetupvoid
newAuthChallenge(AuthChallengeRequest authChallengeRequest)
Trigger a new authentication challenge.void
newAuthChallengeInternal(AuthChallengeRequest authChallengeRequest)
void
notifyConnected(MessageChannel channel)
void
notifyDisconnected(MessageChannel channel)
void
notifyProjectUpdated()
void
onKeepaliveReceived(long timestamp)
When the route /data/perspective/keepalive is fetched, it will route back to herevoid
onSessionPropertyChange(PropertyType propertyType, PropertyTreeChangeEvent changeEvent)
Called from the session when the session properties change.protected void
onShutdown()
protected void
onStartup()
void
receive(MessageChannel channel, java.lang.String protocol, java.io.Reader payload)
com.inductiveautomation.ignition.common.gson.JsonObject
report()
Generates a full report of the current views and their values.void
send(java.lang.String protocol, com.inductiveautomation.ignition.common.gson.JsonElement payload)
void
send(java.lang.String protocol, java.lang.String payload)
void
sendGatewayLastActiveTime(long timestamp, long idleTime)
void
sendKeepalive()
Sends a keepalive message down the websocket channel.void
setPageTimeout(java.util.concurrent.ScheduledFuture<?> pageTimeout)
void
updateModulesInfo(java.util.List<GatewayModule> modules)
-
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.AuditingContext
audit
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.LoggingContext
mdc, mdcSetupTree, mdcTeardownTree, mdcWrap
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.PerspectiveElement
getAuditProfile, getQualifiedPath, isRunning
-
-
-
-
Field Detail
-
PAGE
public static final java.lang.ThreadLocal<PageModel> PAGE
-
session
public final InternalSession session
-
gson
public final com.inductiveautomation.ignition.common.gson.Gson gson
-
log
public final LoggerEx log
-
id
protected final java.lang.String id
identifier of this view group. will be unique per tab open for a project
-
created
protected final long created
-
views
protected final java.util.Map<ViewInstanceId,ViewModel> views
-
syncManager
protected final com.inductiveautomation.perspective.gateway.model.PropertySyncManager syncManager
-
channel
protected final java.util.concurrent.atomic.AtomicReference<MessageChannel> channel
-
handlers
protected final PageModel.Handlers handlers
-
viewConfigLoader
protected final java.util.function.Function<java.lang.String,java.util.concurrent.CompletableFuture<java.util.Optional<ViewConfig>>> viewConfigLoader
-
props
protected final PropertyTree props
-
lastKeepalive
protected volatile long lastKeepalive
-
roundtrip
protected volatile long roundtrip
-
-
Constructor Detail
-
PageModel
public PageModel(@Nonnull InternalSession session, @Nonnull com.inductiveautomation.ignition.common.gson.Gson gson, @Nonnull LoggerEx log, @Nonnull java.lang.String pageId)
-
-
Method Detail
-
getPage
@Nullable public Page getPage()
- Specified by:
getPage
in interfacePerspectiveElement
- 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 interfacePerspectiveElement
- Returns:
- The view within which this element exists, or null if this is a Page or Session
-
getName
@Nonnull public java.lang.String getName()
- Specified by:
getName
in interfacePerspectiveElement
- 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 interfacePerspectiveElement
- Returns:
- The session that this element is a part of.
-
createPropertyReference
@Nonnull public PropertyReference createPropertyReference(java.lang.String referencePath, java.util.function.Consumer<PropertyTreeChangeEvent> subscriber, java.util.Set<Origin> acceptableOrigins)
Description copied from interface:PerspectiveElement
Create aPropertyReference
with thisPerspectiveElement
as the target.- Specified by:
createPropertyReference
in interfacePerspectiveElement
- Parameters:
referencePath
- the path to the propertysubscriber
- the subscriber - aConsumer
ofPropertyTreeChangeEvent
sacceptableOrigins
- theSet
ofOrigin
s in which the subscriber is interested- Returns:
- the
PropertyReference
-
getPropertyTreeOf
@Nullable public PropertyTree getPropertyTreeOf(@Nullable PropertyType propertyType)
Description copied from interface:PropertyTreeOwner
Fetch thePropertyTree
associated with the givenPropertyType
- Specified by:
getPropertyTreeOf
in interfacePropertyTreeOwner
- Parameters:
propertyType
- ThePropertyType
of thePropertyTree
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 interfacePage
-
getPageEventManager
public EventManager getPageEventManager()
- Specified by:
getPageEventManager
in interfacePage
-
createViewConfigLoader
protected java.util.function.Function<java.lang.String,java.util.concurrent.CompletableFuture<java.util.Optional<ViewConfig>>> createViewConfigLoader()
-
createHandlers
protected PageModel.Handlers createHandlers(com.inductiveautomation.ignition.common.gson.Gson gson, LoggerEx log)
-
getCreated
public long getCreated()
- Specified by:
getCreated
in interfacePage
-
getViewCount
public int getViewCount()
-
getComponentCount
public int getComponentCount()
-
getBindingCount
public int getBindingCount()
-
getLogger
public LoggerEx getLogger()
- Specified by:
getLogger
in interfaceLoggingContext
-
getMdcParent
@Nullable public LoggingContext getMdcParent()
- Specified by:
getMdcParent
in interfaceLoggingContext
-
mdcSetup
public void mdcSetup()
Description copied from interface:LoggingContext
Set up the MDC keys for this context- Specified by:
mdcSetup
in interfaceLoggingContext
-
mdcTeardown
public void mdcTeardown()
Description copied from interface:LoggingContext
Tear down the MDC keys that are added in #mdcSetup- Specified by:
mdcTeardown
in interfaceLoggingContext
-
notifyProjectUpdated
public void notifyProjectUpdated()
-
send
public void send(java.lang.String protocol, com.inductiveautomation.ignition.common.gson.JsonElement payload) throws java.io.IOException
- Throws:
java.io.IOException
-
send
public void send(java.lang.String protocol, java.lang.String payload) throws java.io.IOException
-
receive
public void receive(MessageChannel channel, java.lang.String protocol, java.io.Reader payload)
-
isConnected
public boolean isConnected()
- Specified by:
isConnected
in interfacePage
-
notifyConnected
public void notifyConnected(MessageChannel channel)
-
notifyDisconnected
public void notifyDisconnected(MessageChannel channel)
-
setPageTimeout
public void setPageTimeout(java.util.concurrent.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
- ThePropertyType
of the session'sPropertyTree
which fired thePropertyTreeChangeEvent
changeEvent
- ThePropertyTreeChangeEvent
fired from the session'sPropertyTree
-
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)
-
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(java.util.List<GatewayModule> modules)
-
onStartup
protected void onStartup()
- Specified by:
onStartup
in classAbstractLifecycle
-
onShutdown
protected void onShutdown()
- Specified by:
onShutdown
in classAbstractLifecycle
-
disconnect
public void disconnect()
-
newAuthChallenge
public void newAuthChallenge(AuthChallengeRequest authChallengeRequest) throws java.lang.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 interfacePage
- Parameters:
authChallengeRequest
- theAuthChallengeRequest
- Throws:
java.lang.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 java.lang.Exception
- Throws:
java.lang.Exception
-
getAuditSnapshot
@Nonnull public AuditContext.Builder getAuditSnapshot()
- Specified by:
getAuditSnapshot
in interfaceAuditingContext
- Returns:
- A new, or extended,
AuditContext.Builder
, with qualified information about the current scope.
-
-