mttIdentifyUserDomain.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. function user_domain_identification = mttIdentifyUserDomain(environment,domain,domain_item)
  2. user_domain_identification = [] ;
  3. if ~(isempty(domain) | isempty(domain_item))
  4. user_domain_names = mttGetFieldNames(environment,'domain') ;
  5. number_of_user_domains = length(user_domain_names) ;
  6. counter = 0 ;
  7. identifying = 1 ;
  8. while identifying
  9. counter = counter + 1 ;
  10. user_domain_name = user_domain_names{counter} ;
  11. user_domain = getfield(environment,'domain',user_domain_name) ;
  12. specified_domain = user_domain.dom ;
  13. specified_domain_item = user_domain.item ;
  14. if domain==specified_domain
  15. if ~isempty(domain_item)
  16. if isempty(specified_domain_item)
  17. domain_item_names = mttGetFieldNames(environment.public_domain(domain),'item') ;
  18. is_valid_item = ismember(domain_item,domain_item_names) ;
  19. if is_valid_item
  20. user_domain_identification = [user_domain_name,'__',domain_item] ;
  21. end
  22. else
  23. is_matched_item = strcmp(domain_item,specified_domain_item) ;
  24. if is_matched_item
  25. user_domain_identification = user_domain_name ;
  26. end
  27. end
  28. end
  29. end
  30. identifying = (counter<number_of_user_domains) & isempty(user_domain_identification) ;
  31. end
  32. end