lutaml / lutaml-uml

UML module for LutaML
2 stars 2 forks source link

UML syntax: Constraints #17

Open ronaldtse opened 3 years ago

ronaldtse commented 3 years ago

Constraints

Constraints-Notation & Semantics

Screen Shot 2020-08-05 at 12 50 40 AM

Proposal: 1:

class Circle {
  radius: int { radius > 0 }

  # or
  radius {
    type int
    constraint {
      radius > 0
    }
  }

}

(OCL) constraint named "Salary":

class Boss {
  salary
  assistant: Employee[1]
}

constraint Salary {
  self.salary > assistant.salary
}

apply_constraint(Salary, Boss)

class Employee {
  salary
}

xor constraint:

class Article {
}

class Warehouse {}
class Store {}

xor {
  Article -> Warehouse
  Article -> Store
}
w00lf commented 3 years ago

The last example looks confusing and does not quite fit into the object notation we are trying to stick with. Maybe use something like this:

class Article {
  generalizes Warehouse constraint 'xor' 
  generalizes Store constraint 'xor' 
}
class Warehouse {}
class Store {}

or:

class Article {
  generalizes Warehouse, constraint 'xor' 
  generalizes Store, constraint 'xor' 
}
class Warehouse {}
class Store {}
ronaldtse commented 3 years ago

There is an issue here because the xor constraint applies to multiple relationships.

The "->" relationship is called a "supplier and client relationship". We can give it the keyword of "supplies" or "provides".

How about something like:

class Article {
  supplies Warehouse as "relationship1"
}
class Warehouse
class Store {
  provides Article as "relationship2"
}

constraint MyXor {
  type xor
  end relationship1
  end relationship2
}

or

class Article
class Warehouse
class Store

association "relationship1" supplies {
  begin Article
  end Warehouse
}
association "relationship2" provides {
  end Article
  begin Store
}  

constraint MyXor {
  type xor
  end relationship1
  end relationship2
}
w00lf commented 3 years ago

class Article { supplies Warehouse as "relationship1" } class Warehouse class Store { provides Article as "relationship2" }

constraint MyXor { type xor end relationship1 end relationship2 }

We already decided to use association syntax on diagram objects, so I think the first example you have is more suitable:

class Article {
  supplies Warehouse as "relationship1"
}
class Warehouse
class Store {
  provides Article as "relationship2"
}

constraint MyXor {
  type xor
  end relationship1
  end relationship2
}

Although I don't think that type is a suitable name for it, maybe use something like text? If you introduce this keyword we can also use a shorthand syntax for constant associations:

constraint MyXor {
  type xor
  relationship1
  relationship2
}

Can constraint be owned by end of the association? In the example you used end keyword, can it be start one?

ronaldtse commented 3 years ago

We already decided to use association syntax on diagram objects, so I think the first example you have is more suitable:

"xor" is a special operation in UML, it's not supposed to be generic text.

Can constraint be owned by end of the association? In the example you used end keyword, can it be start one?

By end I was just using the convention that in UML they call the connection point the "association end" (also in the XMI). In XML there is the "owner end" vs "member end".

This is a work in progress of the UML.xmi file trying to be simplified into our syntax, haven't worked out the rest yet... e.g.

association A_ownedAttribute_owningSignal {
  memberEnd Signal#ownedAttribute
  memberEnd A_ownedAttribute_owningSignal#owningSignal

  ownedEnd "owningSignal" {
    type Signal
    association A_ownedAttribute_owningSignal
    subsettedProperty A_attribute_classifier#classifier
    subsettedProperty NamedElement#namespace
    lowerValue LiteralInteger
  }
}