Friday, July 15, 2016

Automated Scoping, Validation and Quickfixes for xText based languages

By Christian Beikov, Raphael Löffler, Oliver Reiter and Christopher Schwarz.

Xtext is a language development framework and mostly used to create domain specific languages as well as to develop feature-rich editors. Model validation with error highlighting, scoping and quick fixes are also supported, but have to be implemented manually. Our project generates said features automatically based on OCL constraints, which are defined in the underlying model of the language. The goal is to reduce the amount of work creating textual editors for DSLs by following a model based approach. In cause of the fact that the whole work is based on Xtext, a big part of it was to explore Xtext to find possible solutions for integrating the described automated approach. Xtext is one part of the openArchitectureWare (oAW), which is framework for supporting model driven development. The possibility to not only create a new DSL, but also create automatically specified editors for this DSL makes Xtext very interesting. Another big part were our work is based on is the Object Constraint Language (OCL). OCL is a textual formal specification language and is part of the Unified Modeling Language. It is a declarative language and was introduced by the Object Management Group (OMG) to add the possibility of adding constraints to object-oriented models that can not be defined with standard diagrammatic notations.

Validation

For each class, which has OCL constraints defined, a validator is generated in Java, which also tries to find the erroneous feature of the object. These are further used in a custom implementation of AbstractDeclarativeValidator to be used in an Xtext editor. The improvement to the default validation is the localization of the error, which also enables the possibility to provide quickfixes. The pictures below show our implementation (Fig. 2.) in comparison to the default validator (Fig. 1.), which highlights the complete, invalid object.

Fig. 1. Error highlighting with default validators
Fig. 2. Error highlighting with OCL validators

Scoping

A scoping provider basically returns a set of objects, which can be used in a specific context. Therefore scoping rules have to be implemented manually, as the default provider only generates a scope with objects of a valid type. Our project tries to filter these by the OCL constraints of the context. To give an example, Fig. 4. shows the filtered scope in comparison to the unfiltered one (Fig. 3.). A constraint hereby is, that a page element, e.g. a text-field, can only refer to features contained in the handled entity of the form. In this example, this is Event. Another one in this example is, that a date-selection-field can only refer to attributes of the type Date and therefore the other elements are filtered out.

Fig. 3. Scope of the default validator
Fig. 4. Scope of the OCL based validator

Quickfixes

Quickfixes are provided by the editor, if an error is detected. For cross references, this is basically just the combination of validation and scoping, but for primitive data types, these have to be provided seperately. Our implementation detects the type of the erroneous feature and generates a fix at runtime in the validator. There is currently just one limitation: quickfixes are provided only for boolean values and cross references, but this functionality can easily be extended in the future.

Fig. 5. Quickfix of the OCL based provider

Future work

Of course there are some restrictions and limits of our implementation, which can be improved in future. Especially the generated Java code can be optimized in future. As mentioned our generated quickfixes currently support only boolean values. The code generation can be extended in future to also provide other types. Another way to extend our solution is to integrate all OCL operations. Currently we only implemented the most important ones to provide basic functionality of the implementation. These two extensions can be easily introduced by extending the implementation for the wanted functionality.


The source code of the project can be found on Github (https://github.com/Advanced-Model-Engineering-SS16/xtext-ocl-extensions).

Friday, July 01, 2016

Implementing a GUI for defining ontology/model mappings

By Stefan Beyer, Raimund Hirz, and Christopher Tunkl

Motivation

In the domains of Software Engineering and Model Engineering, models can be used to describe and document complex systems from many different viewpoints with varying levels of detail. If multiple models about the same system are created, the models might potentially contain inconsistencies and contradictions. In order to detect and eliminate such inconsistencies, a way to define constraints on how two or more specific models should relate to each other - on how some model should be mapped to another - needs to be found. While there exist countless approaches to generate such mappings in an automated or semi-automated way by using various heuristics, our task was to develop a graphical user interface for domain experts for manually specifying and modifying mappings. In our case, those models are represented as ontologies, the cornerstone of the Semantic Web. Most standard technologies used in this area make an open-world assumption, which does not allow to express such constraints. Because of that we use SPARQL, the standard query language for Semantic Web data, to build queries that act as our mapping constraints. We define those constraints on separate models which in turn describe the ontologies

Goal

Our task was to create an extensible, Java-based GUI to define mappings between instances of a given meta-model. In particular, we had to fulfill the following requirements: - The implementation must be developed in Java. Whenever possible, the JFace UI toolkit should be used. - A graphical editor should be used to enable the user to create mappings by using drag & drop or similar “direct” interaction methods. The editor should allow mapping between the elements of two distinct models. - It should be possible to open a dialog to define further constraints for a specific mapping. - The user should be able to save the entire mapping as well as all constraints in a machine-readable file format. In addition to these mandatory requirements, four optional requirements were defined: - Instead of a separate application, the mapping editor should be implemented as an Eclipse plug-in so it can be used within other Eclipse-based applications. - It should be possible to load two or more models into the editor. - The nature of a mapping should be visible directly in the editor without having to open the mapping dialog. - In addition to saving the mapping, it should also be possible to load it again.

Terms and Concepts

Amongst others, the meta-model provided to us contains three key elements: - PackageDeclaration: A collection of TypeDeclarations (similar to packages in Java). Mappings are defined between the elements of two or more PackageDeclarations. - TypeDeclaration: The equivalent of a class. It contains AttrDeclarations and AssocDeclarations. - AttrDeclaration: An attribute, consisting of a name and a type - AssocDeclaration: A reference to another TypeDeclaration AttrDeclarations and AssocDeclarations are collectively known as StructuralFeatures



We distuingish between two kinds of mappings in our editor:

SFMapping

A mapping between two or more StructureFeatures, although our implementation is restricted to AttrDeclarations. It consists of a set of arbitrary value transformations and a mapping function, which defines the specific constraints for the values. Examples for value transformers are string operations such as concatentation or mathematical operations such as addition. Mapping functions define the required relations between two or more values, such as equality or order relations.

TDMapping

A mapping between two TypeDeclarations, consisting of a mapping function. For the sake of usability, TDMappings define constraints on the set of attributes as a whole. They can be seen as shortcuts or convenience mappings. For instance, the TDAllAttrEqual required all attributes sharing the same names to have equal values. That way, the user does not have to define the equality relation between each set of same-named attributes separately. It is easily possible to add further value transformers and mapping functions.

The Editor

Our editor consists of a main canvas, which displays the TypeDeclarations from the loaded models in a similar way to an UML class diagram. On the right edge of the canvas, the tool box contains tools to define and extend mappings.



To change the type of an TDMapping, it is possible to choose one of the predefined types using the context menu of the mapping.



In order to further refine SFMappings, the user can double-click the mapping rectangle in order to open the EditSFMappingDialog. The EditSFMappingDialog consists of the following views: - the toolbox on the left side of the window, containing the lists of available value transformers and mapping functions – the attribute list at the top, listing all the attributes and associations belonging to the TypeDeclarations of the current mapping – the mapping specification in the center, showing the mapping function and all used value transformers – the SPARQL view at the bottom, displaying the specified mapping as a SPARQL query



In order to add value transformers to the mapping or to change the mapping function, the user can double-click the corresponding entry in the toolbox. When adding a value transformer, the it is possible to set its arguments by selecting attributes or other value transformers using the respective combobox. For constant arguments, a textfield is displayed instead. Whenever any changes are performed, the SPARQL query at the bottom is updated in real-time.

Future Work

Our editor is designed in a way, that it can be modified and extended quite easily. There are currently plans to enhance and integrate it into an enterprise modeling environment, which uses the described meta-model. Also we would like to encourage others to create more sophisticated user interfaces for mapping tools of all kinds in order to help end users to better understand and leverage the capabilities of those tools.

Friday, August 21, 2015

Enhancement of the xMOF Editor and Debugger

Tooling for Executable Metamodelling with xMOF

By Simon Georg Hecht, Christoph Kubin, Melanie Nothmüller, and Angela Purker

Model execution is very useful for fast prototyping, trace analysis, and many other areas. One important executable modeling language is foundational UML (fUML) - a subset of UML that is executable thanks to a standardized execution semantics. xMOF lifts fUML a meta-level up to the meta-metamodel level M3 to enable the precise specification of the execution semantics of behavioral modelling languages. Therewith, it allows leveraging fUML’s execution semantics for executing models compliant to such behavioral modeling languages defined with xMOF. 

Model execution - and especially model execution of fUML and xMOF models - is a very young topic in the modelling domain and therefore also the tools for model execution are not yet in a mature state. However, to enable the work with executable models like xMOF, it is necessary to have tools providing efficient and effective support for the modelling process. To bring this to a different context, a Java developer needs a good IDE to ease his/her development process. It is the same for the model-based approach. To ease the modelling process, good tools are needed. But model execution is not as old as Java development, so the tools do not support all needed tasks yet.

In this work we focus on two important tools for xMOF, namely the xMOF editor that allows the creation of xMOF models for the definition of execution semantics, and the xMOF debugger that supports the verification process of the defined execution semantics. 

Improvements of the xMOF Editor and Debugger

The purpose of the xMOF editor is to allow an efficient and effective creation of xMOF models. Besides editing support, it is very important to have a debugger to trace the model execution and thereby simplify troubleshooting when errors occur. Both tools can also improve the understandability of the created model itself.

xMOF Editor

There is already an editor available for xMOF providing basic editing functionality needed to create xMOF models. 

The structure of the xMOF editor is subdivided in 4 major parts as you can see in the figure above. On the left hand side (1) there is the tree-based structural view similar to the standard Ecore modelling view. In the middle (2) there is the activity editor itself, based on Graphiti. It is the editor for creating activities in a graphical way. On the right hand side (3) there is the feature palette for the activity editor. At the bottom (4) there is the standard property view for editing the elements in the diagram as well as in the structural view.

Our goal was to enhance the efficiency, effectiveness, and usability of the xMOF editor. Therefore, we extended the original xMOF editor in the following way: 
  1. First, we implemented and improved the initialization of xMOF model elements to speed up the modeling process and reduce potential error sources.
  2. Second, we added support for the visualization and editing of xMOF model elements contained within other elements, which could before be only edited in the tree-based structural view.
  3. Third, we automated the modeling steps needed when overriding the behavior of operations defined in xMOF models.
  4. Fourth, we implemented some heretofore missing usability features of the editor, in particular, the closing and moving of tabs opened within the xMOF editor.
  5. Fifth, we implemented a specialized validation for xMOF facilitating the localization of potential bugs in xMOF models.

xMOF Debugger

xMOF Debugger

For debugging, an fUML debug plugin was already available, which was taken as basis for the new xMOF debug plugin. While the fUML debug plugin was able to debug plain fUML models, our goal was to expand its applicability to xMOF models. Therefore, the most important step was the generalization of the debug functionality for both languages fUML and xMOF in order to avoid code duplicates in the two debug plugins. Another improvement - which is a result of the generalization - is the implementation of the stepping mechanism (use of the debugging methods stepInto(), stepOver() and stepReturn() from the Eclipse debug toolbar) for the xMOF debug plugin. The figure above gives an overview of the newly created classes in the generalized plugin and shows the elements in the Eclipse debug perspective for xMOF.

Outlook

Throughout the project we identified many more interesting improvements of the xMOF editor and debugger. Further improvements for the xMOF editor in detail could be:
  • A more customized property view showing only the necessary properties
  • Direct editing features for the diagram components
  • Context buttons for object suggestions
  • Enabling the creation and setting of pins in the graphical representation
  • Layouting of diagrams, e.g. allowing color for any activity object 
  • Decorating the activity diagrams based on the errors of validation
  • A better validation/error output 
  • A more sophisticated approach on the modularity of validators, for example a setting window where you can choose which validators are needed for your project
  • Live validation and markers
The xMOF debugger currently supports basic debug functionality, such as stepping through activity diagrams. However, interesting further and more advanced features include trace visualization, such as the visualization of a debugged model’s state as an object diagram. 

Implementation

xMOF is part of the moliz project. The source code of the project is publicly available at https://github.com/moliz.

Tuesday, August 04, 2015

Repairing model constraint violations with MOMoT

Introduction

Model Transformation are the key concept of the Model Driven Engineering today. Usually, Model Transformations are applied through Transformation Rules. However, the orchestration of the rules is a very complex task. Manually, it is very hard to determine what would be the best order to apply such rules. One possible way to tackle this, is to apply Search-based optimization techniques. Therefore, a framework called MOMoT has been created which combines two worlds, Model Transformations and Search-based Software Engineering. It is a new framework which has already been applied on 3 problem domains - Stack, Modularization and Refactoring problem. Our goal is to define a new problem domain to apply MOMoT and to evaluate behaviour, vulnerabilities and threats of such an approach.

Problem Definition

Often, models represent real-world problems. As such, they also have constraints and restrictions that need to be fulfilled. Such constraints can be violated and one of the essential tasks in model engineering is to repair such model so that they satisfy all the constraints. Our goal is apply MOMoT approach on such models and to repair them so that at the end they satisfy all the constraints. We applied this approach to many different constraints sequentially and observed their results. In the following, we describe very simple model and have MOMoT can be applied on that. We tested this approach on many different constraint violations including:
  • Multiplicity upper bound
  • ID not set
  • Duplicate id
  • Not-Null attribute
  • OCL constraint(s)
  • Unique attribute
  • Value aggregation and counting
All the projects can be found at public repository at GitHub.

Running Example

In order to apply this approach on this specific problem domain, we need to define a model which violates some of the constraints. First step would naturally be to define meta-model with some specific constraints. In this example we define a very simple meta-model which represents a university.

Meta-model of the university

Here, we see that an university consists of student and courses, where course should have at least 5 students. Now we create a model which doesn't satisfy this constraint. Our model consists of 8 students and 3 courses where each course has 5, 3 and 2 students assigned to it respectively. In order to repair such models we need to define transformation rules which are applied on the models to resolve the constraint violations. We use Henshin to define them.

Henshin transformation rules for our example

We can see that first rule creates a new student while the second rule assigns new student to a course. Orchestration of those rules is defined in a Java class.

Evaluation 

With such approach we were able to repair almost all models. Models that have manipulated ID (null or duplicate) were not able to get repaired since parsing of such models already produces an exception. Therefore, we have removed the ID attribute and replaced it by an equivalent unique, not-null attribute for which a constraint in OCL has been defined.
Concluding, we have discovered that it is very important how a specific OCL is defined in our approach. For example, one way to define that students have unique numbers would be to define it in a class University. However, this would lead to only one constraint violation no matter how many students actually violate that constraint. When we try to minimize the number of constraint violations in the search, a better guidance can be given by defining the constraint in the context of the Student class resulting in a better representation of the actual number of constraint violations.

Monday, July 20, 2015

Extending an EMF Fuzz Testing Framework with support for UML

Extending an EMF Fuzz Testing Framework

with support for UML


Introduction

Randomly or pseudo-randomly generated data is useful in many application areas including software testing and software security. Using this kind of data as input to test software applications, helps improving their quality by increasing code coverage. In the area of model engineering there, currently, exists only very few frameworks that support the generation of UML (Unified Modeling Language) models. Generating such models would help testing software which expects UML models, with or without applied UML profiles, as input. In this blog we present an extension of an EMF (Eclipse Modeling Framework) Fuzz Testing Framework to support UML model generation including UML profiles.

What is Fuzz testing?           

The idea of Fuzz testing is to test software by using (pseudo-)randomly generated data as input in order to find inputs that cause unexpected behavior of the system under test. Using randomly generated input for testing helps improving software quality by increasing code coverage. Therefore, errors can be detected, which would be hard to find with other software testing techniques or manual input data specification. Reproducibility is a very important property of automated tests because it is necessary to reproduce an error in order to analyse and correct it. Additionally, the costs per found error can be significantly decreased. The generation of pseudo-random input is performed by a so called Fuzz generator.
               

Fuzz testing in Model Engineering

Fuzz Testing can also be applied in the area of model engineering, in which the generated inputs are models. Current Fuzz Testing Frameworks do not support the generation of UML models and UML models including UML Profiles. EclipseSource developed a generic Fuzz Testing Framework, which can generate EMF models, for testing EMF tools. Theoretically, this Fuzz Testing Framework should support generation of UML models as well. This assumption is based on the fact that Ecore is the meta-meta model (M3) used in Eclipse while the EMF-based implementation of UML is located in the metamodel layer (M2). Therefore, UML models should be accepted by the framework. However, there are a few problems which have been the starting point for our project.

Our goals

Current Fuzz Testing Frameworks have problems with generating UML models. Our first goal was, therefore, to extend the EMF Fuzz Testing Framework to work with UML models. Furthermore, our second goal was to extend the framework in such a way, that it also works with UML models including UML Profiles. As an additional goal we wrote a framework documentation to support our development process and help further developers to understand the framework quicker.

The Fuzz Testing Framework

As mentioned before, Fuzz testing is about pseudo-randomly generating input data and running tests with this data. Therefore, a test is not written with concrete input data, but with parameters which control the generation process. Parameters specify, for example, the number of test runs, size of the generated models, number of mutations per test run and the model of which instances should be created.
Therefore, the following components are needed to execute a test with the EMF Fuzz Testing Framework:
  • The DataProvider injects different model instances into the test case.
  • The JUnit TestRunner repeatedly runs the same test with different data.
  • The ModelMutator provides different model instances to the DataProvider.
To specify the parameters in the EMF Fuzz Testing Framework a FuzzConfig file is used.
The FuzzConfig file specifies the following parameters:
  • seed: Used for the pseudo-random generation in order to ensure reproducibility.
  • count: Specifies the total number of test runs.
  • testClass: References the corresponding fuzzy test class.
  • id
  • minObjectsCount: Specifies the minimum number of objects of the generated model.
  • mutationCount: Number of mutations to be performed.
  • ePackage: The model mutator generates models with instances of EClasses declared in this package.

Challenges & Results

After setting up the project, we realized that there was only code documentation and no framework description. In order to get familiar with the framework and to help further developers we decided to define a framework description as an additional goal. Next, we started with the implementation by trying to mutate UML2 models instead of Ecore models which failed due to various errors, like missing UML datatypes and wrong return values. One issue we worked on for a rather long time is closely related to the implementation of profile mutations. UML2 uses the class Model for applying and accessing profiles. An adaption which highly eases the implementation of profile mutations was thus to inject the generated model into a framework field of type Model instead of type EObject. We solved this issue by declaring the root object’s EClass (Model) in the fuzzy config file.

After we corrected the errors mentioned, we tried to extend the framework in order to enable the application of UML Profiles. The main part here was to develop custom mutations to apply and unapply the concepts of UML Profiles. The mutations we were working on are therefore:
  • ApplyProfileMutation
  • UnapplyProfileMutation
  • ApplyStereotypeMutation
  • UnapplyStereotypeMutation
In ApplyProfileMutation we first of all randomly generate a profile with a random number of stereotypes, having a random number of attributes (with randomly selected types). After that, the metaclasses of the model (to which the mutation should be applyed) are randomly extended by the previously generated stereotypes. This step is required in order to indicate which elements of the model can later have stereotypes applied. Finally, the generated profile is applied to the model. UnapplyProfileMutation randomly selects one already applied profile, and unapplies it. This can easily be done by using UML2’s method unapplyProfile.
                   
ApplyStereotypeMutation is the most interesting but also the most complex mutation. In this mutation, first of all, all elements which have applicable stereotypes have to be identified. We initially concentrated on applying stereotypes to classes, attributes and references. After checking these features for applicable stereotypes, a random number of stereotypes is selected and applied. Similar to the procedure of applying stereotypes, in UnapplyStereotypeMutation, we search for all features which have applied stereotypes, and unapply a random number of stereotypes.

To sum up, we wrote a framework documentation not only for our purpose but also for further developers who are working on the framework. The framework description is split up into three parts. The first part, Basic Overview, is for people whose aim is to use the Fuzz Testing Framework. In the second part we describe how a concrete Fuzz test can look like. A more technical description can be found in the third part where we describe the framework in greater detail for future developers who want to extend the framework and, therefore, need a deeper understanding of its architecture and how it should be extended.
Furthermore, we extended the EMF Fuzz Testing Framework for generating UML models.
After being able to generate UML models using the generic framework, we finally implemented the profile mutations for randomly applying and unapplying both profiles and stereotypes.        

For more detailed information on our project, we kindly refer the interested reader to our full report and the source code of the developed mutations.

Wednesday, July 08, 2015

SHACL4P: Shapes Constraint Language (SHACL) Plugin for Protégé Ontology Editor

Context & Motivation

Semantic Web is Tim Berners-Lee's vision to have information on the World Wide Web understandable for both humans and machines. It could also be seen as a web evolution approach that aims to help users by making use of machines to process, deliver, understand, and interpret large amounts of data for various purposes in a meaningful way.

Ontologies, as one of the main pillars of Semantic Web Technologies (SWT), are an explicit specification of a conceptualization to enable knowledge sharing and reuse. An ontology can also be seen as a way of organizing and categorizing information with the goal of facilitating its access, use, and distribution among communities. The World Wide Web Consortium (W3C), as international organization that develops Web standards, has defined several important W3C recommendations related to Semantic Web, such as Resource Description Framework (RDF), RDF-Schema (RDFS), Web Ontology Language (OWL) or SPARQL Query Language (SPARQL).

There are two important characteristics of current ontology languages in the Semantic Web: Open World Assumption (OWA) and Non Unique Name Assumption (Non-UNA).
  • OWA means that one cannot infer that a statement is false based on its absence (it may exist in the real world but was not explicated yet). This is the opposite of the Closed World Assumption (CWA), where non-explicit information is expressed as false.
  • Non-UNA implies that individuals could have more than one identifier. In other words, two or more identifiers could point to the same entity. This is different to other knowledge representations (e.g., relational databases), which typically operate under Unique Name Assumption (UNA).
Figure 1 shows the effect of having these two characteristics (OWA and Non-UNA) within ontologies. Depending on the use cases, some applications may require ontology axioms to validate its constraints according to certain constraint definitions, instead of inferring new information from the axioms.
Figure 1 Constraint Checking Example using Current RDF Vocabularies

The Challenges

Semantic Web Technologies have been widely used within data centric applications in various areas, e.g., in Bioinformatics, System Engineering and Cultural Heritage. SWT provide an excellent platform to capture the axiomatic (structural) definition of data (e.g., SKOS for hierarchies and vocabularies; Resource Description Framework Schema and Web Ontology Language for class, property, and relationships definitions). 

Within several of these data centric applications, there is desire to go beyond axiomatic definitions. One example is the definition of constraints that must be satisfied by the instance data. However, due to the Open World Assumption and the absence of the Unique Name Assumption in SWT, it is difficult to define structural constraints of an RDF graph with the current set of RDF vocabularies (e.g., RDFS, SKOS, and OWL).

Recently, Shapes Constraint Language (SHACL) was proposed to address this challenge. There are other approaches aiming to address a similar challenge, most notably Pellet-ICV, RDFUnit, and SPIN. None of them have been accepted as a W3C recommendation, which is specifically important for practitioners since they want to rely on stable specifications for their applications. 

Shapes Constraint Language (SHACL) is an RDF vocabulary for describing RDF structural constraints. SHACL allows validation of RDF graph data according to its SHACL constraint definitions. At the moment, SHACL is a work in progress of the W3C RDF Data Shapes WG.

Currently, the integration of such structural constraints definitions and validations in ontology editors is only available using specific commercial products (e.g., Pellet-ICV within StarDog and SPIN within TopBraid Composer. 

SHACL4P: The SHACL Protégé Plugin

In order to address the challenge of providing support of defining and validating structural constraints over RDF graphs using an open source ontology editor like Protègè, we will introduce the novel SHACL4P, a SHACL plugin for Protégé. The source code of SHACL4P is available under github as two separate Java projects, the Protégé plugin and the SHACL engine.

Our approach

The basic idea behind our approach was to integrate Ontologies and their respective SHACL constraints in order to perform constraint violation checking through the SHACL validation engine (see Figure 2).
Figure 2: Basic concepts of the validation process
We designed the SHACL engine in a modular fashion to increase reusability, maintainability, and readability. Our implementation is focused around three main components that will fulfill the required functionalities, (1) the SHACL user interface, (2) the data transformation component and (3) the SHACL validation engine.
  1. The SHACL user interface inside Protégé is the point of engagement to the user. It provides a way to add SHACL constraints and other vocabulary to existing ontologies. Furthermore, it visualizes the results of the validation process in an user-friendly format.
  2. Data transformation is performed as the intermediate step between the input gathered from the user interface and the actual validation. As we are dealing with two different sets of data, the ontology resulted from Protégé ontology editor which is to be validated and the SHACL constraints to be validated against, it is necessary to bring them in a uniform format before the actual validation. Additionally, it is also because Protégé and SHACL engine are using different API (Protégé uses OWL API, while SHACL uses Apache Jena). In the inverse direction, the component is responsible for transforming the results of the validation engine, which are described in RDF form, to a POJO.
  3. The SHACL validation engine provides a framework that allows constraint checking on a testing domain. The result of this process is a RDF representation that either describes the constraint violations or evaluates the domain to be valid.
Graphically, SHACL4P is implemented as a workspace tab in Protégé consisting of 6 different views, as displayed in the following screenshot (Figure 3):
Figure 3: Screenshot of the SHACL Protégé Plugin
  1. The class hierarchy view (upper left corner) displays all classes of the ontology.
  2. Instances of classes are displayed on the lower left corner.
  3. The SHACL text editor (middle upper view) is used to define SHACL constraints and to start the validation by pressing the button Execute on the lower left corner of the view.
  4. The logging view (middle lower view) informs the user about validation errors, failed syntax checks and other similar events.
  5. The Turtle rendering view (upper right corner) represents the current ontology in Turtle syntax for easier detection of the needed vocabulary.
  6. The prefix view (lower right corner) lists all defined prefixes of the ontology. This view can be helpful when defining the prefixes for the SHACL definition.

Conclusion & Future Work

We developed a plugin implementation that we built on top of Protégé to provide users with the means to define, implement, and execute SHACL constraints against their Semantic Web data within an open source ontology editor.

As for future work, we are looking forward to implement the full (final) version of SHACL within our plugin. Furthermore, we want to perform a user-study evaluation to test usability of the solution prototype.

SPARQL 1.1 Integration for KOMMA

Overview


Our project is an extension for the Knowledge Modeling and Management Architecture (KOMMA), an application framework for ontology based software systems. It is based on the Eclipse platform and is therefore easily extensible. As KOMMA’s support for the execution of SPARQL queries is limited to SPARQL 1.0, we have extended its functionality by introducing full SPARQL 1.1 support using Apache Jena, a general purpose ontology modeling framework.

KOMMA


There were two particularly important factors why we decided to build on KOMMA: Functionality and Maintenance. Upon our first inspection, KOMMA’s feature set looked refined enough in order to be able to use it in productive environments.

The second major factor (i.e. Maintenance) is KOMMA’s up to date state of development, it offers a working Eclipse marketplace version 6 that ran right out of the box on Eclipse Luna which was another requirement that had to be satisfied.

SPARQL


SPARQL is a query language designed to retrieve and manipulate data stored in RDF graphs. SPARQL is considered as one of the key technologies of the Semantic Web and is widely used. It was standardized by the W3C RDF Data Access Working Group (DAWG)  has become a W3C Recommendation on 15 January 2008. It was later replaced by SPARQL 1.1 which has also been declared a W3C Recommendation on 21 March 2013. With SPARQL 1.1, several additions and extensions to the query language have been introduced. In addition to performing query tasks, it is now possible to output the query results in JSON, CSV and TSV formats. Also, the SPARQL query and update system can be provided as a service via HTTP as part of the SPARQL protocol.

Status Quo


According to KOMMA's documentation, it should already be able to parse and execute user entered SPARQL 1.0 and 1.1 queries on ontologies opened in the editor. By analyzing the source code of KOMMA, we discovered that the support of SPARQL 1.1 is limited to only two features (FILTER EXISTS, MINUS). All other SPARQL 1.1 features were not implemented. KOMMA uses its own implementation of SPARQL 1.0 and a partial implementation of SPARQL 1.1 instead of relying on an already existing library or framework. Our task was to analyze and enhance KOMMA’s ability to handle both SPARQL 1.0 and 1.1 queries.

Implementation


There are a three main reasons, why we used an already existing library or framework for our implementation:
  • Test Coverage:Since Jena is a project of the Apache Software Foundation it can be assumed that the implementation is of great quality and very well tested. 
  • Usage:The bigger the user-base the more, and also faster, potential bugs and / or features get fixed and implemented. 
  • Reinvention: Rewriting code for such complex specifications as SPARQL is probably a great learning experience but should not be of highest priority and has resemblance to reinventing the wheel.

Implementation Details


For our modification we first added the Jena framework together with its needed dependencies to one of KOMMA’s submodules in order to be able to use it for our SPARQL 1.1 integration. 

We used Apache Jena's QueryFactory class to parse and validate the user-entered string which gave us the opportunity to detect errors in queries and to help the user correcting them. One of the trickiest parts was to connect Jena with KOMMA's own model representation. For our specific case we used a default model and fed it KOMMA’s representation of the model as a ByteArrayInputStream which was quite tricky since KOMMA was not designed for such a use-case. The third major part of our implementation was the use of the QueryExecutionFactory which utilizes the output of the ModelFactory and QueryFactory to provide us a ResultSet to work with.

We also had to partially adapt KOMMA’s interface in order to integrate our newly implemented code and connect the user interface parts with our input and output parameters.



The image above shows KOMMA’s new SPARQL query interface after our modifications. The user is now able to enter any SPARQL 1.0 or 1.1 query in the input field and KOMMA will parse and execute the query over the ontology. The user also gets notified via a pop-up if the query contains any syntactic or semantic errors. If the query passes, it gets successfully applied to the ontology and the interface then displays the resulting output in the result table which is created dynamically for each individual query.