Questions tagged [ocl]

A formal specification language used with MOF meta-models (including UML) to express queries or constraints that cannot otherwise be expressed in diagramic notation.

The object constraint language (OCL) can be used to define invariants, queries, pre- and postconditions for MOF meta-models (including UML models). It allows a user to specify constraints on models, which can not be specified by the graphical notation of the UML.

OCL itself is a side-effect free, typed language based on first-order logic.

Invariants are defined for a context, typically a class. The following invariant states, that all person names should be unique:

context Person inv namesUnique:
  Person.allInstances->forAll(p|self.name=p2.name implies self=p2)

Note, that OCL provides the built in operation allInstances() to access all instances of a class.

Pre- and postconditions are specified in the context of an operation. In a post condition the special operator @pre can be used to access the values of variables, ettributes, etc. before an operation was called. Also, the special variable result can be used to access the result of the operation call.

The following conditions could be specified for an operation pop():OclAny of a Stack:

pop():OclAny
  pre  self.size > 0
  post self.size = self.size@pre - 1
  post result = self.elements@pre->last()

Beside constraint definition, OCL is used as a query language in model transformation approaches like QVT.

Further information about OCL can be found on the websites of the OCL workshop or the OCL Portal.

180 questions
1
vote
1 answer

how to call OCL constraints( generated java source code of model ) from the main code of java

I am using OCL constraints on ecore model and generating code. So the thing is as simple as this I have a class Task having attribute startDate and endDate it has an ocl constraint :- invariant which states startDate < endDate. I have generated…
Geek
  • 627
  • 1
  • 8
  • 18
1
vote
0 answers

Acceleo invoking Java Service wrapping an OCLHelper

I need to get the OCL model of conditions contained in UML edges from an ACCELEO script navigating the main UML model. To this end I have defined the following Java class: public class GetOCLModel { public Constraint getOCLModel(Classifier context,…
Andrea Sindico
  • 7,358
  • 6
  • 47
  • 84
1
vote
1 answer

On the fly XText model deserialization

I have a UML model having OpaqueActions containing text conform to an XText Grammar/MetaModel. I am turning the UML model into text by means of an ACCELEO transformation. I'd like to invoke from the ACCELEO script a Java service which takes as input…
Andrea Sindico
  • 7,358
  • 6
  • 47
  • 84
0
votes
1 answer

Show in a UML class diagram that an aggregation is a subset of another

I have a class diagram with the following two aggregations: contentCategories is a dynamic array of categories, currentCategory is always an element of that array, but is maintained as a distinct member variable. I need to show the constraint that…
tommazzo
  • 323
  • 1
  • 4
  • 13
0
votes
3 answers

Is it possible to generate real Java code with Dresden OCL Toolkit?

I tried using Dresden OCL to describe constraints for an UML class diagram. It looks like it can generate AspectJ code fine but I could not find a way to generate the Java code representing the modeled classes (and their attributes and methods). The…
paulius_l
  • 4,983
  • 8
  • 36
  • 42
0
votes
1 answer

Merge Project models through EML using complex comparison rules

Problem: I'm using EML and Epsilon Language Workbench to merge two project models, represented by two metamodels (MM1 and MM2), into a third metamodel (target). While I can achieve a simple merge based on element names, I need a more complex rule to…
James
  • 1,653
  • 2
  • 31
  • 60
0
votes
1 answer

get "SAXSparseEception: Content is not allowed in prolog" when parsing an OCL file in my Eclipse plugin

I am working on my own eclipse plugin, which includes parsing CompleteOCL file. I worked it out when I run the plugin by click on the "Luanch an Eclipse application" in overview tab of plugin.xml. But since I wanted to deploy the plugin elsewhere, I…
0
votes
1 answer

Object Constraint Language (OCL) syntax checker

This topic may seem redundant with an old topic (OCL Syntax Checker), but as it's close since 10year, I think answers and possibilities may have changed. I have been looking for an existing open-source syntax-checker for the Object Constraint…
Kaly
  • 51
  • 3
0
votes
1 answer

Generate Java Code from OCLInEcore in MWE2 Workflow

i am trying to generate Java Code from an .ecore meta model with OCL contstraints during a maven-tycho build. I have managed to get code generation to work within Eclipse, but the tycho build does not generate code for OCL. Setup I have an Ecore…
tobs
  • 699
  • 2
  • 8
  • 24
0
votes
1 answer

Representing QVT-Operational transformations in XML, JSON or or any other serialized format

I have a requirement where I need to parse the transformations defined in the QVT-Operational file. I need some way to represent the QVT-Operational transformations in a json, xml or any other serialized format. In model to model transformation…
0
votes
3 answers

OCL to Ecore transformation

I am trying to find a parser for OCL that can generate an Ecore model File so that I can use model to model methods in order to transform the OCL statements into other language models, e.g OCL to SQL (but not only to SQL). Does anyone know how to…
Clint
  • 1
0
votes
3 answers

How to use MDriven OclPs to find all objects matching a list of strings?

In an application I receive a list of strings. Then I want to use OclPs to find all objects where a specific attribute equals any of the strings in the list. E.g. if we have Person objects and receive a list of last names, find all persons whose…
Kjell Rilbe
  • 1,331
  • 14
  • 39
0
votes
1 answer

OCL inv: misplaced Construct error in rational software architecture

okay please help i do no have that much knowledge of OCL written constraints. in the picture below i am trying to put a constraint on class J that its attribute should be true after it but it is giving me an error Parsing Error: 1:1:4 “inv:”…
0
votes
1 answer

OCLinEcore problem during the installation

I'am a student and i try to create a meta-model using the EMF in eclipse. Now i try to add some OCL constraint in my meta-model, so,i try to used the OCLinEcore. Unfortunately, when i have clicked on my (*.ecore / open with / OCLinEcore editor) it…
0
votes
1 answer

Eclipse OCL google.inject creation exception

I use OCLinEcore in my project and use constraint for validation. The following error appears: 1-Error injecting method, java.lang.IllegalStateException: Missing contribution for type: org.eclipse.xtext.ui.containers.JavaProjectsState ... I use…