Пример #1
0
  /**
   * 프로젝트 제한을 두지 않고 전체 이슈를 대상으로 검색할 때 사용한다.
   *
   * @return ExpressionList<Issue>
   */
  public ExpressionList<Issue> asExpressionList() {
    ExpressionList<Issue> el = Issue.finder.where();

    if (assigneeId != null) {
      if (assigneeId.equals(User.anonymous.id)) {
        el.isNull("assignee");
      } else {
        el.eq("assignee.user.id", assigneeId);
      }
    }

    if (authorId != null) {
      el.eq("authorId", authorId);
    }

    if (StringUtils.isNotBlank(filter)) {
      Junction<Issue> junction = el.disjunction();
      junction.icontains("title", filter).icontains("body", filter);
      List<Object> ids = Issue.finder.where().icontains("comments.contents", filter).findIds();
      if (!ids.isEmpty()) {
        junction.idIn(ids);
      }
      junction.endJunction();
    }

    if (commentedCheck) {
      el.ge("numOfComments", AbstractPosting.NUMBER_OF_ONE_MORE_COMMENTS);
    }

    State st = State.getValue(state);
    if (st.equals(State.OPEN) || st.equals(State.CLOSED)) {
      el.eq("state", st);
    }

    if (orderBy != null) {
      el.orderBy(orderBy + " " + orderDir);
    }

    return el;
  }
Пример #2
0
  /**
   * 특정 프로젝트를 대상으로 검색 표현식을 만든다.
   *
   * @return ExpressionList<Issue>
   */
  public ExpressionList<Issue> asExpressionList(Project project) {
    ExpressionList<Issue> el = Issue.finder.where();
    if (project != null) {
      el.eq("project.id", project.id);
    }
    if (StringUtils.isNotBlank(filter)) {
      Junction<Issue> junction = el.disjunction();
      junction.icontains("title", filter).icontains("body", filter);
      List<Object> ids = null;
      if (project == null) {
        ids = Issue.finder.where().icontains("comments.contents", filter).findIds();
      } else {
        ids =
            Issue.finder
                .where()
                .eq("project.id", project.id)
                .icontains("comments.contents", filter)
                .findIds();
      }
      if (!ids.isEmpty()) {
        junction.idIn(ids);
      }
      junction.endJunction();
    }

    if (authorId != null) {
      if (authorId.equals(User.anonymous.id)) {
        el.isNull("authorId");
      } else {
        el.eq("authorId", authorId);
      }
    }

    if (assigneeId != null) {
      if (assigneeId.equals(User.anonymous.id)) {
        el.isNull("assignee");
      } else {
        el.eq("assignee.user.id", assigneeId);
        el.eq("assignee.project.id", project.id);
      }
    }

    if (milestoneId != null) {
      if (milestoneId.equals(Milestone.NULL_MILESTONE_ID)) {
        el.isNull("milestone");
      } else {
        el.eq("milestone.id", milestoneId);
      }
    }

    if (commentedCheck) {
      el.ge("numOfComments", AbstractPosting.NUMBER_OF_ONE_MORE_COMMENTS);
    }

    State st = State.getValue(state);
    if (st.equals(State.OPEN) || st.equals(State.CLOSED)) {
      el.eq("state", st);
    }

    if (CollectionUtils.isNotEmpty(labelIds)) {
      el.add(LabelSearchUtil.createLabelSearchExpression(el.query(), labelIds));
    }

    if (orderBy != null) {
      el.orderBy(orderBy + " " + orderDir);
    }

    return el;
  }
  @Override
  public List<Component> getComponents(
      Long applicationId, Long componentId, Long instanceId, Long cloudId) {
    List<Component> result = new ArrayList<Component>();
    List<Component> components = componentModelService.getAll();
    List<Instance> instances = null;
    List<VirtualMachine> vms = null;

    List<ApplicationComponent> appComps = applicationComponentModelService.getAll();

    for (Component component : components) {
      boolean suitable = false;

      if (applicationId != null) {
        for (ApplicationComponent ac : appComps) {
          if (ac.getComponent().getId().equals(componentId)
              && ac.getApplication().getId().equals(applicationId)) {
            suitable = true;
          }
        }
      }

      if (componentId != null) {
        if (componentId.equals(component.getId())) {
          suitable = suitable && true;
        }
      }

      if (instanceId != null) {
        if (instances == null) instances = instanceModelService.getAll();
        boolean oneFits = false;

        for (Instance instance : instances) {
          if (isInstanceOf(instance, appComps, component)) {
            oneFits = true;
          }
        }

        if (oneFits) {
          suitable = suitable && true;
        } else {
          suitable = false;
        }
      }

      if (cloudId != null) {
        if (instances == null) instances = instanceModelService.getAll();
        if (vms == null) vms = virtualMachineModelService.getAll();
        boolean oneFits = false;

        for (Instance instance : instances) {
          if (isInstanceOf(instance, vms, cloudId)) {
            if (isInstanceOf(instance, appComps, component)) {
              oneFits = true;
            }
          }
        }

        if (oneFits) {
          suitable = suitable && true;
        } else {
          suitable = false;
        }
      }

      if (suitable) {
        result.add(component);
      }
    }

    return result;
  }