Exemplo n.º 1
0
  @Override
  public void prepareQL(StringBuilder ql, Searchable search) {
    super.prepareQL(ql, search);

    boolean hasOrganization = search.containsSearchKey("organization");
    boolean hasJob = search.containsSearchKey("job");
    if (hasOrganization || hasJob) {
      ql.append(" and exists(select 1 from UserOrganizationJob oj");
      if (hasOrganization) {
        ql.append(" left join oj.organization o ");
      }
      if (hasJob) {
        ql.append(" left join oj.job j ");
      }
      ql.append(" where oj.user=x ");
      if (hasOrganization) {
        ql.append(" and (o.id=:organizationId or o.parentIds like :organizationParentIds)");
      }
      if (hasJob) {
        ql.append(" and (j.id=:jobId or j.parentIds like :jobParentIds)");
      }

      ql.append(")");
    }
  }
Exemplo n.º 2
0
  @Override
  public void setValues(Query query, Searchable search) {
    super.setValues(query, search);

    if (search.containsSearchKey("organization")) {
      Organization organization = search.getValue("organization");
      query.setParameter("organizationId", organization.getId());
      query.setParameter("organizationParentIds", organization.makeSelfAsNewParentIds() + "%");
    }

    if (search.containsSearchKey("job")) {
      Job job = search.getValue("job");
      query.setParameter("jobId", job.getId());
      query.setParameter("jobParentIds", job.makeSelfAsNewParentIds() + "%");
    }
  }