blob: 6d210361bece2a7a1a688aba695f71738c9bd61f [file] [log] [blame]
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="en">
<meta name="lang:search.pipeline.stopwords" content="True">
<meta name="lang:search.pipeline.trimmer" content="True">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<link rel="shortcut icon" href="../../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.0.4, mkdocs-material-4.4.2">
<title>Papyrus UML support - Eclipse Hawk</title>
<link rel="stylesheet" href="../../assets/stylesheets/application.30686662.css">
<link rel="stylesheet" href="../../assets/stylesheets/application-palette.a8b3c06d.css">
<meta name="theme-color" content="#7e57c2">
<script src="../../assets/javascripts/modernizr.74668098.js"></script>
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono&display=fallback">
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
<link rel="stylesheet" href="../../assets/fonts/material-icons.css">
<link rel="manifest" href="../../assets/images/site.webmanifest">
<link rel="stylesheet" href="../../stylesheets/extra.css">
<!-- FAVICON -->
<link rel="apple-touch-icon" sizes="180x180" href="../../assets/images/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="../../assets/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../../assets/images/favicon-16x16.png">
<link rel="mask-icon" href="../../assets/images/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="../../assets/images/favicon.ico">
<meta name="msapplication-TileColor" content="#b91d47">
<meta name="msapplication-config" content="../../assets/images/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
</head>
<body dir="ltr" data-md-color-primary="deep-purple" data-md-color-accent="deep-purple">
<svg class="md-svg">
<defs>
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
<a href="#supported-file-extensions" tabindex="1" class="md-skip">
Skip to content
</a>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="../.." title="Eclipse Hawk" class="md-header-nav__button md-logo">
<img src="../../assets/images/hawk-logo-white.svg" width="24" height="24">
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">
Eclipse Hawk
</span>
<span class="md-header-nav__topic">
Papyrus UML support
</span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active">
<label class="md-icon md-search__icon" for="__search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
&#xE5CD;
</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a href="https://git.eclipse.org/c/hawk/hawk.git/" title="Go to repository" class="md-source" data-md-source="">
<div class="md-source__repository">
Git repository @ Eclipse
</div>
</a>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container">
<main class="md-main" role="main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="__drawer">
<a href="../.." title="Eclipse Hawk" class="md-nav__button md-logo">
<img src="../../assets/images/hawk-logo-white.svg" width="48" height="48">
</a>
Eclipse Hawk
</label>
<div class="md-nav__source">
<a href="https://git.eclipse.org/c/hawk/hawk.git/" title="Go to repository" class="md-source" data-md-source="">
<div class="md-source__repository">
Git repository @ Eclipse
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../.." title="Home" class="md-nav__link">
Home
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-2" type="checkbox" id="nav-2" checked>
<label class="md-nav__link" for="nav-2">
Basic use
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-2">
Basic use
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../installation/" title="Installation" class="md-nav__link">
Installation
</a>
</li>
<li class="md-nav__item">
<a href="../core-concepts/" title="Core concepts" class="md-nav__link">
Core concepts
</a>
</li>
<li class="md-nav__item">
<a href="../examples-xmi/" title="Examples (XMI)" class="md-nav__link">
Examples (XMI)
</a>
</li>
<li class="md-nav__item">
<a href="../examples-modelio/" title="Examples (Modelio)" class="md-nav__link">
Examples (Modelio)
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
Papyrus UML support
</label>
<a href="./" title="Papyrus UML support" class="md-nav__link md-nav__link--active">
Papyrus UML support
</a>
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#supported-file-extensions" class="md-nav__link">
Supported file extensions
</a>
</li>
<li class="md-nav__item">
<a href="#predefined-uml-packages" class="md-nav__link">
Predefined UML packages
</a>
</li>
<li class="md-nav__item">
<a href="#multi-version-papyrus-uml-profile-support" class="md-nav__link">
Multi-version Papyrus UML profile support
</a>
</li>
<li class="md-nav__item">
<a href="#example-using-hawk-to-index-all-uml-models-in-an-eclipse-workspace" class="md-nav__link">
Example: using Hawk to index all UML models in an Eclipse workspace
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#models" class="md-nav__link">
Models
</a>
</li>
<li class="md-nav__item">
<a href="#creating-the-hawk-index" class="md-nav__link">
Creating the Hawk index
</a>
</li>
<li class="md-nav__item">
<a href="#adding-metamodels-and-models" class="md-nav__link">
Adding metamodels and models
</a>
</li>
<li class="md-nav__item">
<a href="#querying-hawk" class="md-nav__link">
Querying Hawk
</a>
</li>
<li class="md-nav__item">
<a href="#finding-uml-objects-by-stereotype" class="md-nav__link">
Finding UML objects by stereotype
</a>
</li>
<li class="md-nav__item">
<a href="#finding-stereotype-applications-from-the-uml-object" class="md-nav__link">
Finding stereotype applications from the UML object
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-3" type="checkbox" id="nav-3">
<label class="md-nav__link" for="nav-3">
Advanced use
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-3">
Advanced use
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../advanced-use/graph-as-emf/" title="Graph as EMF model" class="md-nav__link">
Graph as EMF model
</a>
</li>
<li class="md-nav__item">
<a href="../../advanced-use/advanced-props/" title="Advanced properties" class="md-nav__link">
Advanced properties
</a>
</li>
<li class="md-nav__item">
<a href="../../advanced-use/meta-queries/" title="Meta-level queries" class="md-nav__link">
Meta-level queries
</a>
</li>
<li class="md-nav__item">
<a href="../../advanced-use/temporal-queries/" title="Temporal queries" class="md-nav__link">
Temporal queries
</a>
</li>
<li class="md-nav__item">
<a href="../../advanced-use/oomph/" title="Oomph and Hawk" class="md-nav__link">
Oomph and Hawk
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Server
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Server
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../server/architecture/" title="Architecture" class="md-nav__link">
Architecture
</a>
</li>
<li class="md-nav__item">
<a href="../../server/api/" title="Thrift API" class="md-nav__link">
Thrift API
</a>
</li>
<li class="md-nav__item">
<a href="../../server/api-security/" title="Thrift API security" class="md-nav__link">
Thrift API security
</a>
</li>
<li class="md-nav__item">
<a href="../../server/deployment/" title="Deployment" class="md-nav__link">
Deployment
</a>
</li>
<li class="md-nav__item">
<a href="../../server/cli/" title="Console client" class="md-nav__link">
Console client
</a>
</li>
<li class="md-nav__item">
<a href="../../server/eclipse/" title="Eclipse client" class="md-nav__link">
Eclipse client
</a>
</li>
<li class="md-nav__item">
<a href="../../server/file-config/" title="File-based configuration" class="md-nav__link">
File-based configuration
</a>
</li>
<li class="md-nav__item">
<a href="../../server/logging/" title="Logging" class="md-nav__link">
Logging
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-5" type="checkbox" id="nav-5">
<label class="md-nav__link" for="nav-5">
Developers
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-5">
Developers
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../developers/run-from-source/" title="Run GUI from source" class="md-nav__link">
Run GUI from source
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/server-from-source/" title="Run Server from source" class="md-nav__link">
Run Server from source
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/plain-maven/" title="Build with plain Maven" class="md-nav__link">
Build with plain Maven
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/website/" title="Work on the website" class="md-nav__link">
Work on the website
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-6" type="checkbox" id="nav-6">
<label class="md-nav__link" for="nav-6">
Community
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-6">
Community
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="https://www.eclipse.org/forums/index.php/f/442/" title="Forum" class="md-nav__link">
Forum
</a>
</li>
<li class="md-nav__item">
<a href="https://gitlab.eclipse.org/eclipse/hawk/hawk/-/issues/new" title="File a bug" class="md-nav__link">
File a bug
</a>
</li>
<li class="md-nav__item">
<a href="https://gitlab.eclipse.org/eclipse/hawk/hawk/-/issues" title="Open bugs" class="md-nav__link">
Open bugs
</a>
</li>
<li class="md-nav__item">
<a href="https://ci.eclipse.org/hawk/" title="Builds" class="md-nav__link">
Builds
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../../additional-resources/" title="Additional resources" class="md-nav__link">
Additional resources
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#supported-file-extensions" class="md-nav__link">
Supported file extensions
</a>
</li>
<li class="md-nav__item">
<a href="#predefined-uml-packages" class="md-nav__link">
Predefined UML packages
</a>
</li>
<li class="md-nav__item">
<a href="#multi-version-papyrus-uml-profile-support" class="md-nav__link">
Multi-version Papyrus UML profile support
</a>
</li>
<li class="md-nav__item">
<a href="#example-using-hawk-to-index-all-uml-models-in-an-eclipse-workspace" class="md-nav__link">
Example: using Hawk to index all UML models in an Eclipse workspace
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#models" class="md-nav__link">
Models
</a>
</li>
<li class="md-nav__item">
<a href="#creating-the-hawk-index" class="md-nav__link">
Creating the Hawk index
</a>
</li>
<li class="md-nav__item">
<a href="#adding-metamodels-and-models" class="md-nav__link">
Adding metamodels and models
</a>
</li>
<li class="md-nav__item">
<a href="#querying-hawk" class="md-nav__link">
Querying Hawk
</a>
</li>
<li class="md-nav__item">
<a href="#finding-uml-objects-by-stereotype" class="md-nav__link">
Finding UML objects by stereotype
</a>
</li>
<li class="md-nav__item">
<a href="#finding-stereotype-applications-from-the-uml-object" class="md-nav__link">
Finding stereotype applications from the UML object
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset">
<h1>Papyrus UML support</h1>
<p>Hawk includes specific support for MDT2 UML models and UML profiles developed using Papyrus UML. This can be used by enabling the <code>UMLMetaModelResourceFactory</code> and <code>UMLModelResourceFactory</code> plugins when creating a Hawk instance.</p>
<p>The implementation mostly reuses MDT UML2 and Papyrus UML as-is, in order to maximize compatibility. There are some minor caveats, which are documented in this page.</p>
<h2 id="supported-file-extensions">Supported file extensions<a class="headerlink" href="#supported-file-extensions" title="Permanent link">&para;</a></h2>
<p>Hawk indexes plain UML2 models with the <code>.uml</code> extension, and Papyrus profiles with the <code>.profile.uml</code> extension. It does not index <code>.di</code> nor <code>.notation</code> files at the moment, as these do not provide semantic information.</p>
<p><code>.xmi</code> files are not indexed by the Hawk UML components, to avoid conflicts with the plain EMF support (matching the file to the proper model resource is done strictly by file extension). You are recommended to rename your UML2 XMI files to <code>.uml</code> for now.</p>
<h2 id="predefined-uml-packages">Predefined UML packages<a class="headerlink" href="#predefined-uml-packages" title="Permanent link">&para;</a></h2>
<p>UML2 provides an implementation of the UML standard libraries, with packages containing some common datatypes (e.g. String or Integer). If your models use any of these libraries, we heavily recommend that you add a <code>PredefinedUMLLibraries</code> component in your "Indexed Locations" section. Otherwise, any references from your models to the libraries will be left unresolved, and you will not be able to use those predefined entities in your queries.</p>
<p>This is because Hawk operates normally on files, and the predefined UML libraries are generally bundled within the UML2 plugins. The <code>PredefinedUMLLibraries</code> exposes those bundled resources to Hawk in a way that is transparent to the querying language.</p>
<h2 id="multi-version-papyrus-uml-profile-support">Multi-version Papyrus UML profile support<a class="headerlink" href="#multi-version-papyrus-uml-profile-support" title="Permanent link">&para;</a></h2>
<p>Beyond registering all the metamodels required to index plain UML models, the UML metamodel resource factory in Hawk can register <code>.profile.uml</code> files as metamodels. This allows us to index UML models with custom profiles in Hawk.</p>
<p>Since UML profiles can be versioned, Hawk will register version <code>X.Y.Z</code> of profile with URI <code>http://your/profile</code> with <code>http://your/profile/X.Y.Z</code> as the URI. When querying with Hawk, you will have to specify <code>http://your/profile/X.Y.Z</code> in your default namespaces, in order to resolve the ambiguity that may exist between multiple versions of the same metamodel.</p>
<p>If a new version of the UML profile is created, you will need to register the <code>.profile.uml</code> file again with Hawk before it can index models that use that version of the profile. Hawk treats entities of different versions of the same profile as entirely different types.</p>
<p>In terms of implementation details, Hawk takes advantage of the fact that <code>.profile.uml</code> files contain a collection of Ecore <code>EPackages</code>. Hawk simply adds the <code>/X.Y.Z</code> version suffix to their namespace URI, and otherwise leaves them untouched.</p>
<h2 id="example-using-hawk-to-index-all-uml-models-in-an-eclipse-workspace">Example: using Hawk to index all UML models in an Eclipse workspace<a class="headerlink" href="#example-using-hawk-to-index-all-uml-models-in-an-eclipse-workspace" title="Permanent link">&para;</a></h2>
<p>We will show how Hawk can be used to index all the UML models in an Eclipse workspace, including those that have custom profiles applied to them. To illustrate our approach, we will use <a href="https://github.com/mondo-project/mondo-hawk/raw/gh-pages/examples/models/profiles/specialThings.zip">these toy models</a> created with Papyrus. We assume that you have installed Hawk into your Eclipse instance, following the steps in [[this wiki page|Installation]].</p>
<h3 id="models">Models<a class="headerlink" href="#models" title="Permanent link">&para;</a></h3>
<p>The model is a very simple UML class diagram:</p>
<p><img alt="Sample UML class diagram" src="../profiles/02-model.png" /></p>
<p>It only has two classes, one of which has the <code>&lt;&lt;Special&gt;&gt;</code> stereotype with a <code>priority</code> property equal to 23. This value is not shown in the diagram, but it can be checked from the "Profile" page of the "Properties" view when the class is selected.</p>
<p>The profile including the <code>&lt;&lt;Special&gt;&gt;</code> stereotype is also very simple:</p>
<p><img alt="Sample UML profile" src="../profiles/01-model.profile.png" /></p>
<p>The diagram imports the <code>Class</code> UML metaclass, and then extends it with the <code>&lt;&lt;Special&gt;&gt;</code> stereotype.</p>
<h3 id="creating-the-hawk-index">Creating the Hawk index<a class="headerlink" href="#creating-the-hawk-index" title="Permanent link">&para;</a></h3>
<p>Before we can run any queries, we need to create a Hawk index. If we have installed Hawk correctly, we will be able to open the "Hawk" view and see something like this:</p>
<p><img alt="Hawk view with no instances" src="../profiles/03a-hawk-view-empty.png" /></p>
<p>Right now, we have no indexes in Hawk. We need to press the "Add" button, which is highlighted in red above. We should see a dialog similar to this:</p>
<p><img alt="Add new Hawk index dialog" src="../profiles/03b-hawk-configuration.png" /></p>
<p>Important points:</p>
<ul>
<li>We can pick any name we want, as long as it is unique.</li>
<li><code>Instance type</code> should be a <code>LocalHawkFactory</code> if we intend to index our workspace.</li>
<li>The <code>Local storage folder</code> will contain some of the configuration of that Hawk instance, and the database.</li>
<li><code>Remote location</code> is irrelevant when using the <code>LocalHawkFactory</code>.</li>
<li>If we are only interested in indexing the UML models in the workspace, it is a good idea to <code>Disable all</code> the plugins and then check only the UML metamodel and model resource factories.</li>
<li>You can choose to use Neo4j (if you [[build it on your own|Running from source]]), OrientDB, or any other backend we may support in the future.</li>
<li><code>Min/Max Delay</code> indicate how often will Hawk poll all the indexed locations. If you are only indexing the current workspace, you can leave both at 0 to disable polling: regardless of this setting, Hawk will react automatically whenever something in the workspace changes.</li>
</ul>
<p>Once the index has been created, you should see an entry for it in the "Hawk" view:</p>
<p><img alt="Hawk view with one instance" src="../profiles/03c-hawk-view.png" /></p>
<h3 id="adding-metamodels-and-models">Adding metamodels and models<a class="headerlink" href="#adding-metamodels-and-models" title="Permanent link">&para;</a></h3>
<p>From the screenshot above, we know that the index is <code>RUNNING</code> (available for queries) and not <code>UPDATING</code> nor <code>STOPPED</code>, so we can start configuring it as we need. First, we should double click on it to open the configuration dialog:</p>
<p><img alt="Hawk index config dialog" src="../profiles/04-config-dialog.png" /></p>
<p>We should go to the "Metamodels" tab and click on "Add...", then select the <code>specialThings.profile/model.profile.uml</code> file. Hawk will register our custom profile as a metamodel, and we will be ready to index models using all the versions of this profile so far. Should we define any newer versions, we will have to add the file again to Hawk.</p>
<p>The dialog will now list the new metamodel:</p>
<p><img alt="Hawk index config dialog after registering profile" src="../profiles/05-added-metamodel.png" /></p>
<p>Now we are ready to add the locations where the models to be indexed are stored. We go to the "Indexed Locations" tab and click on "Add". First, we will add the predefined UML libraries with some commonly used instances (e.g. UML data types):</p>
<p><img alt="Adding UML predefined libraries" src="https://github.com/mondo-project/mondo-hawk/blob/gh-pages/examples/models/profiles/06-add-predefinedlibs.png" /></p>
<p>We need to pick the right "Type", and then enter <code>/</code> in the "Location" field. The location is ignored for this repository, but due to current limitations in the UI we have to enter something in the field.</p>
<p>Next, we have to tell Hawk to index all the models in the workspace. We will "Add" another location, and this time fill the dialog like this:</p>
<p><img alt="Adding workspace" src="../profiles/07-add-workspace.png" /></p>
<p>Again, the <code>/</code> "Location" is irrelevant but required by the UI.</p>
<p>Hawk will spend some time <code>UPDATING</code>, and once it is <code>RUNNING</code> again we will be ready to run some queries on it.</p>
<h3 id="querying-hawk">Querying Hawk<a class="headerlink" href="#querying-hawk" title="Permanent link">&para;</a></h3>
<p>We can finally query Hawk now. To do so, we need to select our index on the "Hawk" view and click on the "Query" button, which looks like a magnifying glass:</p>
<p><img alt="Query button in the Hawk view" src="../profiles/08a-hawk-query.png" /></p>
<p>We will see a dialog like this one, with all fields empty:</p>
<p><img alt="Query dialog" src="../profiles/08-query-classNames.png" /></p>
<p>Enter the query <code>return Class.all.name;</code> and click on the "Run Query" button. This query lists the names of all the classes indexed so far by Hawk. You will notice that we obtain these results:</p>
<div class="codehilite"><pre><span></span><code>[E, T, MyClass, Special, V, NotSoSpecial, Stereotype1, K, E]
</code></pre></div>
<p>The E/T/V/K/E classes came from the predefined UML libraries. If you want only the results from your workspace, you must tell Hawk through the "Context Repositories" field, by entering <code>platform:/resource</code>. This is the base URI used by Hawk to identify all the files in your workspace. Click on "Run Query" again, and you should obtain the results shown in the screenshot:</p>
<div class="codehilite"><pre><span></span><code>[MyClass, Stereotype1, Special, NotSoSpecial]
</code></pre></div>
<p>Note how the query also returns the classes in the profile. Should you want to avoid this, you can either use the "Context Files" field (<code>*model.uml</code> will do this) to further restrict the scope of the query.</p>
<h3 id="finding-uml-objects-by-stereotype">Finding UML objects by stereotype<a class="headerlink" href="#finding-uml-objects-by-stereotype" title="Permanent link">&para;</a></h3>
<p>If you would like to find all applications of stereotype <code>X</code>, you can simply use <code>X.all</code> and then use <code>base_Metaclass</code> to find the object that was annotated with that stereotype. For instance, this query will find the name of all the classes that had the <code>&lt;&lt;Special&gt;&gt;</code> stereotype applied to them:</p>
<div class="codehilite"><pre><span></span><code>return Special.all.base_Class.name;
</code></pre></div>
<p>You will get:</p>
<div class="codehilite"><pre><span></span><code>[MyClass]
</code></pre></div>
<p>You can also access stereotype properties:</p>
<div class="codehilite"><pre><span></span><code>return Special.all.collect(s|
Sequence { s.priority, s.base_Class.name }
).asSequence;
</code></pre></div>
<p>This will produce:</p>
<div class="codehilite"><pre><span></span><code>[[23, MyClass]]
</code></pre></div>
<h3 id="finding-stereotype-applications-from-the-uml-object">Finding stereotype applications from the UML object<a class="headerlink" href="#finding-stereotype-applications-from-the-uml-object" title="Permanent link">&para;</a></h3>
<p>If you want to go the other way around, you can use reverse reference navigation on those <code>base_X</code> references to find the stereotypes that have been applied to a UML object:</p>
<div class="codehilite"><pre><span></span><code>return Class.all
.selectOne(s|s.name = &#39;MyClass&#39;)
.revRefNav_base_Class
.collect(st|Model.getTypeOf(st))
.name;
</code></pre></div>
<p>This would produce:</p>
<div class="codehilite"><pre><span></span><code>[Special]
</code></pre></div>
</article>
</div>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="../examples-modelio/" title="Examples (Modelio)" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Previous
</span>
Examples (Modelio)
</span>
</div>
</a>
<a href="../../advanced-use/graph-as-emf/" title="Graph as EMF model" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Next
</span>
Graph as EMF model
</span>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
Copyright © Eclipse Foundation, Inc. All Rights Reserved.
</div>
powered by
<a href="https://www.mkdocs.org">MkDocs</a>
and
<a href="https://squidfunk.github.io/mkdocs-material/">Material for MkDocs</a>
</div>
<div class="md-footer-copyright hawk-eclipse-links">
<ul>
<li><a href="https://www.eclipse.org/legal/privacy.php">Privacy Policy</a></li>
<li><a href="https://www.eclipse.org/legal/termsofuse.php">Terms of Use</a></li>
<li><a href="https://www.eclipse.org/legal/copyright.php">Copyright Agent</a></li>
</ul>
</div>
</div>
</div>
</footer>
</div>
<script src="../../assets/javascripts/application.c648116f.js"></script>
<script>app.initialize({version:"1.0.4",url:{base:"../.."}})</script>
</body>
</html>