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
0
votes
1 answer

Export UML diagrams from Entreprise Architect to an OCL tool (USE or OCLE)

I have some diagrams made on Enterprise Architect and i want to export them to an OCL tool "USE" or "OCLE".I tried the option export and converted the diagrams to a xml extension but it doesen't work on the OCL tool. How can i do that ?
0
votes
1 answer

OCL constraint UML Profile Rational Software Architect

I have a UML Profile that I need to add a constraint to my stereotype of ModeBehaviour which is an extension of StateMachine. Constraint: Owned States must be stereotyped as Mode, and Owned Transitions must be stereotyped as ModeTransition For the…
Dav3yDoo
  • 1
  • 3
0
votes
1 answer

How to get an ordered set in OCL?

When I have a result of type Set(Integer), numbers are not ordered. We have an operation usable on collections called sortedBy ( expr : OclExpression ) : Sequence(T), but when there's only integers in this set, what's the expression to use?
sgy
  • 2,922
  • 2
  • 35
  • 42
0
votes
1 answer

Automated test case generation from UML/OCL model in eclipse

I am doing model based testing and i've modeled my application with UML diagrams and also wrote all the constrains for testing using OCL, and i was wondering if there is a tool or plugin for eclipse which helps to generate testcases from UML/OCL…
0
votes
1 answer

OCL Requirement: Invariant for possible range of attribute values

So I have the following Object structure: Class Node RSSI: int I need to write a OCL invariant for the requirement that the the RSSI values of all Node objects do not differ by more than 2. I tried to solve it with an iterate expression but since…
gaussd
  • 899
  • 6
  • 15
  • 28
0
votes
1 answer

OCL constraint using Ecore classifiers - Unknow type exception

I'm developing an Ecore model with some invariants defined in OCL, using the OCLinEcore editor. In my model, some elements have references to EClassifier; in some OCL constraints, I need to check if the EClassifier referred to is an EDataType or an…
Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
0
votes
2 answers

How to do Acceleo code generation on in-memory model?

I am trying to generate some code using Acceleo. I am constructing my model entity in-memory and I want to generate the code for it. Now, when Acceleo tries to match my model object to the argument type of my template function, it does not match.…
parasietje
  • 1,529
  • 8
  • 36
0
votes
2 answers

OclInEcore: operation return type issue

I want to write the following operation in the oclInEcore editor in the context of the "Comp" class, which is supposed to collect the parents of a Comp object to a Set. operation parents(): Set(Comp) { body:…
Anvar
  • 404
  • 2
  • 9
  • 19
-1
votes
1 answer

Write OCL restrictions related to associations with other classes

How do you model the following restriction? A place is popular if it has been bookmarked by 2 or more than 2 users. Here the corresponding uml diagram: uml I tried several ways, for example: context place inv: place.popular =…
JesusCrt
  • 23
  • 3
-1
votes
1 answer

convert natural language to OCL script

i have some statements in natural language that i have to convert to OCL format, i am beginner and have written some by myself but failed to convert some advanced level statements , i have searched a lot like this, this and this but failed to…
Khan
  • 43
  • 1
  • 8
-1
votes
1 answer

How to convert natural language to OCL constraint?

I have a class diagram which consist a class on the name of SYSTEM. I have written a constraint for availability of this system. For example : The system should be available 24/7. Now I want to convert the above statement into OCL constraint. I am…
discky
  • 7
  • 3
-1
votes
1 answer

uml/ocl access to parent class name

I try to write ocl to add constraint to child (animal), but the constraint must user parent class name (mamifere). I think the first version doesn't work, and I think there is a nicer solution that the second example. Help me please ? image for…
-1
votes
1 answer

Search in list OCL

We have a list of items and we want to compare element by element with another list of items and the result is a list with items that don´t have items in both lists or duplicates items. For Example: L1={S1, S2, S3, S4, S5, S6, S7, S8, S9, S10},…
-3
votes
1 answer

OCL function-operation

I need help with an OCL operation to pass one of my master's subject. I do not know much about OCL language. What I've to do is next: Implement the operation: Server::validMovement(playerName:String, movement:Movement):bool This operation returns…
-4
votes
1 answer

Natural language processing tools for generating OCL

please I have a university project called (automatic generation of OCL constraints) and my supervisor asked me to choose a tool from this list of tools for natural language processing: Apache OpenNLP, Deeplearning4j, ChatScript, DELPH-IN, DKPro…
nayla
  • 11
  • 1
1 2 3
11
12