Class ResourceSetPartition


  • public class ResourceSetPartition
    extends Object
    Implementation of a blackboard partition based on EMF Resource Sets. Each partition has a resource set configured for the given EPackages. It can load a set of model resources. Inter-Model links are resolved up to the boundaries of the underlying resource set
    • Field Detail

      • rs

        protected ResourceSet rs
        Common EMF resource set for all models in this partition.
    • Constructor Detail

      • ResourceSetPartition

        public ResourceSetPartition()
    • Method Detail

      • getResourceSet

        public ResourceSet getResourceSet()
        Gets the resource set.
        Returns:
        Returns the internal used resource set of this blackboard partition
      • initialiseResourceSetEPackages

        public void initialiseResourceSetEPackages​(EPackage[] ePackages)
        Initialize the EPackages of the models to be stored in this blackboard partition.
        Parameters:
        ePackages - The list of EPackages which form the meta-model of the model stored in this model partition
      • loadModel

        public Resource loadModel​(URI modelURI)
        Load the model with the given URI into this blackboard partition.
        Parameters:
        modelURI - The URI of the model to be loaded
        Returns:
        The loaded resource
      • getContents

        public List<EObject> getContents​(URI modelURI)
        Returns all top level EObjects of the given model stored under the given URI. The model has to be created first.
        Parameters:
        modelURI - The model URI
        Returns:
        All top level elements of the model. Empty list if none have been found.
      • getFirstContentElement

        public EObject getFirstContentElement​(URI modelURI)
        Returns the first top level EObject of the given model stored under the given URI. The model has to be created first and it has to have at least one top level element
        Parameters:
        modelURI - The model URI
        Returns:
        The first top level element of the model
      • loadModel

        @Deprecated
        public Resource loadModel​(String modelURI)
        Deprecated.
        Use loadModel taking a URI instead
        Load the model with the given URI into this blackboard partition.
        Parameters:
        modelURI - The URI of the model to be loaded
        Returns:
        The loaded resource
      • resolveAllProxies

        public void resolveAllProxies()
        Resolve all model proxies, i.e., load all dependent models.
      • setContents

        public void setContents​(URI modelID,
                                List<EObject> newContents)
        Replaces the contents of the given model with newContents.
        Parameters:
        modelID - The model extent whose contents get replaced
        newContents - The new contents
      • setContents

        public void setContents​(URI modelID,
                                EObject newContents)
        Replaces the contents of the given model with newContents.
        Parameters:
        modelID - The model extent whose contents get replaced
        newContents - The new contents, single object
      • hasModel

        public boolean hasModel​(URI modelURI)
        Determines if the Resource referenced by the parameter contains an EMF model.
        Parameters:
        modelURI - URI of the Resource.
        Returns:
        true if, and only if, an EMF model is contained.
      • storeAllResources

        public void storeAllResources()
                               throws IOException
        Stores all resources in the resource set.
        Throws:
        IOException - If saving leads to I/O-Errors.
      • storeAllResources

        public void storeAllResources​(Map<String,​Object> saveOptions)
                               throws IOException
        Stores all resources in the resource set.
        Parameters:
        saveOptions - Save options to use
        Throws:
        IOException - IOException If saving leads to I/O-Errors.
      • getElement

        public <T extends EObjectList<T> getElement​(EClass targetType)
        Helper to find root objects of a specified class.
        Type Parameters:
        T - the generic type
        Parameters:
        targetType - the target type
        Returns:
        The list of found root elements. Empty list if none have been found.
      • hasElement

        public boolean hasElement​(EClass targetType)
        Helper to determine whether root objects of a specified class exist.
        Parameters:
        targetType - the target type
        Returns:
        true if elements have been found; false otherwise.