FUNCTION acyclic_mapped_representation
(parent_set : SET [0:?] OF representation, children_set : SET [0:?] OF representation_item) : BOOLEAN;
LOCAL x,y,u : SET OF representation_item := []; END_LOCAL; -- Determine the subset OF children_set that are mapped_items x := QUERY(z <* children_set | 'REPRESENTATION_SCHEMA.MAPPED_ITEM' IN TYPEOF(z)); -- Determine that the subset has elements IF SIZEOF(x) > 0 THEN -- Check each element OF the set REPEAT i := 1 TO HIINDEX(x); -- IF the selected element maps a representation IN the -- parent_set, THEN RETURN false IF x[i]\mapped_item.mapping_source.mapped_representation IN parent_set THEN RETURN (FALSE); END_IF; -- Recursive check OF the items OF mapped_representation IF NOT acyclic_mapped_representation (parent_set + x[i]\mapped_item.mapping_source.mapped_representation, x[i]\mapped_item.mapping_source.mapped_representation.items) THEN RETURN (FALSE); END_IF; END_REPEAT; END_IF; -- Determine the subset OF children_set that are not -- mapped_items u := children_set - x; -- Determine that the subset has elements IF SIZEOF(u) > 0 THEN -- FOR each element OF the set: REPEAT i := 1 TO HIINDEX(u); -- Determine the SET OF representation_items referenced y := QUERY(z <* bag_to_set( USEDIN(u[i], '')) | 'REPRESENTATION_SCHEMA.REPRESENTATION_ITEM' IN TYPEOF(z)); -- Recursively check FOR an offending mapped_item -- RETURN FALSE FOR any errors encountered IF NOT acyclic_mapped_representation(parent_set, y) THEN RETURN (FALSE); END_IF; END_REPEAT; END_IF; -- RETURN TRUE when all elements are checked and -- no error conditions found RETURN (TRUE); END_FUNCTION; -- acyclic_mapped_representation
|