<HTML><HEAD><link type="text/css" href="../css/main_styles.css" rel="stylesheet"></HEAD>
<BODY><TITLE>%mqc_check_multi_ref_sets_ent</TITLE><H1>%mqc_check_multi_ref_sets_ent </H1><P CLASS="Paragraph">Classname: <B>%mqc_check_multi_ref_sets_ent </B></P><P CLASS="Paragraph">Inherits from: <B><A href=..\checkmate\xug_base_checker.html>%ug_base_checker </A></B></P><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"> </PRE><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">
<B>Description:</B>
    1. Check if specified reference sets do not contain disallowed entity types.
       For example, REP reference set allows only Facetted_Bodies,
       any other type elements are invalid.
       To use this function, please make sure the option
       "Only specified type allowed?" is on.
    2. Check if given reference set contains at least one specified type member.
       For example, MODEL reference set must contain at least one Body.
       To use this function, please make sure the option
       "At least one valid member exist?" is on.
Parameter:
   (List) refSets_EntityType_map:-  List of description strings of the
                                   'Reference Set / Entity Type' mapping relations.
                                    For example:
                                    {
                                       "MODEL    |    Bodies",
                                       "REP      |    Facetted Bodies",
                                       "DATUM    |    Datum Axis, Datum Planes"
                                    };
                                    Make sure the entity type list is the same with the other
                                    checker: Check Single Reference Set / Entity Mapping
                                    This is the mandatory parameter for the checker.
   (Boolean) invalid_type_check: -  If verify "Only specified type allowed?"
                                    Default value is true.
   (Boolean) required_type_check:-  If verify "At least one valid member exist?"
                                    Default value is false.
    (Boolean)  disabled?        -  If it is true, the checker is disabled.
                                     Default is False.
    (Boolean)  save_log_in_part -  The flag indicates whether the checking results can
                                     be saved to the part file
                                     Default is True.
   (Integer) log_type:           -  Indicate which logging type to use to report
                                    the violation
                                        1 - log error
                                        2 - log warning
                                        3 - log information
                                    The default value is 1 which is to log error.
   (String)  log_msg:            -  User defined message to be added when the system
                                    reports the violation.
                                    The default is no additional message.
Results:
    PASS    -- 1. If the given reference sets only contain the specified type(s) members.
               2. If the given reference sets contain at least one specified type(s) members.
    FAILED  -- 1. If the given reference set contains member(s)
                  that do not fall into the specified type.
               2. If the given reference set does not contain
                  any of specified type(s) member.
Note: 1. The checker will complain Input argument error
         if none of "Only specified type allowed?"
         and "At least one valid member exist?" is selected.
      2. User can use this checker template to design
         multiple "reference sets/entities relations" mapping,
         say, it is different with the other checker:
         "Check Single Reference Set / Entity Mapping"

<B>See Also:</B>
    %mqc_check_single_ref_sets_ent
============================================================================================
Create a new checker from this template by providing the mandatory parameters:
   1. (Must) change the class name and the category name
   2. (Optional) change the display name. (optional)
   3. (Must) specify the Reference Set / Entity Type mapping strings
             for interactive selections:
        (List) refSets_EntityType_map_init:
               List of strings of check category and entity type(s) mapping descriptions.
               It must have the format like:
               {
                    "reference_set_name_1  |  entity_type_1",
                    "reference_set_name_2  |  entity_type_2",
                    ...
                    "reference_set_name_n  |  entity_type_n"
               };
               The reference_set_name and the entity_type must be
               separated by vertical line ('|').
                            ^^^^^^^^^^^^^^^^^^^
                 e.g. "MODEL   |   Bodies"
               Mutiple entity types in the description strings must be
               separated by commas(,).
                            ^^^^^^^^^
                 e.g. "Points,Lines" means
                      "points entity type" and
                      "lines entity type".
               Every entity type in the description strings must included in
               the following list.
                  "Points",
                  "Lines",
                  "Arcs",
                  "Conics",
                  "B-curves",
                  "Patterns",
                  "Dimensions",
                  "Dimension Sub-types",
                  "B-surfaces",
                  "Coordinate Systems",
                  "Planes",
                  "Components",          # actually this means instance
                  "Bodies",
                  "Faces",
                  "Edges",
                  "Surfaces",
                  "Surface Edges",
                  "Machining Parameters",
                  "Machining Tools",
                  "Datum Axis",
                  "Datum Planes",
                  "Facetted Bodies",
                  "Others"
               For example:
               {
                  "MODEL    |    Bodies",
                  "REP      |    Facetted Bodies",
                  "DATUM    |    Datum Axis, Datum Planes"
               };
   3. (Must) Determine whether check "Only specified type allowed?"
        (Boolean) invalid_type_check: True or False;
   4. (Must) Determine whether check "At least one valid member exist?"
        (Boolean)required_type_check: True or False;
   5. (Optional) change log type:
        (Integer) log_type:   1;
   6. (Optional) Change log message
        (String)  log_msg:    "THE MESSAGE YOU WANT TO SHOW WHILE CHECKING FAILED";
=============================================================================================
</PRE><PRE><FONT COLOR= blue>DefClass: %mqc_check_multi_ref_sets_ent( %ug_base_checker ); 
</FONT></PRE><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Check-Mate attributes and parameters </PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )    %test_category:  "Template.File Structure";
   ( String )    %displayed_name: "Check Reference Set / Entity Mappings";
   
</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( Boolean Parameter )  disabled?: false;
   ( Boolean Parameter )  save_log_in_part: true;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Parameter for mapping rules to check</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( List Parameter )     refSets_EntityType_map: refSets_EntityType_map_init:;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Parameter for selecting rule "Only specified type allowed?"</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( List )               refSets_EntityType_map_init:{};
   ( String )             refSets_EntityType_map_label: "Reference Set / Entity Type";
  

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( Boolean Parameter )   invalid_type_check: true;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Parameter for selecting rule "At least one valid member exist?"</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( String )              invalid_type_check_label: "Only specified type allowed?";
  
  
</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( Boolean Parameter )   required_type_check: false;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Parameter for selecting log option                                 </PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( String )              required_type_check_label:"At least one valid member exist?";
  
  
</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( Integer Parameter )   log_type: 1;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Parameter for inputting log message</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( List )                log_type_option: { LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_ANY };
  ( String )              log_type_label: "Log Option";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( String Parameter )    log_msg: "";
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Attribute for referencing </PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( String )              log_msg_label: "Log Message";
 
 
</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( List )                valid_type_string:
                          {
                                "Points",
                                "Lines",
                                "Arcs",
                                "Conics",
                                "B-curves",
                                "Patterns",
                                "Dimensions",
                                "Dimension Sub-types",
                                "B-surfaces",         
                                "Coordinate Systems", 
                                "Planes",
                                "Components",
                                "Bodies",
                                "Faces",
                                "Edges",
                                "Surfaces",
                                "Surface Edges",       
                                "Machining Parameters",
                                "Machining Tools",     
                                "Datum Axis",          
                                "Datum Planes",        
                                "Facetted Bodies",     
                                "Others"
                          };


</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Attribute for checking rules</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>  ( List ) rules_to_check:
  
    If Empty?( refSets_EntityType_map: )
              
    Then
        {}

    Else Loop
    {
         For  $each_sel  In  refSets_EntityType_map:; 
         
         For  $sel_list  Is  Splitstring( $each_sel, "|" ); 
                           
         For  $refset    Is  First( mqc_removePreSufBlank( $sel_list ) );
               
         For  $ent_type  Is  Second( $sel_list ); 

         For  $valid_type_string Is ( -( $ent_type = "" ) )      &
                                    ( -( $ent_type = noValue ) ) &
                                    ( -( $refset   = "" ) )      & 
                                    ( -( $refset   = noValue ) ); 

         For  $type_list Is 
         @{          
              If ( $valid_type_string = true )
              Then
              @{ 
                   $ent_list  <<  Splitstring( $ent_type, "," );

                   $type_name_list << Loop 
                   { 
                        For $each_type In mqc_removePreSufBlank($ent_list); 
                             
                        For $valid_type Is member( $each_type,valid_type_string: ); 
                             
                        Do  If ( $valid_type )  
                            Then donothing 
                            Else  ug_mqc_log( LOG_WARNING, {},
                                              "   Entity type '" + $each_type +
                                              "' with invalid string." ); 

                        If ( $valid_type )  
                        Append { $each_type }; 
                   };
              }
              Else {}; 
         }; 

         Do If ( $valid_type_string ) & ( -( Empty?( $type_list ) ) )
            Then  donothing
            Else  ug_mqc_log( LOG_WARNING, 
                              {}, 
                              " Invalid mapping " + $each_sel + "." );

         If ( $valid_type_string ) & ( - ( Empty?( $type_list ) ) )
         Append { { $refset, $type_list } };
    };


</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  Checking ...</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( Any Uncached ) do_check:

    #If the mandatory parameters are not specified,
    #Then log a warning message, and stop check.
    If  Empty?( rules_to_check: )
    Then
    @{
        ug_mqc_empty_param_warning();
    }
       
    #If none of rules is specified,
    #Then log a warning message, and stop check.
    Else If ( invalid_type_check:  = false ) &
            ( required_type_check: = false )
    Then
    @{
        $warning_message << "Input argument error: ~n"+
                            "  None of 'Only specified type allowed?' and ~n"+
                            "          'At least one valid member exist?' ~n"+
                            "  is selected.";
        
        ug_mqc_log( LOG_WARNING, {}, $warning_message );
    }
        
    #No inputting error
    Else Loop
    {
        #Make sure the reference set is exist in part.
        With $all_refsets Is mqc_askNameOfObject(mqc_askObjectOfType(false, 64,-1));
        
        For  $each_rule   In rules_to_check:;
        
        For  $refset_name Is First ( $each_rule );
        For  $entity_type Is Second( $each_rule );
        
        Do  If ( -Member( $refset_name, $all_refsets ) )
            Then
            @{
                 $message << "Reference set '"+$refset_name+
                             "' does not exist in part.";
             
                 ug_mqc_log( LOG_WARNING, {}, $message );
            }
            Else
            @{
                 #If check "Only specified type allowed?" rule
                 If ( invalid_type_check: = true )
                 Then 
                 @{
                      #Get all valid members of the specified reference set.
                      $val_member << Loop
                      {
                          For $each_type  In  $entity_type;
    
                          For $memb_list  Is  mqc_askRefsetMembers( $refset_name,
                                                                    $each_type,
                                                                    false,
                                                                    false );
                     
                          If ( -Empty?( $memb_list ) )
                          Append $memb_list;
                      };

                      #Get all members of the specified reference set.            
                      $all_member << mqc_askRefsetMembers( $refset_name,
                                                           ALL,
                                                           false,
                                                           false );
                
                      #Get invalid members
                      $inv_member << SetDifference( $all_member, $val_member );
    
                      #If found invalid member(s), then write log.
                      If ( -Empty?( $inv_member ) )
                      Then
                      @{
                           $message << @{ If ( log_msg: = "" ) Then "" Else log_msg:+"~n";}+
                                       @{ "Reference set '"+$refset_name+
                                          "' contains "+Stringvalue(Length($inv_member))+
                                          " invalid type member(s)."; };
                             
                           ug_mqc_log( Nth( log_type:, log_type_option: ), $inv_member, $message );
                      }
                      Else donothing;
                 }
                 Else
                     donothing;


                 #If check "At least one valid member exist?" rule
                 If ( required_type_check: = true )
                 Then 
                 @{
                      #Get valid members that must exist.
                      $val_member << Loop
                      {
                           For $each_type  In  $entity_type;
                     
                           For $memb_list  Is  mqc_askRefsetMembers( $refset_name,
                                                                     $each_type,
                                                                     false,
                                                                     false );
                 
                           If ( -Empty?( $memb_list ) )
                           Append $memb_list;
                      };
            
                      #If not found the required members, then write log.
                      If ( Empty?( $val_member ) )
                      Then
                      @{
                           $message << @{ If ( log_msg: = "" ) Then "" Else log_msg:+"~n";}+
                                       @{ "Reference set '"+$refset_name+
                                          "' does not contain required type member."; };
                 
                           ug_mqc_log( Nth( log_type:, log_type_option: ), {}, $message );
                      }
                      Else donothing;
                  }
                  Else
                      donothing;
            };
    };       

</SPAN></FONT></PRE></DIV></TABLE><p class=EndLine>&nbsp;</p><p class=blank>&nbsp;</p></BODY></HTML>