Example #1
0
  public EvalGroup makeEvalGroupObject(String evalGroupId) {
    if (evalGroupId == null) {
      throw new IllegalArgumentException("evalGroupId cannot be null");
    }

    EvalGroup c = null;

    if (c == null) {
      // check external
      c = externalLogic.makeEvalGroupObject(evalGroupId);
      if (c != null && EvalConstants.GROUP_TYPE_INVALID.equals(c.type)) {
        c = null;
      }
    }

    if (c == null) {
      // try to get the adhoc group
      EvalAdhocGroup adhocGroup =
          adhocSupportLogic.getAdhocGroupById(
              EvalAdhocGroup.getIdFromAdhocEvalGroupId(evalGroupId));
      if (adhocGroup != null) {
        c = new EvalGroup(evalGroupId, adhocGroup.getTitle(), EvalConstants.GROUP_TYPE_ADHOC);
      }
    }

    if (c == null) {
      // use external provider
      if (evalGroupsProvider != null) {
        c = evalGroupsProvider.getGroupByGroupId(evalGroupId);
        if (c != null) {
          c.type = EvalConstants.GROUP_TYPE_PROVIDED;
          if (c.title == null || c.title.trim().length() == 0) {
            c.title = UNKNOWN_TITLE;
          }
        }
      }
    }

    if (c == null) {
      LOG.debug("Could not get group from evalGroupId:" + evalGroupId);
      // create a fake group placeholder as an error notice
      c =
          new EvalGroup(
              evalGroupId, "** INVALID: " + evalGroupId + " **", EvalConstants.GROUP_TYPE_INVALID);
    }

    return c;
  }
Example #2
0
  @SuppressWarnings("rawtypes")
  public List<EvalGroup> getEvalGroupsForUser(String userId, String permission) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("userId: " + userId + ", permission: " + permission);
    }

    List<EvalGroup> l = new ArrayList<>();

    // get the groups from external
    l.addAll(externalLogic.getEvalGroupsForUser(userId, permission));

    // also check the internal groups
    List<EvalAdhocGroup> adhocGroups =
        adhocSupportLogic.getAdhocGroupsByUserAndPerm(userId, permission);
    for (EvalAdhocGroup adhocGroup : adhocGroups) {
      l.add(
          new EvalGroup(
              adhocGroup.getEvalGroupId(), adhocGroup.getTitle(), EvalConstants.GROUP_TYPE_ADHOC));
    }

    // also check provider
    if (evalGroupsProvider != null) {
      if (EvalConstants.PERM_BE_EVALUATED.equals(permission)
          || EvalConstants.PERM_TAKE_EVALUATION.equals(permission)
          || EvalConstants.PERM_ASSIGN_EVALUATION.equals(permission)
          || EvalConstants.PERM_ASSISTANT_ROLE.equals(permission)) {
        LOG.debug("Using eval groups provider: userId: " + userId + ", permission: " + permission);
        List eg =
            evalGroupsProvider.getEvalGroupsForUser(
                userId, EvalExternalLogicImpl.translatePermission(permission));
        for (Iterator iter = eg.iterator(); iter.hasNext(); ) {
          EvalGroup c = (EvalGroup) iter.next();
          c.type = EvalConstants.GROUP_TYPE_PROVIDED;
          l.add(c);
        }
      }
    }

    if (l.isEmpty()) {
      LOG.debug("Empty list of groups for user:"******", permission: " + permission);
    }
    return l;
  }