IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

wb-fetch-objects.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import arvadosTypeName from 'arvados-type-name';
  2. import makeArvadosRequest from 'make-arvados-request';
  3. function wbFetchObjects(arvHost, arvToken, uuids) {
  4. const unique = {};
  5. uuids.map(u => (unique[u] = true));
  6. uuids = {};
  7. Object.keys(unique).map(u => {
  8. let typeName = arvadosTypeName(u);
  9. if (!typeName) {
  10. console.log('Unknown type name for UUID: ' + u);
  11. return;
  12. }
  13. if (!(typeName in uuids))
  14. uuids[typeName] = [];
  15. uuids[typeName].push(u);
  16. });
  17. const lookup = {};
  18. let prom = new Promise(accept => accept());
  19. for (let typeName in uuids) {
  20. let filters = [
  21. ['uuid', 'in', uuids[typeName]]
  22. ];
  23. prom = prom.then(() => makeArvadosRequest(arvHost, arvToken,
  24. '/arvados/v1/' + typeName + 's?filters=' +
  25. encodeURIComponent(JSON.stringify(filters))));
  26. prom = prom.then(xhr => xhr.response.items.map(it => (
  27. lookup[it.uuid] = it)));
  28. prom = prom.catch(xhr => console.log(xhr.responseURL + ': ' + xhr.statusText));
  29. }
  30. prom = prom.then(() => lookup);
  31. return prom;
  32. }
  33. export default wbFetchObjects;