Hawk is an extensible system. Currently, it contains the following kinds of components:
Type | Role | Current implementations |
---|---|---|
Change listeners | React to changes in the graph produced by the updaters | Tracing, Validation |
Graph backends | Integrate database technologies | Neo4j, OrientDB, Greycat |
Model drivers | Integrate modelling technologies | Ecore, BPMN, Modelio, IFC2x3/IFC4 in this repo, and UML2 |
Query languages | Translate high-level queries into efficient graph queries | Epsilon Object Language, Epsilon Pattern Language, OrientDB SQL |
Updaters | Update the graph based on the detected changes in the models and metamodels | Built-in |
VCS managers | Integrate file-based model repositories | Local folders, SVN repositories, Git repositories, Eclipse workspaces, HTTP files |
Using Hawk generally involves these steps:
In the following sections, we will show how to perform these steps.
To manage and use Hawk indexes, first open the “Hawk” Eclipse view, using “Window > Show View > Other... > Hawk > Hawk”. It should look like this:
Hawk indexes are queried and managed from this view. From left to right, the buttons are:
Shift+Delete
.To create a new index, open the Hawk view and use the “New” button to open this dialog:
The dialog requires these fields:
mondo-integrtion
.Once these fields have been filled in, Hawk will create and set up the index in a short period.
After creating the index, the next step is to register the metamodels of the models that are going to be indexed. To do this, select the index in the Hawk view and either double click it or click on the “Configure” button. The configure dialog will open:
The configure dialog has several tabs. For managing metamodels, we need to go to the “Metamodels” tab. It will list the URIs of the currently registered metamodels. If a metamodel we need is not listed there, we can use the “Add” button to provide Hawk with the appropriate file to be indexed (e.g. the .ecore
file for EMF-based models, or the metamodel-descriptor.xml
for Modelio-based models). We can also “Remove” metamodels: this will remove all dependent models and metamodels as well.
To try out Hawk, we recommend adding the JDTAST.ecore metamodel, which was used in the GraBaTs 2009 case study from AtlanMod. For Modelio metamodels, use the metamodel-descriptor.xml for Modelio 3.6 projects (for older projects, use the older descriptors included as metamodel_*.xml
files in the Modelio 3.6 sources).
Keep in mind that metamodels may have dependencies to others. You will need to either add all metamodels at once, or add each metamodel after those it depends upon. If adding all the metamodels at once, Hawk will rearrange their addition taking into account their mutual dependencies.
Note: the EMF driver can parse regular Ecore metamodels with the .ecore
extension.
Note: regarding the Modelio metamodel-descriptor.xml
files, you can find those as part of the Modelio source code.
Having added the metamodels of the models to be indexed, the following step is to add the repositories to be indexed. To do so, go to the “Indexed Locations” tab of the Hawk configure dialog, and use the “Add” button. Hawk will present the following dialog:
![Hawk add repository dialog](img/hawk_add_repo.png**
The fields to be used are as follows:
JGitRepository
connector: the old Git
connector is deprecated. You can use a path to the root folder of your Git clone, or a file://path/to/repo[?branch=BRANCH]
URL (where the optional ?branch=BRANCH
part can be used to specify a branch other than the one currently checked out).To try out Hawk, after adding the JDTAST.ecore
metamodel from the previous section, we recommend adding a folder with a copy of the set0.xmi file. It has around 70k model elements. To watch over the indexing process, look at the “Error Log” view or run Eclipse with the -console
option.
The supported file extensions are as follows:
Driver | Extensions |
---|---|
EMF | .xmi , .model , any extensions in the EMF extension factory map that use XMIResourceFactoryImpl , any extensions mentioned through the org.hawk.emf.model.extraExtensions Java system property (e.g. -Dorg.hawk.emf.model.extraExtensions=.railway,.rail ). |
UML2 | .uml . .profile.uml files can be indexed normally and also registered as metamodels. |
BPMN | .bpmn , .bpmn2 . |
Modelio | .exml , .ramc . Parses mmversion.dat internally for metadata. |
IFC | .ifc , .ifcxml , .ifc.txt , .ifcxml.txt , .ifc.zip , .ifczip . |
Simply indexing the models into the graph will already speed up considerably some common queries, such as finding all the instances of a type: in Hawk, this is done through direct edge traversal instead of going through the entire model. However, queries that filter model elements through the value of their attributes will need additional indexing to be set up.
For instance, if we wanted to speed up return Class.all.selectOne(c|c.name='MyClass');
(which returns the class named “MyClass”), we would need to index the name
attribute in the Class
type. To do so, we need to go to the Hawk configure dialog, select the “Indexed Attributes” tab and press the “Add” button. This dialog will open:
Its fields are as follows:
Please allow some time after the dialog is closed to have Hawk generate the index.
Currently, Hawk can index attributes with strings, booleans and numbers. Indexing will speed up not only =
, but also >
and all the other relational operators.
Sometimes we will need to filter model elements through a piece of information that is not directly stored among its attributes, but is rather computed from them. To speed up the process, Hawk can keep precompute these derived attributes in the graph, keeping them up to date and indexing them. For instance, if we wanted to quickly filter UML classes by their number of operations, we would go to the Hawk configure dialog, select the “Derived Attributes” tab and click on the “Add” button. This dialog would appear:
The fields are as follows:
self
variable to access the model element being extended.For this particular example, we'd set the fields like this:
return self.ownedOperation.size;
.After pressing OK, Hawk will spend some time computing the derived attribute and indexing the value. After that, queries such as return Class.all.select(c|c.ownedOperationCount > 20);
will complete much faster.
To query the indexed models, use the “Query” button of the Hawk view. This dialog will open:
The actual query can be entered through the “Query” field manually, or loaded from a file using the “Query File” button. The query should be written in the language selected in “Query Engine”. The scope of the query can be limited using the “Context Repositories” and “Context Files” fields: for instance, using set1.xmi
on the “Context Files” field would limit it to the contents of the set1.xmi
file.
Running the query with “Run Query” button will place the results on the “Result” field.