Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod CanExecuteImportProfiles ( 
 | 
  output String feedback_o, 
 | 
  MPSync mpsync, 
 | 
  Boolean isrefreshfromsource, 
 | 
  UserImportProfiles userimportprofiles 
 | 
) declarative remote as Boolean 
 | 
{ 
 | 
  Description: 'Validate whether the selected import profiles have different sources for a single object group' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // If MPSync is empty, prompt the user to refresh from data source 
 | 
    if( not isrefreshfromsource  
 | 
        and guard( mpsync.IOBase( relsize ), 0 ) = 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MPSync_ImportProfile_ValidateInput_EmptyMPSync(); 
 | 
    } 
 | 
    // Check if there are more than one userimportprofiles 
 | 
    else if( userimportprofiles.Size() > 1 ) 
 | 
    { 
 | 
      stringbreaker := '[qQsTrBrk@]'; 
 | 
       
 | 
      // Get the name of expected import group name 
 | 
      expectedGroups := selectuniquevalues( userimportprofiles, Elements.ImportObjectGroupInUserProfile, e,  
 | 
                                            e.IsIncludeInImportExport(),  
 | 
                                            e.ObjectGroupName() ); 
 | 
      // Get the unique name of the combination of user import profile, import group name, and import file location 
 | 
      uniqueGroups := selectuniquevalues( userimportprofiles, Elements.BaseImportObjectGroupInProfile, e,  
 | 
                                          e.IsIncludeInImportExport(),  
 | 
                                          e.GetSourcePathObjectGroupString( stringbreaker ) ); 
 | 
       
 | 
      // If the number of expected groups is not the same as unique groups 
 | 
      if( expectedGroups.Size() <> uniqueGroups.Size() ) 
 | 
      { 
 | 
        // Select the set of duplicated import groups 
 | 
        erroneousGroups := selectduplicates( uniqueGroups, Elements, e, 
 | 
                                             true, 
 | 
                                             e.RestString( e.FindString( stringbreaker, 0 ) ) ); 
 | 
        // Get the names of the duplicated import groups 
 | 
        erroneousgroupnames := selectuniquevalues( erroneousGroups, Elements, e, 
 | 
                                                   true, 
 | 
                                                   e.RestString( e.FindString( stringbreaker, 0 ) ).ReplaceAll( stringbreaker, '' ) ); 
 | 
        erroneousgroupnames.Sort(); 
 | 
        erroneousgroups_feedback := construct( Strings ); 
 | 
        // Traverse all duplicated import groups' names to construct the feedback 
 | 
        traverse( erroneousgroupnames, Elements, erroneousgroup_name ) 
 | 
        { 
 | 
          // Get the user import profile names that has duplicating import groups that import data from different file locations 
 | 
          erroneous_userimportprofilenames := selectvalues( userimportprofiles, Elements.BaseImportObjectGroupInProfile, groupinprofile, 
 | 
                                                            groupinprofile.IsIncludeInImportExport() 
 | 
                                                            and groupinprofile.ImportObjectGroup().GetDisplayName() = erroneousgroup_name 
 | 
                                                            and erroneousGroups.Find( groupinprofile.GetSourcePathObjectGroupString( stringbreaker ) ) <> -1, 
 | 
                                                            groupinprofile.BaseImportProfile().astype( UserImportProfile ).Name() ); 
 | 
           
 | 
          erroneous_userimportprofilenames.Sort(); 
 | 
          // Generate feedback text 
 | 
          erroneousgroupandprofile := erroneousgroup_name 
 | 
                                      + ' - ' 
 | 
                                      + erroneous_userimportprofilenames.ToString( ', ' ); 
 | 
          // Add feedback text to the set 
 | 
          erroneousgroups_feedback.Add( erroneousgroupandprofile ); 
 | 
        } 
 | 
         
 | 
        erroneousgroups_detail := erroneousgroups_feedback.ToString( String::NewLine() ); 
 | 
        feedback_o := Translations::MPSync_ImportProfile_ValidateInput_InvalidSources( erroneousgroups_detail ); 
 | 
      } 
 | 
    } 
 | 
     
 | 
    return feedback_o = ''; 
 | 
  *] 
 | 
} 
 |