Class ContextCollectingSession

java.lang.Object
com._1c.g5.v8.internal.derived.context.ContextCollectingSession
All Implemented Interfaces:
IContextCollectingSession

public class ContextCollectingSession extends Object implements IContextCollectingSession
Implementation of IContextCollectingSession which wraps the context manager and ensures that all context operations are tracked properly.
  • Constructor Details

    • ContextCollectingSession

      public ContextCollectingSession(IContextTransactionManager manager, Object computationCause, boolean trackWaitingScope, boolean forcedUpdate)
      Creates new context collecting session with given context collection mode (sync or async).
      Parameters:
      manager - The reference to the context manager.
      syncContextCollection - True in case if the session is used to collect sync DD contexts; false for async context collection.
      computationCause - The object bound to the computation context and used to track computations.
      trackWaitingScope - Enables collection of the implicit waiting scope if true
      forcedUpdate - Forces update of contexts, even if they aren't changed
  • Method Details

    • commit

      public void commit()
      Description copied from interface: IContextCollectingSession
      Commits the session, unlocking context objects being locked during the context collecting session.
      Specified by:
      commit in interface IContextCollectingSession
    • getObjectContext

      public IObjectDerivedDataContext getObjectContext(IBmObject bmObject, String segmentId)
      Description copied from interface: IContextCollectingSession
      Gets the object context of the provided object. Effectively locks the provided context from changes via other context collecting sessions. Creates a new context if no context was collected since the last processing
      Specified by:
      getObjectContext in interface IContextCollectingSession
      Parameters:
      bmObject - The object to get the context for.
      segmentId - The DD segment identifier.
      Returns:
      The corresponding context for the object.
    • getServiceId

      public Object getServiceId()
      Description copied from interface: IContextCollectingSession
      Gets the identifier of the service that initiated the context collecting session. This identifier is used to implement complex scearios, like selective computation of DD based on events raised as a result of another DD modification.
      Specified by:
      getServiceId in interface IContextCollectingSession
      Returns:
      The identifier of the service to check the equality against. Can be null,
    • getTypedObjectContext

      public <T extends IObjectDerivedDataContext> T getTypedObjectContext(IBmObject bmObject, String segmentId, Class<T> contextType)
      Description copied from interface: IContextCollectingSession
      Convenience method that checks the type of the internal context and casts it to the given type. Creates a new context if no context was collected since the last processing
      Specified by:
      getTypedObjectContext in interface IContextCollectingSession
      Parameters:
      bmObject - The object to get the context for. Cannot be null or proxy
      segmentId - The DD segment identifier. May not be null
      contextType - The target type of the context. May not be null
      Returns:
      The corresponding context for the object. May not be null
    • getTypedObjectContext

      public <T extends IObjectDerivedDataContext> T getTypedObjectContext(IBmObject bmObject, String segmentId)
      Description copied from interface: IContextCollectingSession
      Convenience method that checks the type of the internal context and casts it to the given type. Creates a new context if no context was collected since the last processing
      Specified by:
      getTypedObjectContext in interface IContextCollectingSession
      Type Parameters:
      T - A required type of the context
      Parameters:
      bmObject - A target object. May not be null
      segmentId - A target DD segment identifier. May not be null
      Returns:
      Required context if any. May not be null
    • isContextExists

      public boolean isContextExists(IBmObject bmObject, String segmentId)
      Description copied from interface: IContextCollectingSession
      Checks if the DD context exists(supported) for the given object and segment
      Specified by:
      isContextExists in interface IContextCollectingSession
      Parameters:
      bmObject - The object to get the context for. May not be null
      segmentId - The DD segment identifier. May not be null
      Returns:
      True if the context is exist/may be created
    • isContextExists

      public boolean isContextExists(org.eclipse.emf.ecore.EClass topObjectEClass, long topObjectId, String segmentId)
      Description copied from interface: IContextCollectingSession
      Checks if the DD context exists(supported) for the given object and segment
      Specified by:
      isContextExists in interface IContextCollectingSession
      Parameters:
      topObjectEClass - Top object EClass. May not be null
      topObjectId - Top object identifier. May not be null
      segmentId - The DD segment identifier. May not be null
      Returns:
      True if the context is exist/may be created
    • getTypedObjectContext

      public <T extends IObjectDerivedDataContext> T getTypedObjectContext(long bmObjectId, org.eclipse.emf.ecore.EClass objectEClass, String segmentId, Class<T> contextType)
      Description copied from interface: IContextCollectingSession
      Convenience method that checks the type of the internal context and casts it to the given type. Throws IllegalArgumentException in case of type mismatch.
      Specified by:
      getTypedObjectContext in interface IContextCollectingSession
      Parameters:
      bmObjectId - The identifier of the object to get the context for.
      objectEClass - The EClass of the object to get the context for. Cannot be null
      segmentId - The DD segment identifier. Cannot be null
      contextType - The target type of the context. Cannot be null
      Returns:
      The corresponding context for the object.
    • getTypedObjectContext

      public <T extends IObjectDerivedDataContext> T getTypedObjectContext(Object objectId, org.eclipse.emf.ecore.EClass objectEClass, String segmentId, Class<T> contextType)
      Description copied from interface: IContextCollectingSession
      Convenience method that checks the type of the internal context and casts it to the given type. Creates a new context if no context was collected since the last processing
      Specified by:
      getTypedObjectContext in interface IContextCollectingSession
      objectEClass - The EClass of the object to get the context for. Cannot be null
      segmentId - The DD segment identifier. May not be null
      contextType - The target type of the context. May not be null
      Returns:
      The corresponding context for the object. May not be null
    • getExistingObjectContext

      public <T extends IObjectDerivedDataContext> T getExistingObjectContext(Object objectId, String segmentId)
      Description copied from interface: IContextCollectingSession
      Gets existing (previously scheduled and not yet computed) context
      Specified by:
      getExistingObjectContext in interface IContextCollectingSession
      Type Parameters:
      T - A required type of the context
      Parameters:
      objectId - A target object identifier. May not be null
      segmentId - A target DD segment identifier. May not be null
      Returns:
      Required context if any. null if no object exists
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: IContextCollectingSession
      Checks if the session has no collected contexts.
      Specified by:
      isEmpty in interface IContextCollectingSession
      Returns:
      True if the session has no collected contexts; false otherwise.
    • scheduleOperation

      public IObjectDerivedDataContext scheduleOperation(Consumer<org.eclipse.core.runtime.IProgressMonitor> operation, OperationType operationType, boolean important, DerivedDataSegmentBucket bucket)
      Description copied from interface: IContextCollectingSession
      Schedules managed operation
      Specified by:
      scheduleOperation in interface IContextCollectingSession
      Parameters:
      operation - The oepration executable logic to schedule. May not be null
      operationType - The type of the operation. May not be null
      bucket - The target stage of the async pipeline. May not be null
    • scheduleModalOperation

      public Object scheduleModalOperation(Consumer<org.eclipse.core.runtime.IProgressMonitor> operation, DerivedDataSegmentBucket stage, IModalOperationController modalOperationController)
      Description copied from interface: IContextCollectingSession
      Schedules a new modal operation with corresponding controller
      Specified by:
      scheduleModalOperation in interface IContextCollectingSession
      Parameters:
      operation - The operation executable to schedule. May not be null
      stage - The target stage of the operation. May not be null
      modalOperationController - The modal operation controller. May not be null
      Returns:
      The handle of the scheduled operation. May not be null
    • removeOperation

      public void removeOperation(IObjectDerivedDataContext handle)
      Description copied from interface: IContextCollectingSession
      Removes previously scheduled operation
      Specified by:
      removeOperation in interface IContextCollectingSession
      Parameters:
      handle - The operation handle. May not be null