package ru.micord.ervu.account_applications.component.rpc;

import java.util.List;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import ru.micord.ervu.account_applications.service.AccountFetchService;
import ru.micord.ervu.account_applications.service.UserApplicationListService;

import ru.cg.webbpm.modules.webkit.annotations.RpcCall;
import ru.cg.webbpm.modules.webkit.annotations.RpcService;
import ru.cg.webbpm.modules.webkit.beans.Behavior;

/**
 * @author gulnaz
 */
@RpcService
public class UserApplicationListRpcService extends Behavior {
  private static final Logger LOGGER = LoggerFactory.getLogger(UserApplicationListRpcService.class);

  @Autowired
  private UserApplicationListService applicationListService;
  @Autowired
  private AccountFetchService accountService;

  @RpcCall
  public void saveError(long appNumber, String errorMsg) {
    LOGGER.error("error for application = {}, message: {}", appNumber, errorMsg);
    applicationListService.saveError(appNumber, errorMsg);
  }

  @RpcCall
  public void saveAcceptedStatus(long appNumber) {
    applicationListService.saveAcceptedStatus(appNumber);
  }

  @RpcCall
  public List<String> getRemovedRoleIds(String accountId, Set<String> roleIds) {
    return accountService.fetchRemovedRoleIdsByAccountId(accountId, roleIds);
  }
}
