Print Page | Close Window

Constraint on objects' properties for relationship

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=838
Printed Date: 27.Mar.2026 at 03:35
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Constraint on objects' properties for relationship
Posted By: zjf
Subject: Constraint on objects' properties for relationship
Date Posted: 25.Jul.2016 at 18:42
I want to put a constraint on relationships so they check their objects' properties. I have two object types, Task and Team, and both have a property, Capability, which is a collection of objects. A Team can only have a relationship to a Task if the Team's Capability property contains all the items mentioned in the Task's Capability property. Otherwise the relationship is wrong and an error message should be displayed.

In OCL this constraint could be written like this:
(if (self.ownedperform->isEmpty()=false) then
   (self.ownedperform.OwnedTeam.Members.CapabilitesOfTask->includesAll(self.ownedCapability))
else 
   true
endif)



Replies:
Posted By: stevek
Date Posted: 25.Jul.2016 at 19:47
You can make a symbol for the relationship that uses a generator to display the missing Capabilities. There are several ways you could do this; I'll show two. Here's a way that only uses simple MERL commands. Note that the http://www.metacase.com/support/51/manuals/mwb/Mw-6_1_2.html" rel="nofollow - ;1 level number in .Team;1 and id;1 means "do this on the element one loop further out".
do .Task:Capability 
{  $found = ''
   do .Team;1:Capability { if id = id;1 then $found = 'T' endif }
   if not $found='T' then id ' ' endif
}

In the second way, to make it a little faster, you can avoid having to navigate N*M times to Team Capabilities. Instead, save them one per line in a variable $caps, then looking up each Task Capability in $caps using a http://www.metacase.com/support/51/manuals/mwb/Mw-6_3_1.html" rel="nofollow - =~ wildcard comparison .
$caps = __(newline do .Team:Capability { id newline })
do .Task:Capability 
{  if not $caps =~ __('*' newline id newline '*') then id ' ' endif
}



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net