Add a method for getting many external ids at once.

This commit is contained in:
Nathan Curtis
2012-08-27 14:25:22 -07:00
parent 0162191fec
commit 30c38839f9
@@ -93,6 +93,22 @@ public class ExternalAuthRepository extends DepotRepository
return ids;
}
/**
* Loads a mapping of (ooouser id -> exid) for all members in the supplied list that are found
* in the database.
*/
public Map<Integer, String> loadExternalIds (ExternalAuther auther, Collection<Integer> oooIds)
{
Preconditions.checkNotNull(auther);
Map<Integer, String> ids = Maps.newHashMap();
for (ExternalAuthRecord exrec : from(ExternalAuthRecord.class).where(
ExternalAuthRecord.AUTHER.eq(auther),
ExternalAuthRecord.USER_ID.in(oooIds)).select()) {
ids.put(exrec.userId, exrec.externalId);
}
return ids;
}
/**
* Creates a mapping for the specified user to the supplied external credentials.
*/