Class BmContentImportSupport

    • Constructor Detail

      • BmContentImportSupport

        public BmContentImportSupport()
    • Method Detail

      • computeSha256Hash

        protected byte[] computeSha256Hash​(InputStream content)
        Computes a content hash using SHA256
        Parameters:
        content - The content stream. May not be null
        Returns:
        A hash of the provided content. May not be null
      • doResourceLoad

        protected org.eclipse.emf.ecore.resource.Resource doResourceLoad​(IDtProject project,
                                                                         org.eclipse.core.runtime.IPath path,
                                                                         InputStream content,
                                                                         IBmNamespace namespace,
                                                                         boolean resolveExternalReferencesDuringImport,
                                                                         BmContentImportSupport.ILoadOptionsProvider loadOptionsProvider,
                                                                         Version runtimeVersion,
                                                                         org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory,
                                                                         IBmModelManager bmModelManager)
        Loads a resource from a provided content
        Parameters:
        project - The target IDtProject. Cannot be null
        path - The target path. Cannot be null
        content - The imported content stream. Can be null
        namespace - The target BM namespace for an import. Never null
        resolveExternalReferencesDuringImport - Flag that specifies the additional resolving of external references during the import
        loadOptionsProvider - The load options provider for load process customization. Cannot be null
        runtimeVersion - The target runtime version. Cannot be null
        bmModelManager - IBmModelManager service reference. Cannot be null
        Returns:
        The loaded resource. May be null
      • executeTaskInContextIfNecessary

        protected <T> T executeTaskInContextIfNecessary​(Function<IBmPlatformTransaction,​T> importFunction,
                                                        IDtProject project,
                                                        boolean executeInGlobalContext,
                                                        boolean disableEvents,
                                                        IBmModelManager bmModelManager)
        Executes provided generic import function in global editing context or directly as a RW BM task
        Parameters:
        importFunction - Import function to execute. Never null
        project - Target IDtProject. Never null
        executeInGlobalContext - Flag that enables global context execution mode
        disableEvents - Disables sending ob BM events as a result of import function execution
        bmModelManager - IBmModelManager service reference. Never null
        Returns:
        Result of a funtion. May be null depending on the function itself
      • forceDerivedDataRebuild

        protected void forceDerivedDataRebuild​(IDtProject project,
                                               IBmNamespace namespace,
                                               IBmObject importedObject,
                                               IDerivedDataManagerProvider derivedDataManagerProvider)
        During full override we are emulating object attachment for DD subsystem to improve performance
        Parameters:
        project - Target IDtProject. Never null
        namespace - The target BM namespace for an import. Never null
        importedObject - The object being imported. Never null
        derivedDataManagerProvider - The IDerivedDataManagerProvider service reference. Never null
      • getRuntimeVersion

        protected Version getRuntimeVersion​(IDtProject project,
                                            IRuntimeVersionSupport runtimeVersionSupport)
        Gets a runtime version for a given project
        Parameters:
        project - A project to get version for. Cannot be null
        runtimeVersionSupport - The IRuntimeVersionSupport service reference. Cannot be null
        Returns:
        A platform version of a project. Cannot be null
      • loadData

        protected BmContentImportSupport.LoadedData loadData​(IBmPlatformTransaction transaction,
                                                             IBmNamespace namespace,
                                                             IDtProject project,
                                                             org.eclipse.core.runtime.IPath path,
                                                             InputStream content,
                                                             boolean resolveExternalReferencesDuringImport,
                                                             BmContentImportSupport.ILoadOptionsProvider loadOptionsProvider,
                                                             org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory,
                                                             IBmModelManager bmModelManager,
                                                             IRuntimeVersionSupport runtimeVersionSupport,
                                                             IQualifiedNameFilePathConverter qualifiedNameFilePathConverter)
        Loads the data from the provided content input stream
        Parameters:
        transaction - The target BM transaction. Cannot be null
        namespace - The target BM namespace. Cannot be null
        project - The target IDtProject. Cannot be null
        path - The target path. Cannot be null
        content - The imported content stream. Cannot be null
        resolveExternalReferencesDuringImport - Flag that specifies the additional resolving of external references during the import
        loadOptionsProvider - The load options provider for load process customization. Cannot be null
        resourceFactory - The optional resource factory. May be null. Uses standard resource factory registry if no custom factory is specified
        bmModelManager - The IBmModelManager service reference. Cannot be null
        runtimeVersionSupport - The IRuntimeVersionSupport service reference. Cannot be null
        qualifiedNameFilePathConverter - The IQualifiedNameFilePathConverter service reference. Cannot be null
        Returns:
        A loaded data container. May be null in case of resource absense or unsupported object types for import
      • resolveFqn

        protected String resolveFqn​(org.eclipse.core.runtime.IPath path,
                                    IQualifiedNameFilePathConverter qualifiedNameFilePathConverter)
        Resolves an FQN from a provided path
        Parameters:
        path - Path to resolve. May not be null
        qualifiedNameFilePathConverter - The IQualifiedNameFilePathConverter service reference. Cannot be null
        Returns:
        FQN if found. May be null