当前位置: 首页>>代码示例>>Java>>正文


Java AccountGroupMember类代码示例

本文整理汇总了Java中com.google.gerrit.reviewdb.client.AccountGroupMember的典型用法代码示例。如果您正苦于以下问题:Java AccountGroupMember类的具体用法?Java AccountGroupMember怎么用?Java AccountGroupMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AccountGroupMember类属于com.google.gerrit.reviewdb.client包,在下文中一共展示了AccountGroupMember类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNewUser

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
private AccountExternalId createNewUser(ReviewDb db) throws OrmException, UnprocessableEntityException {
	Account.Id id = new Account.Id(db.nextAccountId());
	AccountExternalId extUser =
		new AccountExternalId(id, new AccountExternalId.Key(
			AccountExternalId.SCHEME_USERNAME, username));

	/*
	if (input.httpPassword != null) {
		extUser.setPassword(input.httpPassword);
	}
	*/
	db.accountExternalIds().insert(Collections.singleton(extUser));
	Account a = new Account(id, TimeUtil.nowTs());
	a.setFullName(name);
	//a.setPreferredEmail(input.email);
	db.accounts().insert(Collections.singleton(a));

	Set<AccountGroup.Id> groups = parseGroups(Lists.newArrayList("2"));

	for (AccountGroup.Id groupId : groups) {
		AccountGroupMember m =
			new AccountGroupMember(new AccountGroupMember.Key(id, groupId));
		db.accountGroupMembers().insert(Collections.singleton(m));
	}

	accountCache.evictByUsername(username);

	return extUser;
}
 
开发者ID:atteo,项目名称:jfactory,代码行数:30,代码来源:CreateBatchUser.java

示例2: addGroupMemberInReviewDb

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
private static void addGroupMemberInReviewDb(
    ReviewDb db, AccountGroup.UUID groupUuid, Account.Id accountId)
    throws OrmException, NoSuchGroupException {
  AccountGroup group = getExistingGroup(db, groupUuid);
  AccountGroup.Id groupId = group.getId();

  if (isMember(db, groupId, accountId)) {
    return;
  }

  db.accountGroupMembers()
      .insert(
          ImmutableList.of(
              new AccountGroupMember(new AccountGroupMember.Key(accountId, groupId))));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:GroupsOnInit.java

示例3: addGroupMembersInReviewDb

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
private void addGroupMembersInReviewDb(
    ReviewDb db, AccountGroup.Id groupId, Set<Account.Id> newMemberIds) throws OrmException {
  Set<AccountGroupMember> newMembers =
      newMemberIds
          .stream()
          .map(accountId -> new AccountGroupMember.Key(accountId, groupId))
          .map(AccountGroupMember::new)
          .collect(toImmutableSet());

  if (currentUser != null) {
    auditService.dispatchAddAccountsToGroup(currentUser.getAccountId(), newMembers);
  }
  db.accountGroupMembers().insert(newMembers);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:GroupsUpdate.java

示例4: removeGroupMembersInReviewDb

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
private void removeGroupMembersInReviewDb(
    ReviewDb db, AccountGroup.Id groupId, Set<Account.Id> accountIds) throws OrmException {
  Set<AccountGroupMember> membersToRemove =
      accountIds
          .stream()
          .map(accountId -> new AccountGroupMember.Key(accountId, groupId))
          .map(AccountGroupMember::new)
          .collect(toImmutableSet());

  if (currentUser != null) {
    auditService.dispatchDeleteAccountsFromGroup(currentUser.getAccountId(), membersToRemove);
  }
  db.accountGroupMembers().delete(membersToRemove);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:GroupsUpdate.java

示例5: onAddAccountsToGroup

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
@Override
public void onAddAccountsToGroup(Account.Id me, Collection<AccountGroupMember> added) {
  List<AccountGroupMemberAudit> auditInserts = new ArrayList<>();
  for (AccountGroupMember m : added) {
    AccountGroupMemberAudit audit = new AccountGroupMemberAudit(m, me, TimeUtil.nowTs());
    auditInserts.add(audit);
  }
  try (ReviewDb db = schema.open()) {
    db.accountGroupMembersAudit().insert(auditInserts);
  } catch (OrmException e) {
    logOrmExceptionForAccounts(
        "Cannot log add accounts to group event performed by user", me, added, e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:DbGroupMemberAuditListener.java

示例6: onDeleteAccountsFromGroup

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
@Override
public void onDeleteAccountsFromGroup(Account.Id me, Collection<AccountGroupMember> removed) {
  List<AccountGroupMemberAudit> auditInserts = new ArrayList<>();
  List<AccountGroupMemberAudit> auditUpdates = new ArrayList<>();
  try (ReviewDb db = schema.open()) {
    for (AccountGroupMember m : removed) {
      AccountGroupMemberAudit audit = null;
      for (AccountGroupMemberAudit a :
          db.accountGroupMembersAudit().byGroupAccount(m.getAccountGroupId(), m.getAccountId())) {
        if (a.isActive()) {
          audit = a;
          break;
        }
      }

      if (audit != null) {
        audit.removed(me, TimeUtil.nowTs());
        auditUpdates.add(audit);
      } else {
        audit = new AccountGroupMemberAudit(m, me, TimeUtil.nowTs());
        audit.removedLegacy();
        auditInserts.add(audit);
      }
    }
    db.accountGroupMembersAudit().update(auditUpdates);
    db.accountGroupMembersAudit().insert(auditInserts);
  } catch (OrmException e) {
    logOrmExceptionForAccounts(
        "Cannot log delete accounts from group event performed by user", me, removed, e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:DbGroupMemberAuditListener.java

示例7: logOrmExceptionForAccounts

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
private void logOrmExceptionForAccounts(
    String header, Account.Id me, Collection<AccountGroupMember> values, OrmException e) {
  List<String> descriptions = new ArrayList<>();
  for (AccountGroupMember m : values) {
    Account.Id accountId = m.getAccountId();
    String userName = accountCache.get(accountId).getUserName();
    AccountGroup.Id groupId = m.getAccountGroupId();
    String groupName = getGroupName(groupId);

    descriptions.add(
        MessageFormat.format(
            "account {0}/{1}, group {2}/{3}", accountId, userName, groupId, groupName));
  }
  logOrmException(header, me, descriptions, e);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:DbGroupMemberAuditListener.java

示例8: dispatchAddAccountsToGroup

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
public void dispatchAddAccountsToGroup(Account.Id actor, Collection<AccountGroupMember> added) {
  for (GroupMemberAuditListener auditListener : groupMemberAuditListeners) {
    try {
      auditListener.onAddAccountsToGroup(actor, added);
    } catch (RuntimeException e) {
      log.error("failed to log add accounts to group event", e);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:AuditService.java

示例9: dispatchDeleteAccountsFromGroup

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
public void dispatchDeleteAccountsFromGroup(
    Account.Id actor, Collection<AccountGroupMember> removed) {
  for (GroupMemberAuditListener auditListener : groupMemberAuditListeners) {
    try {
      auditListener.onDeleteAccountsFromGroup(actor, removed);
    } catch (RuntimeException e) {
      log.error("failed to log delete accounts from group event", e);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:AuditService.java

示例10: get

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
@Override
@PrimaryKey("key")
AccountGroupMember get(AccountGroupMember.Key key) throws OrmException;
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:4,代码来源:AccountGroupMemberAccess.java

示例11: byAccount

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
@Query("WHERE key.accountId = ?")
ResultSet<AccountGroupMember> byAccount(Account.Id id) throws OrmException;
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:3,代码来源:AccountGroupMemberAccess.java

示例12: byGroup

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
@Query("WHERE key.groupId = ?")
ResultSet<AccountGroupMember> byGroup(AccountGroup.Id id) throws OrmException;
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:3,代码来源:AccountGroupMemberAccess.java

示例13: isMember

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
private static boolean isMember(ReviewDb db, AccountGroup.Id groupId, Account.Id accountId)
    throws OrmException {
  AccountGroupMember.Key key = new AccountGroupMember.Key(accountId, groupId);
  return db.accountGroupMembers().get(key) != null;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:GroupsOnInit.java

示例14: getGroupsWithMemberFromReviewDb

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
/**
 * Returns the groups of which the specified account is a member.
 *
 * <p><strong>Note</strong>: This method returns an empty stream if the account doesn't exist.
 * This method doesn't check whether the groups exist.
 *
 * @param db the {@code ReviewDb} instance to use for lookups
 * @param accountId the ID of the account
 * @return a stream of the IDs of the groups of which the account is a member
 * @throws OrmException if an error occurs while reading from ReviewDb
 */
public static Stream<AccountGroup.Id> getGroupsWithMemberFromReviewDb(
    ReviewDb db, Account.Id accountId) throws OrmException {
  ResultSet<AccountGroupMember> accountGroupMembers =
      db.accountGroupMembers().byAccount(accountId);
  return Streams.stream(accountGroupMembers).map(AccountGroupMember::getAccountGroupId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:Groups.java

示例15: getMembersFromReviewDb

import com.google.gerrit.reviewdb.client.AccountGroupMember; //导入依赖的package包/类
/**
 * Returns the members (accounts) of a group.
 *
 * <p><strong>Note</strong>: This method doesn't check whether the accounts exist!
 *
 * @param db the {@code ReviewDb} instance to use for lookups
 * @param groupId the ID of the group
 * @return a stream of the IDs of the members
 * @throws OrmException if an error occurs while reading from ReviewDb
 */
public static Stream<Account.Id> getMembersFromReviewDb(ReviewDb db, AccountGroup.Id groupId)
    throws OrmException {
  ResultSet<AccountGroupMember> accountGroupMembers = db.accountGroupMembers().byGroup(groupId);
  return Streams.stream(accountGroupMembers).map(AccountGroupMember::getAccountId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:Groups.java


注:本文中的com.google.gerrit.reviewdb.client.AccountGroupMember类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。