Class BmModelManager

java.lang.Object
com._1c.g5.v8.dt.internal.core.platform.bm.BmModelManager
All Implemented Interfaces:
IResourcePlan, IBmModelManager, IManagedService

@LifecycleService(name="BM_MODEL_MANAGER") public class BmModelManager extends Object implements IBmModelManager, IResourcePlan
IBmModelManager implementation.
  • Constructor Details

    • BmModelManager

      public BmModelManager()
      Constructs an instance
  • Method Details

    • activate

      public void activate()
      Description copied from interface: IBmModelManager
      Start up BM manager work. The manager configures itself and all associated infrastructure.

      Clients are intended to invoke #shutdown() when manager work is no longer needed.

      Specified by:
      activate in interface IBmModelManager
      Specified by:
      activate in interface IManagedService
    • deactivate

      public void deactivate()
      Description copied from interface: IBmModelManager
      Shut down BM manager work. The manager shutdowns itself and all associated infrastructure.
      Specified by:
      deactivate in interface IBmModelManager
      Specified by:
      deactivate in interface IManagedService
    • registerLifecycleParticipant

      public void registerLifecycleParticipant(IBmModelManager.BmModelManagerLifecycleParticipant participant)
      Description copied from interface: IBmModelManager
      Registers lifecycle participant. To be sure that registered participant will participate during each supported lifecycle phase of IBmModelManager the participant should be registered during the LifecyclePhase.LINKING phase of service lifecycle
      Specified by:
      registerLifecycleParticipant in interface IBmModelManager
      Parameters:
      participant - The participant to register. Cannot be null
    • getBmPlatform

      public BmPlatform getBmPlatform()
      Description copied from interface: IBmModelManager
      Gets the underlying BM platform.
      Specified by:
      getBmPlatform in interface IBmModelManager
      Returns:
      the underlying BM platform or null in case the model manager is not initialized yet.
    • getBmNamespace

      public IBmNamespace getBmNamespace(IDtProject project)
      Description copied from interface: IBmModelManager
      Gets the namespace storing the data of the specified project.
      Specified by:
      getBmNamespace in interface IBmModelManager
      Parameters:
      project - The project. May not be null.
      Returns:
      the namespace or null if the project context is not started yet.
    • getBmNamespace

      public IBmNamespace getBmNamespace(org.eclipse.core.resources.IProject project)
      Description copied from interface: IBmModelManager
      Gets the namespace storing the data of the specified project.
      Specified by:
      getBmNamespace in interface IBmModelManager
      Parameters:
      project - The project. May not be null.
      Returns:
      the namespace or null if the project context is not started yet.
    • getModel

      public IBmModel getModel(org.eclipse.emf.ecore.EObject object)
      Description copied from interface: IBmModelManager
      Returns IBmModel which contains the given model object.
      Can return null if there is no BM instances, that handles the given model object.
      Specified by:
      getModel in interface IBmModelManager
      Returns:
      IBmModel which contains the given model object or null if object is not handled by any IBmModel
    • getModel

      public IBmModel getModel(org.eclipse.core.resources.IProject project)
      Description copied from interface: IBmModelManager
      Returns IBmModel instance by given project.
      Can return null if there is no BM instance, associated with the given project.
      Specified by:
      getModel in interface IBmModelManager
      Parameters:
      project - the project (not null)
      Returns:
      IBmModel instance or null if given project doesn't associated with any BM model and cannot create one
    • getModel

      public IBmModel getModel(org.eclipse.emf.common.util.URI uri)
      Description copied from interface: IBmModelManager
      Returns IBmModel which contains object with given URI.
      Can return null if there is no BM instances, that handles the object with the given URI.
      Specified by:
      getModel in interface IBmModelManager
      Parameters:
      uri - the object URI (not null)
      Returns:
      IBmModel which contains object with given URI or null if object is not handled by any IBmModel
    • getProject

      public org.eclipse.core.resources.IProject getProject(IBmModel bmModel)
      Description copied from interface: IBmModelManager
      Returns project associated with given BM instance.
      Can return null if there is no projects, associated with the given BM instance.
      Specified by:
      getProject in interface IBmModelManager
      Parameters:
      bmModel - the IBmModel instance (not null)
      Returns:
      project associated with given big model instance
    • getDtProject

      public IDtProject getDtProject(String engineId)
      Description copied from interface: IBmModelManager
      Returns project associated with given BM engine.
      Can return null if there is no projects, associated with the given BM engine.
      Specified by:
      getDtProject in interface IBmModelManager
      Parameters:
      engineId - the identifier of the BM engine, (not null)
      Returns:
      project associated with given engine
    • getDtProject

      public IDtProject getDtProject(IBmModel bmModel)
      Description copied from interface: IBmModelManager
      Returns IDtProject project associated with given BM instance.
      Can return null if there is no projects, associated with the given BM instance.
      Specified by:
      getDtProject in interface IBmModelManager
      Parameters:
      bmModel - the IBmModel instance (not null)
      Returns:
      IDtProject project associated with given big model instance
    • resolve

      public <T extends org.eclipse.emf.ecore.EObject> T resolve(T proxyOrObject, org.eclipse.emf.ecore.resource.Resource context, org.eclipse.emf.ecore.EObject objContext)
      Description copied from interface: IBmModelManager
      Resolves given proxy using the provide resource context for the resolving/starting point.
      Aware of BM infrastructure and standalone resources.
      Specified by:
      resolve in interface IBmModelManager
      Parameters:
      proxyOrObject - proxy to resolve.
      context - the context resource.
      objContext - the object context.
      Returns:
      The resolved object (if referenced object already exists and reachable) or proxy of the source type.
    • waitModelSynchronization

      public void waitModelSynchronization(org.eclipse.core.resources.IProject project)
      Description copied from interface: IBmModelManager
      Waits for project BM synchronization jobs.
      Specified by:
      waitModelSynchronization in interface IBmModelManager
    • lockModel

      public void lockModel(org.eclipse.core.resources.IProject project)
      Description copied from interface: IBmModelManager
      Raises the lock on the given model. The lock indicates that all data critical clients should cease their requests and wait until the lock is released.
      Specified by:
      lockModel in interface IBmModelManager
      Parameters:
      project - The target project which BM should be locked. Cannot be null
    • unlockModel

      public void unlockModel(org.eclipse.core.resources.IProject project)
      Description copied from interface: IBmModelManager
      Releases previously defined lock for the given project's model
      Specified by:
      unlockModel in interface IBmModelManager
      Parameters:
      project - The project to unlock the BM model for. Cannot be null
    • isLocked

      public boolean isLocked(org.eclipse.core.resources.IProject project)
      Description copied from interface: IBmModelManager
      Checks if the given project's BM model is locked at the moment.
      Specified by:
      isLocked in interface IBmModelManager
      Parameters:
      project - The project to check the locked state for. Cannot be null
      Returns:
      True if the corresponding BM is locked at the moment; false otherwise
    • gatherActivities

      public Map<String,IActivityDemandsDefinition> gatherActivities()
      Description copied from interface: IResourcePlan
      Proclaim demands of resources for a given set of activities.
      Specified by:
      gatherActivities in interface IResourcePlan
      Returns:
      Returns IActivityDemandsDefinition mapped to respective name of the activity.
    • addLifecycleListener

      public void addLifecycleListener(IBmModel model, IBmLifecycleListener listener)
      Description copied from interface: IBmModelManager
      Registers the given lifecycle listener.
      Specified by:
      addLifecycleListener in interface IBmModelManager
      listener - The lifecycle listener. May not be null.
    • removeLifecycleListener

      public void removeLifecycleListener(IBmModel model, IBmLifecycleListener listener)
      Description copied from interface: IBmModelManager
      Unregisters the given lifecycle listener.
      Specified by:
      removeLifecycleListener in interface IBmModelManager
      listener - The lifecycle listener. May not be null.
    • getModelPackages

      public Collection<org.eclipse.emf.ecore.EPackage> getModelPackages()
      Description copied from interface: IBmModelManager
      Gets the collection of EMF packages supported by the model.
      Specified by:
      getModelPackages in interface IBmModelManager
      Returns:
      the collection of EMF packages supported by the model, never null.
    • executeReadOnlyTask

      public <T> T executeReadOnlyTask(IBmPlatformTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a IBmPlatformTask in a read-only mode
      Specified by:
      executeReadOnlyTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return valu
      Parameters:
      task - The task to run. May not be null
      Returns:
      The result of the task execution. May not be null
    • executeReadOnlyTask

      public <T> T executeReadOnlyTask(IDtProject dtProject, IBmSingleNamespaceTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a IBmSingleNamespaceTask which is bound to a single namespace in a read-only mode
      Specified by:
      executeReadOnlyTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value
      Parameters:
      dtProject - The target IDtProject. May not be null
      task - The task to run. May not be null
      Returns:
      The result of the task execution. May not be null
    • executeReadOnlyTask

      public <T> T executeReadOnlyTask(org.eclipse.core.resources.IProject project, IBmSingleNamespaceTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a IBmSingleNamespaceTask which is bound to a single namespace in a read-only mode
      Specified by:
      executeReadOnlyTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value
      Parameters:
      project - The target IProject. May not be null
      task - The task to run. May not be null
      Returns:
      The result of the task execution. May not be null
    • executeReadOnlyTask

      public <T> T executeReadOnlyTask(IBmNamespace namespace, IBmSingleNamespaceTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a IBmSingleNamespaceTask which is bound to a single namespace in a read-only mode
      Specified by:
      executeReadOnlyTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value
      Parameters:
      namespace - The target IBmNamespace. May not be null
      task - The task to run. May not be null
      Returns:
      The result of the task execution. May not be null
    • executeReadWriteTask

      public <T> T executeReadWriteTask(Object taskId, Object serviceId, IBmPlatformTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a read-write task.
      Specified by:
      executeReadWriteTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value.
      Parameters:
      taskId - The ID of the task. May be null.
      serviceId - The ID of the service that requested the task execution. May be null.
      task - The task to execute. May not be null.
      Returns:
      the result returned by IBmPlatformTask.execute(IBmPlatformTransaction) method.
    • executeReadWriteTask

      public <T> T executeReadWriteTask(Object taskId, Object serviceId, boolean disableEvents, IBmPlatformTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a read-write task.
      Specified by:
      executeReadWriteTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value.
      Parameters:
      taskId - The ID of the task. May be null.
      serviceId - The ID of the service that requested the task execution. May be null.
      disableEvents - The flag that disables sending of BM data change events
      task - The task to execute. May not be null.
      Returns:
      the result returned by IBmPlatformTask.execute(IBmPlatformTransaction) method.
    • executeReadWriteTask

      public <T> T executeReadWriteTask(IDtProject dtProject, IBmSingleNamespaceTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a IBmSingleNamespaceTask which is bound to a single namespace
      Specified by:
      executeReadWriteTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value
      Parameters:
      dtProject - The target IDtProject. May not be null
      task - The task to run. May not be null
      Returns:
      The result of the task execution. May not be null
    • executeReadWriteTask

      public <T> T executeReadWriteTask(org.eclipse.core.resources.IProject project, IBmSingleNamespaceTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a IBmSingleNamespaceTask which is bound to a single namespace
      Specified by:
      executeReadWriteTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value
      task - The task to run. May not be null
      Returns:
      The result of the task execution. May not be null
    • executeReadWriteTask

      public <T> T executeReadWriteTask(IBmNamespace namespace, IBmSingleNamespaceTask<T> task)
      Description copied from interface: IBmModelManager
      Executes a IBmSingleNamespaceTask which is bound to a single namespace
      Specified by:
      executeReadWriteTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value
      Parameters:
      namespace - The target IBmNamespace. May not be null
      task - The task to run. May not be null
      Returns:
      The result of the task execution. May not be null
    • executeReadWriteTask

      public <T> T executeReadWriteTask(IBmNamespace namespace, IBmSingleNamespaceTask<T> task, boolean disableEvents)
      Description copied from interface: IBmModelManager
      Executes a IBmSingleNamespaceTask which is bound to a single namespace
      Specified by:
      executeReadWriteTask in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value
      Parameters:
      namespace - The target IBmNamespace. May not be null
      task - The task to run. May not be null
      Returns:
      The result of the task execution. May not be null
    • createLocalEditingContext

      public IBmPlatformLocalEditingContext createLocalEditingContext(String name)
      Description copied from interface: IBmModelManager
      Creates a local platform context.
      Specified by:
      createLocalEditingContext in interface IBmModelManager
      Parameters:
      name - The name of the context. May not be null.
      Returns:
      a newly created local context instance, never null.
    • getGlobalEditingContext

      public IBmPlatformGlobalEditingContext getGlobalEditingContext()
      Description copied from interface: IBmModelManager
      Gets platform global editing context instance
      Specified by:
      getGlobalEditingContext in interface IBmModelManager
      Returns:
      The global editing context of the platform. May not be null
    • beginBatchSession

      public Object beginBatchSession(Object handle)
      Description copied from interface: IBmModelManager
      Begins batch mode.
      Specified by:
      beginBatchSession in interface IBmModelManager
      Returns:
      the batch mode handle object, never null.
    • endBatchSession

      public void endBatchSession(Object handle)
      Description copied from interface: IBmModelManager
      Ends the batch session associated with the specified handle.
      Specified by:
      endBatchSession in interface IBmModelManager
      Parameters:
      handle - The batch session handle. May not be null.
      See Also:
      • #beginBatchMode()
    • executeInBatchSession

      public <T> T executeInBatchSession(Object handle, IBmPlatformTask<T> task)
      Description copied from interface: IBmModelManager
      Executes task in a batch session.
      Specified by:
      executeInBatchSession in interface IBmModelManager
      Type Parameters:
      T - The type of the task's return value.
      Parameters:
      handle - The batch session handle. May not be null.
      task - The task to execute. May not be null.
      Returns:
      the result returned by IBmPlatformTask.execute(IBmPlatformTransaction) method.
    • executeAsynchronously

      public <T> Future<T> executeAsynchronously(org.eclipse.core.resources.IProject project, IBmSingleNamespaceTask<T> task)
      Description copied from interface: IBmModelManager
      Executes the given task in a separate thread (comparing to the calling thread). This method could be used to ensure the data modification will be performed independently of a BM transaction that may be started in the calling thread already. Please note that this operation is not a performance-effective one, so it should be used only in case if some process flow conflicts with other threads IBmTransaction locks and cannot be redesigned at the moment to a normal orchestrated form
      Specified by:
      executeAsynchronously in interface IBmModelManager
      Parameters:
      project - A target project. May not be null
      task - A task to run. May not be null
      Returns:
      A future that provides access to a result of an operation. Never null
    • executeAsynchronously

      public <T> Future<T> executeAsynchronously(IDtProject dtProject, IBmSingleNamespaceTask<T> task)
      Description copied from interface: IBmModelManager
      Executes the given task in a separate thread (comparing to the calling thread). This method could be used to ensure the data modification will be performed independently of a BM transaction that may be started in the calling thread already. Please note that this operation is not a performance-effective one, so it should be used only in case if some process flow conflicts with other threads IBmTransaction locks and cannot be redesigned at the moment to a normal orchestrated form
      Specified by:
      executeAsynchronously in interface IBmModelManager
      Parameters:
      dtProject - A target DT project. May not be null
      task - A task to run. May not be null
      Returns:
      A future that provides access to a result of an operation. Never null
    • waitAllEnqueuedEventsSent

      public void waitAllEnqueuedEventsSent()
      Description copied from interface: IBmModelManager
      Waits till all the events enqueued prior to calling this method are sent.
      Specified by:
      waitAllEnqueuedEventsSent in interface IBmModelManager
    • addSyncEventListener

      public void addSyncEventListener(IBmNamespace namespace, IBmSyncEventListener listener)
      Description copied from interface: IBmModelManager
      Adds the specified synchronous event listener.
      Specified by:
      addSyncEventListener in interface IBmModelManager
      Parameters:
      namespace - The namespace to add the listener to. May not be null.
      listener - The listener to add. May not be null.
    • removeSyncEventListener

      public void removeSyncEventListener(IBmNamespace namespace, IBmSyncEventListener listener)
      Description copied from interface: IBmModelManager
      Removes the specified synchronous event listener.
      Specified by:
      removeSyncEventListener in interface IBmModelManager
      Parameters:
      namespace - The namespace to remove the listener from. May not be null.
      listener - The listener to remove. May not be null.
    • addAsyncEventListener

      public void addAsyncEventListener(IBmNamespace namespace, IBmAsyncEventListener listener, BmEventFilter... filters)
      Description copied from interface: IBmModelManager
      Adds the specified asynchronous event listener. The listener is notified in case the event matches at least one of the specified filters or no filter is specified.
      Specified by:
      addAsyncEventListener in interface IBmModelManager
      Parameters:
      namespace - The namespace to add the listener to. May not be null.
      listener - The listener to add. May not be null.
      filters - The filters. May be null.
    • removeAsyncEventListener

      public void removeAsyncEventListener(IBmNamespace namespace, IBmAsyncEventListener listener)
      Description copied from interface: IBmModelManager
      Removes the specified asynchronous event listener.
      Specified by:
      removeAsyncEventListener in interface IBmModelManager
      Parameters:
      namespace - The namespace to remove the listener from. May not be null.
      listener - The listener to remove. May not be null.
    • link

      @LifecycleParticipant(phase=LINKING) public void link()
      Participates the linking phase.

      For more information see LifecyclePhase.LINKING

      See Also:
    • shutdown

      public void shutdown()
      Performs the shutdown.

      We do not call this method on unlinking phase as unlinking can be executed a few times per EDT session whereas this method must be executed exactly once.

    • initStorage

      @LifecycleParticipant(phase=STORAGE_INITIALIZATION) public void initStorage(ILifecycleContext lifecycleContext)
      Participates the storage initialization phase.
      Initiates the BmModel instance for the project of the specified projectContext.

      For more information see LifecyclePhase.STORAGE_INITIALIZATION

      Parameters:
      projectContext - the project context, cannot be null.
      See Also:
    • resourceLoading

      @LifecycleParticipant(phase=RESOURCE_LOADING, dependsOn="LIBRARY_PROJECT_RESOURCE_MANAGER") public void resourceLoading(ProjectContext projectContext)
      Participates the resource loading phase.
      Starts the synchronization.

      For more information see LifecyclePhase.RESOURCE_LOADING

      Parameters:
      projectContext - the project context, cannot be null.
      See Also:
    • postResourceLoading

      @LifecycleParticipant(phase=POST_RESOURCE_LOADING) public void postResourceLoading(ProjectContext projectContext)
      Participates the post resource loading phase.
      Waits for derived data computations of 'MD_PRE' and 'FORM_PRE' segments.

      For more information see LifecyclePhase.POST_RESOURCE_LOADING

      Parameters:
      projectContext - the project context, cannot be null.
      See Also:
    • storageClosing

      @LifecycleParticipant(phase=STORAGE_CLOSING) public void storageClosing(ProjectContext projectContext)
      Participates the storage closing phase.
      Performs closing steps for BM Model associated with the project of the specified projectContext.

      For more information see LifecyclePhase.STORAGE_CLOSING

      Parameters:
      projectContext - the project context, cannot be null.
      See Also:
    • getModel

      public IBmModel getModel(IDtProject dtProject)
      Description copied from interface: IBmModelManager
      Returns IBmModel instance by given project.
      Can return null if there is no BM instance, associated with the given project.
      Specified by:
      getModel in interface IBmModelManager
      Returns:
      IBmModel instance or null if given project doesn't associated with any BM model and cannot create one
    • disposeEditingContextsAffectingProject

      public void disposeEditingContextsAffectingProject(IDtProject project)
      Disposes all the editing contexts affecting objects belonging to the specified project.
      Parameters:
      project - The project. May not be null.
    • saveProjectStoreSnapshot

      public void saveProjectStoreSnapshot(org.eclipse.core.resources.IProject project, OutputStream out)
      Saves project store snapshot. The method has been introduced to migrate BmSnapshotParticipant only.
      Parameters:
      project - The project. May not be null.
      out - The output stream to write snapshot to. May not be null.
    • applyProjectStoreSnapshot

      public void applyProjectStoreSnapshot(org.eclipse.core.resources.IProject project, InputStream in)
      Applies project store snapshot. The method has been introduced to migrate BmSnapshotParticipant only.
      Parameters:
      project - The project. May not be null.
      in - The input stream to read snapshot from. May not be null.
    • forceExport

      public boolean forceExport(IDtProject project, String fqn)
      Description copied from interface: IBmModelManager
      Forces export of the object with the specified FQN. This method is supposed to be called within an exclusive workspace operation.
      Specified by:
      forceExport in interface IBmModelManager
      Parameters:
      project - The project the object belongs to. May not be null.
      fqn - The FQN of the object. May not be null.
      Returns:
      true in case export was performed, false if there was nothing to export, i.e. there was nothing to export.
    • forceExport

      public boolean forceExport(IDtProject project, List<String> fqns)
      Description copied from interface: IBmModelManager
      Forces export of the objects with the specified FQNs. The save process is parallelized.
      Specified by:
      forceExport in interface IBmModelManager
      Parameters:
      project - The project the object belongs to. May not be null.
      fqns - The FQN of the objects. May not be null.
      Returns:
      true in case export was performed, false if there was nothing to export, i.e. there was nothing to export.