\subsection{Model Loading Tasks} | |
The \textit{LoadModelTask (epsilon.loadModel)} loads a model from an arbitrary location (e.g. file-system, database) and adds it to the project repository so that subsequent Epsilon tasks can query or modify it. Since Epsilon supports many modelling technologies (e.g. EMF, MDR, XML), the \textit{LoadModelTask} defines only three generic attributes. The \textit{name} attribute specifies the name of the model in the project repository. The \textit{type} attribute specifies the modelling technology with which the model is captured and is used to resolve the technology-specific model loading functionality. Finally, the \textit{aliases} attribute defines a comma-separated list of alternative names by which the model can be accessed in the model repository. | |
The rest of the information needed to load a model is implementation-specific and is therefore provided through \textit{parameter} nested elements, each one defining a pair of \textit{name}-\textit{value} attributes. As an example, a task for loading an EMF model that has a file-based ECore metamodel is displayed in Listing \ref{lst:LoadModelTask}. | |
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize, nolol=true, flexiblecolumns=true, caption=Loading an EMF model using the epsilon.loadModel task, label=lst:LoadModelTask, language=XML] | |
<epsilon.loadModel name="Tree1" type="EMF"> | |
<parameter name="modelFile" value="TreeInstance.ecore"/> | |
<parameter name="metamodelFile" path="Tree.ecore"/> | |
<parameter name="isMetamodelFileBased" value="true"/> | |
<parameter name="readOnLoad" value="true"/> | |
</epsilon.loadModel> | |
\end{lstlisting}%$ | |
\textit{LoadEmfModelTask} is a specialised version of \textit{LoadModelTask} only for EMF models. While the \textit{type} attribute is no longer available, the task still supports the \textit{name} and \textit{aliases} attributes. In addition, some of the values which had to be provided through \textit{parameter} nested elements can now be set using regular attributes, such as \textit{modelFile}, \textit{modelUri}, \textit{metamodelFile} (which implicitly indicates that the metamodel is file-based), \textit{metamodelUri}, \textit{reuseUnmodifiedMetamodelFile} (which can be set to ``false'' to avoid reusing file-based metamodels that have not been modified since the last time they were loaded), \textit{read} (equivalent to \textit{readOnLoad}) and \textit{store} (equivalent to \textit{storeOnDisposal}). Listing~\ref{lst:LoadEmfModelTask} shows the equivalent fragment required to produce the same result as in Listing~\ref{lst:LoadModelTask}. | |
\begin{lstlisting}[float=tbp, basicstyle=\ttfamily\footnotesize, nolol=true, flexiblecolumns=true, caption=Loading an EMF model using the epsilon.emf.loadModel task, label=lst:LoadEmfModelTask, language=XML] | |
<epsilon.emf.loadModel name="Tree1" | |
modelFile="TreeInstance.ecore" | |
metamodelFile="Tree.ecore" /> | |
\end{lstlisting} |