use of com.infiniteautomation.mango.db.tables.records.OAuth2UsersRecord in project ma-core-public by infiniteautomation.
the class UserDao method updateLinkedAccounts.
public void updateLinkedAccounts(int userId, Iterable<? extends LinkedAccount> accounts) {
this.doInTransaction(txStatus -> {
create.deleteFrom(oauth).where(oauth.userId.equal(userId)).execute();
InsertValuesStep3<OAuth2UsersRecord, Integer, String, String> insert = create.insertInto(oauth, oauth.userId, oauth.issuer, oauth.subject);
for (LinkedAccount account : accounts) {
if (account instanceof OAuth2LinkedAccount) {
OAuth2LinkedAccount oAuth2Account = (OAuth2LinkedAccount) account;
insert = insert.values(userId, oAuth2Account.getIssuer(), oAuth2Account.getSubject());
} else {
throw new UnsupportedOperationException();
}
}
insert.execute();
});
}
Aggregations