ocl object constraint language - universidad …agaris/slides/3-ocl.pdf · contenido object...
TRANSCRIPT
![Page 1: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/1.jpg)
OCLObject Constraint Language
Maestría en Ingeniería de Software
![Page 2: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/2.jpg)
Agenda
- Model Driven Architecture (MDA)
- Unified Model Language (UML)
- Object Constraint Language (OCL)
- Patrones
- Conclusiones
![Page 3: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/3.jpg)
Contenido
Object Constraint Language (OCL)• Introducción a OCL
• Motivaciones• Historia• Objetivos
• Conceptos básicos• Propiedades• Invariantes• Pre y post condiciones• Operaciones
![Page 4: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/4.jpg)
Contenido
Object Constraint Language (OCL)• Tipos
• Tipos básicos• Tipos especiales
• Ejemplos
• OCL y metamodelo
• OCL y Perfiles UML
• OCL en MDA
![Page 5: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/5.jpg)
Introducción a OCL
Niveles de madurezN0 Sin especificaciónN1 Especificación textualN2 Texto con modelosN3 Modelos con textoN4 Modelos precisosN5 Solamente modelos
[Fuente: Kleppe and Warmer]
Niveles de madurez N0 No UML N1 No UML N2 Poco UML N3 Mucho UML N4 Mucho UML + OCL N5 -------------
![Page 6: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/6.jpg)
Introducción a OCL
Lenguaje de especificación formal que combina cálculo de
predicados y teoría de conjuntos. El contexto sintáctico está determinado gráficamente. Su sintaxis es simple. Permite describir expresiones y restricciones en modelos y
artefactos orientados a objetos Por ser un lenguaje de especificación no tiene efectos colaterales.
OCL
![Page 7: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/7.jpg)
Introducción a OCL
• OCL fue desarrollado por IBM como lenguaje de modelado de negocio
• En UML 1.1 planteado como lenguaje de constraints
• En UML 2.0 puede ser usado para escribir cualquier expresión sobre los elementos en el diagrama.
Historia
![Page 8: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/8.jpg)
Introducción a OCL
Por qué OCL?
Para lograr especificaciones precisas y no ambiguas en modelos UML.
Necesidad de describir restricciones adicionales sobre los objetos del modelo sin usar lenguaje natural.
Lenguajes formales tradicionales son difíciles para modelador de negocios o de sistemas promedio. El OCL ha sido desarrollado para cubrir esa brecha.
![Page 9: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/9.jpg)
Introducción a OCL
OCL puede ser usado en modelos UML y metamodelos
con diferentes propósitos: Para especificar invariantes sobre clases y tipos en modelos de clase Para especificar guardas en diagramas de estado Para describir precondiciones y postcondiciones sobre operaciones y
métodos Para especificar invariantes en estereotipos …
OCL ha sido usado para definir la semántica de UML
![Page 10: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/10.jpg)
• Introducción a OCL
• Conceptos básicos
• Tipos
• Ejemplos
• OCL y metamodelo
• OCL y Perfiles UML
• OCL en MDA
![Page 11: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/11.jpg)
Conceptos básicos
<ocl-formula> -- truth values
Gramática
![Page 12: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/12.jpg)
Conceptos básicos
Contexto Las expresiones OCL se escriben
en el contexto de una instancia de un tipo específico
context Company
Self La palabra reservada “self” se
refiere a la instancia contextual
![Page 13: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/13.jpg)
Conceptos básicos
Tipos válidos Clasificadores de diagramas UML (interfaces,
tipos de datos, componentes, nodos, casos de uso y subsistemas)
Propiedades Tipos válidos tienen asociadas propiedades.
(atributos, asociaciones finales, métodos y operaciones sin efectos colaterales)
context Company
.........
self.numberOfEmployees
Propiedades
![Page 14: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/14.jpg)
Expresiones formales básicas (atómicas):<type>.<attribute>
Dependiendo del contexto,<type> puede ser:
objeto clase implícito
Conceptos básicos
context Company.........self.numberOfEmployees......Company.allInstances......stockPrice()
![Page 15: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/15.jpg)
Expresiones formales básicas (atómicas):<type>.<attribute>
Dependiendo del contexto,<attribute> puede ser:
atributo de clase asociaciones finales
(navegación) operacion de clase
Conceptos básicos
context Company.........self.numberOfEmployees......self.manager......self.stockPrice()
![Page 16: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/16.jpg)
Conceptos básicos
InvarianteExpresión booleana asociada a un clasificador (relación, clase, interfaz, caso de uso) que es cierta en cada instante de ejecución del programa
PrecondiciónExpresión booleana asociada a un método que es cierta en el instante en que se comienza a ejecutar
PostcondiciónExpresión booleana asociada a un método que es cierta en el instante en que se termina de ejecutar
![Page 17: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/17.jpg)
Conceptos básicos
Invariantes
context Company
inv: self.numberOfEmployees>100
![Page 18: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/18.jpg)
Conceptos básicos
Pre y Post condiciones
Las pre-condiciones o post-condiciones se aplican tanto a Métodos como a Operaciones. nombreDeTipo::nombreDeOperación(parametro1 : Tipo1, ... ): TipoDevolución
pre : parametero1 > …
post: resultado = ...
![Page 19: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/19.jpg)
Conceptos básicos
context Person::birthdayHappens()pre:post: age = age@pre+1
Pre y Post condiciones
![Page 20: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/20.jpg)
• Introducción a OCL
• Conceptos básicos
• Tipos
• Ejemplos
• OCL y metamodelo
• OCL y perfiles UML
• OCL en MDA
![Page 21: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/21.jpg)
Tipos OCL
Tipos predefinidos Básicos (Integer, Real, String, Boolean y Enumerate) Colecciones (Collection, Set, Ordered-Set, Bag, Sequence)
Tipos definidos por el usuario
Jerarquía de tipos
Un tipo t conforma a otro t1 cuando una instancia de
tipo t puede ser sustituida por una de tipo t1:
-Cada tipo conforma a sus supertipos.
-Si t1 conforma a t2, y t2 conforma a t3, luego t1 conforma a t3.
![Page 22: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/22.jpg)
Tipos básicos
• b = (b2:Boolean) : Boolean• b or (b2 : Boolean) : Boolean• b xor (b2: Boolean) : Boolean• b and ( b2: Boolean) : Boolean• not b : Boolean• b implies ( b2: Boolean) : Boolean
Operaciones
Boolean
<ocl-formula> -- truth values( <ocl-formula> and <ocl-formula> )( <ocl-formula> or <ocl-formula> )( <ocl-formula> implies <ocl-formula> )( <ocl-formula> xor <ocl-formula> )( not <ocl-formula> )
![Page 23: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/23.jpg)
Tipos básicos
Operaciones
• r = (r2 :Real) : Boolean • r < > (r2 :Real) : Boolean• r + (r1: Real) : Real• r – (r1 :Real) : Real• r * (r1 :Real) :Real• r / (r1:Real) : Real• r. abs : Real
Real
![Page 24: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/24.jpg)
Tipos básicos
• i = (i2 : Integer) : Boolean• i + (i2: Integer) : Integer• i – ( i2: Integer) : Integer• i * (i2: Integer) : Integer• i / (i2:Integer) : Real• i.abs : Integer• i.div (i2: Integer) : Integer
Operaciones
• string = (string2 : String) : Boolean• string.size : Integer• string.concat (string2: String): String• string.toUpper : String• string.toLower : String
IntegerString
![Page 25: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/25.jpg)
Tipos básicos
context Companyinv: self.manager.gender=#female
Enumeration
![Page 26: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/26.jpg)
Tipos Especiales
Colecciones
Collection
Set Bag Sequence
![Page 27: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/27.jpg)
Tipos especiales
context Company inv: self.manager.isUnemployed = false
context Company::edades():Set(Integer)
post: result= self.employee.age
Combinación de propiedades
![Page 28: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/28.jpg)
Tipos Especiales
Tipos predefinidos: Colecciones
Notación: <collection>→ <operation>
Operaciones:
select, collect, forAll, exists, etc
![Page 29: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/29.jpg)
Tipos Especiales
Select
context Companyself.employee->select(p:Person|
p.age>50)->notEmpty()
self.employee->select(p | p.age>50)->notEmpty()
self.employee->select(age>50)->notEmpty()
![Page 30: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/30.jpg)
Tipos especiales
Collect
context Company
self.employee->collect(p:Person| p.birthDate)
self.employee->collect(p | p.birthDate)
self.employee->collect(birthDate)
self.employee.birthDate
![Page 31: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/31.jpg)
Tipos especiales
Cuantificadores
<ocl-term>->forAll( <variable | <ocl-formula> )
<ocl-term>->exists( <variable | <ocl-formula> )
![Page 32: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/32.jpg)
Tipos especiales
Cuantificadores
self.employee->forAll(p | p.age > 18)
self.employee->forAll(firstName=’Jack’)
![Page 33: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/33.jpg)
Tipos especiales
Cuantificadores
context Company inv:
self.employee->exists( forename = 'Jack' )
context Company inv:
self.employee->exists( p | p.forename = 'Jack' )
context Company inv: self.employee->exists( p : Person | p.forename = 'Jack' )
![Page 34: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/34.jpg)
Tipos especiales
collection->size : Integer
collection->includes(objet : OclAny) : Boolean
collection->count(objet : OclAny) : Integer
collection->includesAll(c : Collection(T)) : Boolean
collection->isEmpty : Boolean
collection->notEmpty : Boolean
Operaciones
![Page 35: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/35.jpg)
Tipos especiales
context Person inv: -- oclTypeself.oclType = Person
context Person -- oclIsTypeOfinv: self.oclIsTypeOf(Person)inv: not(self.oclIsTypeOf(Company))
“oclType” y “oclIsTypeOf”
![Page 36: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/36.jpg)
• Introducción a OCL
• Conceptos básicos
• Tipos
• Ejemplos
• OCL y metamodelo
• OCL y perfiles UML
• OCL en MDA
![Page 37: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/37.jpg)
Ejemplos
![Page 38: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/38.jpg)
Ejemplos
[1] Married people are of age >= 18context person inv:self.wife->notEmpty implies self.wife.age >= 18 andself.husband->notEmpty implies self.husband.age >= 18
[2] a company has at most 50 employeescontext Company inv:self.employee->size <= 50
[3] A marriage is between a female (wife) and male (husband)context marriage inv:self.wife.gender = #female andself.husband.gender = #male
[4] A person can not both have a wife and a husbandcontext person inv:not ((self.wife->size=1) and (self.husband->size=1))
![Page 39: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/39.jpg)
• Introducción a OCL
• Conceptos básicos
• Tipos
• Ejemplos
• OCL y metamodelo
• OCL y perfiles UML
• OCL en MDA
![Page 40: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/40.jpg)
OCL y metamodelo
![Page 41: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/41.jpg)
OCL y metamodelo
El valor de ”isComposite” es true solo si “aggregation” es “composite”
isComposite = (self.aggregation = #composite)
![Page 42: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/42.jpg)
OCL y metamodelo
Una interface solo puede contener operaciones
self.allFeatures->forAll(f | f.oclIsKindOf(Operation) or f.oclIsKindOf(Reception))
![Page 43: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/43.jpg)
• Introducción a OCL
• Conceptos básicos
• Tipos
• Ejemplos
• OCL y metamodelo
• OCL y perfiles UML
• OCL en MDA
![Page 44: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/44.jpg)
OCL y Perfiles UML
PIMcontext Beaninv: realization->realizer -> collect( ili.hasStereotype(“”Remote”)->size ()) == 1 && realization->realizer -> collect( ili.hasStereotype(“”Home”)->size ()) == 1
![Page 45: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/45.jpg)
OCL y Perfiles UML
context Dependencyinv:self.supplier->exists(S:ModelElement | S.isStereotyped (’optional’)) impliesself.client->forAll( C:ModelElement | C.isStereotyped(’optional’) )
![Page 46: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/46.jpg)
• Introducción a OCL
• Conceptos básicos
• Tipos
• Ejemplos
• OCL y metamodelo
• OCL y perfiles UML
• OCL en MDA
![Page 47: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/47.jpg)
OCL en MDA
OCL es utilizado en MDA de 3 formas: Elaborar modelos mas precisos Definir lenguajes de modelado Especificación de semántica de Perfiles UML Definir transformaciones
![Page 48: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/48.jpg)
OCL en MDA
− Existen limitaciones para crear modelos precisos y completos.
Pasajero
nombre
Vuelo
numeroVuelo
plazasDisponibles()
0..n
0..n
Avion
númeroPlazas10..n
+pasajeros
+vuelos
+avion
1
0..n
0..n
0..n
+vuelos
context Vuelo inv: pasajeros->size()<=avion.númeroPlazas
Modelos mas precisos
![Page 49: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/49.jpg)
OCL en MDA
UML metamodel
Context Class inv:attributes->isUnique(name)
Classname : Integer
Attributename : String
0..*
owner1
attributes
Definición de lenguajes
![Page 50: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/50.jpg)
Transformation ManyAssociationToAttribute (UML, UML) {
source ae : UML::AssociationEnd ;
target att : UML::Attribute;
source condition
ae.multiplicity = MultiplicityKind::many;
target condition
att.visibility = VisibilityKind::public and att.type.isTypeOf(Set);
mapping
ae.name <~> att.name;
ae.type <~> att.type.elementType;}
OCL en MDA
Companyname : Integeremployees : Set(Person)
Personname : String
Companyname : Integer
Personname : String
0..* employees
transformación
![Page 51: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/51.jpg)
OCL en MDA
OCL en MOF-QTV
Parte esencial en el lenguaje de transformación QTV
![Page 52: OCL Object Constraint Language - Universidad …agaris/slides/3-OCL.pdf · Contenido Object Constraint Language (OCL) • Introducción a OCL • Motivaciones • Historia • Objetivos](https://reader031.vdocuments.mx/reader031/viewer/2022020303/5b977dfa09d3f2e10f8c9b17/html5/thumbnails/52.jpg)
OCL en MDA
Reglas en un perfil UML de java:
context Class inv:
generalizations->size() <= 1
.
Semántica en Perfiles UML
Class