Interface Model

    • Method Detail

      • getMetamodel

        Metamodel getMetamodel()
        Returns the metamodel this model is based on.
        Returns:
        the metamodel.
      • getAppliedMetamodelExtensions

        Collection<MetamodelExtension> getAppliedMetamodelExtensions()
        Returns the metamodel extensions currently applied on this model.
        Returns:
        the metamodel extensions currently applied on this model.
        Since:
        MDWorkbench 3.0.0
      • getApplicableMetamodelExtensions

        Collection<MetamodelExtension> getApplicableMetamodelExtensions()
        Returns all metamodel extensions that can be applied on this model. This list contains extensions that may already be applied on this model.
        Returns:
        all metamodel extensions that can be applied on this model.
        Since:
        MDWorkbench 3.0.0
      • applyMetamodelExtensions

        void applyMetamodelExtensions​(Collection<MetamodelExtension> extensions)
        Applies the specified metamodel extensions on this model. If those extensions require other extensions, those extensions are applied as well. It should be noted that once an extension has been applied, it cannot be unapplied.
        Parameters:
        extensions - the metamodel extensions to apply on the model.
        Since:
        MDWorkbench 3.0.0
      • read

        void read​(String readerName,
                  String uri)
           throws CoreException
        Clear this model and then populates its contents using the specified connector information.

        The reader name must match a connector registered on the related metamodel. The uri is used to locate a resource from where the connector should read information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific resource locator, including null when the connector does not expect any uri.

        Parameters:
        readerName - the connector name to be used.
        uri - an additional resource locator used by the connector to read the model (can be null)
        Throws:
        CoreException - if the model could not be loaded. Reasons include:
        • The reader name does not match any registered connector.
        • The uri is not valid.
        • The connector failed to read the resource located by the uri.
        See Also:
        Metamodel.getModelReaderDescriptors(), ConnectorDescriptor.getKind()
      • read

        void read​(String readerName,
                  String uri,
                  Map<String,​?> options)
           throws CoreException
        Clear this model and then populates its contents using the specified connector information.

        The reader name must match a connector registered on the related metamodel. The uri is used to locate a resource from where the connector should read information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific resource locator, including null when the connector does not expect any uri.

        Parameters:
        readerName - the connector name to be used.
        uri - an additional resource locator used by the connector to read the model (can be null)
        options - properties to configure the model reader.
        Throws:
        CoreException - if the model could not be loaded. Reasons include:
        • The reader name does not match any registered connector.
        • The uri is not valid.
        • The connector failed to read the resource located by the uri.
        Since:
        3.1.0
        See Also:
        Metamodel.getModelReaderDescriptors(), ConnectorDescriptor.getKind()
      • getReader

        ConnectorDescriptor getReader()
        Returns the last connector used to read this model.
        Returns:
        the last connector used to read this model, null if the model has never been loaded from a resource.
      • getReadURI

        String getReadURI()
        Returns the last uri used to read this model.
        Returns:
        the last connector used to read this model, null if the model has never been loaded from a resource or if the uri used was null.
      • write

        void write​(String writerName,
                   String uri)
            throws CoreException
        Writes the model contents using the specified connector information.

        The writer name must match a connector registered on the related metamodel. The uri is used to locate a resource where the connector should write information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific resource locator, including null when the connector does not expect any uri.

        Parameters:
        writerName - the connector name to be used.
        uri - an additional resource locator used by the connector to write the model (can be null)
        Throws:
        CoreException - if the model could not be written. Reasons include:
        • The writer name does not match any registered connector.
        • The uri is not valid.
        • The connector failed to write the resource located by the uri.
        See Also:
        Metamodel.getModelWriterDescriptors(), ConnectorDescriptor.getKind()
      • write

        void write​(String writerName,
                   String uri,
                   Map<String,​?> options)
            throws CoreException
        Writes the model contents using the specified connector information.

        The writer name must match a connector registered on the related metamodel. The uri is used to locate a resource where the connector should write information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific resource locator, including null when the connector does not expect any uri.

        Parameters:
        writerName - the connector name to be used.
        uri - an additional resource locator used by the connector to write the model (can be null)
        options - properties to configure the model writer.
        Throws:
        CoreException - if the model could not be written. Reasons include:
        • The writer name does not match any registered connector.
        • The uri is not valid.
        • The connector failed to write the resource located by the uri.
        See Also:
        Metamodel.getModelWriterDescriptors(), ConnectorDescriptor.getKind()
      • getWriter

        ConnectorDescriptor getWriter()
        Returns the last connector used to write this model.
        Returns:
        the last connector used to write this model, null if the model has never been written to a resource.
      • getWriteURI

        String getWriteURI()
        Returns the last uri used to write this model.
        Returns:
        the last connector used to write this model, null if the model has never been written to a resource or if the uri used was null.
      • getInstances

        <T extends MDWObject> MDWList<T> getInstances()
        Returns all model elements attached to this model.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. This list has no predictable order.

        Type Parameters:
        T - the type of the instance to retrieve.
        Returns:
        an unmodifiable list of MDWObject contained in this model.
        Throws:
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        See Also:
        MDWObject
      • getInstances

        <T extends MDWObject> MDWList<T> getInstances​(String typeName)
        Returns all model elements of the specified type attached to this model. This method does not consider sub types of the specified type.

        The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class" for example), or a simple name ( "Class"), if this name is unique in the metamodel.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. These elements are ordered the way they were created and added to this model.

        Type Parameters:
        T - the type of the instance to retrieve.
        Parameters:
        typeName - the type name of model elements to retrieve.
        Returns:
        an unmodifiable list of MDWObject contained in this model that matches the specified type.
        Throws:
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        See Also:
        MDWObject, getInstances(String, boolean)
      • getInstances

        <T extends MDWObject> MDWList<T> getInstances​(String typeName,
                                                      boolean includeSubTypes)
        Returns all model elements of the specified type, or one of its sub types, attached to this model.

        The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Classifier" for example), or a simple name ("Classifier"), if this name is unique in the metamodel.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. This list has no predictable order.

        Type Parameters:
        T - the type of the instance to retrieve.
        Parameters:
        typeName - the type name of model elements to retrieve.
        includeSubTypes - determines whether to retrieve elements based on sub types.
        Returns:
        an unmodifiable list of MDWObject contained in this model that matches the specified type, or one of its sub types.
        Throws:
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        See Also:
        MDWObject, getInstances(String)
      • getInstances

        <T extends MDWObject> MDWList<T> getInstances​(org.eclipse.emf.ecore.EClass type)
        Returns all model elements of the specified type attached to this model. This method does not consider sub types of the specified type.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. These elements are ordered the way they were created and added to this model.

        Type Parameters:
        T - the type of the instance to retrieve.
        Parameters:
        type - the type of model elements to retrieve.
        Returns:
        an unmodifiable list of MDWObject contained in this model that matches the specified type.
        Throws:
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        Since:
        MDWorkbench 3.0.0
        See Also:
        MDWObject, getInstances(EClass, boolean)
      • getInstances

        <T extends MDWObject> MDWList<T> getInstances​(org.eclipse.emf.ecore.EClass type,
                                                      boolean includeSubTypes)
        Returns all model elements of the specified type, or one of its sub types, attached to this model.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. This list has no predictable order.

        Type Parameters:
        T - the type of the instance to retrieve.
        Parameters:
        type - the type of model elements to retrieve.
        includeSubTypes - determines whether to retrieve elements based on sub types.
        Returns:
        an unmodifiable list of MDWObject contained in this model that matches the specified type, or one of its sub types.
        Throws:
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        Since:
        MDWorkbench 3.0.0
        See Also:
        MDWObject, getInstances(String)
      • getProfiledInstances

        <T extends MDWObject> MDWList<T> getProfiledInstances​(String typeName,
                                                              String profileName)
        Returns model elements of the specified type attached to this model, which match the specified profile name. This method does not consider sub types of the specified type.

        The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class" for example), or a simple name ( "Class"), if this name is unique in the metamodel.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. These elements are ordered the way they were created and added to this model.

        Type Parameters:
        T - the type of the instance to retrieve.
        Parameters:
        typeName - the type name of model elements to retrieve.
        profileName - the name of the profile type the instances must match.
        Returns:
        an unmodifiable list of MDWObject contained in this model that matches the specified type.
        Throws:
        InvalidCallException - if this API is not called during an MDWorkbench evaluation.
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        See Also:
        MDWObject, getProfiledInstances(String, String, boolean)
      • getProfiledInstances

        <T extends MDWObject> MDWList<T> getProfiledInstances​(String typeName,
                                                              String profileName,
                                                              boolean includeSubTypes)
        Returns all model elements of the specified type, or one of its sub types, attached to this model, which match the specified profile name.

        The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Classifier" for example), or a simple name ("Classifier"), if this name is unique in the metamodel.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. This list has no predictable order.

        Type Parameters:
        T - the type of the instance to retrieve.
        Parameters:
        typeName - the type name of model elements to retrieve.
        profileName - the name of the profile type the instances must match.
        includeSubTypes - determines whether to retrieve elements based on sub types.
        Returns:
        an unmodifiable list of MDWObject contained in this model that matches the specified type, or one of its sub types.
        Throws:
        InvalidCallException - if this API is not called during an MDWorkbench evaluation.
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        See Also:
        MDWObject, getProfiledInstances(String, String)
      • getProfiledInstances

        <T extends MDWObject> MDWList<T> getProfiledInstances​(org.eclipse.emf.ecore.EClass type,
                                                              String profileName)
        Returns model elements of the specified type attached to this model, which match the specified profile name. This method does not consider sub types of the specified type.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. These elements are ordered the way they were created and added to this model.

        Type Parameters:
        T - the type of the instance to retrieve.
        Parameters:
        type - the type of model elements to retrieve.
        profileName - the name of the profile type the instances must match.
        Returns:
        an unmodifiable list of MDWObject contained in this model that matches the specified type.
        Throws:
        InvalidCallException - if this API is not called during an MDWorkbench evaluation.
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        Since:
        MDWorkbench 3.0.0
        See Also:
        MDWObject, getProfiledInstances(EClass, String, boolean)
      • getProfiledInstances

        <T extends MDWObject> MDWList<T> getProfiledInstances​(org.eclipse.emf.ecore.EClass type,
                                                              String profileName,
                                                              boolean includeSubTypes)
        Returns all model elements of the specified type, or one of its sub types, attached to this model, which match the specified profile name.

        The returned list is a MDWList so you can directly invoke scripts on the model elements. This list has no predictable order.

        Type Parameters:
        T - the type of the instance to retrieve.
        Parameters:
        type - the type of model elements to retrieve.
        profileName - the name of the profile type the instances must match.
        includeSubTypes - determines whether to retrieve elements based on sub types.
        Returns:
        an unmodifiable list of MDWObject contained in this model that matches the specified type, or one of its sub types.
        Throws:
        InvalidCallException - if this API is not called during an MDWorkbench evaluation.
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        Since:
        MDWorkbench 3.0.0
        See Also:
        MDWObject, getProfiledInstances(EClass, String)
      • create

        <T extends MDWObject> T create​(String typeName)
        Creates a new instance of a MDWObject based on the specified type. The created element is automatically registered to this model, there's no need to call the add(MDWObject) method.

        The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class" for example), or a simple name ( "Class"), if this name is unique in the metamodel. This must be a concrete (i.e. non abstract) type.

        If this model is based on EMF, the EMF factory registered to the EPackage of the related metamodel is used to instantiate the model element.

        Type Parameters:
        T - the type of the instance to create.
        Parameters:
        typeName - the type name of the instance to create.
        Returns:
        the created instance.
        Throws:
        UnsupportedOperationException - if this method is not supported by a particular model implementation
      • create

        <T extends MDWObject> T create​(org.eclipse.emf.ecore.EClass type)
        Creates a new instance of a MDWObject based on the specified type. The created element is automatically registered to this model, there's no need to call the add(MDWObject) method.

        If this model is based on EMF, the EMF factory registered to the EPackage of the related metamodel is used to instantiate the model element.

        Type Parameters:
        T - the type of the instance to create.
        Parameters:
        type - the type of the instance to create.
        Returns:
        the created instance.
        Throws:
        UnsupportedOperationException - if this method is not supported by a particular model implementation
        Since:
        MDWorkbench 3.0.0
      • add

        void add​(MDWObject object)
        Register this model element to the model. Has no effect if the element is already part of this model.

        This method is only to be used if the element has been created outside of a Model, for example using an EMF factory directly. If the model element has been created using the create(String) method, the element is already part of the model.

        Parameters:
        object - the model element to be registered.
      • remove

        void remove​(MDWObject object)
        Unregister this model element from the model. Has no effect if the model element is not part of this model.

        This method only detach the model element from this model. To completely destroy the object and ensure it's not accessible from other elements, you should rather use the eRemove() method on this object.

        Parameters:
        object - the object to unregister.
        See Also:
        MDWObject.eRemove()
      • clear

        void clear()
        Clears the contents of this model.
      • getDiagram

        DiagramImage getDiagram​(MDWObject object,
                                DiagramOptions options)
                         throws CoreException
        Get the diagram image for a specific model element.

        This method uses the diagram provider of the model reader that loaded this model. If this model is not loaded by a model reader, or if the model reader does not define a diagram provider, this method throws a CoreException.

        Please note that many model readers won't be able to support diagrams (XMI reader for example). To support diagrams, a model reader should generally have a live connection with a CASE tool, through COM APIs for example, to be able to dynamically retrieve images.

        Parameters:
        object - a model element which is a logical diagram, or which has an attached diagram.
        options - some options used to retrieve the diagram image (may be null).
        Returns:
        the diagram image.
        Throws:
        CoreException - if no diagram image could be retrieved.
        Since:
        2.1.0
        See Also:
        DiagramProvider