OntoUML / ontouml-js

Javascript library for manipulating OntoUML models.
Apache License 2.0
11 stars 8 forks source link

Get Source Cardinality #82

Open Matt-81 opened 2 years ago

Matt-81 commented 2 years ago

Just to keep track of an issue we already discussed. At the current state, to get relation cardinalities information we have to get the relation properties and then get information about cardinalities. It would be nice in the future to get information directly from a relation type.

claudenirmf commented 2 years ago

I like the idea, but we must agree about how. The Cardinality class has multiple methods for retrieving lower and upper bounds in different ways. Replicating these methods on the Relation class API will add a dozen methods approximately.

P.s.: you may be interested in the method isMandatory(): boolean.

const isTheSouceLowerBoundGreaterThanZero : boolean = relation.getSourceEnd().isMandatory();
Matt-81 commented 2 years ago

Great, thanks, Claudenir. Meanwhile, I accessed the needed data by extracting all the relation properties:

const relationProperties = relations.map(relation => relation.getSourceEnd()); const sourceCardinalities = relationProperties.map(sourceCardinality => sourceCardinality.cardinality);