Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

getExperimenter.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function [experid, expername] = getExperimenter(exper_info)
  2. % get_experid_from_info(exper_info):
  3. % input:
  4. % a string that will match something about an experimenter. Could be firstname, gitlabuser, or netid
  5. % output:
  6. % the ID for that experimenter in the database.
  7. % e.g. id = get_experid_from_info('jerlich') % returns 10
  8. dbc = db.labdb.getConnection();
  9. dbc.use('met');
  10. if nargin==0
  11. exper_info=0;
  12. end
  13. if isnumeric(exper_info)
  14. if exper_info==0
  15. % Try based on first name
  16. [~,uname]=system('git config user.name');
  17. uname = strtrim(uname);
  18. firstname = strtok(uname,' ');
  19. [experid, expername] = db.getExperimenter(firstname);
  20. if experid>0
  21. return;
  22. end
  23. % Try based on email handle
  24. [~,umail]=system('git config user.email');
  25. umail = strtrin(umail);
  26. mailname = strtok(umail,'@');
  27. [experid, expername] = db.getExperimenter(mailname);
  28. else
  29. [experid, expername] = dbc.get('select experid, concat(firstname," ",lastname) as name from experimenters where experid = %d',{exper_info});
  30. end
  31. else
  32. eid = dbc.query('select experid, concat(firstname," ",lastname) as name from experimenters where Firstname like "%s%%"', {exper_info});
  33. if numel(eid) > 0
  34. experid = eid.experid;
  35. expername = eid.name{1};
  36. return;
  37. end
  38. eid = dbc.query('select experid, concat(firstname," " ,lastname) as name from experimenters where gitlabuser="%s"', {exper_info});
  39. if numel(eid) > 0
  40. experid = eid.experid;
  41. expername = eid.name{1};
  42. return;
  43. end
  44. eid = dbc.query('select experid, concat(firstname," ",lastname) as name from experimenters where netid="%s"', {exper_info});
  45. if numel(eid) > 0
  46. experid = eid.experid;
  47. expername = eid.name;
  48. return;
  49. end
  50. error('Could not match a unique experimenter to the supplied information')
  51. end
  52. expername = expername{1};