예제 #1
0
  private Filter filterUserAssignedByOthers(
      Context context, ProducteevUser user, long currentUserId) {
    String title = context.getString(R.string.producteev_FEx_responsible_title, user.toString());
    ContentValues values = new ContentValues();
    values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY);
    values.put(ProducteevTask.ID.name, 0);
    values.put(ProducteevTask.CREATOR_ID.name, 0);
    values.put(ProducteevTask.RESPONSIBLE_ID.name, user.getId());
    Filter filter =
        new Filter(
            user.toString(),
            title,
            new QueryTemplate()
                .join(ProducteevDataService.METADATA_JOIN)
                .where(
                    Criterion.and(
                        MetadataCriteria.withKey(ProducteevTask.METADATA_KEY),
                        TaskCriteria.isActive(),
                        TaskCriteria.isVisible(),
                        Criterion.not(ProducteevTask.CREATOR_ID.eq(currentUserId)),
                        ProducteevTask.RESPONSIBLE_ID.eq(user.getId()))),
            values);

    return filter;
  }
예제 #2
0
  /** @param context */
  public static Filter filterFromList(
      Context context, ProducteevDashboard dashboard, long currentUserId) {
    String dashboardTitle = dashboard.getName();
    String title = dashboard.getName();
    ContentValues values = new ContentValues();
    values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY);
    values.put(ProducteevTask.DASHBOARD_ID.name, dashboard.getId());
    values.put(ProducteevTask.ID.name, 0);
    values.put(ProducteevTask.CREATOR_ID.name, 0);
    values.put(ProducteevTask.RESPONSIBLE_ID.name, 0);
    Filter filter;
    if (currentUserId != -1)
      filter =
          new Filter(
              dashboardTitle,
              title,
              new QueryTemplate()
                  .join(ProducteevDataService.METADATA_JOIN)
                  .where(
                      Criterion.and(
                          MetadataCriteria.withKey(ProducteevTask.METADATA_KEY),
                          TaskCriteria.isActive(),
                          TaskCriteria.isVisible(),
                          Criterion.or(
                              ProducteevTask.CREATOR_ID.eq(currentUserId),
                              ProducteevTask.RESPONSIBLE_ID.eq(currentUserId)),
                          ProducteevTask.DASHBOARD_ID.eq(dashboard.getId()))),
              values);
    else
      filter =
          new Filter(
              dashboardTitle,
              title,
              new QueryTemplate()
                  .join(ProducteevDataService.METADATA_JOIN)
                  .where(
                      Criterion.and(
                          MetadataCriteria.withKey(ProducteevTask.METADATA_KEY),
                          TaskCriteria.isActive(),
                          TaskCriteria.isVisible(),
                          ProducteevTask.DASHBOARD_ID.eq(dashboard.getId()))),
              values);

    return filter;
  }